vis: add key for fzf change directory
This commit is contained in:
@@ -70,7 +70,12 @@ local function escape_and_quoted(s)
|
||||
return "'" .. s:gsub("'", "\\'") .. "'"
|
||||
end
|
||||
|
||||
local function search(cmd)
|
||||
local function search(cmd, action)
|
||||
if action == nil then
|
||||
action = function(out)
|
||||
open_file_pos(out, 'e')
|
||||
end
|
||||
end
|
||||
if cmd:match('^fzf ') and vis.register ~= '"' then
|
||||
local reg = string.gsub(vis.registers[vis.register][1], '%z', '')
|
||||
if reg ~= '' then
|
||||
@@ -79,7 +84,7 @@ local function search(cmd)
|
||||
end
|
||||
local code, out, err = vis:pipe(cmd, true)
|
||||
if code == 0 then
|
||||
open_file_pos(out, 'e')
|
||||
action(out)
|
||||
elseif err ~= nil then
|
||||
vis:info(err)
|
||||
elseif code ~= 0 then
|
||||
@@ -197,6 +202,12 @@ vis.events.subscribe(vis.events.INIT, function()
|
||||
vis:map(vis.modes.NORMAL, 'gf', function()
|
||||
open_file_current_line('o')
|
||||
end, 'open file from current line (with line and col')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' cd', function()
|
||||
search('zoxide query -l | fzf', function(path)
|
||||
vis:command('cd ' .. path)
|
||||
end)
|
||||
end, 'fzf change directory')
|
||||
end)
|
||||
|
||||
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
|
||||
|
||||
Reference in New Issue
Block a user