Skip to content

LintaoAmons/context-menu.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warning

This plugin is in its early stages, and the data structures is like to undergo significant changes over time.

Philosophy · Install & Configuration · Usecases

Instead of keymaps, you can put your actions in the context menu

  • Menu is a buffer, use hjkl to navigate the items and trigger it or just trigger it by the number
  • Build your own menu, (items order) and (display or hide) are easily configurable
  • Split you config in multiple places, encapsulating those item in its own place
  • Adjust your config at runtime, simply source the setup function again
  • Local keymaps of the items

show

Philosophy

  • Minimise the cognitive overload in the head, but still put every functionality around you hand
  • Less keybindings but remian productivity
  • Configuration can be put in seperated spec files, and behaviour can be config at runtime and take effect immediately

Install & Configuration

-- lazy.nvim
return {
  "LintaoAmons/context-menu.nvim",
  config = function(_, opts)
    require("context-menu").setup({
      -- Available predefined modules:
      -- "git"|"http"|"markdown"|"test"|"copy"
      modules = {
        "git",       -- Module implementations can be found in `lua/context-menu/modules`
                     -- To check the dependencies of the module, e.g. git module requires VGit.nvim
        "copy",      -- Remove any predefined modules you don't need
        "markdown",  -- Reference existing modules to learn how to create your own
        "http",      -- http module requires kulala.nvim
      },
    })

    -- Add custom menu items
    -- This method can be called from any location to modularize your configuration
    -- Items can be modified at runtime to simplify configuration and debugging
    require("context-menu").add_items({
      {
        order = 1, -- Lower numbers indicate higher priority
        name = "Code Action", -- Display name in the menu
        -- Additional filters are defined in `lua/context-menu/types.lua`
        -- Options include ft, not_ft, and filter_func
        not_ft = { "markdown", "toggleterm" }, -- Hide item for specified filetypes
        action = function(_) -- Function executed when item is selected
          vim.lsp.buf.code_action()
        end,
      },
    })
  end,
}

Keymaps

No default keymaps, you need to set the shortcut by yourself, here's a reference

vim.keymap.set({ "v", "n" }, "<M-l>", function()
  require("context-menu.picker.vim-ui").select()
end, {})

-- or
vim.keymap.set({ "v", "n" }, "<M-l>", "ContextMenuTrigger", {})

CONTRIBUTING

Don't hesitate to ask me anything about the codebase if you want to contribute.

By telegram or 微信: CateFat

Some Other Neovim Stuff

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages