Skip to content
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

Disable language server for syntax test files by default #2504

Closed
jfcherng opened this issue Jul 19, 2024 · 1 comment · Fixed by #2531
Closed

Disable language server for syntax test files by default #2504

jfcherng opened this issue Jul 19, 2024 · 1 comment · Fixed by #2531

Comments

@jfcherng
Copy link
Contributor

jfcherng commented Jul 19, 2024

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 sublimelsp/LSP-pyright#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")
        )
@jwortmann
Copy link
Member

jwortmann commented Oct 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants