From a0fb571da150fb6e275907aac6559516e551ff59 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sat, 11 Nov 2023 09:31:08 -0300 Subject: [PATCH 1/8] wip: add rust toolchain --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 970761b..ff2408b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -103,7 +103,8 @@ RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes \ && mkdir -p /usr/local/lib/docker/cli-plugins \ && curl -L ${DC_URL} -o /usr/local/lib/docker/cli-plugins/docker-compose \ && chmod 750 /usr/local/lib/docker/cli-plugins/docker-compose \ - && chgrp --recursive docker /usr/local/lib/docker + && chgrp --recursive docker /usr/local/lib/docker \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh USER coder WORKDIR /home/coder -- 2.47.2 From 8c7cdd6a581d3fa8e2092368dad37c5661fdd655 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sat, 11 Nov 2023 18:14:22 +0000 Subject: [PATCH 2/8] feat: add jetporch to provision machines --- Dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff2408b..801da43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -103,8 +103,7 @@ RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes \ && mkdir -p /usr/local/lib/docker/cli-plugins \ && curl -L ${DC_URL} -o /usr/local/lib/docker/cli-plugins/docker-compose \ && chmod 750 /usr/local/lib/docker/cli-plugins/docker-compose \ - && chgrp --recursive docker /usr/local/lib/docker \ - && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + && chgrp --recursive docker /usr/local/lib/docker USER coder WORKDIR /home/coder @@ -119,7 +118,9 @@ 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): 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. @@ -142,7 +143,12 @@ RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elix # command line utilities 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 + && 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 -- 2.47.2 From 1556c55680cc0f6e26d1c4469947799b66f27888 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sat, 11 Nov 2023 18:15:56 +0000 Subject: [PATCH 3/8] chore: git config is the last step of image --- Dockerfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 801da43..cd7c9e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,13 +170,6 @@ RUN fish -c true \ && echo 'alias ll="l -Fahl"' >> ${XDG_CONFIG_HOME}/fish/config.fish \ && echo 'alias la="l -a"' >> ${XDG_CONFIG_HOME}/fish/config.fish -# 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 ${LOCAL_BIN_HOME}/mise plugins install --force --yes \ awscli \ -- 2.47.2 From 98a83f737523edbced3e23b90f3002b4c4782010 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Thu, 30 Nov 2023 13:50:06 +0000 Subject: [PATCH 4/8] chore: move frequently updated layers to the end --- Dockerfile | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd7c9e0..c4883cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -150,16 +150,6 @@ RUN curl https://mise.jdx.dev/install.sh | sh \ && make \ && ln -s ${LOCAL_SRC_HOME}/jetporch/target/release/jetp ${LOCAL_BIN_HOME}/ -# git configuration -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 2510c29d62d39d63bb75f1a613d2ae628a2af4ee \ - && git apply /tmp/updates.patch \ - && cp /tmp/init.lua ${XDG_CONFIG_HOME}/nvim/lua/custom/plugins \ - && nvim --headless "+Lazy! sync" +qa - # configure fish and bash RUN fish -c true \ && echo 'starship init fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \ @@ -170,6 +160,16 @@ RUN fish -c true \ && echo 'alias ll="l -Fahl"' >> ${XDG_CONFIG_HOME}/fish/config.fish \ && echo 'alias la="l -a"' >> ${XDG_CONFIG_HOME}/fish/config.fish +# git configuration +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 2510c29d62d39d63bb75f1a613d2ae628a2af4ee \ + && git apply /tmp/updates.patch \ + && cp /tmp/init.lua ${XDG_CONFIG_HOME}/nvim/lua/custom/plugins \ + && nvim --headless "+Lazy! sync" +qa + # install rtx plugins RUN ${LOCAL_BIN_HOME}/mise plugins install --force --yes \ awscli \ @@ -194,5 +194,12 @@ RUN ${LOCAL_BIN_HOME}/mise plugins install --force --yes \ yarn \ zoxide +# 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 + COPY ./scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint COPY ./scripts/elixir-ls-setup.sh /usr/local/bin/elixir-ls-setup -- 2.47.2 From cefafaee826623e2dac19fa1b40ef15bd54cdc85 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 14 Jan 2024 20:11:08 +0000 Subject: [PATCH 5/8] chore(jetp): build jetp in an separate stage Create a multi-stage build to compile jetporch and copy the binary to nvim image. --- Dockerfile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4883cd..b69afee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,12 @@ +FROM ubuntu:22.04 as jetporch-builder +ENV PATH /root/.cargo/bin:${PATH} +RUN apt-get update \ + && apt-get install -y build-essential curl git libssl-dev pkg-config \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + && git clone https://git.sr.ht/~mpdehaan/jetporch /tmp/jetporch \ + && cd /tmp/jetporch \ + && make + FROM ubuntu:22.04 # system deps @@ -143,12 +152,10 @@ RUN git clone https://github.com/elixir-lsp/elixir-ls.git ${LOCAL_SRC_HOME}/elix # command line utilities 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 \ - && 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 clone https://github.com/tmux-plugins/tpm.git ${XDG_CONFIG_HOME}/tmux/plugins/tpm + +# fetch jetporch from builder step +COPY --from=jetporch-builder --chown=coder:coder /tmp/jetporch/target/release/jetp ${LOCAL_BIN_HOME} # configure fish and bash RUN fish -c true \ -- 2.47.2 From 1b8e518623d366bbaa07a8e8e7a80ac1a36d81e5 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 29 Jan 2024 16:41:07 -0300 Subject: [PATCH 6/8] chore(nvim): upgrade kicktstart to latest version Also change the theme from onedark to bw --- Dockerfile | 2 +- config/nvim/lua/custom/plugins/init.lua | 8 ++++ patch/kickstart.nvim/updates.patch | 59 +++++++++++++++++++------ 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index b69afee..8af97ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -172,7 +172,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 2510c29d62d39d63bb75f1a613d2ae628a2af4ee \ + && git reset --hard b11581491671ed49b1dfdb1ea777932ade7ff2e5 \ && git apply /tmp/updates.patch \ && cp /tmp/init.lua ${XDG_CONFIG_HOME}/nvim/lua/custom/plugins \ && nvim --headless "+Lazy! sync" +qa diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua index 6b865a6..bc16785 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -3,6 +3,14 @@ -- -- See the kickstart.nvim README for more information return { + { + 'mgoral/vim-bw', + url = 'https://git.goral.net.pl/mgoral/vim-bw.git', + priority = 1000, + config = function () + vim.cmd.colorscheme 'bw-onedark' + end + }, { 'joaodubas/gitlinker.nvim', config = function () diff --git a/patch/kickstart.nvim/updates.patch b/patch/kickstart.nvim/updates.patch index 8209164..91e9eb5 100644 --- a/patch/kickstart.nvim/updates.patch +++ b/patch/kickstart.nvim/updates.patch @@ -1,8 +1,41 @@ diff --git a/init.lua b/init.lua -index 1ff16af..2ef9591 100644 +index 6c6ae02..233e6b1 100644 --- a/init.lua +++ b/init.lua -@@ -266,7 +266,7 @@ require('lazy').setup({ +@@ -189,19 +189,19 @@ require('lazy').setup({ + }, + }, + +- { +- -- Theme inspired by Atom +- 'navarasu/onedark.nvim', +- priority = 1000, +- lazy = false, +- config = function() +- require('onedark').setup { +- -- Set a style preset. 'dark' is default. +- style = 'dark', -- dark, darker, cool, deep, warm, warmer, light +- } +- require('onedark').load() +- end, +- }, ++ -- { ++ -- -- Theme inspired by Atom ++ -- 'navarasu/onedark.nvim', ++ -- priority = 1000, ++ -- lazy = false, ++ -- config = function() ++ -- require('onedark').setup { ++ -- -- Set a style preset. 'dark' is default. ++ -- style = 'dark', -- dark, darker, cool, deep, warm, warmer, light ++ -- } ++ -- require('onedark').load() ++ -- end, ++ -- }, + + { + -- Set lualine as statusline +@@ -271,7 +271,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins @@ -11,7 +44,7 @@ index 1ff16af..2ef9591 100644 }, {}) -- [[ Setting options ]] -@@ -276,11 +276,12 @@ require('lazy').setup({ +@@ -281,11 +281,12 @@ require('lazy').setup({ -- Set highlight on search vim.o.hlsearch = false @@ -27,22 +60,22 @@ index 1ff16af..2ef9591 100644 -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. -@@ -310,6 +311,14 @@ vim.o.completeopt = 'menuone,noselect' +@@ -315,6 +316,14 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +-- Set foldmethod +-- See `:help foldmethod` -+vim.opt.foldmethod = 'expr' -+vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -+vim.opt.foldnestmax = 5 -+vim.opt.foldlevel = 1 -+vim.opt.foldenable = false ++vim.o.foldcolumn = '1' ++vim.o.foldlevel = 99 ++vim.o.foldlevelstart = 99 ++vim.o.foldenable = true ++vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + -- [[ Basic Keymaps ]] -- Keymaps for better default experience -@@ -423,8 +432,31 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = +@@ -428,8 +437,31 @@ vim.keymap.set('n', '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 @@ -76,7 +109,7 @@ index 1ff16af..2ef9591 100644 -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, -- Install languages synchronously (only applied to `ensure_installed`) -@@ -568,13 +600,16 @@ require('mason-lspconfig').setup() +@@ -573,13 +605,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 = { @@ -100,7 +133,7 @@ index 1ff16af..2ef9591 100644 lua_ls = { Lua = { workspace = { checkThirdParty = false }, -@@ -583,6 +618,8 @@ local servers = { +@@ -588,6 +623,8 @@ local servers = { -- diagnostics = { disable = { 'missing-fields' } }, }, }, @@ -109,7 +142,7 @@ index 1ff16af..2ef9591 100644 } -- Setup neovim lua configuration -@@ -601,12 +638,23 @@ mason_lspconfig.setup { +@@ -606,12 +643,23 @@ mason_lspconfig.setup { mason_lspconfig.setup_handlers { function(server_name) -- 2.47.2 From 7151b3a7101c3d7f7c278db8bc8113a56792dfe9 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 29 Jan 2024 16:42:12 -0300 Subject: [PATCH 7/8] chore(nvim): re-order plugins definition Try to keep alphabetical order, by plugin name. --- config/nvim/lua/custom/plugins/init.lua | 68 +++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua index bc16785..ef22920 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -32,6 +32,65 @@ return { }) end }, + 'nvim-treesitter/nvim-treesitter-context', + { + 'kevinhwang91/nvim-ufo', + dependencies = { 'kevinhwang91/promise-async' }, + event = 'BufRead', + keys = function () + local ufo = require('ufo') + return { + { 'zR', ufo.openAllFolds, { desc = "Open all folds" } }, + { 'zM', ufo.closeAllFolds, { desc = "Close all folds" } }, + { 'zr', ufo.openFoldsExceptKinds, { desc = "Open fold" } }, + { 'zm', ufo.closeFoldsWith, { desc = "Close fold" } }, + } + end, + opts = function () + local handler = function (virtText, lnum, endLnum, width, truncate) + local newVirtText = {} + local suffix = (' 󰁂 %d '):format(endLnum - lnum) + local sufWidth = vim.fn.strdisplaywidth(suffix) + local targetWidth = width - sufWidth + local curWidth = 0 + for _, chunk in ipairs(virtText) do + local chunkText = chunk[1] + local chunkWidth = vim.fn.strdisplaywidth(chunkText) + if targetWidth > curWidth + chunkWidth then + table.insert(newVirtText, chunk) + else + chunkText = truncate(chunkText, targetWidth - curWidth) + local hlGroup = chunk[2] + table.insert(newVirtText, {chunkText, hlGroup}) + chunkWidth = vim.fn.strdisplaywidth(chunkText) + -- str width returned from truncate() may less than 2nd argument, need padding + if curWidth + chunkWidth < targetWidth then + suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth) + end + break + end + curWidth = curWidth + chunkWidth + end + table.insert(newVirtText, { suffix, 'MoreMsg' }) + return newVirtText + end + + return { + fold_virt_text_handler = handler, + provider_selector = function (_, _, _) + return { 'treesitter', 'indent' } + end + } + end, + }, + { + 'stevearc/oil.nvim', + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = { + { '-', 'Oil', desc = "Open parent directory" }, + }, + opts = {}, + }, { 'rest-nvim/rest.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, @@ -77,7 +136,6 @@ return { } end }, - 'nvim-treesitter/nvim-treesitter-context', { 'akinsho/toggleterm.nvim', opts = { @@ -118,12 +176,4 @@ return { } end }, - { - 'stevearc/oil.nvim', - dependencies = { "nvim-tree/nvim-web-devicons" }, - keys = { - { '-', 'Oil', desc = "Open parent directory" }, - }, - opts = {}, - }, } -- 2.47.2 From 086cdf46de69fb953d9a78c458e302f1489198b8 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Thu, 1 Feb 2024 11:29:29 +0000 Subject: [PATCH 8/8] chore: remove jetporch Even though this branch is called `add-jetportch`, the project was discontinued. --- Dockerfile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8af97ba..3cbc9bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,3 @@ -FROM ubuntu:22.04 as jetporch-builder -ENV PATH /root/.cargo/bin:${PATH} -RUN apt-get update \ - && apt-get install -y build-essential curl git libssl-dev pkg-config \ - && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ - && git clone https://git.sr.ht/~mpdehaan/jetporch /tmp/jetporch \ - && cd /tmp/jetporch \ - && make - FROM ubuntu:22.04 # system deps @@ -127,9 +118,7 @@ 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 CARGO_HOME ${XDG_DATA_HOME}/cargo -ENV RUSTUP_HOME ${XDG_DATA_HOME}/rustup -ENV PATH ${LOCAL_BIN_HOME}:${CARGO_HOME}/bin:$PATH +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. @@ -154,9 +143,6 @@ 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 -# fetch jetporch from builder step -COPY --from=jetporch-builder --chown=coder:coder /tmp/jetporch/target/release/jetp ${LOCAL_BIN_HOME} - # configure fish and bash RUN fish -c true \ && echo 'starship init fish | source' >> ${XDG_CONFIG_HOME}/fish/config.fish \ -- 2.47.2