Description
Thank you for the bug report
- I am using the latest version of
lsp-mode
related packages. - 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
The test command for the PHP Language Server (php-ls) returns true when lsp-clients-php-server-command is nil.
When invoking lsp
for the first time, lsp--filter-clients
will check all available clients for lsp--supports-buffer?
and server-binary-present?
. When it checks php-ls
, server-binary-present?
will rely on the output of the test-command
passed to lsp-stdio-connection
. I
Since the test-command
runs before the command
, lsp-clients-php-server-command
is never set. This means that it will fail the first condition here, and then will return t
.
This results in php-ls
appearing in the list of available servers despite not being installed. All the other servers (save for phpactor
) have a higher priority. So php-ls
will only be run if either no other server is installed, or if only phpactor
is installed.
Subsequent invocations of lsp
will behave as expected, since the command
for php-ls
sets lsp-clients-php-server-command
.
Steps to reproduce
- Fresh emacs
- Don't install Intelephense or Serenata
- Don't install PHP Language Server
- Install
phpactor
(Optional) - Open a php file
Expected behavior
php-ls
shouldn't appear in the available servers list if the PHP language server isn't installed.
Which Language Server did you use?
lsp-php
OS
MacOS
Error callstack
First Invocation:
Command "semgrep lsp" is not present on the path.
Command "/usr/local/bin/phpactor language-server" is present on the path.
Command "serenata.phar -u 0" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "/usr/local/bin/phpactor language-server" is present on the path.
Command "serenata.phar -u 0" is not present on the path.
Found the following clients for [php 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)
Second Invocation:
Command "semgrep lsp" is not present on the path.
Command "/usr/local/bin/phpactor language-server" is present on the path.
Command "serenata.phar -u 0" is not present on the path.
[home dir]/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php is not present.
Command "semgrep lsp" is not present on the path.
Command "/usr/local/bin/phpactor language-server" is present on the path.
Command "serenata.phar -u 0" is not present on the path.
[home dir]/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php is not present.
Found the following clients for [php file]: (server-id phpactor, priority -4)
The following clients were selected based on priority: (server-id phpactor, priority -4)
Creating watchers for following 25 folders:
Anything else?
I believe I've identified the issue and will be submitting a PR shortly.