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

Feature Request: conditional language server selection #702

Open
aThorp96 opened this issue Nov 29, 2023 · 1 comment
Open

Feature Request: conditional language server selection #702

aThorp96 opened this issue Nov 29, 2023 · 1 comment

Comments

@aThorp96
Copy link

aThorp96 commented Nov 29, 2023

Forgive me if there is already a mechanism to do this.

The problem

I have multiple Typescript applications I work on. One of which uses Node and the other uses Deno, using typescript-language-server and deno-lsp respectively. Neither language server works with the other application type, though both projects use filetype: typescript.

Currently I can get around this by using both language servers (config below). This gives me language support, completion, etc, however it also means that I always get erroneous error diagnostics from the wrong server. E.g. In a deno project typescript-language-server will complain that my imports cannot be resolved but in a node application instead deno-lsp will complain about the imports.

Current config:

[language_server.typescript-language-server]
filetypes = ["typescript", "javascript"]
roots = ["package.json"]
command = "typescript-language-server"
args = ["--stdio"]

[language_server.deno-lsp]
filetypes = ["typescript", "javascript"]
roots = ["deno.json"]
command = "deno"
args = ["lsp"]

[language_server.deno-lsp.settings.deno]
enable = true
lint = true

Proposed Solution

Currently (I believe) filetype is the only mechanism used to determine which language server(s) is selected. However we also have roots to define the project root. If it doesn't present a technical challenge or a specification divergence, I believe it would be possible to select the language server based first on filetype, then, if multiple servers are selected use only those which have at least one root resolved. If no roots are supplied, the server is considered to match. As to not break the current config API, it be better to specify a require_root_match field, which would cause the server selection to behave as described.

I'm very open to alternative mechanisms, so long as there would be a way for me to infer (or specify somehow) which language server to use when multiple are matched.

@krobelus
Copy link
Member

duplicate of #537 which links to an approach to change the lsp_cmd option per project to include different --config file arguments

I appreciate this isn't super convenient. I think in general we should try to move away from the toml and allow setting everything via Kakoune options, then we solve this for free.

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

No branches or pull requests

2 participants