-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use title to determine wheather to update the quickfix/location list #3
Comments
To expand on this: neovim 0.6 nightly fetaures a handy I am currently using something like this in my personal config: function update_diagnostics(global_too)
if not vim.lsp.buf.server_ready() then
return
end
if vim.fn.getloclist(vim.fn.winnr(), { title = 0 }).title == 'Buffer diagnostics' then
vim.diagnostic.setloclist{ open = false, title = 'Buffer diagnostics' }
end
if global_too and vim.fn.getqflist{ title = 0 }.title == 'Workspace diagnostics' then
vim.diagnostic.setqflist{ open = false, title = 'Workspace diagnostics' }
end
end and in my vim.api.nvim_command('autocmd BufWinEnter * lua update_diagnostics(false)')
vim.api.nvim_command('autocmd User DiagnosticsChanged lua update_diagnostics(true)')
vim.api.nvim_buf_set_keymap(0, 'n', '<C-k>k','<CMD>silent! lua vim.diagnostic.setloclist{ title = "Buffer diagnostics" }<CR>', {noremap=true})
vim.api.nvim_buf_set_keymap(0, 'n', '<C-k><C-k>','<CMD>silent! lua vim.diagnostic.setqflist{ title = "Workspace diagnostics" }<CR>', {noremap=true}) This allows me to use all kinds of non-standard quickfix/location lists (references, implementations, symbols etc.) and populate them with auto-updating diagnostics using a keymap. Something similar (but much more polished) could be integrated into this plugin (although the "release" neovim 0.5.1 does not have |
Hi @piotr-machura , I finally found time to fully adapt plugin to 0.6.x and test your idea. Apparently it works well so master now uses title to identify foreign quickfix! Thank you for the great idea and wonderful examples. Foreign loclist is still to be done. |
The plugin sets a flag on
QuickFixCmdPre
to signify that the quickfix has been populated by something other than the diagnostics. This unfortunatelly conflicts with non-builtin functions utilizing quickfix (likevim.lsp.buf.workspace_symbol()
orvim.lsp.buf.references()
).Both this and the current issue of not respecting foregin location lists can be fixed using
setqflist()
(andgetqflist()
,setloclist()
,getloclist()
), perhaps by specifying the lists' ID or even just the title. Thelsp_diagnostic_hook
can then check if current quickfix list has a specific title (say "Diagnostics") and only then update. If the user wants to force the update they can do so withopen_all_diagnostics()
oropen_buffer_diagnostics()
.I would try making a PR myself, but the above are vimscript functions and I have no clue how to nicely use them from lua.
The text was updated successfully, but these errors were encountered: