
Expandable TypeScript type inspection for NeoVim. Uses TypeScript 5.9's verbosityLevel API to let you progressively expand and collapse type aliases directly inside a hover float.
+ to expand type aliases one level at a time, - to collapse@param/@returns/@example tags rendered below the type blockvim.lsp.buf.hover() when vtsls is not attached or TypeScript < 5.9verbosityLevel support in tsserver's quickinfo){
"nemanjamalesija/ts-expand-hover.nvim",
ft = { "typescript", "typescriptreact" },
opts = {
-- Recommended: avoid conflicts with distros/plugins that already map `K`
keymaps = { hover = "<leader>th" },
},
}
use {
"nemanjamalesija/ts-expand-hover.nvim",
ft = { "typescript", "typescriptreact" },
config = function()
require("ts_expand_hover").setup()
end,
}
MiniDeps.add({ source = "nemanjamalesija/ts-expand-hover.nvim" })
require("ts_expand_hover").setup()
Clone to your NeoVim packages directory:
git clone https://github.com/nemanjamalesija/ts-expand-hover.nvim \
~/.local/share/nvim/site/pack/plugins/start/ts-expand-hover.nvim
Then add to your config:
require("ts_expand_hover").setup()
Calling setup() with no arguments uses all defaults:
require("ts_expand_hover").setup()
Full configuration with defaults shown:
require("ts_expand_hover").setup({
keymaps = {
hover = "K", -- normal mode key to open hover float
expand = "+", -- expand type one level (inside float)
collapse = "-", -- collapse type one level (inside float)
close = { "q", "<Esc>" }, -- close float and return to source
},
float = {
border = "rounded", -- border style: "rounded", "single", "double", "none"
max_width = 80, -- maximum float width in columns
max_height = 30, -- maximum float height in lines
},
})
require("ts_expand_hover").setup({
keymaps = {
hover = "<leader>th",
expand = "]t",
collapse = "[t",
},
})
Many Neovim distributions and plugins already map K (often buffer-local for LSP hover),
which can override global mappings. To avoid conflicts, use a custom binding:
require("ts_expand_hover").setup({
keymaps = {
hover = "<leader>th",
},
})
If you want to keep K, prefer a TypeScript-only mapping:
require("ts_expand_hover").setup({
keymaps = { hover = false }, -- disable global mapping
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "typescript", "typescriptreact" },
callback = function(ev)
vim.keymap.set("n", "K", require("ts_expand_hover").hover, {
buffer = ev.buf,
desc = "TypeScript expandable hover",
})
end,
})
Set any keymap to false to prevent the plugin from registering it. This is useful if you want to bind the hover function yourself:
require("ts_expand_hover").setup({
keymaps = { hover = false },
})
-- Bind it yourself
vim.keymap.set("n", "gh", require("ts_expand_hover").hover, { desc = "TS hover" })
| Key | Scope | Action |
|---|---|---|
K |
Normal mode (global) | Open hover float at cursor |
+ |
Inside float | Expand type one level |
- |
Inside float | Collapse type one level |
q / Esc |
Inside float | Close float, return focus to source |
The float also closes automatically when you move the cursor in the source buffer.
The footer at the bottom of the float shows the current verbosity depth and available actions:
depth: 0 [+] expand [-] collapse [q] close
When maximum expansion is reached, the footer shows [max] instead of [+] expand.
The plugin sends typescript.tsserverRequest commands to vtsls using the workspace/executeCommand LSP method. It passes the verbosityLevel parameter (introduced in TypeScript 5.9) to tsserver's quickinfo command, which controls how deeply type aliases are expanded in the response.
K — sends a quickinfo request with verbosityLevel: 0 (default)+ — increments verbosity and re-requests; the float updates in-place- — decrements verbosity and re-requestsK again while a response is in-flight, the stale response from the previous session is discardedWhen vtsls is not attached to the buffer (e.g., in a Lua or Python file) or when TypeScript < 5.9 is detected, the plugin falls back to the standard vim.lsp.buf.hover().
Run :checkhealth ts_expand_hover to verify your setup. It reports:
Open a TypeScript file before running the health check so vtsls has a chance to attach.
Hover shows the standard LSP float instead of the expandable one
vtsls is not attached to the buffer. Check with :checkhealth ts_expand_hover. Make sure your LSP config starts vtsls for TypeScript files.
Pressing + does nothing
[max] — you've reached maximum expansion for this typeverbosityLevel; the plugin falls back to standard hoverFloat doesn't open at all
footer option in nvim_open_winsetup() was never called — make sure your plugin manager calls require("ts_expand_hover").setup()K is already bound to something else
Recommended: use a custom hover key to avoid mapping conflicts.
require("ts_expand_hover").setup({
keymaps = { hover = "<leader>th" },
})
If you specifically want K, disable the global mapping and remap it only for
TypeScript buffers (see "Recommended binding strategy" above).
make test
Requires NeoVim and plenary.nvim. Tests run headlessly with no live LSP dependency.
MIT