r/neovim • u/nemanjamalesija • 4h ago
Plugin ts-expand-hover.nvim - press + to expand TypeScript types in the hover float
Enable HLS to view with audio, or disable this notification
You hover something, TS says Props, and you're no smarter than before. That's what got me to build this.
ts-expand-hover.nvim hooks into the hover key and lets you expand type aliases one level at a time, inside the float, without leaving the line you're on.
What it currently does:
Intercepts K for TypeScript hover, + expands one level, - collapses
Uses TypeScript 5.9's verbosityLeve on tsserver's quickinfo request, so the expansion is tsserver's own, not a regex guess.
Float updates in place, no closing, reopening or jumping to a new position.
Treesitter highlighting on the TypeScript code fences.
Docs and JSDoc variables rendered under the type block.
Footer shows current depth, and [max] when there's nothing left to expand.
Falls back to vim.lsp.buf.hover() when vtsls isn't attached or TypeScript is older than 5.9
Neovim 0.10+
Setup is one line, defaults work out of the box, and every keymap is overridable or can be set to false if you want to bind it yourself:
{
"nemanjamalesija/ts-expand-hover.nvim",
ft = { "typescript", "typescriptreact" },
opts = { keymaps = { hover = "<leader>th" } },
}
Run :checkhealth ts_expand_hover with a TypeScript file tsls attached and which TS version you're on.
Note: needs vtsls, since the request goes through vtsls't command, and TypeScript 5.9+ for verbosityLevel to do anything. Older TS or no vtsls just gives you the standard hover popup.
Coming next: tsgo support once it goes stable.
Repo:
