diff --git a/shell/.config/shellconfig/aliases.sh b/shell/.config/shellconfig/aliases.sh index d840545..0245567 100644 --- a/shell/.config/shellconfig/aliases.sh +++ b/shell/.config/shellconfig/aliases.sh @@ -29,5 +29,5 @@ ta() { } vf() { - fzf --bind 'enter:become:vis {}' -q "$1" + vis "+fzf-files auto-files '$1'" } diff --git a/vis/.config/vis/visrc.lua b/vis/.config/vis/visrc.lua index 1fa3b52..7104051 100644 --- a/vis/.config/vis/visrc.lua +++ b/vis/.config/vis/visrc.lua @@ -91,7 +91,7 @@ local function cmd_action(cmd, action) end end -local function fzf_sh(arg) +local function fzf_sh(arg, query) action = function(out) if (out:find('\n') or #out) == #out then open_file_pos(out, vis.win.file.modified and 'o' or 'e') @@ -102,16 +102,19 @@ local function fzf_sh(arg) local home = os.getenv('HOME') local path = vis.win.file.path or '' local dir = path:match('^.*/') or '' - local reg = '' - if vis.register ~= '"' then - reg = string.gsub(vis.registers[vis.register][1], '%z', '') + if not query and vis.register ~= '"' then + query = string.gsub(vis.registers[vis.register][1], '%z', '') end local cmd = home .. '/.config/vis/fzf.sh ' .. - escape_and_quoted(arg) .. ' ' .. escape_and_quoted(dir) .. ' ' .. escape_and_quoted(reg) + escape_and_quoted(arg) .. ' ' .. escape_and_quoted(dir) .. ' ' .. escape_and_quoted(query or '') cmd_action(cmd, action) end +vis:command_register('fzf-files', function(argv, force, win, selection, range) + fzf_sh(argv[1] or 'auto-files', argv[2]) +end) + local function search(cmd, action) if action == nil then action = function(out) @@ -269,13 +272,8 @@ vis.events.subscribe(vis.events.INIT, function() 'open file slot ' .. num) end - vis:map(vis.modes.NORMAL, ' s', function() - fzf_sh('auto-search') - end, 'fzf: search') - - vis:map(vis.modes.NORMAL, ' f', function() - fzf_sh('auto-files') - end, 'fzf: files') + vis:map(vis.modes.NORMAL, ' s', ':fzf-files auto-search', 'fzf: search') + vis:map(vis.modes.NORMAL, ' f', ':fzf-files auto-files', 'fzf: files') vis:map(vis.modes.NORMAL, ' /', function() search(fzf_reload(ripgrep .. ' --with-filename {q} ' .. escape_and_quoted(vis.win.file.path)))