telescope-menu.nvim
is an extension for telescope.nvim which provides custom menus.
Using dein.vim
call dein#add('nvim-telescope/telescope.nvim')
call dein#add('octarect/telescope-menu.nvim')
If using TOML,
[[plugins]]
repo = 'nvim-telescope/telescope.nvim'
[[plugins]]
repo = 'octarect/telescope-menu.nvim'
require("telescope").setup {
extensions = {
menu = {
default = {
items = {
-- You can add an item of menu in the form of { "<display>", "<command>" }
{ "Checkhealth", "checkhealth" },
{ "Show LSP Info", "LspInfo" },
{ "Files", "Telescope find_files" },
-- The above examples are syntax-sugars of the following;
{ display = "Change colorscheme", value = "Telescope colorscheme" },
},
},
},
},
}
require("telescope").load_extension "menu"
Run Telescope menu
to open the menu default
.
Mappings | Action |
---|---|
<CR> |
Confirm selection |
Vim Command | Lua | Description |
---|---|---|
:Telescope menu |
:lua require"telescope".extensions.menu.menu{} |
Open default menu |
:Telescope menu filetype |
lua require"telescope".extensions.menu.filetype{} |
Open filetype-specific menu |
:Telescope menu <menu_name> |
:lua require"telescope".extensions.menu.<menu_name>{} |
Open <menu_name> |
Defining multiple menus is supported. Menus except for default
is opened by Telescope menu <menu_name>
.
For example, you can have another menu named editor
by the following config;
{
extensions = {
menu = {
default = {
items = {
-- Jump to another menu
{ "Editor", "Telescope menu editor" },
},
},
-- `editor` is an example, and you can name it as you like.
editor = {
items = {
{ "Split window vertically", "vsplit" },
{ "Split window horizontally", "split" },
{ "Write", "w" },
},
},
},
},
}
Then, you can open the menu by
- ExCommand:
Telescope menu editor
- Lua:
require("telescope").extensions.menu.editor()
You can define menu for a particular filetype, and open them by Telescope menu filetype
.
Example:
{
extensions = {
menu = {
filetype = {
lua = {
items = {
{ "Format", "!stylua %" },
{ "Open Luadev menu", "Luadev" },
{ "Execute a current buffer", "LuaRun" },
},
},
-- Format
-- <filetype> = {
-- items = {
-- -- your favorite commands
-- }
-- }
}
},
},
}
You can specify lua function as command instead of string.
{
extensions = {
menu = {
default = {
items = {
{ "Example", function()
print("This is example."\n")
end},
},
}
},
},
}
local keymap = require("telescope-menu.actions").keymap
require("telescope").setup {
extensions = {
menu = {
default = {
items = {
{ "Jump to the previous hunk", "<Plug>(GitGutterPrevHunk)", keymap },
{ "Jump to the next hunk", "<Plug>(GitGutterNextHunk)", keymap },
},
},
},
},
}
Any pull requests are welcome. We consider you have granted non-exclusive right to your contributed code under MIT License. Use http://github.com/octarect/telescope-menu.nvim/issues for discussion.
v0.1.0
- Basic features (Open a custom menu by
Telescope menu
) - CI for automated test
v0.2.0
New features
- Filetype-specific menu (
Telescope menu filetype
) - Multiple menus
- Supported list format for item (syntax-sugar)
Breaking changes
- Changed name of default menu:
global
->default
Other
- Improved CI
- Matrix test
- Added lint and stylecheck