An extension for neovim that allows you to run arbitrary commands via a command palette.
Useful for repetitive but map unworthy actions you frequently perform.
use {
"muchzill4/yacp.nvim",
-- when using provider other than "native":
-- requires = {
-- "nvim-telescope/telescope.nvim", -- provider = "telescope"
-- "ibhagwan/fzf-lua" -- provider = "fzf"
-- },
}
require("yacp").setup {
provider = "native", -- native (default, uses vim.ui.select) | telescope | fzf
palette = {
{ name = "echo in term", cmd = "term echo SUCCESS" },
{ name = "help", cmd = "Telescope help_tags" },
{ name = "hi", cmd = function() print("HI!") end },
{
name = "do stuff only in go files",
cmd = "...",
show = function()
return vim.bo.filetype == "go"
end
},
},
}
:lua require("yacp").yacp()
Re-run last command executed via command palette:
:lua require("yacp").replay()
This can be useful in a project specific setup. Instead of polluting your global command palette via setup()
, you can use exrc
or windwp/nvim-projectconfig to run palette.extend()
when running vim in a specific directory.
local palette = require "yacp.palette"
palette.extend({
{ name = "build", cmd = "make build" },
...
})
Focus is an optional feature, which allows you to set a temporary palette entry named "focus run".
- "Focus run" becomes visible, once focus command is set
- You can set the focus command by using either:
- "focus set" palette entry
:lua require("yacp.focus").set()
To use focus, you need to first enable it in your setup:
require("yacp").setup {
...
enable_focus = true,
}
focus-demo.mp4
- Run a command you'd like to focus on using vim command line mode
- Execute "focus set" entry from command palette
- Paste the command you've run in step 1. using
":
vim register:<C-r>: