LSP
LSP copied to clipboard
Ignores diagnostics that shouldn't be ignored
Describe the bug
The logic to ignore diagnostics when the file is outside the project is erroneously ignoring diagnostics in some cases.
To Reproduce
With LSP-json installed, open some project and run Project: Edit Project
from the the command palette and add some invalid property.
The project configuration that opens might live outside of the project folder (it's a personal choice but for me it always does since I'm using "Project Manager" package).
Expected that diagnostics are not ignored in that case.
Should we just add a client config option for that? What it should be named? include_non_project_diagnostics
(defaults to false
)? Or inverted - ignore_non_project_diagnostics
(defaults to true
)?
Naming is the hardest part.
As far as I understand, this config option would be set dependent on whether the server is "project-based" (like most servers are), or "single-file-based" (e.g. LSP-json, LSP-html, LSP-css). I think there is no real definition of that in the LSP specs and it can't be derived from for example the initialize response.
How about naming the client config key maybe "project_aware" or "project_based" then, defaulting to true
? It could be useful for more things than just whether to ignore diagnostics or not, in the future.
I'm not sure if it's worth making the option so generic and make the meaning not so clear on the first look. Especially since we don't currently have any idea what else might go under that option in the future.
An alternative suggestion I have is single_file_mode
that, I believe, I've seen used somewhere else (maybe neovim) and I think I like that one the most.
An alternative suggestion I have is
single_file_mode
that, I believe, I've seen used somewhere else (maybe neovim) and I think I like that one the most.
Wouldn't that just be the negation of project_aware
? :thinking:
I think single_file_mode
could be misleading, because I would use that to describe the current mode of a session. In other words, a single server, e.g. pyright can be both in a project mode (when a folder was opened in the sidebar), and in a single-file mode (when you just open a single file in ST). There are already differences in LSP behavior dependent on those two situations.
Maybe better to have a setting that is specifically handling the issue at hand since it's not clear whether more generic naming would be useful for anything in the future. And it's hard to figure out a good name for the more generic option anyway, not knowing what it might be used in the future.
Going back and forth on the naming of the new option.
Been thinking about project_aware
again in context of https://github.com/sublimelsp/LSP/issues/2120 but what makes me think that it's not a good option is the fact that someone might want to enable out-of-project diagnostics even when server is project-aware because server might still support those fine.
Yeah, I agree now that something like ignore_non_project_diagnostics
is probably better.