aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Readme.md1
-rw-r--r--spellcheck.lua17
2 files changed, 18 insertions, 0 deletions
diff --git a/Readme.md b/Readme.md
index 48d5f15..f0c2865 100644
--- a/Readme.md
+++ b/Readme.md
@@ -14,6 +14,7 @@ A spellchecking lua plugin for the [vis editor](https://github.com/martanne/vis)
+ To toggle highlighting press `<F7>` in normal mode.
+ To correct the word under the cursor press `<Ctrl+w>w` in normal mode.
+ To ignore the word under the cursor press `<Ctrl+w>i` in normal mode.
++ To add the word under the cursor to the user dictionary press '<Ctrl+w>a' in normal mode.
## Configuration
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)