aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-01-10 13:25:00 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-01-10 13:33:37 +0100
commit88cf954638a399b2c385bc71f09de48b5628832f (patch)
tree9ebcc863f41e94ca46ccb948e007ef2c535e22ee
parent629088aeb9b38d6710995e8abd51df7d4706b025 (diff)
downloadvis-spellcheck-88cf954638a399b2c385bc71f09de48b5628832f.tar.gz
update to api 0.4
-rw-r--r--spellcheck.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index 71023de..85d6ef9 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -36,9 +36,13 @@ function spellcheck(file, range)
if correction and correction ~= "*" then
-- get corrections
local orig, pos, sug = correction:match("& (%S+) %d+ (%d+): (.*)")
+ if not orig then
+ orig = correction:match("# (%S+).*")
+ vis:info("No correction availlable for " .. orig .. ".")
+ end
if orig ~= w then
orig = orig or "nil"
- print("Bad things happend!! Correction: " .. orig .. " is not for " .. w)
+ vis:message("Bad things happend!! Correction: " .. orig .. " is not for " .. w)
return w
end
-- select a correction
@@ -51,8 +55,6 @@ function spellcheck(file, range)
if correction then
return correction
end
- else
- print("Bad things happend!! No correction available for " .. w)
end
end)
@@ -62,7 +64,7 @@ function spellcheck(file, range)
end
end
-vis:map(vis.modes.NORMAL, "<C-s>", function(keys)
+vis:map(vis.modes.NORMAL, "<C-w>a", function(keys)
local win = vis.win
local file = win.file
ret, err = spellcheck(file, { start=0, finish=file.size })
@@ -73,19 +75,25 @@ vis:map(vis.modes.NORMAL, "<C-s>", function(keys)
return 0
end, "Spellcheck the whole file")
-vis:map(vis.modes.NORMAL, "<C-w>", function(keys)
+vis:map(vis.modes.NORMAL, "<C-w>w", function(keys)
local win = vis.win
local file = win.file
- local pos = win.cursor.pos
+
+ local pos = win.selection.pos
if not pos then return end
local range = file:text_object_word(pos > 0 and pos-1 or pos);
if not range then return end
if range.start == range.finish then return end
+
ret, err = spellcheck(file, range)
if ret then
vis:info(err)
end
+
+ win.selection.pos = pos
+
win:draw()
+
return 0
end, "Spellcheck word")