lsp-mode
lsp-mode copied to clipboard
lsp-eslint doesn't respect `working-directories` setting
Thank you for the bug report
- [X] I am using the latest version of
lsp-mode
related packages. - [X] I checked FAQ and Troubleshooting sections
- [ ] You may also try reproduce the issue using clean environment using the following command:
M-x lsp-start-plain
Bug description
lsp-eslint
ignores the lsp-eslint-working-directories
variable.
Steps to reproduce
Open a file that uses lsp-eslint
with lsp-eslint-working-directories
set to anything, and lsp-log-io
set to t
. You'll see that the response to workspace/configuration
does not include the workingDirectores
setting.
Expected behavior
lsp-eslint
should send workingDirectories
in the workspace/configuration
response when lsp-eslint-working-directories
is set.
Which Language Server did you use?
lsp-eslint
OS
Linux
Error callstack
No response
Anything else?
I was able to fix this by adding :workingDirectories (vector lsp-eslint-working-directories)
below this line: https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-eslint.el#L281 -- however, it's unclear to me why I need to wrap lsp-eslint-working-directories
in a vector (when the variable is already set to a vector) so I'm not sure if this is the correct fix.
I can confirm this is still an issue. I set lsp-eslint-working-directories
from .dir-locals.el
but it is not passed to the eslint
server, the logs show that this setting is ignored.
I spent some time debugging this, it turns out that workingDirectories
should not be passed to the server (so lsp-mode
is doing the right thing), instead the lsp client transforms workingDirectories
to workingDirectory
and passes it alongside the other params. Example of a config set by the VSCode EsLint extension:
// For file "./xyz/test.js" in the lsp project "abc"
[Trace - 17:53:02] Sending response 'workspace/configuration - (2)'. Processing request took 2ms
Result: [
{
...
"workingDirectory": {
"directory": "/home/meril/dev/abc/xyz",
"!cwd": false
},
"workspaceFolder": {
"name": "abc",
"uri": "file:///home/meril/dev/abc"
},
...
// Config:
{
"workingDirectories": [ "./xyz" ]
}
The workingDirectory
param is created by this code, in a nutshell the client figures out which directory the current file is part of.