Skip to content

Commit

Permalink
feat: make delay configurable for marks/registers/spelling. Fixes #379.
Browse files Browse the repository at this point in the history
Fixes #152, Fixes #220, Fixes #334
  • Loading branch information
folke committed Feb 28, 2023
1 parent 5224c26 commit 5649320
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ WhichKey comes with the following defaults:
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
spelling = {
enabled = false, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
},
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
operators = true, -- adds help for operators like d, y, ...
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
Expand All @@ -109,21 +109,24 @@ WhichKey comes with the following defaults:
-- ["<cr>"] = "RET",
-- ["<tab>"] = "TAB",
},
motions = {
count = true,
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+", -- symbol prepended to a group
},
popup_mappings = {
scroll_down = '<c-d>', -- binding to scroll down inside the popup
scroll_up = '<c-u>', -- binding to scroll up inside the popup
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
window = {
border = "none", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0
padding = { 1, 2, 1, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
Expand All @@ -132,23 +135,35 @@ WhichKey comes with the following defaults:
align = "left", -- align columns left, center or right
},
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "^:", "^ ", "^call ", "^lua " }, -- hide mapping boilerplate
show_help = true, -- show a help message in the command line for using WhichKey
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specify a list manually
-- triggers = {"<leader>"} -- or specifiy a list manually
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks
"`",
"'",
"g`",
"g'",
-- registers
'"',
"<c-r>",
-- spelling
"z=",
},
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
-- this is mostly relevant for key maps that start with a native binding
-- most people should not need to change this
-- this is mostly relevant for keymaps that start with a native binding
i = { "j", "k" },
v = { "j", "k" },
},
-- disable the WhichKey popup for certain buf types and file types.
-- Disabled by deafult for Telescope
disable = {
buftypes = {},
filetypes = { "TelescopePrompt" },
filetypes = {},
},
}
```
Expand Down
14 changes: 13 additions & 1 deletion lua/which-key/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ local defaults = {
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specifiy a list manually
triggers_nowait = {}, -- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks
"`",
"'",
"g`",
"g'",
-- registers
'"',
"<c-r>",
-- spelling
"z=",
},
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
-- this is mostly relevant for keymaps that start with a native binding
Expand Down
6 changes: 1 addition & 5 deletions lua/which-key/plugins/marks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ M.actions = {
{ trigger = "g'", mode = "n" },
}

function M.setup(_wk, _config, options)
for _, action in ipairs(M.actions) do
table.insert(options.triggers_nowait, action.trigger)
end
end
function M.setup(_wk, _config, options) end

local labels = {
["^"] = "Last position of cursor in insert mode",
Expand Down
10 changes: 2 additions & 8 deletions lua/which-key/plugins/registers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ M.name = "registers"
M.actions = {
{ trigger = '"', mode = "n" },
{ trigger = '"', mode = "v" },
{ trigger = "@", mode = "n", delay = true },
{ trigger = "@", mode = "n" },
{ trigger = "<c-r>", mode = "i" },
{ trigger = "<c-r>", mode = "c" },
}

function M.setup(_wk, _config, options)
for _, action in ipairs(M.actions) do
if not action.delay then
table.insert(options.triggers_nowait, action.trigger)
end
end
end
function M.setup(_wk, _config, options) end

M.registers = '*+"-:.%/#=_abcdefghijklmnopqrstuvwxyz0123456789'

Expand Down
1 change: 0 additions & 1 deletion lua/which-key/plugins/spelling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ M.actions = { { trigger = "z=", mode = "n" } }
M.opts = {}

function M.setup(_, config, options)
table.insert(options.triggers_nowait, "z=")
M.opts = config
end

Expand Down

0 comments on commit 5649320

Please sign in to comment.