aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-04-20 12:14:27 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-04-20 12:14:27 +0200
commitfe56553ae62a96344fe8b71bcd81b87afab0b1b6 (patch)
tree9010491465bc6ba537c6a6e94b83ec5a05a08a80
parent775fe52abb7575590a3a172e884e52566d4f6023 (diff)
downloadvis-spellcheck-fe56553ae62a96344fe8b71bcd81b87afab0b1b6.tar.gz
ignore newly added word to prevent it from being highlighted
-rw-r--r--spellcheck.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index ba87550..38d72b1 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -396,7 +396,7 @@ vis:map(vis.modes.NORMAL, '<C-w>w', function()
return 0
end, 'Correct misspelled word')
-vis:map(vis.modes.NORMAL, '<C-w>i', function()
+local ignore = function()
local win = vis.win
local file = win.file
local pos = win.selection.pos
@@ -425,6 +425,10 @@ vis:map(vis.modes.NORMAL, '<C-w>i', function()
end
win:draw()
+end
+
+vis:map(vis.modes.NORMAL, '<C-w>i', function()
+ ignore()
return 0
end, 'Ignore misspelled word')
@@ -442,7 +446,14 @@ vis:map(vis.modes.NORMAL, '<C-w>a', function()
local cmd = string.format(':!echo "*%s\\n#" | %s', file:content(range),
spellcheck.cmd:format(spellcheck.get_lang()))
- return vis:command(cmd)
+
+ if not vis:command(cmd) then
+ vis:info('executing vis command: "' .. cmd .. '" failed')
+ end
+
+ -- ignore the added word to prevent it from being highlighted in this session
+ ignore()
+ return 0
end, 'Add word to user dictionary')
vis:option_register('spelllang', 'string', function(value)