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

lsp: rework workspace folders #14455

Closed
kitsonk opened this issue May 1, 2022 · 6 comments
Closed

lsp: rework workspace folders #14455

kitsonk opened this issue May 1, 2022 · 6 comments
Assignees
Labels
feat new feature (which has been agreed to/accepted) lsp related to the language server

Comments

@kitsonk
Copy link
Contributor

kitsonk commented May 1, 2022

Not all editors / LSP clients support per-project configuration, not all even support any configuration. So it becomes non-trivial to make it work with some editors.

For example I've had to figure out a magic incantation to add to Helix's languages.toml:

config = { deno = { enable = true, lint = true } }

by looking at debug messages to see what the server doesn't like.

Originally posted by @unrelentingtech in #13228 (comment)

The initial implementation of workspace folders was naïve on my part and in doing the enableFolders feature I realised a much cleaner and better way to do it. We need to rework this feature and respect the client capability around workspace folders, so clients don't have to implement such things.

@kitsonk kitsonk added feat new feature (which has been agreed to/accepted) lsp related to the language server labels May 1, 2022
@kitsonk kitsonk self-assigned this May 31, 2022
@hemedani
Copy link

hemedani commented Dec 5, 2022

helix support local config. just put this config for deno LSP in .helix/languages.toml in the root of the project :

[[language]]
name = "javascript"
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
config = { enable = true, lint = true, unstable = true }
language-server = { command = "deno", args = ["lsp"], language-id = "javascript" }

[[language]]
name = "jsx"
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
config = { enable = true, lint = true, unstable = true }
language-server = { command = "deno", args = ["lsp"], language-id = "javascriptreact" }

[[language]]
name = "typescript"
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
config = { enable = true, lint = true, unstable = true }
language-server = { command = "deno", args = ["lsp"], language-id = "typescript" }

[[language]]
name = "tsx"
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
config = { enable = true, lint = true, unstable = true }
language-server = { command = "deno", args = ["lsp"], language-id = "typescriptreact" }

@lino-levan
Copy link
Contributor

@kitsonk I know you're not part of deno core anymore, but could you give any quick tips / ideas on what you meant by this?

I realised a much cleaner and better way to do it.

@nayeemrmn
Copy link
Collaborator

Fixed by #20358.

@3210jr
Copy link

3210jr commented Nov 17, 2023

@hemedani Your comment saved me a lot of pain before!!! Now with the updates to helix editor (v 23.10) seems like nothing works - I might just not really understand how to get things set up. Suggestions, hover, go to definition, etc not working currently.

Can you please please please share your current helix config for your per project languages.toml file? (or just the relevant parts for a deno project)

Thanks again for all the pain you saved me with your previous config!!!

@hemedani
Copy link

@3210jr It's very simple bro
It is the new languages.toml file:

[[language]]
name = "javascript"
scope = "source.js"
injection-regex = "^(js|javascript)$"
file-types = ["js", "jsx", "mjs"]
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
# comment-token = "//"
# config = { enable = true, lint = true, unstable = true, importMap = "deno.json" }
language-servers = ["deno"]
indent = { tab-width = 2, unit = "  " }
auto-format = true

[[language]]
name = "jsx"
scope = "source.jsx"
injection-regex = "jsx"
file-types = ["jsx"]
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
language-servers = ["deno"]
indent = { tab-width = 2, unit = "  " }
grammar = "javascript"
auto-format = true

[[language]]
name = "typescript"
scope = "source.ts"
injection-regex = "^(ts|typescript)$"
file-types = ["ts"]
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
language-servers = ["deno"]
indent = { tab-width = 2, unit = "  " }
auto-format = true

[[language]]
name = "tsx"
scope = "source.tsx"
injection-regex = "^(tsx)$" # |typescript
file-types = ["tsx"]
shebangs = ["deno", "node"]
roots = ["deno.json", "package.json", "tsconfig.json"]
language-servers = ["deno"]
indent = { tab-width = 2, unit = "  " }
auto-format = true

[language-server.deno]
command = "deno"
args = ["lsp"]
config = { enable = true, lint = true, unstable = true, importMap = "deno.json" }

@3210jr
Copy link

3210jr commented Nov 17, 2023

Okay I found what was wrong!! Turns out the config-reload command doesn't really reload everything! What i needed to do was actually close out of the session and restart it!

Cheers @hemedani ! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted) lsp related to the language server
Projects
None yet
Development

No branches or pull requests

5 participants