A small Neovim plugin that opens a VSCode-style floating context menu at the cursor:
┌─────────────────────────┐
│ Go to Definition │
│ Go to Declaration │
│ Go to Type Definition │
│ Go to Implementation │
│ Find References │
│ ─────────────────────── │
│ Rename Symbol │
│ Code Action │
│ ─────────────────────── │
│ Format Document │
│ Format Selection │
│ ─────────────────────── │
│ Hover Documentation │
│ Signature Help │
│ Document Symbols │
│ ─────────────────────── │
│ Copy Path │
│ Copy Relative Path │
│ Copy Remote File URL │
└─────────────────────────┘
- Neovim 0.11+ (uses
vim.lsp.get_clients,vim.lsp.protocol.Methods) - nui.nvim — required. It provides
the floating
Menuwidget. It is not bundled with this plugin.
vim.pack.add has no dependencies field, so add nui explicitly:
vim.pack.add({
'https://github.com/MunifTanjim/nui.nvim',
'https://github.com/vincent178/nvim-menu',
})
require('nvim-menu').setup()With lazy.nvim
{
'vincent178/nvim-menu',
dependencies = { 'MunifTanjim/nui.nvim' },
config = function()
require('nvim-menu').setup()
end,
}The plugin registers a :NvimMenu user command. It sets no default keymap —
bind your own if you like:
vim.keymap.set({ 'n', 'v' }, '<Leader>m', '<cmd>NvimMenu<CR>', { desc = 'Context menu' })Run :NvimMenu (or your keymap) and a floating menu appears at the cursor.
- LSP entries only appear when an attached language server advertises the capability, so the menu adapts per language. In a buffer with no LSP attached, only the utility section is shown.
- Copy Remote File URL is omitted when not inside a git repo or the configured remote is missing.
- Copy Path copies the buffer's absolute path; Copy Relative Path
copies the repo-relative path and appends the line range when the menu is
opened from a visual selection (
path:start-endfor multiple lines,path:startfor a single line). - Select a visual range before opening the menu —
Format Selection,Code Action,Copy Relative Path, andCopy Remote File URLwill operate on that range. - Navigate with
j/k/<Up>/<Down>, submit with<CR>, close with<Esc>.
require('nvim-menu').setup({
command = 'NvimMenu', -- name of the user command
})Tests use plenary.nvim. Run them with:
make test
tests/minimal_init.lua clones plenary and nui into /tmp on first run.
MIT. See LICENSE.