Skip to content

Commit

Permalink
docs(README): add save_extra_cmds quickfix example
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronr committed Sep 13, 2024
1 parent 03714d9 commit 3312d7e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,25 @@ require('auto-session').setup {
end
},

-- Save quickfix list and open it when restoring the session
save_extra_cmds = {
function()
return [[echo "hello world"]]
end
}
}
local qflist = vim.fn.getqflist()
-- return nil to clear any old qflist
if #qflist == 0 then return nil end
local qfinfo = vim.fn.getqflist({ title = 1 })

for _, entry in ipairs(qflist) do
-- use filename instead of bufnr so it can be reloaded
entry.filename = vim.api.nvim_buf_get_name(entry.bufnr)
entry.bufnr = nil
end

local setqflist = 'call setqflist(' .. vim.fn.string(qflist) .. ')'
local setqfinfo = 'call setqflist([], "a", ' .. vim.fn.string(qfinfo) .. ')'
return { setqflist, setqfinfo, 'copen' }
end,
},
```

## ➖ Statusline
Expand Down

0 comments on commit 3312d7e

Please sign in to comment.