chore(elixir): add elixir lsp for version 1.12 (#19)

Explicitly add an elixir lsp suitable to elixir version 1.12.

Reviewed-on: #19
This commit is contained in:
João Paulo Dubas 2023-12-08 11:53:14 +00:00
parent 39aeeffcf2
commit 9cee421a21
2 changed files with 15 additions and 10 deletions

View File

@ -131,8 +131,6 @@ ENV XDG_DATA_HOME ${HOME}/.local/share
ENV XDG_CACHE_HOME ${HOME}/.cache ENV XDG_CACHE_HOME ${HOME}/.cache
ENV STARSHIP_CONFIG ${XDG_CONFIG_HOME}/starship/config.toml ENV STARSHIP_CONFIG ${XDG_CONFIG_HOME}/starship/config.toml
ENV PATH ${LOCAL_BIN_HOME}:$PATH ENV PATH ${LOCAL_BIN_HOME}:$PATH
# NOTE (jpd): to install elixirls we have to set the shell to something known
ENV SHELL /usr/bin/bash
# command line utilities # command line utilities
RUN curl https://rtx.pub/install.sh | sh \ RUN curl https://rtx.pub/install.sh | sh \
@ -194,13 +192,17 @@ RUN mkdir -p ${HOME}/.local/src \
# && make test \ # && make test \
&& make install && make install
# fetch elixir-ls compatible with elixir 1.11.x # fetch elixir-ls compatible with elixir 1.11.x and 1.12.x
# to setup this project run the following commands: # to setup this project run the following commands:
# mix do local.rebar --force, local.hex --force # mix do local.rebar --force, local.hex --force
# mix do deps.get, deps.compile # mix do deps.get, deps.compile
# MIX_ENV=prod mix compile # MIX_ENV=prod mix compile
# MIX_ENV=prod mix elixir_ls.release # MIX_ENV=prod mix elixir_ls.release
RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elixir-ls \ RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elixir-ls/v0.12.0 \
&& cd ${LOCAL_SRC_HOME}/elixir-ls \ && cd ${LOCAL_SRC_HOME}/elixir-ls/v0.12.0 \
&& git checkout tags/v0.12.0 \ && git checkout tags/v0.12.0 \
&& cp .release-tool-versions .tool-versions \
&& git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elixir-ls/v0.14.6 \
&& cd ${LOCAL_SRC_HOME}/elixir-ls/v0.14.6 \
&& git checkout tags/v0.14.6 \
&& cp .release-tool-versions .tool-versions && cp .release-tool-versions .tool-versions

View File

@ -1,5 +1,5 @@
diff --git a/init.lua b/init.lua diff --git a/init.lua b/init.lua
index 3a98da0..e8e41b4 100644 index 3a98da0..e8c5b7d 100644
--- a/init.lua --- a/init.lua
+++ b/init.lua +++ b/init.lua
@@ -229,7 +229,7 @@ require('lazy').setup({ @@ -229,7 +229,7 @@ require('lazy').setup({
@ -111,7 +111,7 @@ index 3a98da0..e8e41b4 100644
} }
-- Setup neovim lua configuration -- Setup neovim lua configuration
@@ -542,12 +578,20 @@ mason_lspconfig.setup { @@ -542,12 +578,23 @@ mason_lspconfig.setup {
mason_lspconfig.setup_handlers { mason_lspconfig.setup_handlers {
function(server_name) function(server_name)
@ -124,9 +124,12 @@ index 3a98da0..e8e41b4 100644
} }
+ if server_name == 'elixirls' then + if server_name == 'elixirls' then
+ local version = vim.fn.system('rtx current elixir') or '' + local version = vim.fn.system('rtx current elixir') or ''
+ local match_version = string.match(version, '^1.11') + local match_version_111 = string.match(version, '^1.11')
+ if match_version ~= nil then + local match_version_112 = string.match(version, '^1.12')
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/release/language_server.sh' } }) + if match_version_111 ~= nil then
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/v0.12.0/release/language_server.sh' } })
+ elseif match_version_112 ~= nil then
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/v0.14.6/release/language_server.sh' } })
+ end + end
+ end + end
+ require('lspconfig')[server_name].setup(opts) + require('lspconfig')[server_name].setup(opts)