aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-28 09:54:32 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-28 09:54:32 +0100
commit28fae462be95a0573113c76d9d2641e73dd1b44e (patch)
tree33f19ca3a12ffca36b0b5c34dd1466e36ee16292 /lua/plugins
parentb759216c0ab22f03f8dbcdfbcaae9fa41d998949 (diff)
downloadvis-28fae462be95a0573113c76d9d2641e73dd1b44e.tar.gz
vis-28fae462be95a0573113c76d9d2641e73dd1b44e.tar.xz
lua: move digraph handling to separate 'plugin'
Load a standard plugins directly from vis-std.lua.
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/digraph.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/lua/plugins/digraph.lua b/lua/plugins/digraph.lua
new file mode 100644
index 0000000..b783612
--- /dev/null
+++ b/lua/plugins/digraph.lua
@@ -0,0 +1,23 @@
+-- insert digraphs using vis-digraph(1)
+
+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")