turn fancy spell suggest ui into a lambda, and fix some styling

This commit is contained in:
2024-11-19 13:16:10 -06:00
parent 0953326894
commit 11e1d60804

View File

@ -41,20 +41,18 @@ map('n', ']]', '<cmd>tabn<CR>')
-- good spell suggestion ui
-- (stolen from https://github.com/neovim/neovim/pull/25833)
local spell_on_choice = vim.schedule_wrap(function(_, idx)
if type(idx) == 'number' then
vim.cmd('normal! ' .. idx .. 'z=')
end
end)
vim.keymap.set('n', 'z=', function()
local spell_on_choice = vim.schedule_wrap(function(_, idx)
if type(idx) == 'number' then
vim.cmd('normal! '..idx..'z=')
end
end)
local spellsuggest_select = function()
if vim.v.count > 0 then
spell_on_choice(nil, vim.v.count)
return
end
local cword = vim.fn.expand('<cword>')
local prompt = 'Change ' .. vim.inspect(cword) .. ' to:'
local prompt = 'Change '..vim.inspect(cword)..' to:'
vim.ui.select(vim.fn.spellsuggest(cword, vim.o.lines), { prompt = prompt }, spell_on_choice)
end
vim.keymap.set('n', 'z=', spellsuggest_select, { desc = 'Shows spelling suggestions' })
end, { desc = 'Shows spelling suggestions' })