vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 9b5df4d082576002408e513f0c870679af299835 parent 4e611fce5192348ccf08cdc20cf1b8d39b728a48 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 28 Feb 2017 09:54:32 +0100 lua: move digraph handling to separate 'plugin' Load a standard plugins directly from vis-std.lua. Diffstat:
| A | lua/plugins/digraph.lua | | | 23 | +++++++++++++++++++++++ |
| M | lua/vis-std.lua | | | 26 | ++++---------------------- |
| M | lua/visrc.lua | | | 2 | -- |
3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/lua/plugins/digraph.lua 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") diff --git a/lua/vis-std.lua b/lua/vis-std.lua @@ -123,26 +123,8 @@ vis.events.subscribe(vis.events.WIN_STATUS, function(win) win:status(left, right); end) --- additional default keybindings +-- default plugins -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") +require('plugins/filetype') +require('plugins/textobject-lexer') +require('plugins/digraph') diff --git a/lua/visrc.lua b/lua/visrc.lua @@ -1,7 +1,5 @@ -- load standard vis module, providing parts of the Lua API require('vis') -require('plugins/filetype') -require('plugins/textobject-lexer') vis.events.subscribe(vis.events.INIT, function() -- Your global configuration options