artemave / workspace-diagnostics.nvim

Populate diagnostics for _all_ projects files, not just opened ones.
https://artem.rocks/posts/workspace_diagnostics_nvim
MIT License
143 stars 4 forks source link

Running workspace diagnostics only on request #12

Closed noearchimede closed 1 month ago

noearchimede commented 2 months ago

Describe the problem

First of all, thank you for publishing this plugin! Having workspace diagnostics is very userful for me for some smaller workspaces, but in my personal workflow I often find it unnecessary and potentially annoying in larger ones. I was wondering if it would be possible to trigger the search for diagnostics in all workspace files only when the user triggers a specific mapping or command instead of having it happen automatically when the LSP is first attached to a buffer in the workspace.

Based on the blogpost where you explain how this plugin works I figured that this should be possible, but I'm not able to figure out how to do it in practice. For example, I don't know what to use in place of client in the require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr) function call if it was triggered outside of the on_attach callback provided by lspconfig.

Describe the solution

The solution would be any way to populate the workspace diagnostics with an explicit command rather than automatically upon opening the first file.

artemave commented 2 months ago

Here's how you can get the list of clients, attached to the current buffer:

vim.lsp.buf_get_clients()
artemave commented 2 months ago

I updated the docs for your use case.

noearchimede commented 2 months ago

Thank you !!