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

Add support for multiple language servers per language #2507

Merged
merged 41 commits into from
May 19, 2023

Commits on May 18, 2023

  1. Adds support for multiple language servers per language.

    Language Servers are now configured in a separate table in `languages.toml`:
    
    ```toml
    [langauge-server.mylang-lsp]
    command = "mylang-lsp"
    args = ["--stdio"]
    config = { provideFormatter = true }
    
    [language-server.efm-lsp-prettier]
    command = "efm-langserver"
    
    [language-server.efm-lsp-prettier.config]
    documentFormatting = true
    languages = { typescript = [ { formatCommand ="prettier --stdin-filepath ${INPUT}", formatStdin = true } ] }
    ```
    
    The language server for a language is configured like this (`typescript-language-server` is configured by default):
    
    ```toml
    [[language]]
    name = "typescript"
    language-servers = [ { name = "efm-lsp-prettier", only-features = [ "format" ] }, "typescript-language-server" ]
    ```
    
    or equivalent:
    
    ```toml
    [[language]]
    name = "typescript"
    language-servers = [ { name = "typescript-language-server", except-features = [ "format" ] }, "efm-lsp-prettier" ]
    ```
    
    Each requested LSP feature is priorized in the order of the `language-servers` array.
    For example the first `goto-definition` supported language server (in this case `typescript-language-server`) will be taken for the relevant LSP request (command `goto_definition`).
    
    If no `except-features` or `only-features` is given all features for the language server are enabled, as long as the language server supports these. If it doesn't the next language server which supports the feature is tried.
    
    The list of supported features are:
    
    - `format`
    - `goto-definition`
    - `goto-declaration`
    - `goto-type-definition`
    - `goto-reference`
    - `goto-implementation`
    - `signature-help`
    - `hover`
    - `document-highlight`
    - `completion`
    - `code-action`
    - `workspace-command`
    - `document-symbols`
    - `workspace-symbols`
    - `diagnostics`
    - `rename-symbol`
    - `inlay-hints`
    
    Another side-effect/difference that comes with this PR, is that only one language server instance is started if different languages use the same language server.
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    71551d3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7d4f7eb View commit details
    Browse the repository at this point in the history
  3. Fix some lints/docgen hints

    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    74e21e1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    05583f8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    44b2b40 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b6c60be View commit details
    Browse the repository at this point in the history
  7. str instead of String

    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    4da6d8c View commit details
    Browse the repository at this point in the history
  8. Fix sorting issues of the editor wide diagnostics and apply diagnosti…

    …cs related review suggestions
    
    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    f9b0865 View commit details
    Browse the repository at this point in the history
  9. Simplify Display implementation of LanguageServerFeature

    Co-authored-by: Ivan Tham <pickfire@riseup.net>
    Philipp-M and pickfire committed May 18, 2023
    Configuration menu
    Copy the full SHA
    19f88fc View commit details
    Browse the repository at this point in the history
  10. Fix error messages when no language server is available

    Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>
    Philipp-M and dead10ck committed May 18, 2023
    Configuration menu
    Copy the full SHA
    dd2f747 View commit details
    Browse the repository at this point in the history
  11. Use DoubleEndedIterator instead of collect to Vec for reversing

    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    0637691 View commit details
    Browse the repository at this point in the history
  12. Refactored doc.language_servers and doc.language_servers_with_feature…

    … to return an iterator and refactor LanguageServerFeature handling to a HashMap (language server name maps to features)
    
    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    76b5cab View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    ec2f909 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    1122928 View commit details
    Browse the repository at this point in the history
  15. Refactor doc.shown_diagnostics to avoid an extra HashSet

    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    9639f42 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    d963050 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    60a6af1 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    7d20740 View commit details
    Browse the repository at this point in the history
  19. Simplify 'lsp_stop' command

    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    58c913c View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    b1199c5 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    2eeac10 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    1d5d5da View commit details
    Browse the repository at this point in the history
  23. Use let else instead of variable and fix some error messages

    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    8ab6d7b View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    8ee5999 View commit details
    Browse the repository at this point in the history
  25. Filter out already seen language servers in requests that can be sent…

    … to multiple language servers (code-action, completion, symbol pickers)
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    451fe52 View commit details
    Browse the repository at this point in the history
  26. Fix docgen again

    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    9d089c2 View commit details
    Browse the repository at this point in the history
  27. Filter language servers also by capabilities in `doc.language_servers…

    …_with_feature`
    
    * Add `helix_lsp::client::Client::supports_feature(&self, LanguageServerFeature)`
    * Extend `doc.language_servers_with_feature` to use this method as filter as well
    * Add macro `language_server_with_feature!` to reduce boilerplate for non-mergeable language server requests (like goto-definition)
    * Refactored most of the `find_map` code to use the either the macro or filter directly via `doc.language_servers_with_feature`
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    ff26208 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    073000e View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    93fd79a View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    2a21b93 View commit details
    Browse the repository at this point in the history
  31. Fix lsp_restart across multiple different document scopes (language s…

    …ervers weren't restarted, if not of the same scope id), and fix some smaller rebase issues
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    3e4bac1 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    5674850 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    dcb0767 View commit details
    Browse the repository at this point in the history
  34. Remove TODO comment in helix_lsp::Registry::restart and add doc-comme…

    …nt on top of function instead
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    521cdec View commit details
    Browse the repository at this point in the history
  35. Add function Editor::language_server_by_id and refactor/simplify re…

    …lated code, also don't 'crash' in completion menu if language_server somehow disappeared
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    39b9a4b View commit details
    Browse the repository at this point in the history
  36. Some minor clarity/cosmetic improvements

    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    2b746ea View commit details
    Browse the repository at this point in the history
  37. Simplify gutter diagnostics rendering by using partition_point instea…

    …d of binary search
    
    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    656ee24 View commit details
    Browse the repository at this point in the history
  38. Apply all review suggestions (doc_id -> id, error message, unnecessar…

    …y if)
    
    Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
    Philipp-M and pascalkuthe committed May 18, 2023
    Configuration menu
    Copy the full SHA
    f45bbf1 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    b6d0e26 View commit details
    Browse the repository at this point in the history
  40. Clarify language-servers documentation for mergeable LSP features (`d…

    …iagnostics`, `code-action`, `completion`, `document-symbols` and `workspace-symbols`)
    Philipp-M committed May 18, 2023
    Configuration menu
    Copy the full SHA
    f8fa0d8 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    2a512f7 View commit details
    Browse the repository at this point in the history