I won't develop this plugin anymore since I found which-key far better than mine: https://github.com/folke/which-key.nvim
telescope-command-palette.nvim
is a neovim plugin written entirely in lua that will help you to access your custom commands/function/key-bindings.
Plug "nvim-telescope/telescope.nvim"
Plug "LinArcX/telescope-command-palette.nvim"
use { "nvim-telescope/telescope.nvim" }
use { "LinArcX/telescope-command-palette.nvim" }
First set up your commands in your Telescope config:
require('telescope').setup({
extensions = {
command_palette = {
{"File",
{ "entire selection (C-a)", ':call feedkeys("GVgg")' },
{ "save current file (C-s)", ':w' },
{ "save all files (C-A-s)", ':wa' },
{ "quit (C-q)", ':qa' },
{ "file browser (C-i)", ":lua require'telescope'.extensions.file_browser.file_browser()", 1 },
{ "search word (A-w)", ":lua require('telescope.builtin').live_grep()", 1 },
{ "git files (A-f)", ":lua require('telescope.builtin').git_files()", 1 },
{ "files (C-f)", ":lua require('telescope.builtin').find_files()", 1 },
},
{"Help",
{ "tips", ":help tips" },
{ "cheatsheet", ":help index" },
{ "tutorial", ":help tutor" },
{ "summary", ":help summary" },
{ "quick reference", ":help quickref" },
{ "search help(F1)", ":lua require('telescope.builtin').help_tags()", 1 },
},
{"Vim",
{ "reload vimrc", ":source $MYVIMRC" },
{ 'check health', ":checkhealth" },
{ "jumps (Alt-j)", ":lua require('telescope.builtin').jumplist()" },
{ "commands", ":lua require('telescope.builtin').commands()" },
{ "command history", ":lua require('telescope.builtin').command_history()" },
{ "registers (A-e)", ":lua require('telescope.builtin').registers()" },
{ "colorshceme", ":lua require('telescope.builtin').colorscheme()", 1 },
{ "vim options", ":lua require('telescope.builtin').vim_options()" },
{ "keymaps", ":lua require('telescope.builtin').keymaps()" },
{ "buffers", ":Telescope buffers" },
{ "search history (C-h)", ":lua require('telescope.builtin').search_history()" },
{ "paste mode", ':set paste!' },
{ 'cursor line', ':set cursorline!' },
{ 'cursor column', ':set cursorcolumn!' },
{ "spell checker", ':set spell!' },
{ "relative number", ':set relativenumber!' },
{ "search highlighting (F12)", ':set hlsearch!' },
}
}
}
})
And then load the extension:
require('telescope').load_extension('command_palette')
The idea is that you declare some categories("Help", "Vim", etc..) and inside each category, you define your commands. Each command has three parts:
Tip: CpMenu
is just a simple table.
If you're working on different projects and want to have special key_bindings per project, you can create a .nvimrc
file in root of your project and append items to CpMenu
like this:
table.insert(require('command_palette').CpMenu,
{"Dap",
{ "pause", ":lua require'dap'.pause()" },
{ "step into", ":lua require'dap'.step_into()" },
{ "step back", ":lua require'dap'.step_back()" },
{ "step over", ":lua require'dap'.step_over()" },
{ "step out", ":lua require'dap'.step_out()" },
{ "frames", ":lua require'telescope'.extensions.dap.frames{}" },
{ "current scopes", ":lua ViewCurrentScopes(); vim.cmd(\"wincmd w|vertical resize 40\")" },
{ "current scopes floating window", ":lua ViewCurrentScopesFloatingWindow()" },
{ "current value floating window", ":lua ViewCurrentValueFloatingWindow()" },
{ "commands", ":lua require'telescope'.extensions.dap.commands{}" },
{ "configurations", ":lua require'telescope'.extensions.dap.configurations{}" },
{ "repl", ":lua require'dap'.repl.open(); vim.cmd(\"wincmd w|resize 12\")" },
{ "close", ":lua require'dap'.close(); require'dap'.repl.close()" },
{ "run to cursor", ":lua require'dap'.run_to_cursor()" },
{ "continue", ":lua require'dap'.continue()" },
{ "clear breakpoints", ":lua require('dap.breakpoints').clear()" },
{ "brakpoints", ":lua require'telescope'.extensions.dap.list_breakpoints{}" },
{ "toggle breakpoint", ":lua require'dap'.toggle_breakpoint()" },
})
Key | Description |
---|---|
c-b |
go back to categories |
Key | Description |
---|---|
c-b |
go back to categories |
:Telescope command_palette
.
If you have any idea to improve this project, please create a pull-request for it. To make changes consistent, i have some rules:
Before submit your work, please format it with StyLua.
stylua .
There should be a one-to-one relation between features and pull requests. Please create separate pull-requests for each feature.
Please use snake_case for function names and local variables
If your PR have more than one commit, please squash them into one.
Use meaningful name for variables and functions. Don't use abbreviations as far as you can.