Skip to content

Commit

Permalink
feat: better support for lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Aug 9, 2024
1 parent b6a3d2f commit 29ab2a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ quicker.nvim supports all the usual plugin managers
```lua
{
'stevearc/quicker.nvim',
event = "FileType qf",
---@module "quicker"
---@type quicker.SetupOptions
opts = {},
Expand Down
15 changes: 15 additions & 0 deletions lua/quicker/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ local function setup(opts)
end

vim.o.quickfixtextfunc = "v:lua.require'quicker.display'.quickfixtextfunc"

-- If the quickfix/loclist is already open, refresh it so the quickfixtextfunc will take effect.
-- This is required for lazy-loading to work properly.
local list = vim.fn.getqflist({ all = 0 })
if not vim.tbl_isempty(list.items) then
vim.fn.setqflist({}, "r", list)
end
for _, winid in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_is_valid(winid) then
local llist = vim.fn.getloclist(winid, { all = 0 })
if not vim.tbl_isempty(list.items) then
vim.fn.setloclist(winid, {}, "r", llist)
end
end
end
end

M.setup = setup
Expand Down

0 comments on commit 29ab2a6

Please sign in to comment.