Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Add initial elixir-ls support #42

Merged
merged 3 commits into from
Apr 22, 2021

Conversation

viniciusmuller
Copy link
Contributor

Due to the way that elixir-ls works in nvim-lspconfig, I could not set cmd on the file, so the installation is currently working and the user needs to set elixirls's cmd as /home/<user>/.local/share/nvim/lspinstall/elixir/language_server.sh on setup in order to the language server to start. I wonder if we can improve this and make it work out of the box or just add documentation about that issue.

@@ -0,0 +1,11 @@
local config = require'lspconfig'.elixirls.document_config
require'lspconfig/configs'.elixirls = nil -- important, immediately unset the loaded config again

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add config.default_config.cmd = { "./language_server.sh" }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting some strange errors with the :LspInstall command completion before when tried with that line, but now it seems to be working

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you were missing the { } before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the first time just indexing the cmd field and setting a string value, but it didn't existed, so I also tried to create it before doing that, (which is the same as the line you sent) and both don't cause errors but the lsp doesn't seem to start.
It has started before because I've forgot that I had hardcoded the path in my vimrc's elixirls setup for testing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does :LspInfo say?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configured servers: elixirls
Neovim logs at: /home/<user>/.cache/nvim/lsp.log

0 client(s) attached to this buffer: 

0 active client(s): 

Clients that match the filetype elixir:
  
  Config: elixirls
  	cmd:               cmd not defined
  	cmd is executable: cmd not defined
  	identified root:   /home/<user>
  	custom handlers:   

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll commit the current code

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be ./elixir-ls/language_server.sh. The ./ is important to be recognized as a local path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, I forgot the ./, but even adding it the behaviour and :LspInfo output are still the same.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very weird. I suspect something in your config is wrong because the code looks fine. Also I just tested it, and it works on my machine.

@kabouzeid
Copy link
Owner

Looks good, only thing is I would prefer it if you would extract the .zip file into a subdirectory elixr-ls. Then use rm -rf elixir-ls before unzipping. This ensures it can be cleanly reinstalled without causing any issues because of existing files during unzipping.

Something like this pseudo code

rm -rf elixr-ls
curl 
unzip zip to elixr-ls
chmod
rm zip

@kabouzeid kabouzeid merged commit 96932ec into kabouzeid:main Apr 22, 2021
@kabouzeid
Copy link
Owner

Thanks!

@viniciusmuller viniciusmuller deleted the add-elixir-ls branch April 22, 2021 22:40
@qgadrian
Copy link

Just for reference, I had problems with elixir-ls not working correctly in my machine (local modules not recognized, for example).

After finding this issue in their repo I manually checked out the project and built it with my local Elixir, and everything started working perfectly again.

I believe nvim-lspinstall for this matter shouldn't use the release zip provided by elixir-ls and compile the project instead, using the Erlang version installed in the system. @kabouzeid I will prepare a PR to compile elixir-ls and just not extract a zip when is installed by nvim-lspinstall.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants