feat: improve depedencies setup and upgrade tools to latest version (#24)

1. Migrate from `rtx` to `mise`
2. Set most of the tools using `mise`
   * Some tools, such as `starship` and `zoxide` are installed locally, so they are available at boot time
3. Improve `tmux` by adding
   * resurrect and continuum to record/restore sessions
   * better color scheme
4. Setup multiple `elixir-ls` releases using the same repository
5. Upgraded `kickstart.nvim` to latest version

Reviewed-on: #24
This commit is contained in:
João Paulo Dubas 2024-01-14 19:00:37 +00:00
parent 20c5f4f816
commit 6feae34b63
8 changed files with 113 additions and 65 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config/tmux/plugins

View File

@ -18,7 +18,6 @@ RUN apt-get update \
ca-certificates \
curl \
doas \
exa \
fish \
g++ \
gcc \
@ -91,23 +90,11 @@ RUN apt-get update \
&& echo 'permit persist :wheel as root' > /etc/doas.conf
# command line utilities
ENV BAT_VERSION 0.24.0
ENV BAT_FILE bat_${BAT_VERSION}_amd64.deb
ENV BAT_URL https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/${BAT_FILE}
ENV RG_VERSION 14.0.3
ENV RG_FILE ripgrep_${RG_VERSION}_amd64.deb
ENV RG_URL https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${RG_FILE}
ENV DO_VERSION 24.0.7
ENV DO_URL https://download.docker.com/linux/static/stable/x86_64/docker-${DO_VERSION}.tgz
ENV DC_VERSION v2.23.3
ENV DC_URL https://github.com/docker/compose/releases/download/${DC_VERSION}/docker-compose-linux-x86_64
RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes \
&& curl -LO ${BAT_URL} \
&& dpkg -i ${BAT_FILE} \
&& rm ${BAT_FILE} \
&& curl -LO ${RG_URL} \
&& dpkg -i ${RG_FILE} \
&& rm ${RG_FILE} \
&& mkdir /tmp/download \
&& curl -L ${DO_URL} | tar -zx -C /tmp/download \
&& chgrp --recursive docker /tmp/download \
@ -133,8 +120,26 @@ ENV XDG_CACHE_HOME ${HOME}/.cache
ENV STARSHIP_CONFIG ${XDG_CONFIG_HOME}/starship/config.toml
ENV PATH ${LOCAL_BIN_HOME}:$PATH
# 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" mise install
RUN mkdir -p ${HOME}/.local/src \
&& cd ${HOME}/.local/src \
&& curl -L https://www.openssl.org/source/openssl-1.1.1m.tar.gz | tar -xz \
&& cd openssl-1.1.1m \
&& ./config --prefix=${HOME}/.local/lib/ssl --openssldir=${HOME}/.local/lib/ssl shared zlib \
&& make \
# && make test \
&& make install
# fetch elixir-ls to install custom releases
RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elixir-ls
# command line utilities
RUN curl https://rtx.pub/install.sh | sh \
RUN curl https://mise.jdx.dev/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
@ -143,7 +148,7 @@ COPY ./patch/kickstart.nvim/updates.patch /tmp
COPY ./config/nvim/lua/custom/plugins/init.lua /tmp
RUN git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME}"/nvim \
&& cd ${XDG_CONFIG_HOME}/nvim \
&& git reset --hard 4d0dc8d4b1bd6b94e59f7773158149bb1b0ee5be \
&& git reset --hard 2510c29d62d39d63bb75f1a613d2ae628a2af4ee \
&& git apply /tmp/updates.patch \
&& cp /tmp/init.lua ${XDG_CONFIG_HOME}/nvim/lua/custom/plugins \
&& nvim --headless "+Lazy! sync" +qa
@ -151,10 +156,10 @@ RUN git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME}
# configure fish and bash
RUN fish -c true \
&& echo 'starship init fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo '{$XDG_DATA_HOME}/rtx/bin/rtx activate fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo '{$LOCAL_BIN_HOME}/mise activate fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'zoxide init fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'alias cat="bat"' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'alias l="exa --time-style long-iso --color=auto -F"' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'alias l="eza --time-style long-iso --color=auto -F"' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'alias ll="l -Fahl"' >> ${XDG_CONFIG_HOME}/fish/config.fish \
&& echo 'alias la="l -a"' >> ${XDG_CONFIG_HOME}/fish/config.fish
@ -166,44 +171,28 @@ RUN git config --global user.email "${GIT_USER_EMAIL}" \
&& git config --global core.editor nvim
# install rtx plugins
RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \
RUN ${LOCAL_BIN_HOME}/mise plugins install --force --yes \
awscli \
bat \
dagger \
elixir \
erlang \
eza \
fzf \
helm \
k3d \
kubectl \
kubie \
lefthook \
poetry \
ripgrep \
starship \
terraform \
tilt
tilt \
tmux \
usql \
yarn \
zoxide
# 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
RUN mkdir -p ${HOME}/.local/src \
&& cd ${HOME}/.local/src \
&& wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz \
&& tar -xzf openssl-1.1.1m.tar.gz \
&& cd openssl-1.1.1m \
&& ./config --prefix=${HOME}/.local/lib/ssl --openssldir=${HOME}/.local/lib/ssl shared zlib \
&& make \
# && make test \
&& make install
# fetch elixir-ls compatible with elixir 1.11.x and 1.12.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/v0.12.0 \
&& cd ${LOCAL_SRC_HOME}/elixir-ls/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
COPY ./scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY ./scripts/elixir-ls-setup.sh /usr/local/bin/elixir-ls-setup

View File

@ -1,18 +1,28 @@
[tools]
awscli = "2.15.6"
bat = "0.24.0"
dagger = "0.9.5"
elixir = "1.16.0-otp-26"
erlang = "26.2.1"
eza = "0.17.0"
fzf = "0.45.0"
go = "1.21.5"
helm = "3.13.3"
k3d = "5.6.0"
kubectl = "1.29.0"
kubie = "0.23.0"
lefthook = "1.5.5"
node = "21.5.0"
poetry = "1.7.1"
python = "3.12.1"
ripgrep = "14.1.0"
starship = "1.17.1"
terraform = "1.6.6"
tilt = "0.33.10"
tmux = "3.3"
usql = "0.17.2"
yarn = "1.22.19"
zoxide = "0.9.2"
[settings]
experimental = true

View File

@ -52,7 +52,7 @@ bind-key & kill-window
# Reload tmux conf
unbind r
bind r source-file ~/.tmux.conf\; display "Reloaded conf."
bind r source-file ~/.config/tmux/tmux.conf\; display "Reloaded conf."
# Full color for vim
set -g default-terminal "screen-256color"
@ -94,6 +94,15 @@ set -g history-limit 50000
# list plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'fabioluciano/tmux-tokyo-night'
set -g @plugin 'Morantron/tmux-fingers'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# configure resurrect/continuum
set -g @continuum-save-interval '15'
set -g @continuum-restore 'on'
# load/install plugins
run '~/.config/tmux/plugins/tpm/tpm'

View File

@ -10,15 +10,17 @@ services:
command: infinity
volumes:
- './config/nvim/lua/custom:/home/coder/.config/nvim/lua/custom'
- './config/rtx:/home/coder/.config/rtx'
- './config/mise:/home/coder/.config/mise'
- './config/starship:/home/coder/.config/starship'
- './config/tmux:/home/coder/.config/tmux'
- './config/tmuxp:/home/coder/.config/tmuxp'
- 'home_cache:/home/coder/.cache'
- 'home_local_share:/home/coder/.local/share'
- 'home_local_state:/home/coder/.local/state'
- 'home_plugins_tmux:/home/coder/.config/tmux/plugins'
volumes:
home_cache: {}
home_local_share: {}
home_local_state: {}
home_plugins_tmux: {}

View File

@ -1,7 +1,5 @@
:100644 100644 7e68de6 0000000 M init.lua
diff --git a/init.lua b/init.lua
index 7e68de6..f886b8a 100644
index 1ff16af..2ef9591 100644
--- a/init.lua
+++ b/init.lua
@@ -266,7 +266,7 @@ require('lazy').setup({
@ -44,7 +42,7 @@ index 7e68de6..f886b8a 100644
-- [[ Basic Keymaps ]]
-- Keymaps for better default experience
@@ -423,11 +432,33 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
@@ -423,8 +432,31 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
vim.defer_fn(function()
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
@ -77,11 +75,8 @@ index 7e68de6..f886b8a 100644
+ },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
-
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
@@ -563,13 +594,16 @@ require('mason-lspconfig').setup()
-- Install languages synchronously (only applied to `ensure_installed`)
@@ -568,13 +600,16 @@ require('mason-lspconfig').setup()
-- If you want to override the default filetypes that your language server will attach to you can
-- define the property 'filetypes' to the map in question.
local servers = {
@ -105,7 +100,7 @@ index 7e68de6..f886b8a 100644
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
@@ -578,6 +612,8 @@ local servers = {
@@ -583,6 +618,8 @@ local servers = {
-- diagnostics = { disable = { 'missing-fields' } },
},
},
@ -114,7 +109,7 @@ index 7e68de6..f886b8a 100644
}
-- Setup neovim lua configuration
@@ -596,12 +632,23 @@ mason_lspconfig.setup {
@@ -601,12 +638,23 @@ mason_lspconfig.setup {
mason_lspconfig.setup_handlers {
function(server_name)
@ -126,13 +121,13 @@ index 7e68de6..f886b8a 100644
filetypes = (servers[server_name] or {}).filetypes,
}
+ if server_name == 'elixirls' then
+ local version = vim.fn.system('rtx current elixir') or ''
+ local version = vim.fn.system('mise current elixir') or ''
+ local match_version_111 = string.match(version, '^1.11')
+ local match_version_112 = string.match(version, '^1.12')
+ 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' } })
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/release/v0.12.0/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' } })
+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. '/elixir-ls/release/v0.14.6/language_server.sh' } })
+ end
+ end
+ require('lspconfig')[server_name].setup(opts)

12
scripts/docker-entrypoint.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
# NOTE (jpd): setup elixir-ls for older versions of elixir
if [ ! -d ${LOCAL_SRC_HOME}/elixir-ls/release ]; then
echo "setup elixir ls version 0.12.0"
/usr/local/bin/elixir-ls-setup v0.12.0
echo "setup elixir ls version 0.14.6"
/usr/local/bin/elixir-ls-setup v0.14.6
fi
exec "$@"

30
scripts/elixir-ls-setup.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
function setup() {
local elixir_ls_home=${LOCAL_SRC_HOME}/elixir-ls
local elixir_ls_release=${elixir_ls_home}/release
echo "elixir-ls repo"
cd ${elixir_ls_home}
echo "checkout versions ${1}"
git checkout tags/${1}
echo "set erlang/elixir versions"
cp .release-tool-versions .tool-versions
local current_erlang=$(mise current erlang)
local current_elixir=$(mise current elixir)
echo "using erlang ${current_erlang} / elixir ${current_elixir}"
echo "install erlang/elixir runtimes"
KERL_CONFIGURE_OPTIONS="-with-ssl=${HOME}/.local/lib/ssl" mise install
echo "install elixir-ls deps"
mise exec erlang@${current_erlang} elixir@${current_elixir} --command "mix do local.rebar --force, local.hex --force, deps.get, deps.compile"
echo "compile and release elixir-ls"
mise exec erlang@${current_erlang} elixir@${current_elixir} --command "MIX_ENV=prod mix compile"
mise exec erlang@${current_erlang} elixir@${current_elixir} --command "MIX_ENV=prod mix elixir_ls.release -o ${elixir_ls_release}/${1}"
echo "remove local .tool-versions"
cp .tool-versions ${elixir_ls_release}/${1}
rm .tool-versions
mise exec erlang@${current_erlang} elixir@${current_elixir} --command "mix do deps.clean --all, clean"
git checkout master
}
setup $1