Skip to content

yet another command palette for neovim

License

Notifications You must be signed in to change notification settings

muchzill4/yacp.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 yacp.nvim

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.

yacp

Setup

Install

use {
  "muchzill4/yacp.nvim",
  -- when using provider other than "native":
  -- requires = {
  --   "nvim-telescope/telescope.nvim", -- provider = "telescope"
  --   "ibhagwan/fzf-lua" -- provider = "fzf"
  -- },
}

Configure

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
    },
  },
}

Usage

:lua require("yacp").yacp()

Re-run last command executed via command palette:

:lua require("yacp").replay()

Extending command palette

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

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

Workflow hint

  1. Run a command you'd like to focus on using vim command line mode
  2. Execute "focus set" entry from command palette
  3. Paste the command you've run in step 1. using ": vim register: <C-r>:

Similar plugins