emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 879 forks source link

Wrong server selected #4454

Open rogorido opened 4 months ago

rogorido commented 4 months ago

Thank you for the bug report

Bug description

Every time I open a JS file lsp-mode selects vue-semantic-server. Even if I remove all emacs.d/ related files (.emacs, .init.el, etc.). There is some configure which is getting loaded somewhere. Where could it be?

Steps to reproduce

  1. Fresh emacs install
  2. M-x lsp-start-plain
  3. open a JS file.

Expected behavior

Open the JS files with ts-ls and not with vue-semantic-server

Which Language Server did you use?

lsp

OS

Linux

Error callstack

In lsp-log I have: 

Command "vue-language-server --stdio" is present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "typescript-language-server --stdio" is present on the path.
Command "vue-language-server --stdio" is present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "typescript-language-server --stdio" is present on the path.
Found the following clients for /home/igor/geschichte/web/code/apis/apiatlantocracies/main.js: (server-id vue-semantic-server, priority 0), (server-id ts-ls, priority -2)
The following clients were selected based on priority: (server-id vue-semantic-server, priority 0)


### Anything else?

_No response_
erickisos commented 4 months ago

I just came here to mention that I'm having a similar issue.

Given that I opened a graphql file instead of a TSX one when opening the project lsp mode suggested Graphql-lsp server (which is cool for the gql file), but whenever I open a tsx, it doesn't change the selected client, and I can't select it using +lsp/switch-client in doomemacs.

jcs090218 commented 4 months ago

Try to configuring the variable lsp-enabled-clients.

erickisos commented 4 months ago

Currently, that variable is empty, however, after manually installing the corresponding clients it apparently worked!

alex-jara commented 4 months ago

Experiencing the exact same problem as OP here. vue-semantic-server is taking precedence over any other server when opening a file, even non-js-related ones. I noticed it only happens in workspaces where the vue server was used at least once, workspaces where I've not used it work normally. Working in multiple php+vue+typescript projects has made this a very annoying issue.

I'm using emacs-lsp in Doom Emacs on macOS although I was able to replicate the problem in a new emacs installation.

I can switch to the correct server (and/or client, not sure about the correct term here) using +lsp/switch-client in Doom to continue working so it seems that the problem is on file opening only.

komali2 commented 3 months ago

I'm having this issue in spacemacs.

Modifying lsp-enabled-clients is a silly solution. Whitelist all servers in order to blacklist one? I want to use vue-semantic-server in vue files. I must modify this variable every time I'm editing a vue app? What about when I'm working on a vue and react app simultaneously?

Is there no other way to manually switch an LSP client? I've been paging through google for about an hour and turned up nothing.

yyoncho commented 3 months ago

M-x add-dir-local-variable with enabled/disabled clients should work.

AlexanderSeto commented 2 months ago

I'm also having this issue, but for phpactor and php-ls.

It seems as though the check to ensure that php-language-server exists is not called the first time lsp is run. The check runs as expected if I run lsp a second time.

Here's a snippet from my *lsp-log*:

... (semgrep and serenata are not on path, phpactor is) ...
Found the following clients for [file]: (server-id phpactor, priority -4), (server-id php-ls, priority -3)  
The following clients were selected based on priority: (server-id php-ls, priority -3)

... (semgrep and serenata are not on path, phpactor is) ...
[home dir]/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php is not present.                                                                                                                                        
Found the following clients for [file]: (server-id phpactor, priority -4)                                                                                                                      
The following clients were selected based on priority: (server-id phpactor, priority -4)
manuel-arguelles commented 3 weeks ago

Hi, I'm in the same situation here, my project has .vue files, .ts files and .js files, vue-semantic-server always takes over.

Not sure if add-dir-local-variable will be of any use, i have some .vue files in the same directory as others.

Is there a way to set the priority based on the file extension? I don't see why everything is sent to vue-semantic-server. IMO vue-semantic-server should only handle .vue files and nothing else...