aboutsummaryrefslogtreecommitdiffstats
path: root/spellcheck.lua
diff options
context:
space:
mode:
authorRandy Palamar <palamar@ualberta.ca>2023-04-19 22:39:52 -0600
committerRandy Palamar <palamar@ualberta.ca>2023-04-19 22:52:52 -0600
commit775fe52abb7575590a3a172e884e52566d4f6023 (patch)
treebd1e547918c9d6c77242099206f80dbaa720177c /spellcheck.lua
parent0e6c04945b6ce920bbd074e61949de62f1b41763 (diff)
downloadvis-spellcheck-775fe52abb7575590a3a172e884e52566d4f6023.tar.gz
add keybind to add word to user dictionary
Diffstat (limited to 'spellcheck.lua')
-rw-r--r--spellcheck.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index 1d0d6c7..ba87550 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -428,6 +428,23 @@ vis:map(vis.modes.NORMAL, '<C-w>i', function()
return 0
end, 'Ignore misspelled word')
+vis:map(vis.modes.NORMAL, '<C-w>a', function()
+ local file = vis.win.file
+ local pos = vis.win.selection.pos
+ if not pos then
+ return
+ end
+
+ local range = file:text_object_word(pos);
+ if not range or range.start == range.finish then
+ return
+ end
+
+ local cmd = string.format(':!echo "*%s\\n#" | %s', file:content(range),
+ spellcheck.cmd:format(spellcheck.get_lang()))
+ return vis:command(cmd)
+end, 'Add word to user dictionary')
+
vis:option_register('spelllang', 'string', function(value)
vis.win.file.spell_language = value
vis:info('Spellchecking language is now ' .. value)