LSP for Elixir language

Hi,
I just started using Kakoune and find it great. I believe its an improvement on the vim key bindings.
I am trying to set up the elixir language server with the kak-lsp plugin but I am not successfull.
I have intalled the kak-lsp plugin using kak-plug.
The language server for elixir is here - https://github.com/JakeBecker/elixir-ls
I have added the following code to kak-lsp.toml
[language.elixir]
filetypes = [“elixir”]
roots = [“mix.exs”]
command = “sh”
args = ["~/Documents/elixir_dev/precompiled_elixir_ls/elixir-ls/language_server.sh"]

I have not made any changes to the kakrc file.
If i open a elixir file (.ex) the kak-lsp doesn’t seem to work. Even if i start it manually its not working for me. I don’t get any error messages. Can someone please help me to set it up properly.
I am really keen on using Kakoune and this would make it even more powerful for my use case.
Thanks.

why did you specified the lanhuage server as sh?

Hello!

First thing which lead to problems is using ~ in the path — bare-bones sh frequently doesn’t expand it.

After fixing this problem I still get language server dying even when I try to communicate to it manually:

$ sh ~/Hub/elixir-ls/target/release/language_server.sh
Content-Length: 160

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"\u001B[22m\n20:01:13.952 [info]  Application hipe exited: :stopped\n\u001B[0m","type":4}}

Content-Length: 99

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Started ElixirLS","type":4}}

Content-Length: 325

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"\u001B[22m\n20:01:13.953 [info]  Application elixir_sense exited: :stopped\n\u001B[0m\u001B[22m\n20:01:13.953 [info]  Application erl2ex exited: :stopped\n\u001B[0m\u001B[22m\n20:01:13.953 [info]  Application forms exited: :stopped\n\u001B[0m","type":4}}

Content-Length: 138

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Elixir version: \"1.8.1 (compiled with Erlang/OTP 21)\"","type":4}}

Content-Length: 105

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Erlang version: \"21\"","type":4}}

Content-Length: 415

{"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"colorProvider":null,"completion":{"completionItem":{"documentationFormat":["plaintext"],"snippetSupport":false}}},"workspace":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"]}}},"processId":17120,"rootUri":"file:///Users/rprakapchuk/Hub/elixir-ls/apps/language_server","trace":"off"},"id":0}
Content-Length: 1258

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{\"id\" => 0, \"jsonrpc\" => \"2.0\", \"method\" => \"initialize\", \"params\" => %{\"capabilities\" => %{\"textDocument\" => %{\"colorProvider\" => nil, \"completion\" => %{\"completionItem\" => %{\"documentationFormat\" => [\"plaintext\"], \"snippetSupport\" => false}}}, \"workspace\" => %{\"workspaceEdit\" => %{\"documentChanges\" => true, \"resourceOperations\" => [\"create\", \"delete\", \"rename\"]}}}, \"processId\" => 17120, \"rootUri\" => \"file:///Users/rprakapchuk/Hub/elixir-ls/apps/language_server\", \"trace\" => \"off\"}}}, 5000)\n    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started\n    (elixir) lib/gen_server.ex:979: GenServer.call/3\n    (elixir) lib/stream.ex:435: anonymous fn/4 in Stream.each/2\n    (elixir) lib/stream.ex:1394: Stream.do_resource/5\n    (elixir) lib/stream.ex:1568: Enumerable.Stream.do_each/4\n    (elixir) lib/stream.ex:640: Stream.run/1\n    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6\n    (elixir) lib/code.ex:232: Code.eval_string/3","type":2}}

I will try to figure out what happens, but I’m not an expert in Erlang/Elixir.

Okay, I managed to get it work with the release https://github.com/JakeBecker/elixir-ls/releases/download/v0.2.24/elixir-ls.zip

So, try to spell out home directory explicitly instead of using ~. Let me know if it doesn’t help.

1 Like

Thank you so much. It worked You rock! and so does kakoune.

Hi,

Can you please give me what you have in your kak-lsp.toml file regarding elixir. I started using kakoune from scratch and cannot get elixir language server to work. LSP is working fine for css and html though.
For elixir-ls i am using - https://github.com/JakeBecker/elixir-ls/releases/download/v0.2.25/elixir-ls.zip

[language.elixir]
filetypes = ["elixir"]
roots = [".git",  "mix.exs"]
command = ["sh"]
args = ["/Users/sreyans/Documents/elixir_dev/elixir-ls-master/language_server.sh"]

Also is there a way by which i can get to know any errors i have made. For ex i tried tweaking the verbosity but didn’t get any error.
Thank you so much.

I got it to run. The problem was I had not created the kak-lsp/kak-lsp.toml file the ~/.config folder. Once i did, it started working. Thanks for the time and help and amazing work with kak-lsp and ofcourse kakoune.