sublimelsp / LSP-elixir

Elixir support for Sublime LSP plugin

Home Page:https://lsp.sublimetext.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lsp-elixir crashes on start

woylie opened this issue · comments

I just installed the Elixir, LSP and LSP-elixir packages. As soon as I open a .exs or .ex file, LSP-elixir crashes. It immediately crashes again after clicking Restart. There are no other Elixir packages installed. There are no messages in the console.

Sublime Text 3.2.2, build 3211
LSP 0.14.3
Elixir v2020.06.24.18.45.23
LSP-elixir 0.3.0

Elixir 1.11.2
Erlang/OTP 22 [erts-10.7]

macOS Big Sur 11.1

imagen

Could you enable logging in LSP settings (not lsp-elixir!) like described here:
https://lsp.readthedocs.io/en/latest/troubleshooting/

Restart, you should get more info in the console, and also see the messages exchanged with the server, if any, by opening "LSP: Toggle Log Panel" from the command palette.

The LSP log panel shows this error:

lsp-elixir: ** (MatchError) no match of right hand side value: {:error, {:crypto, {'no such file or directory', 'crypto.app'}}}
    (language_server 0.6.0) lib/language_server/cli.ex:9: ElixirLS.LanguageServer.CLI.main/0
    (stdlib 3.14) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.11.2) lib/code.ex:341: Code.eval_string_with_error_handling/3

I had two issues here:

  1. I still had the asdf plugins for Erlang and Elixir installed, and the asdf installations took precedence over the Nix installations in the LSP/Sublime for some reason. I had to remove the asdf plugins.
  2. I had to add erlangR22 to my Nix shell.

Now I'm having trouble with the formatting, though.

I put this into Sublime Text -> Preferences -> Settings - Syntax Specific -> Elixir.sublime-settings:

{
  "lsp_format_on_save": true
}

Both formatting on save and manual formatting via the command palette only work sometimes. There seems to be a pattern:

  • change something, format via command palette: works
  • change something, save, format via command palette: does not work
  • change something again without saving, format via command palette: works

As for format on save, it sometimes works the very first time after Sublime is started, a document is opened, changed and saved, but not on subsequent changes and saves.

Output on success (manual format after changing without saving):

::  -> lsp-elixir textDocument/didChange
:: --> lsp-elixir textDocument/formatting(169)
:: <<< lsp-elixir 169
::  -> lsp-elixir textDocument/didChange

Output on failure (changing and saving):

::  -> lsp-elixir textDocument/didChange
:: ==> lsp-elixir textDocument/formatting(175)
::  -> lsp-elixir textDocument/didSave

Output on failure (changing, saving, manual formatting):

::  -> lsp-elixir textDocument/didChange
:: ==> lsp-elixir textDocument/formatting(178)
::  -> lsp-elixir textDocument/didSave
:: --> lsp-elixir textDocument/formatting(179)
:: <<< lsp-elixir 179

I removed the compilation logs and [ElixirLS WorkspaceSymbols] indexing from the output.

Scratch the remarks about the pattern. Not-saving-plus-manual-format vs. Saving-plus-manual-format was reproducible for a while, but now it seems completely random.

Any issues still?

No, this issue seems to be fixed.