close window on fzf

This commit is contained in:
Felix Van der Jeugt 2017-11-17 17:37:24 +01:00
parent f28279f9f4
commit 29c28feec0
No known key found for this signature in database
GPG Key ID: 58B209295023754D

View File

@ -16,15 +16,27 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win)
vis:command('set show-tabs on')
vis:command('set number')
vis:command('set theme dark-16')
vis:command('set escdelay 1')
vis:command('set escdelay 0')
end)
vis:map(vis.modes.NORMAL, ";l", function()
vis:command_register("fzf", function(argv, force, cur_win, selection, range)
local old = cur_win
local out = io.popen("fzf"):read()
if out then
vis:command(string.format('open %s', out))
if argv[1] then
old:close(force)
end
vis:feedkeys("<vis-redraw>")
end
vis:feedkeys("<vis-redraw>")
end)
vis:map(vis.modes.NORMAL, ";l", function()
vis:command('fzf')
end)
vis:map(vis.modes.NORMAL, ";o", function()
vis:command('fzf true')
end)
vis:map(vis.modes.NORMAL, ";;", "<vis-window-next>")