ctrlsf.vim icon indicating copy to clipboard operation
ctrlsf.vim copied to clipboard

Populate CtrlSF from traditional quickfix list?

Open jesseleite opened this issue 5 years ago • 6 comments

Can CtrlSF results be populated from a traditional quickfix window? I'm using another plugin which populates the quickfix, and it'd be cool if we could call a function to transfer what's in the quickfix to CtrlSF to see more context and use CtrlSF's edit mode on the results of this other plugin 😬

jesseleite avatar Nov 05 '18 15:11 jesseleite

Maybe something like ctrlsf#db#SetResultSetFromQuickfix() 🤔

jesseleite avatar Nov 05 '18 16:11 jesseleite

It's almost impossible because the context lines to show must exist at first, but in your case, they do not exist at all in anywhere of Vim.

But what plugin are you using to populate the quickfix? If it does also read result from a grep-like program, maybe CtrlSF could adopt that as a new backend.

dyng avatar Nov 06 '18 00:11 dyng

Not a new grep-like, it's just ag under the hood.

I'm using two plugins actually, fzf.vim and vim-agriculture. Fzf.vim has this awesome realtime filtering post-search that's a big part of my workflow. And agriculture provides an awesome :AgRaw command that lets me pass raw command line arguments directly to ag. If you want to know more, I actually just wrote a post detailing my workflow here.

That said, I absolutely love CtrlSF post-search, with how you display and allow editing of results 🔥 But I'd like to combine that with my own call to ag. Anyway...

It's almost impossible because the context lines to show must exist at first, but in your case, they do not exist at all in anywhere of Vim.

If we can't populate from the quickfix, I actually have access to the both the raw ag output, and the filtered results from fzf.vim. Maybe I can pass my ag output into CtrlSF via a function call somehow?

PS. Not sure if you are open to chatting more on Discord? If so, hit me up at jesseleite#8296!

jesseleite avatar Nov 06 '18 00:11 jesseleite

Ok, I have got your point, it seems quite possible now. Suppose you have read the source code, add a new argument (like -external) that makes CtrlSF read resultset/output from a given variable, then CtrlSF will do the rest.

Make sure it does not interfere with the async mode.

dyng avatar Nov 06 '18 01:11 dyng

Like?

:CtrlSF -external 'agriculture#ctrlsf_output'

Or a new command like?

:CtrlSFFromExternal 'agriculture#ctrlsf_output'

jesseleite avatar Nov 06 '18 01:11 jesseleite

Looks like the -external can not be combined with other arguments, I think a new command may be better.

dyng avatar Nov 06 '18 01:11 dyng