vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
visrc.lua
(742B)
1 package.path = '../../lua/?.lua;'..package.path
2 dofile("../../lua/vis.lua")
3
4 local function run_if_exists(luafile)
5 local f = io.open(luafile, "r")
6 if f ~= nil then
7 f:close()
8 dofile(luafile)
9 end
10 end
11
12 vis.events.subscribe(vis.events.WIN_OPEN, function(win)
13 -- test.in file passed to vis
14 local name = win.file.name
15 if name then
16 -- use the corresponding test.lua file
17 name = string.gsub(name, '%.in$', '')
18 run_if_exists(string.format("%s.lua", name))
19 local file = io.open(string.format("%s.keys", name))
20 local keys = file:read('*all')
21 keys = string.gsub(keys, '%s*\n', '')
22 keys = string.gsub(keys, '<Space>', ' ')
23 file:close()
24 vis:feedkeys(keys..'<Escape>')
25 vis:command(string.format("w! '%s.out'", name))
26 end
27 end)