Skip to content

Commit 2d49435

Browse files
committed
#3 use title to identify foreign quickfix
1 parent 1dd0db5 commit 2d49435

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

lua/diaglist/init.lua

-13
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ function M.init(opts)
1414
vim.api.nvim_command [[au BufEnter * lua require("diaglist").diagnostics_hook(false)]]
1515
vim.api.nvim_command [[aug END]]
1616

17-
vim.api.nvim_command [[aug qf_hook]]
18-
vim.api.nvim_command [[au!]]
19-
vim.api.nvim_command [[au! QuickFixCmdPre * lua require("diaglist").quick_fix_hook()]]
20-
vim.api.nvim_command [[aug END]]
21-
2217
if opts == nil then
2318
opts = {}
2419
end
@@ -57,12 +52,4 @@ function M.diagnostics_hook(diag_changed)
5752
q.diagnostics_hook()
5853
end
5954

60-
function M.quick_fix_hook()
61-
if M.debug then
62-
print("foreign quickfix populated, setting flag")
63-
end
64-
q.foreign_qf = true
65-
end
66-
67-
6855
return M

lua/diaglist/quickfix.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ local util = require('diaglist.util')
44

55
local M = {}
66

7-
M.foreign_qf = false
87
M.last_priority_uri = nil
8+
M.title = 'Workspace Diagnostics'
9+
10+
local function is_qf_foreign()
11+
return vim.fn.getqflist{ title = 0 }.title ~= M.title
12+
end
913

1014
local function populate_qflist(open_qflist)
1115
local priority_uri = vim.uri_from_bufnr(0)
@@ -21,6 +25,7 @@ local function populate_qflist(open_qflist)
2125
})
2226

2327
vim.fn.setqflist(all_diagnostics, 'r')
28+
vim.fn.setqflist({}, 'a', {title = 'Workspace Diagnostics'})
2429
end
2530

2631
M.open_all_diagnostics = function()
@@ -29,7 +34,7 @@ M.open_all_diagnostics = function()
2934
end
3035

3136
M.diagnostics_hook = function()
32-
if not M.foreign_qf then
37+
if not is_qf_foreign() then
3338
populate_qflist()
3439
elseif M.debug then
3540
print('foreign quickfix, not populating')

0 commit comments

Comments
 (0)