LSP
LSP copied to clipboard
Disable language server for syntax test files by default
TL;DR
By default, disable servers for
- syntax test files
- SublimeREPL views
Description
I think enabling servers on syntax test files only cause (linting) issues. Only very few ones (e.g., LSP-copilot) will work well. By suggested rules, the name of a syntax test file starts with syntax_test_ (but in Default/run_syntax_tests.py, it finds filenames start with syntax_test).
The same reason for disabling for SublimeREPL views. See https://github.com/sublimelsp/LSP-pyright/issues/343
A SublimeREPL view has the view setting "repl": True,.
Suggestion
Something equivalent to
@classmethod
def should_ignore(cls, view: sublime.View) -> bool:
return bool(
# SublimeREPL views
view.settings().get("repl")
# syntax test files
or os.path.basename(view.file_name() or "").startswith("syntax_test")
)
I'm not sure whether view.settings().get("repl") would be a good approach; LSP currently registers new (non-file) views in on_activated_async. Dependent on how/when exactly SublimeREPL writes this setting, this approach might be prone to a race condition, i.e. whether this setting is set or read first.
In general, if we want to have this, I would probably prefer a more general setting name like for example lsp_ignore which would not be specific to SublimeREPL.
Edit: Probably a better approach would be for SublimeREPL to provide its own syntax definition with base scope e.g. source.python.repl, and then exclude this scope in Pyright etc. ("selector": "source.python - source.python.repl"). This way users could also easily configure their own syntax specific settings for REPL views.