Closed hesseltuinhof closed 2 years ago
You could create a custom sink. Maybe something like this:
local M = {}
function M.edit_ag_selection(selection)
if not selection then
return
end
local parts = vim.split(selection, ':')
local path = parts[1]
vim.cmd('e ' .. path)
end
You'd put it somewhere in your ~/.config/nvim/lua/
, for example in ~/.config/nvim/lua/myfzy.lua
and then use
fzy.execute('ag --nobreak --noheading .', require('myfzy').edit_ag_selection)<cr>
Works like a charm.
I just replaced
local path = parts[1]
vim.cmd('e ' .. path)
with
local path, line = parts[1], parts[2]
vim.cmd("e +" .. line .. " " .. path)
Is such a live grep sink something you would consider adding? I can additionally test with rg
and prepare a quick PR.
Adding just the sink should be fine if the format works for other tools as well.
Is there an easy way to configure a keybinding that allows for live grep across the working directory?
I am currently stuck with
fzy.execute('ag --nobreak --noheading .', fzy.sinks.edit_file)<cr>"
. This gives me something like thisOf course,
sinks.edit_file
can't open the selection and we need to further parse it. How best to proceed here? Any pointers are appreciated :heart: