helix
helix copied to clipboard
vscode-eslint-language-server does not work
Summary
The eslint language server expects to be passed a workingDirectory
but null
was given.
Reproduction Steps
I tried this:
-
hx
- Open a tsx file
I expected this to happen: The language server could spawn
Instead, this happened: The language server did not spawn
Helix log
~/.cache/helix/helix.log
2022-08-23T16:49:42.652 helix_lsp::transport [ERROR] err <- "(node:12369) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'workingDirectory' of null\n"
Platform
macOS
Terminal Emulator
Iterm2-3.4.16
Helix Version
helix 22.05
workingDirectory
is not part of the LSP spec - this server is expecting it as a configuration option. You can provide configuration options with the config
option in languages.toml
like here
I tried adding the config property but the logs show workingDirectory
is still null.
[[language]]
name = "tsx"
scope = "source.tsx"
injection-regex = "^(tsx)$" # |typescript
file-types = ["tsx"]
roots = []
language-server = { command = "vscode-eslint-language-server", args = ["--stdio"], language-id = "typescriptreact" }
indent = { tab-width = 4, unit = " " }
config = { "workingDirectory" = "./" }
Experiencing the same issue, I have been digging within the vscode-eslint-language-server
code and logged some stuff, it seems that no configuration is found for the workspace despite setting the config
property in the TOML file.
Here is a minimal working configuration based on lspconfig but it requires a fix present in #2507:
[language-server.eslint]
command = "vscode-eslint-language-server"
args = ["--stdio"]
[language-server.eslint.config]
validate = "on"
experimental = { useFlatConfig = false }
rulesCustomizations = []
run = "onType"
problems = { shortenToSingleLine = false }
nodePath = ""
With these settings the eslint language server runs when opening a file without errors.
Additional options like codeAction
can be enabled.
It seems that there is an additional problem. It seems that vscode-eslint-language-server
does not work well for monorepos on it's own. When you have eslintConfig setup in root's package.json, launching eslint in sub-package won't find the root's config. Since vscode-eslint-language-server stops looking for workspace directory as soon it finds any of project's folder indicators such as "package.json". "eslintignore" or "eslintrc". It can be seen in the source code here: https://github.com/microsoft/vscode-eslint/blob/cbb35d03497bb39043033defbad7fd80b2a89698/server/src/eslintServer.ts#L1093
Vscode and vim tend to work cos they provide some hacky work arounds to find workspace directory. In helix, without plugin management, I am not sure what can be done (apart of manually setting workingDirectory path to workspace's directory
@JeviScript I am working in a monorepo as well and having the same issue. Did you find a better solution to this problem in the meantime?
@JeviScript I am working in a monorepo as well and having the same issue. Did you find a better solution to this problem in the meantime?
I switched to vim xD