Skip to content

Commit

Permalink
Remove redundant checks from lsp-credo.el, add note to docs (#4115)
Browse files Browse the repository at this point in the history
* clients/lsp-credo.el: remove redundant checks from `make-lsp-client`

* docs/page/adding-new-language.md: add note about common mistake
  • Loading branch information
suvayu authored Jul 31, 2023
1 parent 55106f0 commit 2b6b899
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 1 addition & 6 deletions clients/lsp-credo.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ be available here: https://github.com/elixir-tools/credo-language-server/release

(lsp-register-client
(make-lsp-client
:new-connection
(lsp-stdio-connection
(lambda ()
`(,(or (executable-find (cl-first lsp-credo-command))
(lsp-package-path 'credo-language-server))
,@(cl-rest lsp-credo-command))))
:new-connection (lsp-stdio-connection lsp-credo-command)
:activation-fn (lsp-activate-on "elixir")
:priority -1
:add-on? t
Expand Down
11 changes: 11 additions & 0 deletions docs/page/adding-new-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ corresponding mode -\> language id - in this case `(python-mode .
buffer language. When the `major-mode` is not sufficient to determine the
language (e.g. `web-mode` is used for `javascript`, `html`, and `css`) you can put regex.

**Note:** In the above example, when a new client is created using
`make-lsp-client`, a new connection to the language server is created
using `lsp-stdio-connection`. Please carefully check its
documentation, as the function checks for various things (e.g. testing
for the executable in PATH) and handles respective errors. Often
while adding a server, the LSP client author might do these checks
themselves, but without handling the errors correctly. This leads to
features like `lsp-install-server` breaking for other users; e.g. see
[this issue](https://github.com/emacs-lsp/lsp-mode/issues/3415). This
is a common mistake that keeps reoccurring.

Here's an example of how to set up a custom language server in your `init.el` file:

```elisp
Expand Down

0 comments on commit 2b6b899

Please sign in to comment.