Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-menu

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    │
└─────────────────────────┘

Requirements

  • Neovim 0.11+ (uses vim.lsp.get_clients, vim.lsp.protocol.Methods)
  • nui.nvim — required. It provides the floating Menu widget. It is not bundled with this plugin.

Installation

With vim.pack (Neovim's built-in packer)

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()
{
  'vincent178/nvim-menu',
  dependencies = { 'MunifTanjim/nui.nvim' },
  config = function()
    require('nvim-menu').setup()
  end,
}

Usage

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-end for multiple lines, path:start for a single line).
  • Select a visual range before opening the menu — Format Selection, Code Action, Copy Relative Path, and Copy Remote File URL will operate on that range.
  • Navigate with j/k/<Up>/<Down>, submit with <CR>, close with <Esc>.

Options

require('nvim-menu').setup({
  command = 'NvimMenu',  -- name of the user command
})

Test

Tests use plenary.nvim. Run them with:

make test

tests/minimal_init.lua clones plenary and nui into /tmp on first run.

License

MIT. See LICENSE.

About

open floating context menu at the cursor just like VSCode

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages