From ea3b1a302e1d476a1bb765af19e8f38ce5e3265a Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 1 Oct 2023 23:39:11 +0000 Subject: [PATCH] feat(nvim): use kickstart.nvim as base configuration To make this effective, the following changes were made: 1. Patch `init.lua` to change common configurations 2. Implement custom configuration for plugins --- Dockerfile | 13 ++- config/nvim/lua/custom/plugins/init.lua | 89 ++++++++++++++++++++ docker-compose.yml | 1 + patch/kickstart.nvim/updates.patch | 107 ++++++++++++++++++++++++ 4 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 config/nvim/lua/custom/plugins/init.lua create mode 100644 patch/kickstart.nvim/updates.patch diff --git a/Dockerfile b/Dockerfile index 7410f01..6e648d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -130,9 +130,16 @@ ENV PATH ${LOCAL_BIN_HOME}:$PATH RUN curl https://rtx.pub/install.sh | sh \ && curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash -# configure fish -RUN git clone https://github.com/NvChad/NvChad.git ~/.config/nvim \ - && fish -c true \ +# 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 313bd75ca04cb2cef48a79ac3ad697a1b9a2daab \ + && 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 \ diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua new file mode 100644 index 0000000..622df37 --- /dev/null +++ b/config/nvim/lua/custom/plugins/init.lua @@ -0,0 +1,89 @@ +-- You can add your own plugins here or in other files in this directory! +-- I promise not to create any merge conflicts in this directory :) +-- +-- See the kickstart.nvim README for more information +return { + { + 'joaodubas/gitlinker.nvim', + config = function () + local actions = require('gitlinker.actions') + local hosts = require('gitlinker.hosts') + require('gitlinker').setup({ + opts = { + remote = "origin", + add_current_line_on_normal_mode = true, + action_callback = actions.copy_to_clipboard, + print_url = true, + }, + callbacks = { + ["github.com"] = hosts.get_github_type_url, + ["bitbucket.org"] = hosts.get_bitbucket_type_url, + ["gitea.dubas.dev"] = hosts.get_gitea_type_url, + }, + mappings = "gy" + }) + end + }, + { + 'rest-nvim/rest.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + ft = { + 'http', + 'rest' + }, + opts = { + result_split_horizontal = false, + result_split_in_place = false, + skip_ssl_verification = false, + encode_url = true, + highlight = { + enabled = true, + timeout = 15 + }, + result = { + show_url = true, + show_curl_command = true, + show_http_info = true, + show_headers = true, + formatters = { + json = 'jq', + html = false + }, + jump_to_request = true, + env_file = '.env', + custom_dynamic_variables = { }, + yank_dry_run = true + } + }, + keys = function () + require('which-key').register({ + ['t'] = { name = 'Res[t]', _ = 'which_key_ignore' } + }) + return { + { 'tr', 'RestNvim', desc = 'Run the request under cursor' }, + { 'tp', 'RestNvimPreview', desc = 'Preview the curl command for the request under cursor' }, + { 'tl', 'RestNvimLast', desc = 'Re-run the last request' } + } + end + }, + { + 'Vigemus/iron.nvim', + config = function () + local iron = require('iron.core') + iron.setup({ + config = { + scratch_repl = true, + repl_definition = { + sh = { + command = { 'fish' } + }, + elixir = require('iron.fts.elixir').iex, + javascript = require('iron.fts.javascript').node, + python = require('iron.fts.python').ipython, + typescript = require('iron.fts.typescript').ts + } + } + }) + end + } +} diff --git a/docker-compose.yml b/docker-compose.yml index e390325..557388d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: - 'home_cache:/home/coder/.cache' - 'home_local_share:/home/coder/.local/share' - './config/rtx:/home/coder/.config/rtx' + - './config/nvim/lua/custom:/home/coder/.confing/nvim/lua/custom' volumes: home_cache: {} diff --git a/patch/kickstart.nvim/updates.patch b/patch/kickstart.nvim/updates.patch new file mode 100644 index 0000000..f774408 --- /dev/null +++ b/patch/kickstart.nvim/updates.patch @@ -0,0 +1,107 @@ +diff --git a/init.lua b/init.lua +index 5257113..4e95937 100644 +--- a/init.lua ++++ b/init.lua +@@ -219,7 +219,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 +- -- { import = 'custom.plugins' }, ++ { import = 'custom.plugins' }, + }, {}) + + -- [[ Setting options ]] +@@ -229,11 +229,12 @@ require('lazy').setup({ + -- Set highlight on search + vim.o.hlsearch = false + +--- Make line numbers default ++-- Make relative line numbers default + vim.wo.number = true ++vim.wo.relativenumber = true + +--- Enable mouse mode +-vim.o.mouse = 'a' ++-- Disable mouse mode ++vim.o.mouse = '' + + -- Sync clipboard between OS and Neovim. + -- Remove this option if you want your OS clipboard to remain independent. +@@ -263,6 +264,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 ++ + -- [[ Basic Keymaps ]] + + -- Keymaps for better default experience +@@ -323,11 +332,27 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = + -- See `:help nvim-treesitter` + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter +- ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, +- ++ ensure_installed = { ++ 'css', ++ 'dockerfile', ++ 'eex', ++ 'elixir', ++ 'erlang', ++ 'go', ++ 'heex', ++ 'html', ++ 'javascript', ++ 'lua', ++ 'markdown', ++ 'python', ++ 'sql', ++ 'tsx', ++ 'typescript', ++ 'vim', ++ 'vimdoc' ++ }, + -- 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 = { +@@ -456,19 +481,24 @@ require('which-key').register({ + -- 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 = { +- -- clangd = {}, +- -- gopls = {}, +- -- pyright = {}, +- -- rust_analyzer = {}, +- -- tsserver = {}, +- -- html = { filetypes = { 'html', 'twig', 'hbs'} }, +- ++ elixirls = { ++ elixirLS = { ++ dialyzerEnabled = true, ++ dialyzerFormat = "dialyxir_long", ++ fetchDeps = false, ++ mixEnv = "test" ++ } ++ }, ++ gopls = {}, ++ html = { filetypes = { 'html', 'twig', 'hbs'} }, + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, ++ pyright = {}, ++ tsserver = {}, + } + + -- Setup neovim lua configuration