Repository navigation
Always request workspace diagnostics if supported by server - #2827
Conversation
β Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Pull diagnostics are cleared now for files outside of the workspace folders (or for all files if there are no workspace folders), when the file gets closed. I think that should be the expected behavior. I noticed that the current code with And the |
| | initialization_options | options to send to the server at startup | | ||
| | priority_selector | Used to prioritize a certain language server when choosing which one to query on views with multiple servers active. Certain LSP actions have to pick which server to query and this setting can be used to decide which one to pick based on the current scopes at the cursor location. For example when having both HTML and PHP servers running on a PHP file, this can be used to give priority to the HTML one in HTML blocks and to PHP one otherwise. That would be done by setting "priority_selector" to `text.html` for HTML server and `source.php` to PHP server. | ||
| | diagnostics_mode | Set to `"workspace"` (default is `"open_files"`) to ignore diagnostics for files that are not within the project (window) folders. If project has no folders then this option has no effect and diagnostics are shown for all files. If the server supports _pull diagnostics_ (`diagnosticProvider`), this setting also controls whether diagnostics are requested only for open files (`"open_files"`), or for all files in the project folders (`"workspace"`). | | ||
| | diagnostics_mode | Set to `"workspace"` (default is `"open_files"`) to ignore diagnostics for files that are not within the project (window) folders. If project has no folders then this option has no effect and diagnostics are shown for all files. | |
There was a problem hiding this comment.
I have some issue with this configuration's name and values.
"open_files" - All diagnostics reported from the server are shown.
"workspace" - If there are project folders (folders in the side bar),
diagnostics for files not within those folders are ignored.
"open_files" seem to lost its meaning. It doesn't have to do anything with open files - server might return diagnostics for the whole workspace or just open files.
"workspace" description seems fine but the name of it is not very descriptive (for example could be called "limited_to_workspace" instead).
If we are OK with just completely changing naming around and break backwards compatibility then we could probably come up with better naming. Are we OK with that?
For what it's worth, no servers seem to use it in their default settings.
Of course people might be using it already and would be affected but probably not that many and if it breaks for them nothing really bad will happen. People might just notice and figure out how to fix it.
There was a problem hiding this comment.
I wonder if we shouldn't just remove this config alltogether, and simply decide for one of the two behaviors, and without it being configurable. I wonder how other editors behave and if the have a config option for this (I assume they don't).
Or we could make it a user setting, because this is not really something specific to the server, but just personal preference. So I'd say it doesn't really make sense to have this as a server-specific config.
There was a problem hiding this comment.
I would be fine with user setting that defaults to ignoring diagnostics outside of workspace.
I suppose the setting should then be a hide_non_project_diagnostics boolean like before (or some variation of it).
There was a problem hiding this comment.
If we want to keep it as part of the server config, we could probably just rename "open_files" to anything else, because that is currently the default value. And that option isn't even referenced anywhere in the source code. The only place left where diagnostics_mode is checked is in
Lines 369 to 374 in 72796d3
Another question is what to do about code actions with files outside of the workspace folders, if someone has "diagnostics_mode": "workspace" configured. Because currently, we completely ignore the diagnostics (instead of just not drawing them in the view):
For pull diagnostics, no request is made:
Lines 620 to 623 in 72796d3
For publishDiagnostics:
Lines 1911 to 1914 in 72796d3
So it's probably useless to automatically request code actions (for current caret position) for such views.
There was a problem hiding this comment.
Another question is what to do about code actions with files outside of the workspace folders
your suggestion makes sense to me
There was a problem hiding this comment.
Yeah but I realized that we actually don't request code actions if there aren't any diagnostics (e.g. if ignored due to outside of workspace folders if configured like that). I have added that logic recently when refactoring the code actions. So it should be fine already.
Perhaps it could be optimized to return early from the function when the file is outside of workspace folders. But that's probably not so important.
Always request workspace diagnostics, independently of the
"diagnostics_mode"setting.If we want to do this change, the code at
LSP/plugin/session_buffer.py
Lines 272 to 275 in eab1a17
probably doesn't make sense anymore in that form. But also I think we can't just clear diagnostics unconditionally on closing a file, because that would forfeit the purpose of workspace diagnostics (to have diagnostics for unopened files). So we might need to consider how to handle the problem 2. from #2727 (comment). Maybe another check whether the file is outside of the workspace folders would do.