blob: 2bb477c1d9518f7b7a95f55c402aa2ef3b0c1a0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
local function file_exists(path)
local f = io.open(path)
local out = f ~= nil
if out then
io.close(f)
end
return out
end
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
if win.file == nil or win.file.path == nil then return end
local ref = win.file.path
-- if the file with colon actually exists, don't do anything
if file_exists(ref) then
return
end
local _, _, path, line = string.find(ref, "^(.+):(%d+)$")
if path == nil or line == nil or line == 0 or not file_exists(path) then
return
end
win:close()
win.file = path
vis:command("e "..path)
vis:command("+"..line-1)
-- or vis:feedkeys(tostring(line).."G")
end)
|