diff --git a/Dockerfile b/Dockerfile index 5d9b52b..b997eea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -161,7 +161,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 7af594fd319fbae6b2aaa06337f3df8acbbb7f18 \ + && git reset --hard e6710a461ab08513af80c213929ff64e75b5e456 \ && 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 ef22920..1279603 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -7,47 +7,50 @@ return { 'mgoral/vim-bw', url = 'https://git.goral.net.pl/mgoral/vim-bw.git', priority = 1000, - config = function () + config = function() vim.cmd.colorscheme 'bw-onedark' - end + end, }, + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', { 'joaodubas/gitlinker.nvim', - config = function () - local actions = require('gitlinker.actions') - local hosts = require('gitlinker.hosts') - require('gitlinker').setup({ + config = function() + local actions = require 'gitlinker.actions' + local hosts = require 'gitlinker.hosts' + require('gitlinker').setup { opts = { - remote = "origin", + 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, + ['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 + mappings = 'gy', + } + end, }, 'nvim-treesitter/nvim-treesitter-context', { 'kevinhwang91/nvim-ufo', dependencies = { 'kevinhwang91/promise-async' }, event = 'BufRead', - keys = function () - local ufo = require('ufo') + 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" } }, + { '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) + opts = function() + local handler = function(virtText, lnum, endLnum, width, truncate) local newVirtText = {} local suffix = (' 󰁂 %d '):format(endLnum - lnum) local sufWidth = vim.fn.strdisplaywidth(suffix) @@ -61,11 +64,11 @@ return { else chunkText = truncate(chunkText, targetWidth - curWidth) local hlGroup = chunk[2] - table.insert(newVirtText, {chunkText, hlGroup}) + 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) + suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth) end break end @@ -77,17 +80,17 @@ return { return { fold_virt_text_handler = handler, - provider_selector = function (_, _, _) + provider_selector = function(_, _, _) return { 'treesitter', 'indent' } - end + end, } end, }, { 'stevearc/oil.nvim', - dependencies = { "nvim-tree/nvim-web-devicons" }, + dependencies = { 'nvim-tree/nvim-web-devicons' }, keys = { - { '-', 'Oil', desc = "Open parent directory" }, + { '-', 'Oil', desc = 'Open parent directory' }, }, opts = {}, }, @@ -96,7 +99,7 @@ return { dependencies = { 'nvim-lua/plenary.nvim' }, ft = { 'http', - 'rest' + 'rest', }, opts = { result_split_horizontal = false, @@ -105,7 +108,7 @@ return { encode_url = true, highlight = { enabled = true, - timeout = 15 + timeout = 15, }, result = { show_url = true, @@ -114,27 +117,27 @@ return { show_headers = true, formatters = { json = 'jq', - html = false + html = false, }, jump_to_request = true, env_file = '.env', - custom_dynamic_variables = { }, - yank_dry_run = true - } + custom_dynamic_variables = {}, + yank_dry_run = true, + }, }, - keys = function () + keys = function() local status_ok, which_key = pcall(require, 'which-key') if status_ok then - which_key.register({ - ['t'] = { name = 'Res[t]', _ = 'which_key_ignore' } - }) + which_key.register { + ['t'] = { name = 'Res[t]', _ = 'which_key_ignore' }, + } end 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' } + { 'tl', 'RestNvimLast', desc = 'Re-run the last request' }, } - end + end, }, { 'akinsho/toggleterm.nvim', @@ -142,22 +145,22 @@ return { size = vim.o.lines * 0.75, open_mapping = [[]], hide_numbers = true, - shade_filetypes = { }, + shade_filetypes = {}, shade_terminals = true, shading_factor = 2, direction = 'horizontal', shell = vim.o.shell, }, - keys = function () + keys = function() local status_ok, which_key = pcall(require, 'which-key') if status_ok then - which_key.register({ - ['m'] = { name = 'Toggle ter[m]inal', _ = 'which_key_ignore' } - }) + which_key.register { + ['m'] = { name = 'Toggle ter[m]inal', _ = 'which_key_ignore' }, + } end vim.api.nvim_create_autocmd('TermOpen', { group = vim.api.nvim_create_augroup('kickstart-custom-term-open-mapping', { clear = true }), - callback = function (args) + callback = function(args) local bufnr = args.buf local opts = { buffer = bufnr } vim.keymap.set('t', '', [[]], opts) @@ -167,13 +170,23 @@ return { vim.keymap.set('t', '', [[wincmd k]], opts) vim.keymap.set('t', '', [[wincmd l]], opts) vim.keymap.set('t', '', [[]], opts) - end + end, }) return { - { 'mh', 'ToggleTerm direction=horizontal size=' .. tostring(vim.o.lines * 0.75) .. '', desc = 'Open ter[m]inal [h]orizontally', noremap = true }, - { 'mv', 'ToggleTerm direction=vertical size=' .. tostring(vim.o.columns * 0.5) .. '', desc = 'Open ter[m]inal [v]ertically', noremap = true }, - { 'mc', 'ToggleTermSendCurrentLine', desc = 'Send [c]urrent line under the cursor', noremap = true } + { + 'mh', + 'ToggleTerm direction=horizontal size=' .. tostring(vim.o.lines * 0.75) .. '', + desc = 'Open ter[m]inal [h]orizontally', + noremap = true, + }, + { + 'mv', + 'ToggleTerm direction=vertical size=' .. tostring(vim.o.columns * 0.5) .. '', + desc = 'Open ter[m]inal [v]ertically', + noremap = true, + }, + { 'mc', 'ToggleTermSendCurrentLine', desc = 'Send [c]urrent line under the cursor', noremap = true }, } - end + end, }, } diff --git a/patch/kickstart.nvim/updates.patch b/patch/kickstart.nvim/updates.patch index fafed8c..312c2aa 100644 --- a/patch/kickstart.nvim/updates.patch +++ b/patch/kickstart.nvim/updates.patch @@ -1,175 +1,202 @@ diff --git a/init.lua b/init.lua -index fd4567d..236fb97 100644 +index 292ec07..19075db 100644 --- a/init.lua +++ b/init.lua -@@ -200,19 +200,19 @@ require('lazy').setup({ - }, - }, +@@ -101,8 +101,12 @@ vim.opt.number = true + -- Experiment for yourself to see if you like it! + -- vim.opt.relativenumber = true -- { -- -- 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 -@@ -282,7 +282,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 ]] -@@ -292,11 +292,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.number = true +vim.wo.relativenumber = true ++ + -- Enable mouse mode, can be useful for resizing splits for example! +-vim.opt.mouse = 'a' ++vim.opt.mouse = '' ---- 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. -@@ -326,6 +327,14 @@ vim.o.completeopt = 'menuone,noselect' - -- NOTE: You should make sure your terminal supports this - vim.o.termguicolors = true + -- Don't show the mode, since it's already in status line + vim.opt.showmode = false +@@ -148,6 +152,14 @@ vim.opt.cursorline = true + -- Minimal number of screen lines to keep above and below the cursor. + vim.opt.scrolloff = 10 +-- Set foldmethod +-- See `:help foldmethod` -+vim.o.foldcolumn = '1' -+vim.o.foldlevel = 99 -+vim.o.foldlevelstart = 99 -+vim.o.foldenable = true -+vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] ++vim.opt.foldcolumn = '1' ++vim.opt.foldlevel = 99 ++vim.opt.foldlevelstart = 99 ++vim.opt.foldenable = true ++vim.opt.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + -- [[ Basic Keymaps ]] + -- See `:help vim.keymap.set()` - -- Keymaps for better default experience -@@ -439,8 +448,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 -- ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, -- -+ ensure_installed = { -+ 'css', -+ 'dockerfile', -+ 'eex', -+ 'elixir', -+ 'erlang', -+ 'gitcommit', -+ 'go', -+ 'heex', -+ 'html', -+ 'http', -+ 'javascript', -+ 'json', -+ 'lua', -+ 'markdown', -+ 'markdown_inline', -+ 'python', -+ 'sql', -+ 'toml', -+ 'tsx', -+ 'typescript', -+ 'vim', -+ 'vimdoc', -+ 'yaml' -+ }, - -- 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`) -@@ -586,13 +618,18 @@ 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 = { -- -- clangd = {}, -- -- gopls = {}, -- -- pyright = {}, -- -- rust_analyzer = {}, -- -- tsserver = {}, -- -- html = { filetypes = { 'html', 'twig', 'hbs'} }, -- -+ elixirls = { -+ elixirLS = { -+ dialyzerEnabled = true, -+ dialyzerFormat = "dialyxir_long", -+ fetchDeps = false, -+ mixEnv = "test" -+ } -+ }, -+ gopls = {}, -+ helm_ls = {}, -+ html = { filetypes = { 'html', 'twig', 'hbs'} }, -+ htmx = {}, - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, -@@ -601,6 +638,10 @@ local servers = { - -- diagnostics = { disable = { 'missing-fields' } }, +@@ -250,6 +262,66 @@ require('lazy').setup { + changedelete = { text = '~' }, + }, }, - }, -+ pyright = {}, -+ templ = {}, -+ terraformls = {}, -+ tsserver = {}, - } - - -- Setup neovim lua configuration -@@ -619,12 +660,25 @@ 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('mise current elixir') or '' -+ local elixir_servers = { -+ { version = '^1.11', path = '/elixir-ls/release/v0.12.0/language_server.sh' }, -+ { version = '^1.12', path = '/elixir-ls/release/v0.14.6/language_server.sh' }, -+ } -+ for _, server in ipairs(elixir_servers) do -+ if string.match(version, server.version) == nil then goto continue end -+ opts = vim.tbl_extend('keep', opts, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. server.path } }) -+ ::continue:: ++ on_attach = function(bufnr) ++ local gs = package.loaded.gitsigns ++ ++ local function map(mode, l, r, opts) ++ opts = opts or {} ++ opts.buffer = bufnr ++ vim.keymap.set(mode, l, r, opts) + end -+ end -+ require('lspconfig')[server_name].setup(opts) - end, ++ ++ -- Navigation ++ map({ 'n', 'v' }, ']c', function() ++ if vim.wo.diff then ++ return ']c' ++ end ++ vim.schedule(function() ++ gs.next_hunk() ++ end) ++ return '' ++ end, { expr = true, desc = 'Jump to next hunk' }) ++ ++ map({ 'n', 'v' }, '[c', function() ++ if vim.wo.diff then ++ return '[c' ++ end ++ vim.schedule(function() ++ gs.prev_hunk() ++ end) ++ return '' ++ end, { expr = true, desc = 'Jump to previous hunk' }) ++ ++ -- Actions ++ -- visual mode ++ map('v', 'hs', function() ++ gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } ++ end, { desc = 'stage git hunk' }) ++ map('v', 'hr', function() ++ gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } ++ end, { desc = 'reset git hunk' }) ++ -- normal mode ++ map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) ++ map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) ++ map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) ++ map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) ++ map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) ++ map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) ++ map('n', 'hb', function() ++ gs.blame_line { full = false } ++ end, { desc = 'git blame line' }) ++ map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) ++ map('n', 'hD', function() ++ gs.diffthis '~' ++ end, { desc = 'git diff against last commit' }) ++ ++ -- Toggles ++ map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) ++ map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) ++ ++ -- Text object ++ map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) ++ end, + }, + + -- NOTE: Plugins can also be configured to run lua code when they are loaded. +@@ -544,6 +616,18 @@ require('lazy').setup { + -- tsserver = {}, + -- + ++ elixirls = { ++ elixirLS = { ++ dialyzerEnabled = true, ++ dialyzerFormat = 'dialyxir_long', ++ fetchDeps = false, ++ mixEnv = 'test', ++ }, ++ }, ++ gopls = {}, ++ helm_ls = {}, ++ html = { filetypes = { 'html', 'twig', 'hbs' } }, ++ htmx = {}, + lua_ls = { + -- cmd = {...}, + -- filetypes { ...}, +@@ -570,6 +654,10 @@ require('lazy').setup { + }, + }, + }, ++ pyright = {}, ++ templ = {}, ++ terraformls = {}, ++ tsserver = {}, + } + + -- Ensure the servers and tools above are installed +@@ -596,6 +684,21 @@ require('lazy').setup { + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) ++ -- overwrite elixirls for older versions of elixir ++ -- * elixir 1.11 use version 0.12.0 ++ -- * elixir 1.12 use verions 0.14.6 ++ if server_name == 'elixirls' then ++ local version = vim.fn.system('mise current elixir') or '' ++ local elixir_servers = { ++ { version = '^1.11', path = '/elixir-ls/release/v0.12.0/language_server.sh' }, ++ { version = '^1.12', path = '/elixir-ls/release/v0.14.6/language_server.sh' }, ++ } ++ for _, ex_server in ipairs(elixir_servers) do ++ if string.match(version, ex_server.version) == nil then goto continue end ++ server = vim.tbl_extend('keep', server, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. ex_server.path } }) ++ ::continue:: ++ end ++ end + require('lspconfig')[server_name].setup(server) + end, + }, +@@ -781,7 +884,31 @@ require('lazy').setup { + + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup { +- ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, ++ ensure_installed = { ++ 'css', ++ 'dockerfile', ++ 'eex', ++ 'elixir', ++ 'erlang', ++ 'gitcommit', ++ 'go', ++ 'heex', ++ 'html', ++ 'http', ++ 'javascript', ++ 'json', ++ 'lua', ++ 'markdown', ++ 'markdown_inline', ++ 'python', ++ 'sql', ++ 'toml', ++ 'tsx', ++ 'typescript', ++ 'vim', ++ 'vimdoc', ++ 'yaml', ++ }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { enable = true }, +@@ -807,14 +934,14 @@ require('lazy').setup { + -- Uncomment any of the lines below to enable them (you will need to restart nvim). + -- + -- require 'kickstart.plugins.debug', +- -- require 'kickstart.plugins.indent_line', ++ require 'kickstart.plugins.indent_line', + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- This is the easiest way to modularize your config. + -- + -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` +- -- { import = 'custom.plugins' }, ++ { import = 'custom.plugins' }, } + -- The line beneath this is called `modeline`. See `:help modeline`