From 3dbe74f2eef627e2dc19b79fe06753d5dc09003f Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 15 May 2024 09:00:31 +0200 Subject: update nvim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- .vim/lua/plugins.lua | 495 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 331 insertions(+), 164 deletions(-) (limited to '.vim/lua/plugins.lua') diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 7028cda..d53eaf6 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -19,7 +19,7 @@ vim.g.loaded_netrwSettings = 1 vim.g.loaded_netrwFileHandlers = 1 local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then +if not vim.uv.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', @@ -85,6 +85,10 @@ local pluginspec = { require('telescope.builtin').quickfix() end) end, { buffer = bufnr, desc = 'list hunks' }) + vim.keymap.set('n', 'gs', vim.cmd.Gitsigns, { + buffer = bufnr, + desc = 'gitsigns', + }) end, }, }, @@ -92,23 +96,26 @@ local pluginspec = { { 'lukas-reineke/indent-blankline.nvim', lazy = false, + main = 'ibl', opts = { - char = '▏', - char_highlight_list = { 'Whitespace' }, - -- show_trailing_blankline_indent = false, - -- show_end_of_line = true, - use_treesitter = true, - filetype_exclude = { 'alpha' }, - -- strict_tabs = true, - show_current_context = false, - -- context_patterns = { 'class', 'function', 'method', 'block' }, - -- context_highlight_list = {'Folded'}, - context_highlight_list = { 'deEmph' }, + indent = { + char = '▏', + highlight = { 'NonText' }, + }, + exclude = { + filetypes = { 'alpha' }, + }, + scope = { + enabled = true, + show_start = false, + show_end = false, + highlight = { 'Comment' }, + }, }, keys = { { 'ti', - [[:IndentBlanklineToggle!]], + vim.cmd.IBLToggle, desc = 'toggle indent-blankline', }, }, @@ -126,18 +133,6 @@ local pluginspec = { }, }, - { - 'editorconfig/editorconfig-vim', - event = 'VeryLazy', - config = function() - vim.api.nvim_create_autocmd('FileType', { - pattern = { 'gitcommit' }, - command = [[let b:EditorConfig_disable = 1]], - group = vim.api.nvim_create_augroup('EditorConfigDisable', {}), - }) - end, - }, - { 'windwp/nvim-autopairs', priority = 40, @@ -147,29 +142,87 @@ local pluginspec = { { 'elihunter173/dirbuf.nvim', + enabled = true, + dev = true, lazy = false, - config = function() - require('dirbuf').setup({ - hash_padding = 4, - sort_order = 'directories_first', - }) - vim.api.nvim_create_autocmd('FileType', { - pattern = 'dirbuf', - callback = function() - vim.keymap.set('n', 'gT', function() - vim.loop.spawn('swaymsg', { args = { 'exec', '--', 'foot', '-D', vim.fn.expand('%') } }) - -- vim.fn.system('swaymsg exec -- foot -D ' .. vim.fn.expand('%')) - end, { buffer = 0, desc = 'open in foot terminal' }) + keys = { + { + '', + function() + local cpath = require('dirbuf').get_cursor_path() + for _, w in ipairs(vim.api.nvim_list_wins()) do + if vim.api.nvim_get_option_value('previewwindow', { win = w }) then + if vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) == cpath then + vim.cmd.pclose() + return + end + end + end + require('dirbuf').enter('pedit') end, - group = vim.api.nvim_create_augroup('DirBufEnter', {}), - }) - end, + desc = 'Dirbuf: preview file', + }, + }, + }, + { + 'nvim-tree/nvim-tree.lua', + version = '*', + main = 'nvim-tree', + enabled = false, + lazy = false, + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + renderer = { + icons = { + show = { + file = false, + folder = false, + folder_arrow = true, + git = false, + }, + glyphs = { + default = '󰈤 ', + symlink = '󰌹 ', + bookmark = 'b', + folder = { + arrow_open = '▾', + arrow_closed = '▸', + default = '󰉖 ', + open = '󰷏 ', + empty = '󱞞 ', + symlink = '󰌹 ', + }, + }, + }, + }, + -- on_attach = function(bufnr) + -- end, + }, + keys = { + { + '-', + function() + require('nvim-tree.api').tree.open({ + current_window = true, + path = vim.fn.expand('%:p:h'), + }) + end, + desc = 'NvimTree: open containing directory', + }, + { + 'gt', + function() + require('nvim-tree.api').tree.toggle() + end, + desc = 'NvimTree: toggle', + }, + }, }, { 'nvim-treesitter/nvim-treesitter', lazy = false, - build = ':TSUpdate', + build = ':TSUpdateSync', config = function(_, opts) local tsconf = require('nvim-treesitter.parsers').get_parser_configs() tsconf.gotmpl = { @@ -193,12 +246,10 @@ local pluginspec = { 'comment', 'css', 'dockerfile', - -- 'elixir', 'go', 'gomod', 'gowork', 'hcl', - 'help', 'html', 'java', 'javascript', @@ -212,19 +263,21 @@ local pluginspec = { 'markdown_inline', 'ninja', 'norg', + 'query', 'regex', 'rust', 'scss', 'toml', 'typescript', 'vim', + 'vimdoc', 'yaml', 'zig', + 'yuck', -- eww -- experimental 'hare', 'gotmpl', }, - -- disable = { 'jsonc' }, highlight = { enable = true, additional_vim_regex_highlighting = { 'markdown' }, @@ -278,7 +331,10 @@ local pluginspec = { 'nvim-treesitter/nvim-treesitter-textobjects', keys = { 'ib', 'ob', 'ic', 'oc', 'if', 'of', 'il', 'ol', 'is', 'os' }, }, - { 'nvim-treesitter/playground', cmd = 'TSPlaygroundToggle' }, + { + 'nvim-treesitter/playground', + cmd = { 'TSPlaygroundToggle', 'TSHighlightCapturesUnderCursor' }, + }, { 'neovim/nvim-lspconfig', @@ -323,7 +379,10 @@ local pluginspec = { local cmp = require('cmp') local luasnip = require('luasnip') cmp.setup({ - experimental = { ghost_text = true }, + experimental = { + ghost_text = { hl_group = 'NonText' }, + native_menu = false, + }, -- disable completion in comments enabled = function() local ok, enable = pcall(function() @@ -340,45 +399,41 @@ local pluginspec = { end) return not ok or enable end, + -- performance = { + -- max_view_entries = 20, + -- }, preselect = cmp.PreselectMode.Item, window = { completion = { + scrollbar = true, border = 'none', }, documentation = { border = 'solid', }, }, + completion = { + autocomplete = false, + }, + sorting = { + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.recently_used, + require("clangd_extensions.cmp_scores"), + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, mapping = { - [''] = cmp.complete, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.confirm({ select = true }) - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }) - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }) - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.confirm({ select = true }) - else - fallback() - end - end, { 'i', 'c', 's' }), + [''] = cmp.mapping.complete({ reason = cmp.ContextReason.Auto }), + [''] = cmp.mapping.complete({ reason = cmp.ContextReason.Auto }), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }), + [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping(function(fallback) if cmp.visible() then -- NOTE: poor mans replacement for cmp.confirm without expanding snippet @@ -417,12 +472,8 @@ local pluginspec = { fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function() - cmp.scroll_docs(-4) - end, { 'i', 's' }), - [''] = cmp.mapping(function() - cmp.scroll_docs(4) - end, { 'i', 's' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), }, snippet = { expand = function(args) @@ -455,6 +506,8 @@ local pluginspec = { } item.kind = require('internal.lsp_symbols')[item.kind] or '' item.menu = menus[entry.source.name] + local maxw = vim.api.nvim_win_get_width(0) - 25 + item.abbr = string.sub(item.abbr, 1, (#item.abbr > maxw) and maxw or #item.abbr) return item end, expandable_indicator = true, @@ -478,18 +531,10 @@ local pluginspec = { end, }), [''] = cmp.mapping({ - c = function() - if cmp.visible() then - cmp.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) - end - end, + c = cmp.mapping.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }), }), [''] = cmp.mapping({ - c = function() - if cmp.visible() then - cmp.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) - end - end, + c = cmp.mapping.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }), }), }, sources = cmp.config.sources({ @@ -567,9 +612,22 @@ local pluginspec = { }, n = { [''] = require('telescope.actions.layout').toggle_preview, + [';'] = function() + vim.cmd.Telescope('resume') + end, }, }, }, + pickers = { + buffers = { + sort_mru = true, + mappings = { + i = { + [""] = require('telescope.actions').delete_buffer, + } + } + } + }, extensions = { ['fzf'] = { fuzzy = true, @@ -649,7 +707,7 @@ local pluginspec = { desc = 'command history', }, { - ';l', + ';bf', function() require('telescope.builtin').current_buffer_fuzzy_find() end, @@ -669,13 +727,23 @@ local pluginspec = { end, desc = 'diagnostics', }, + { + ';j', + function() + require('telescope.builtin').jumplist() + end, + desc = 'jumplist', + }, { ';v', function() require('telescope.builtin').find_files({ prompt_title = 'vimrc', previewer = false, - cwd = vim.fn.stdpath('config'), + search_dirs = { + vim.fn.stdpath('config'), + vim.fn.stdpath('data') .. '/lazy', + } }) end, desc = 'vim config', @@ -683,7 +751,7 @@ local pluginspec = { { 'gw', function() - require('internal.misc').word_under_cursor(function(s) + require('internal.cursor').word(function(s) require('telescope.builtin').grep_string({ search = s }) end) end, @@ -705,20 +773,28 @@ local pluginspec = { mode = 'background', }) end, + build = [[git cherry-pick patch]], }, - { 'gentoo/gentoo-syntax', lazy = false }, + { 'gentoo/gentoo-syntax', lazy = false }, { 'NMAC427/guess-indent.nvim', lazy = false, opts = { auto_cmd = true, - filetype_exclude = { 'netrw', 'tutor', 'dirbuf' }, + filetype_exclude = { 'netrw', 'tutor', 'dirbuf', 'nvimtree' }, buftype_exclude = { 'help', 'nofile', 'terminal', 'prompt' }, }, }, + { + 'echasnovski/mini.align', + version = false, + opts = {}, + keys = { 'ga', 'gA' } + }, + { url = 'https://git.sr.ht/~robertgzr/spinner.nvim', opts = { @@ -730,6 +806,7 @@ local pluginspec = { { 'stevearc/aerial.nvim', cmd = { 'AerialOpen', 'AerialToggle' }, + keys = { { '', vim.cmd.AerialToggle, desc = 'Toggle aerial' } }, opts = { backends = { 'lsp', 'treesitter', 'markdown' }, filter_kind = { @@ -785,12 +862,13 @@ local pluginspec = { event = 'VeryLazy', config = function() vim.lsp.handlers['textDocument/codeAction'] = - require('code_action_menu').open_code_action_menu + require('code_action_menu').open_code_action_menu end, }, { 'jose-elias-alvarez/null-ls.nvim', + enabled = false, ft = { 'sh', 'bash', @@ -834,7 +912,7 @@ local pluginspec = { nls.builtins.formatting.stylua, -- nls.builtins.formatting.gofumpt, -- nls.builtins.formatting.json_tool, - nls.builtins.formatting.mdformat, + -- nls.builtins.formatting.mdformat, -- custom sources beautifier.with({ filetypes = { 'html', 'gotmpl.html' }, command = 'html-beautify' }), @@ -847,16 +925,21 @@ local pluginspec = { { 'mfussenegger/nvim-dap', - dependencies = { 'nvim-telescope/telescope-dap.nvim' }, + dependencies = { + 'nvim-telescope/telescope-dap.nvim', + 'rcarriga/nvim-dap-ui', + }, config = function() require('telescope').load_extension('dap') require('internal.dap') end, - keys = { 'd' }, + keys = { + 'd', + }, }, - { 'farmergreg/vim-lastplace', event = 'VeryLazy' }, -- restore last cursor position (and handle many edge cases) - { 'tpope/vim-surround', event = 'VeryLazy' }, - { 'tpope/vim-repeat', event = 'VeryLazy' }, -- extend '.' to plugins + { 'farmergreg/vim-lastplace', event = 'VeryLazy' }, -- restore last cursor position (and handle many edge cases) + { 'tpope/vim-surround', event = 'VeryLazy' }, + { 'tpope/vim-repeat', event = 'VeryLazy' }, -- extend '.' to plugins { 'michaeljsmith/vim-indent-object', event = 'VeryLazy' }, -- indentation text-objects -- {'kshenoy/vim-signature'}, -- toggle, display and navigate marks -- {'rhysd/conflict-marker.vim'}, @@ -949,7 +1032,7 @@ local pluginspec = { }, { - 'mickael-menu/zk-nvim', + 'zk-org/zk-nvim', cmd = { 'ZkNew', 'ZkNotes' }, ft = { 'markdown', 'neorg' }, config = function() @@ -965,18 +1048,38 @@ local pluginspec = { }, auto_attach = { enabled = true, - filetypes = { 'markdown', 'neorg' }, + filetypes = { 'markdown' }, }, }, }) end, keys = { { - ';z', + ';zn', + vim.cmd.ZkNotes, + desc = 'zk notes', + }, + { + ';zb', + vim.cmd.ZkBacklinks, + desc = 'zk backlinks', + }, + { + ';zt', + vim.cmd.ZkTags, + desc = 'zk tags', + }, + { + ';zl', + vim.cmd.ZkLinks, + desc = 'zk links', + }, + { + ';zN', function() - require('zk').edit(nil, { multi_select = false }) + end, - desc = 'zk', + desc = 'zk new note', }, }, }, @@ -987,6 +1090,7 @@ local pluginspec = { { 'lervag/vimtex', + enabled = false, ft = { 'latex', 'tex' }, config = function() local g = vim.g @@ -995,32 +1099,25 @@ local pluginspec = { g.vimtex_compiler_method = 'tectonic' g.vimtex_compiler_tectonic = "{'executable': 'tectonic'}" g.vimtex_view_method = 'zathura' - -- g.vimtex_view_zathura_check_libsynctex = false - -- g.vimtex_view_use_temp_files = true - -- g.vimtex_view_forward_search_on_start = false end, }, { - 'plasticboy/vim-markdown', + 'preservim/vim-markdown', ft = 'markdown', + enabled = true, config = function() - local g = vim.g - g.vim_markdown_folding_disabled = true - g.vim_markdown_math = true - g.vim_markdown_frontmatter = true - g.vim_markdown_json_frontmatter = true - g.vim_markdown_toml_frontmatter = true - g.vim_markdown_yaml_frontmatter = true - -- g.vim_markdown_folding_level = 2 - g.vim_markdown_strikethrough = true - g.vim_markdown_auto_insert_bullets = true - g.vim_markdown_new_list_item_indent = false - g.vim_markdown_conceal = true - g.vim_markdown_conceal_code_blocks = true + vim.g.vim_markdown_frontmatter = 0 -- handled by tre-sitter + vim.g.vim_markdown_strikethrough = 1 + vim.g.vim_markdown_conceal_code_blocks = 0 -- doesn't work due to tree-sitter: https://github.com/nvim-treesitter/nvim-treesitter/issues/2825 + vim.g.vim_markdown_no_default_key_mappings = 1 end, }, + { + 'https://git.sr.ht/~p00f/clangd_extensions.nvim', + }, + { 'folke/zen-mode.nvim', dependencies = { @@ -1038,8 +1135,8 @@ local pluginspec = { cmd = { 'ZenMode' }, opts = { window = { - backdrop = 1, - width = 0.3, + -- backdrop = 1, + -- width = 0.3, -- height = 1, options = { number = false, @@ -1053,6 +1150,7 @@ local pluginspec = { showcmd = false, }, twilight = { enabled = true }, + gitsigns = { enabled = false }, }, }, }, @@ -1068,6 +1166,7 @@ local pluginspec = { { 'goolord/alpha-nvim', + enabled = false, cmd = 'Alpha', config = function() local MAX_WIDTH = 80 @@ -1104,18 +1203,18 @@ local pluginspec = { -- exit here if we're not showing a label if label_len == 0 then return string.rep(' ', margin) - .. string.rep('─', max_width) - .. string.rep(' ', margin) + .. string.rep('─', max_width) + .. string.rep(' ', margin) end if label_len > max_width then return error('overfull box: ' .. label) end max_width = max_width - label_len return string.rep(' ', margin) - .. string.rep('─', max_width / 2) - .. label - .. string.rep('─', max_width / 2) - .. string.rep(' ', margin) + .. string.rep('─', max_width / 2) + .. label + .. string.rep('─', max_width / 2) + .. string.rep(' ', margin) end, } end @@ -1156,7 +1255,7 @@ local pluginspec = { -- initialize the oldfiles table local oldfiles = {} - local cwd = vim.loop.cwd() + local cwd = vim.uv.cwd() for _, v in pairs(vim.v.oldfiles) do if #oldfiles == 10 then break @@ -1219,7 +1318,7 @@ local pluginspec = { for _, bufnr in ipairs(bufnrs) do local bufpath = - require('plenary.path').new(vim.fn.getbufinfo(bufnr)[1].name):shorten(1, { -2, -1 }) + require('plenary.path').new(vim.fn.getbufinfo(bufnr)[1].name):shorten(1, { -2, -1 }) table.insert(items, button('b' .. bufnr, bufpath, ':b' .. bufnr .. '')) end return items @@ -1274,35 +1373,24 @@ local pluginspec = { }, { - 'ruifm/gitlinker.nvim', + 'linrongbin16/gitlinker.nvim', + cmd = { 'GitLink' }, dependencies = { 'nvim-lua/plenary.nvim' }, - config = { - opts = { - -- action_callback = require('gitlinker.actions').copy_to_clipboard, - }, + opts = { + message = true, }, keys = { { - 'gy', - function() - require('gitlinker').get_buf_range_url() - end, - desc = 'gitlinker', - }, - { - mode = 'v', - 'gy', - function() - require('gitlinker').get_buf_range_url() - end, - desc = 'gitlinker', + 'gl', + vim.cmd.GitLink, + desc = 'gitlinker -> clipboard', }, }, }, { 'rhysd/git-messenger.vim', - cmd = 'GitMessenger', + cmd = { 'GitMessenger' }, config = function() -- vim.g.git_messenger_include_diff = false vim.g.git_messenger_always_into_popup = true @@ -1310,33 +1398,54 @@ local pluginspec = { vim.g.git_messenger_no_default_mappings = true end, keys = { - { 'gm', vim.cmd.GitMessenger, desc = 'git-messenger' }, + { 'gb', vim.cmd.GitMessenger, desc = 'blame (git-messenger)' }, }, }, { 'folke/todo-comments.nvim', + lazy = false, cmd = { 'TodoTelescope' }, - config = true, + config = { + keywords = { + FIX = { icon = '󰃤' }, + TODO = { icon = '󰸞' }, + HACK = { icon = '󰈸' }, + WARN = { icon = '󱇎' }, + PERF = { icon = '󰅒' }, + NOTE = { icon = '󰐃' }, + TEST = { icon = '󰂓' }, + }, + search = { + pattern = [[\b(KEYWORDS)(|\(.+\)):]], + }, + highlight = { + keyword = "bg", + pattern = [[(KEYWORDS)]], + } + }, keys = { - { ';t', vim.cmd.TodoTelescope, desc = 'todo-comments' }, + { ';t', vim.cmd.TodoTelescope, desc = 'todo-comments' }, + { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, + { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, }, }, { 'cbochs/grapple.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, - cmd = 'GrapplePopup', + cmd = { 'GrapplePopup' }, opts = { + icons = false, popup_options = { border = 'none', }, }, keys = { { - 'm', + 'ml', function() - require('grapple').popup_tags() + require('grapple').toggle_tags() end, desc = 'grapple: show tags', }, @@ -1371,12 +1480,35 @@ local pluginspec = { }, }, + { + 'tjdevries/sg.nvim', + enabled = false, + lazy = false, + build = 'cargo build --workspace', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require('sg').setup({ + on_attach = require('internal.lsp').my_attach, + }) + end, + keys = { + { + 's', + function() + require('sg.telescope').fuzzy_search_results() + end, + desc = 'sg.nvim: fuzzy search results', + }, + }, + }, + { url = 'https://git.sr.ht/~robertgzr/karafuru', + dev = true, lazy = false, - -- build = 'make colorscheme', + enabled = false, priority = 1000, - cond = vim.g.night_and_day == 'night', + cond = (vim.opt.background:get() == 'dark'), config = function(plugin) vim.opt.rtp:append(plugin.dir .. '/vim') vim.cmd.colorscheme('karafuru') @@ -1386,8 +1518,9 @@ local pluginspec = { { 'yorik1984/newpaper.nvim', lazy = false, + enabled = false, priority = 1000, - cond = vim.g.night_and_day == 'day', + cond = (vim.opt.background:get() == 'light'), config = function() vim.cmd.colorscheme('newpaper') end, @@ -1398,14 +1531,48 @@ local pluginspec = { lazy = false, enabled = false, priority = 1000, - cond = vim.g.night_and_day == 'night', + cond = (vim.opt.background:get() == 'dark'), config = function() vim.opt.background = 'dark' vim.cmd.colorscheme('oxocarbon') end, }, + + { + 'mcchrish/zenbones.nvim', + dependencies = { 'rktjmp/lush.nvim' }, + lazy = false, + enabled = false, + priority = 1000, + config = function() + vim.opt.termguicolors = true + local scheme = 'tokyobones' + vim.g[scheme] = { + lighten_non_text = 20, + transparent_background = (vim.opt.background:get() == 'dark'), + } + vim.cmd.colorscheme(scheme) + end, + }, + + -- quarantine + { + 'zbirenbaum/copilot.lua', + enabled = false, + cmd = { 'Copilot' }, + opts = { + panel = { auto_refresh = true }, + suggestion = { auto_trigger = true }, + }, + }, + { + 'Kicamon/markdown-table-mode.nvim', + enabled = true, + ft = { 'markdown' }, + }, } require('lazy').setup(pluginspec, { defaults = { lazy = true }, + dev = { path = '~/src' }, }) -- cgit 1.4.1