Compare commits

...

4 Commits

Author SHA1 Message Date
b36bfb3085 chore: git config is the last step of image 2023-11-14 01:52:51 +00:00
12c4eedc84 feat: add jetporch to provision machines 2023-11-14 01:47:00 +00:00
Joao P Dubas
04a8637f07 wip: add rust toolchain 2023-11-14 01:47:00 +00:00
6c1a8e92bc feat: add elixir-ls compatible with version 1.11 (#15)
1. Clone `elixir-ls` and set it to version [v0.12.0](https://github.com/elixir-lsp/elixir-ls/blob/master/CHANGELOG.md#v0120-7-november-2022)
2. Set up `neovim` to check `elixir` current elixir version and use the appropriate `elixir-ls`

Reviewed-on: #15
2023-11-13 11:33:09 +00:00
2 changed files with 53 additions and 10 deletions

View File

@ -130,14 +130,21 @@ ENV XDG_CONFIG_HOME ${HOME}/.config
ENV XDG_DATA_HOME ${HOME}/.local/share
ENV XDG_CACHE_HOME ${HOME}/.cache
ENV STARSHIP_CONFIG ${XDG_CONFIG_HOME}/starship/config.toml
ENV PATH ${LOCAL_BIN_HOME}:$PATH
ENV CARGO_HOME ${XDG_DATA_HOME}/cargo
ENV RUSTUP_HOME ${XDG_DATA_HOME}/rustup
ENV PATH ${LOCAL_BIN_HOME}:${CARGO_HOME}/bin:$PATH
# NOTE (jpd): to install elixirls we have to set the shell to something known
ENV SHELL /usr/bin/bash
# command line utilities
RUN curl https://rtx.pub/install.sh | sh \
&& curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash \
&& git clone https://github.com/tmux-plugins/tpm.git ${XDG_CONFIG_HOME}/tmux/plugins/tpm
&& git clone https://github.com/tmux-plugins/tpm.git ${XDG_CONFIG_HOME}/tmux/plugins/tpm \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& git clone https://git.sr.ht/~mpdehaan/jetporch ${LOCAL_SRC_HOME}/jetporch \
&& cd ${LOCAL_SRC_HOME}/jetporch \
&& make \
&& ln -s ${LOCAL_SRC_HOME}/jetporch/target/release/jetp ${LOCAL_BIN_HOME}/
# git configuration
COPY ./patch/kickstart.nvim/updates.patch /tmp
@ -158,13 +165,6 @@ RUN fish -c true \
&& echo 'eval "$(${XDG_DATA_HOME}/rtx/bin/rtx activate bash)"' >> ${HOME}/.bashrc \
&& echo 'eval "$(zoxide init bash)"' >> ${HOME}/.bashrc
# configure git
ARG GIT_USER_EMAIL
ARG GIT_USER_NAME
RUN git config --global user.email "${GIT_USER_EMAIL}" \
&& git config --global user.name "${GIT_USER_NAME}" \
&& git config --global core.editor nvim
# install rtx plugins
RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \
awscli \
@ -176,6 +176,9 @@ RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \
poetry \
terraform
# NOTE (jpd): the section below exists mainly to handle a project running elixir 1.11.
# It allows the usage of openssl 1.1 and a compatible elixir-ls.
# configure openssl 1.1
# this is needed to compile older erlang versions
# example: KERL_CONFIGURE_OPTIONS="-with-ssl=${HOME}/.local/lib/ssl" asdf install
@ -188,3 +191,21 @@ RUN mkdir -p ${HOME}/.local/src \
&& make \
# && make test \
&& make install
# fetch elixir-ls compatible with elixir 1.11.x
# to setup this project run the following commands:
# mix do local.rebar --force, local.hex --force
# mix do deps.get, deps.compile
# MIX_ENV=prod mix compile
# MIX_ENV=prod mix elixir_ls.release
RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elixir-ls \
&& cd ${LOCAL_SRC_HOME}/elixir-ls \
&& git checkout tags/v0.12.0 \
&& cp .release-tool-versions .tool-versions
# configure git
ARG GIT_USER_EMAIL
ARG GIT_USER_NAME
RUN git config --global user.email "${GIT_USER_EMAIL}" \
&& git config --global user.name "${GIT_USER_NAME}" \
&& git config --global core.editor nvim

View File

@ -1,5 +1,5 @@
diff --git a/init.lua b/init.lua
index 748e7f8..47e327a 100644
index 748e7f8145427b7f17639d4c9f978b9bbe47d2c9..7d05ed25928e7526b02da1671068cdaa24ebc240 100644
--- a/init.lua
+++ b/init.lua
@@ -229,7 +229,7 @@ require('lazy').setup({
@ -107,3 +107,25 @@ index 748e7f8..47e327a 100644
}
-- Setup neovim lua configuration
@@ -542,12 +574,20 @@ mason_lspconfig.setup {
mason_lspconfig.setup_handlers {
function(server_name)
- require('lspconfig')[server_name].setup {
+ local opts = {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
}
+ if server_name == 'elixirls' then
+ local version = vim.fn.system('rtx current elixir') or ''
+ local match_version = string.match(version, '^1.11')
+ if match_version ~= nil then
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/release/language_server.sh' } })
+ end
+ end
+ require('lspconfig')[server_name].setup(opts)
end,
}