Glad it helped you! Yeah we are getting a little behind at this point. Will try to sync it up soon
Hey all, Iām trying to get spacemacs, elixir-ls (the fork), and friends to play nice on Ubuntu.
I think Iāve followed all the steps correctly, but am getting:
File mode specification error: (wrong-type-argument lsp-session [cl-struct-lsp-session ( *** GIANT LIST OF ALL MY ELIXIR, RUST AND PYTHON projects (LSP!) *** ) nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.800000011920929 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.800000011920929 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.800000011920929 data ())])
Any advice?
Hmmm, Iām not sure about what would cause that. Are you using a recent version of Emacs? (at least 26?). Iām really not sure where the list of your elixir, rust, and python projects are coming from because I didnāt think that lsp-mode stored a list like that. Is your Spacemacs setup pretty vanilla or have you customized it already?
0.300.0@26.1 (spacemacs) on Ubuntu 19.04. I try to keep my Spacemacs setup as close to vanilla as possible.
Do you have a .spacemacs file to copy or are there diagnostic steps i can take to make sure iāve got elixir-ls installed correctly?
Thanks for the great resource, Iāve been looking for exactly this.
I am using spacemacs latest develop 0.300.0@26.1 too with https://github.com/JakeBecker/elixir-ls ā lsp
layer, auto-completion
layer itās working.
One bit that I found out is that you have to use the same elixir/otp version in elixir_ls and the one in the project that you are working on.
Although I am not sure about your specific error, i hope that this helps!
ā¦and welcome!
I started over from vanilla with JakeBeckerās elixir-ls and itās working now. Not sure what I did wrong but thanks all for the help.
Iām glad you got it working!
Hi, all. Thank you for the great information about Elixir setup for Emacs.
How do you get Emacs checking syntax errors as a linter?
After a quick research, I found flycheck and flymake didnāt support Elixir officially.
In flycheck document, thereās a recommendation for Elixir syntax checker flycheck-mix, and several packages are listed on melpa like flicheck-credo and flymake-elixir. But it seems these extensions are outdated and also their development is stopped.
What packages do you use for syntax checking in Emacs? Itās good to mention it in this wiki, I think. Thanks.
What kind of linting do you miss?
Syntax errors and compile time warnings are marked properly when I do use emacs and the ELS. I did not configure something special, its just that flycheck
is part of my base configuration.
I tend to not use credo
at all though. Formatter does most of the things I used credo for back when I used it. And I do not agree with a lot of the other lints and would disable many anywayā¦
Compile time messages are useful, but inline warnings when writing source code are also convenient in my opinion.
Syntax errors and compile time warnings are marked properly when I do use emacs and the ELS.
Maybe Iām missing something, can elixir-ls indicate syntax errors alongside the line numbers or something?
In my case, I set up code formatting when I save the buffer according to elixir-mode instruction. So, if I get syntax errors, warnings only appear in *elixir-format-errors* after saving. Thereās no indicator on the same buffer.
As the LS compiles on save, they are there āas you typeā.
I do see red and yellow squiggly lines. My office box has no emacs installed though and I canāt SSH to home for some reasons that I have to debug later, so I can not show you a screenshot right now, perhaps later today (6 to 10 hours from now).
I do use eglot
, for LS, perhaps that is making the difference?
Anyway, you can look my emacs config up at https://gitlab.com/NobbZ/emacs.d, perhaps you spot the difference?
Ohh⦠It seems I just misconfigured project root directory settings. Iām using elixir-ls with lsp-mode, and exec M-x lsp-workspace-folders-remove
then M-x lsp-workspace-folders-add
to set proper project root. After that syntax errer indicator appears in the current buffer. Sorry for the noise, Iām a Emacs and Elixir noob :P.
@NobbZ Out of curiosity, I tried to configure elixir-ls with eglot. How do you set project root under eglot? In lsp-mode, above commands can handle root directory, but I canāt find such counterparts in eglot. Eglot recognize the current directory where the editing file exists as project root, so syntax error detection doesnāt work.
Iāve not done anything special, my assumption is that it just works because eglot or projectile recognise the git root as project root.
git init
at project root resolve the issue. I really appreciate you.
By the way, mix new
already created .gitignore
file, so isnāt it better mix new
also create git repository at the same time like cargo new
in Rust language? (a bit off topic though)
Because this would require you to have a working git
installation before you were able to use elixir.
Even worse, both had to work within the same terminal session. Especially this is not trivial on some operating systems.
Using latest spacemacs develop and tried using both LS I get the following error:
File mode specification error: (error elixir-ls: Cannot communicate with the process (exit))
LSP :: elixir-ls has exited (exited abnormally with code 127)
Server elixir-ls:22877 status:starting exited with status exit. Do you want to restart it? (y or n) y
LSP :: Restarting LSP in buffer cli.ex
error in process sentinel: lsp--send-no-wait: elixir-ls: Cannot communicate with the process (exit)
Not sure how I correct this, anybody got some tips?
Iām on the latest spacemacs dev and latest elixir-lsp/elixir-ls master branch and everything is working for me so it seems like thereās something funky going on with your setup.
Can you tell me:
- Operating System version
- Elixir version
- Erlang version
- What happens if you run
elixir-ls/release/language_server.sh
Ubuntu 19.04
Elixir 1.8.1 (installed using asdf)
Erlang 21
running sh language_server.sh
I get:
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Content-Length: 559
{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":" Warning: the `dialyxir` application's start function was called, which likely means you\n did not add the dependency with the `runtime: false` flag. This is not recommended because\n it will mean that unnecessary applications are started, and unnecessary applications are most\n likely being added to your PLT file, increasing build time.\n Please add `runtime: false` in your `mix.exs` dependency section e.g.:\n {:dialyxir, \"~> 0.5\", only: [:dev], runtime: false}\n","type":4}}
Content-Length: 99
{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Started ElixirLS","type":4}}
Content-Length: 138
{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Elixir version: \"1.8.1 (compiled with Erlang/OTP 20)\"","type":4}}
Content-Length: 105
{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Erlang version: \"21\"","type":4}}
Iāll try a clean install of spacemacs and elixir-lsp
EDIT: Clean install worked perfectly! Not sure what happened there but sorry for the trouble.
No worries, Iām glad you got it working
@ynakao Iāve once written flycheck-mix
. It does the job for me and it was working for me since then. It is quite stupid because it just runs mix compile
over and over but that worked for me. I am not even sure if spacemacs
creators didnāt pull it in as part of the elixir layer.
If you think it needs improvements, feel free to ping me