Open ariel-frischer opened 2 years ago
Hey @ariel-frischer essentially there is currently no sessionoptions
for quickfix
in Vim. I agree it would be a welcome addition, in fact there is an old open issue about it in https://github.com/neovim/neovim/issues/7602 about this very thing. Hopefully we can get some traction on that.
As for somehow implementing this through auto-session, it's not one of the goals of this plugin to implement its own session management separately from what Neovim has to offer, that said, one could use probably the session hooks to achieve saving and reloading the quickfix window while there isn't any upstream support for it.
@rmagatti Thanks for the response, that issue does seem super old though (2017!) so I'll look into using the session hook. Really loving the repository though it works great out of the box!
I'll just keep this open though for tracking
For reference, you can use pre_save_cmds and post_restore_cmds to achieve that, I implemented it here.
(accidentally deleted my earlier reply)
@rbmarliere nice solution! if you don't want to handle the file management, you could leverage the save_extra_cmds
auto-session
hook to automatically create a <session_file>x.vim
file on save and it'll automatically source it on restore. for example, from your dotfiles, you could do this:
save_extra_cmds = {
function()
local _qflist = vim.fn.getqflist()
if #_qflist == 0 then return nil end
local _qfinfo = vim.fn.getqflist({ title = 1 })
for _, entry in ipairs(_qflist) do
-- the goal is to use SaveQf across nvim instances,
-- so use filename instead of bufnr
entry.filename = vim.api.nvim_buf_get_name(entry.bufnr)
entry.bufnr = nil
end
local _setqflist = string.format('call setqflist(%s)', vim.fn.string(_qflist))
local _setqfinfo = string.format('call setqflist([], "a", %s)', vim.fn.string(_qfinfo))
return { _setqflist, _setqfinfo, 'copen' }
end,
},
As for somehow implementing this through auto-session, it's not one of the goals of this plugin to implement its own session management separately from what Neovim has to offer, that said, one could use probably the session hooks to achieve saving and reloading the quickfix window while there isn't any upstream support for it.
I am revisiting my position on this particular feature request. While it still holds true that extending auto-session to support session features that aren't nvim-out-of-the-box-supported is still a non-goal, perhaps this could be a worthwhile exception given that quickfix would 1. be very useful 2. is a vim staple feature 3. is fairly simple to implement
Is your feature request related to a problem? Please describe. I want to be able to save the quickfix list for each session and maybe even location list.
Describe the solution you'd like Saving the quickfix list in the session file.