Awesome! I’ve been meaning to figure out how to accomplish that.
This is pure gold Thank you!
I’ve added the popwin line to the wiki, seems popular!
Cool, thank you for the suggestion. I’m currently using doom-emacs, I think the snippet should work properly.
Thanks for adding it! I promoted it on the slack as well and some people enjoyed it there. I also added :noselect t
to the snippet (at the recommendation of someone on the Slack) so that the compilation buffer doesn’t take focus when you run the tests.
I actually prefer it to be selected so it’s easier to navigate to failing output and jump to the test. Each to their own though!
If anyone wants to use flycheck with eglot, I wrote a simple wrapper which replaces flymake with flycheck https://github.com/akash-akya/eglot-flycheck-adaptor
Update: I finally solved my flycheck problems (yes, from July 2019). I’ve got lsp checking (dialyzer & elixir compiler) and credo working in a chain. The key was this: (setq lsp-flycheck-live-reporting nil)
. Disabling that prevents lsp from stomping on the value in flycheck-check-syntax-automatically
. I think they are trying to replace that, but at least in a project the size of mine you cannot be running flycheck on idle/new line etc. I’ve long run it only on enable and save. Every now and then I’ll save before the last check finished and things get out of a sync so I do a quick s e b
Relevant configs:
(add-hook 'elixir-mode-hook
(lambda ()
(setq lsp-flycheck-live-reporting nil)
(setq-local flycheck-check-syntax-automatically '(mode-enabled save))))
(add-hook 'lsp-after-initialize-hook
(lambda ()
(lsp--set-configuration `(:elixirLS, lsp-elixir--config-options))
(elixir/init-flycheck-credo)
(flycheck-add-next-checker 'lsp 'elixir-credo)))
Care, as it can completely bork the checking of lsp (at least it did ~a month ago when I tried to tackle this again).
The core of the issue is how lsp-mode interacts with flycheck.
The idea is that lsp runs the checker when it is needed by lsp specification, and only then.
By disabling that, your dialyzer checkers can stop working properly.
So, as I said earlier, the proper solution is to implement credo linter as part of the elixir-ls (or as a standalone plugin for the elixir-ls. I don’t know if elixir-ls supports plugins). And I am pretty sure such a contribution will be welcome
It is not just credo that doesn’t work for me. The compiler and dialyzer checkers also get stuck and stop updating unless I disable lsp-flycheck-live-reporting. It seems odd they’d document a customizable variable that can “completely bork … lsp” and not document that fact?
Hi there!
Thanks for the guide!
I am using Spacemacs
and eglot
. The guide is not totally accurate.
package-install
is prohibited in Spacemacs.
-
You should add
eglot
indotspacemacs-additional-packages
instead. -
Then you need to add in
dotspacemacs/user-config
:
(require 'eglot)
(add-to-list 'eglot-server-programs '(elixir-mode "/home/nicolas/elixir-ls/release/language_server.sh"))
- To make your life easier and not having to type
M-x eglot
in any Elixir file, you may add indotspacemacs/user-config
AFTER(require 'eglot)
:
(add-hook 'elixir-mode-hook 'eglot-ensure)
Lastly, three things:
- The
elixir
layer in Spacemacs does not play well with Eglot. It callslsp-mode
from the Spacemacslsp
layer. If you want to useeglot
in Spacemacs, you should add directlyelixir-mode
indotspacemacs-additional-packages
. Do not add theelixir
layer. - If you fail to add the
require 'eglot
instruction appropriately,eglot
will randomly stop working on Emacs restart, and you will be prompted the error described in this GitHub issue. - You can find my full .spacemacs dot file for more guidance on my GitHub.
Btw, if you guys and gals agree I can edit the wiki directly. Didn’t realize I could do it.
Go for it! That’s why it’s a wiki. That all looks like good information
I don’t use eglot so the instructions tend to lag a bit.
Done editing the Spacemacs eglot
configuration in the wiki!
Indeed, I still have some problems… But the other configuration didn’t work well for Spacemacs anyway :/.
I tried to setup Spacemacs with elixir-ls, but I am still facing this error:
LSP :: The following servers support current file but do not have automatic installation configuration: elixir-ls
You may find the installation instructions at https://github.com/emacs-lsp/lsp-mode/#supported-languages.
(If you have already installed the server check *lsp-log*).
- I am running
develop
Spacemacs 0.300.0@26.1 - I cloned and built a
elixir-ls
(fork) release - I put
(elixir :variables elixir-backend 'lsp)
into mylayers
config - I put
(use-package lsp-mode :commands lsp :ensure t :diminish lsp-mode :hook (elixir-mode . lsp) :init (add-to-list 'exec-path "/Users/eskimag/.emacs.d/elixir-ls/release/language_server.sh")) )
into myuser-config
Any idea what could be wrong? Thanks a lot. I am struggling with Spacemacs for quite few hours already and I am losing my faith in it.
Have you checked *lsp-log*
buffer as mentioned in the error message?
Also exec-path
is emacs equivalent of most OS’ PATH
variable. You need to specify a folder, not the file directly.
If you want to specify the exectuable directly, then you need to (setq lsp-clients-elixir-server-executable "/Users/eskimag/.emacs.d/elixir-ls/release/language_server.sh)
. The default value for that variable is "language_server.sh"
, so it should work if you add "/Users/eskimag/.emacs.d/elixir-ls/release"
to exec-path
.
Thanks a lot. At least it’s not showing me this error anymore. Now I have to figure out all the remaining stuff like code completion, format on save etc. It reminds me a lot of the times when I used Linux.
What is this view? I want to do this in my setup.