elixir-lsp / coc-elixir

Elixir language server extension based on elixir-ls for coc.nvim
MIT License
168 stars 11 forks source link

Please help, everything works except autocompletion #64

Open hissssst opened 2 years ago

hissssst commented 2 years ago

I've checked and autocompletion works correctly with other languages. In elixir, I am able to have buffer completion, but not LS completion while other features like goto definition and documentation work correctly. There's nothing special in coc log too

hissssst commented 2 years ago

Hmmm, Setting elixirLS like described here works correctly with autocompletion https://github.com/neoclide/coc.nvim/wiki/Language-servers#elixir

lauriannala commented 2 years ago

Autocompletion is not working for me either, setting up elixir-ls on coc-config works. CocCommand workspace.showOutput reports an error on autocompletion attempt:

[Error  - 1:50:57 PM] Request textDocument/completion failed.
  Message: an exception was raised:
    ** (CaseClauseError) no case clause matching: {:ok, 1, 11, [], [{:atom, {1, 5, nil}, :world}]}
        (elixir_sense 2.0.0) lib/elixir_sense/core/normalized/tokenizer.ex:16: ElixirSense.Core.Normalized.Tokenizer.do_tokenize_1_7/1
        (elixir_sense 2.0.0) lib/elixir_sense/core/parser.ex:230: ElixirSense.Core.Parser.fix_parse_error/3
        (elixir_sense 2.0.0) lib/elixir_sense/core/parser.ex:118: ElixirSense.Core.Parser.string_to_ast/5
        (elixir_sense 2.0.0) lib/elixir_sense/core/parser.ex:32: ElixirSense.Core.Parser.parse_string/4
        (language_server 0.7.0) lib/language_server/providers/completion.ex:100: ElixirLS.LanguageServer.Providers.Completion.completion/4
        (language_server 0.7.0) lib/language_server/server.ex:770: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
  Code: -32000 
defmodule CocElixirIssue do
  def hello do
    Enum. # <-- Problem experienced here on autocomplete attempt.
    :world
  end
end

Version info:

Started ElixirLS v0.7.0
Elixir version: "1.13.0 (compiled with Erlang/OTP 24)"
Erlang version: "24"
ElixirLS compiled with Elixir 1.8.2 and erlang 21
MIX_ENV: test
MIX_TARGET: host
cr0t commented 2 years ago

From this comment https://github.com/elixir-lsp/elixir_sense/issues/148 it seems that the ElixirLS version is outdated.

I (and I might assume as the other participants in this issue) have installed coc-elixir via :CocInstall coc-elixir command that is given in the README of https://github.com/elixir-lsp/coc-elixir.

It turns out that it downloads and installs an outdated (last release was 7 months ago) coc-elixir NPM package, instead of the new one.

@amiralies, is there any way to build and publish a new release to the npmjs?

If not, shall the vim-plug be a preferrable way of using this server? Or any other tips?

cr0t commented 2 years ago

This repo seems a little bit abandoned (on activity since May 2020, no tags after version 0.7.0, no releases of new version). @lukaszsamson do you know maintainer of this package, or if anything can be done do update the package? Sorry for disturbing you.

cr0t commented 2 years ago

@hissssst @lauriannala I have found a workaround.

  1. Download the latest releases of here https://github.com/elixir-lsp/elixir-ls/releases (download elixir-ls.zip file).

  2. Find where coc.nvim have installed your Elixir's Language Server – you can do it like this:

    $ find ~ -name 'language_server.sh'
    /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/language_server.sh
  3. In my case, I have replaced all the files in my /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/ directory with the files from the downloaded zip-archive – like that:

    $ rm -rf /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/*
    $ cd ~/Downloads
    $ unzip elixir-ls.zip -d /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/

(keep in mind, that in your system -d option to unzip might not work or work differently; I ran these commands on macOS 12.1)

  1. Profit! (Now autocompletion works even in Elixir 1.13 projects!)
amiralies commented 2 years ago

I've switched to neovim's lsp recently and do not work much on elixir projects at work atm. so I couldn't give attention to this small project.

This extension doesn't do anything fancy it's a wrapper around elixir-ls. so with manual installation mentioned in the readme or using coc's manual configuration same experience should be available for the end user. but with extra steps. achieving out of the box experience is a bit tricky (we should publish with minimum version of elixir and otp supported by the language server to support more users and some small issues that i can't remember now).

With that being said if i find a way to automate build/publish via github actions that would be great (PR welcome).

vinibrsl commented 2 years ago

@hissssst @lauriannala I have found a workaround.

  1. Download the latest releases of here https://github.com/elixir-lsp/elixir-ls/releases (download elixir-ls.zip file).
  2. Find where coc.nvim have installed your Elixir's Language Server – you can do it like this:
$ find ~ -name 'language_server.sh'
/Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/language_server.sh
  1. In my case, I have replaced all the files in my /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/ directory with the files from the downloaded zip-archive – like that:
$ rm -rf /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/*
$ cd ~/Downloads
$ unzip elixir-ls.zip -d /Users/cr0t/.config/coc/extensions/node_modules/coc-elixir/els-release/

(keep in mind, that in your system -d option to unzip might not work or work differently; I ran these commands on macOS 12.1)

  1. Profit! (Now autocompletion works even in Elixir 1.13 projects!)

Thank you! That worked flawlessly :)