Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ local defaults = {
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
-- set custom keys for spell choices (e.g. home keys)
keys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
},
presets = {
operators = true, -- adds help for operators like d, y, ...
Expand Down
2 changes: 2 additions & 0 deletions doc/which-key.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Default Options ~
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
-- set custom keys for spell choices (e.g. home keys)
keys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
},
presets = {
operators = true, -- adds help for operators like d, y, ...
Expand Down
2 changes: 2 additions & 0 deletions lua/which-key/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ local defaults = {
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
-- set custom keys for spell choices (e.g. home keys)
keys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
},
presets = {
operators = true, -- adds help for operators like d, y, ...
Expand Down
9 changes: 8 additions & 1 deletion lua/which-key/plugins/spelling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ M.opts = {}

function M.setup(opts)
M.opts = opts
-- NOTE This logic could be within opts validation
if M.opts.suggestions > string.len(M.opts.keys) then
require("which-key.util").warn(
{ "Error in spelling config", "Number of suggestions exceeds provided keys" },
{ once = true }
)
end
end

function M.expand()
Expand All @@ -36,7 +43,7 @@ function M.expand()
local suggestions = vim.fn.spellsuggest(word, M.opts.suggestions or 20, bad[2] == "caps" and 1 or 0)

local items = {} ---@type wk.Plugin.item[]
local keys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
local keys = M.opts.keys

for i, label in ipairs(suggestions) do
local key = keys:sub(i, i)
Expand Down