Skip to content

Instantly share code, notes, and snippets.

@kawarimidoll
Last active May 24, 2025 09:46
Show Gist options
  • Save kawarimidoll/31edc1b58e44fdd350fa378bbb7c9722 to your computer and use it in GitHub Desktop.
Save kawarimidoll/31edc1b58e44fdd350fa378bbb7c9722 to your computer and use it in GitHub Desktop.
Show sources of ins-completion by which-key.nvim
local wk = require("which-key")
wk.setup()
-- :h ins-completion
wk.register({
["<C-l>"] = 'Whole lines',
["<C-n>"] = 'keywords in the current file',
["<C-k>"] = 'keywords in dictionary',
["<C-t>"] = 'keywords in thesaurus',
["<C-i>"] = 'keywords in the current and included files',
["<C-]>"] = 'tags',
["<C-f>"] = 'file names',
["<C-d>"] = 'definitions or macros',
["<C-v>"] = 'Vim command-line',
["<C-u>"] = 'User defined completion',
["<C-o>"] = 'omni completion',
["<C-s>"] = 'Spelling suggestions',
["<C-z>"] = 'stop completion',
}, {
mode = "i",
prefix = "<C-x>",
})
@kawarimidoll
Copy link
Author

@dacbd
Copy link

dacbd commented May 24, 2025

here is an example i put together for those using Lazy and which-key v3.

  {
    "folke/which-key.nvim",
    event = "VeryLazy",
    opts = {
      delay = 0,
      spec = {
        { "<leader>s", group = "[S]earch" },
        { "<leader>g", group = "LSP Actions" },
        { "<leader>gg", group = "[G]oto" },
        {
          mode = "i", -- insert mode mappings
          { "<C-x>", group = "Insert Completion" }, -- label the prefix
          { "<C-x><C-l>", desc = "Whole lines" },
          { "<C-x><C-n>", desc = "Keywords in current file" },
          { "<C-x><C-k>", desc = "Keywords in dictionary" },
          { "<C-x><C-t>", desc = "Keywords in thesaurus" },
          { "<C-x><C-i>", desc = "Keywords in current+included files" },
          { "<C-x><C-]>", desc = "Tags" },
          { "<C-x><C-f>", desc = "File names" },
          { "<C-x><C-d>", desc = "Definitions/macros" },
          { "<C-x><C-v>", desc = "Vim command-line" },
          { "<C-x><C-u>", desc = "User-defined completion" },
          { "<C-x><C-o>", desc = "Omni completion" },
          { "<C-x><C-s>", desc = "Spelling suggestions" },
          { "<C-x><C-z>", desc = "Stop completion" },
        },
      },
      triggers = {
        { "<auto>", mode = "nixsotc" },
      },
    },
    keys = {
      {
        "<leader>?",
        function()
          require("which-key").show({ global = false })
        end,
        desc = "Buffer Local Keymaps (which-key)",
      },
    },
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment