aboutsummaryrefslogtreecommitdiff
path: root/lua/vis-std.lua
diff options
context:
space:
mode:
authorjosuah <mail@josuah.net>2017-01-27 17:03:14 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-27 21:09:02 +0100
commitb8afec996a400fe42e110033031443d18175d4cd (patch)
tree867380968f313cc22d78c58981b2a0a7879d8676 /lua/vis-std.lua
parent8871316904a9a9cf75f94fae4d6cef76b7271bc2 (diff)
downloadvis-b8afec996a400fe42e110033031443d18175d4cd.tar.gz
vis-b8afec996a400fe42e110033031443d18175d4cd.tar.xz
vis-digraph: add utility to handle digraphs
Hook it up via Lua to <C-k> in insert and replace mode. Close #460 #475
Diffstat (limited to 'lua/vis-std.lua')
-rw-r--r--lua/vis-std.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lua/vis-std.lua b/lua/vis-std.lua
index ff5469a..4da7293 100644
--- a/lua/vis-std.lua
+++ b/lua/vis-std.lua
@@ -137,3 +137,27 @@ vis.events.subscribe(vis.events.WIN_STATUS, function(win)
local right = ' ' .. table.concat(right_parts, " « ") .. ' '
win:status(left, right);
end)
+
+-- additional default keybindings
+
+vis:map(vis.modes.INSERT, "<C-k>", function(keys)
+ if #keys < 2 then
+ return -1 -- need more input
+ end
+ local file = io.popen(string.format("vis-digraph '%s' 2>&1", keys:gsub("'", "'\\''")))
+ local output = file:read('*all')
+ local success, msg, status = file:close()
+ if success then
+ if vis.mode == vis.modes.INSERT then
+ vis:insert(output)
+ elseif vis.mode == vis.modes.REPLACE then
+ vis:replace(output)
+ end
+ elseif msg == 'exit' then
+ if status == 2 then
+ return -1 -- prefix need more input
+ end
+ vis:info(output)
+ end
+ return #keys
+end, "Insert digraph")