diff options
Diffstat (limited to '.vim/lua/plugins.lua')
| -rw-r--r-- | .vim/lua/plugins.lua | 2069 |
1 files changed, 1075 insertions, 994 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index cc008bc..d250a4a 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -1,485 +1,314 @@ --- vim: fdm=marker fdl=0 ----@diagnostic disable: undefined-global --- load by calling `lua require('plugins')` from init.vim - -local g = vim.g - --- force packer into a system directory {{{ -if not vim.fn.filewritable(vim.fn.stdpath('cache')) == 2 then --- TODO: what does this check for? - return -end - -local ensure_packer = function() - local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' - if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.notify('Installing packer.nvim...') - vim.fn.system({ 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }) - vim.cmd.packadd [[packer.nvim]] - return true - end - return false -end -local packer_bootstrapped = ensure_packer() --- }}} - -local function disable_distribution_plugins() -- {{{ - g.loaded_gzip = 1 - g.loaded_tar = 1 - g.loaded_tarPlugin = 1 - g.loaded_zip = 1 - g.loaded_zipPlugin = 1 - g.loaded_getscript = 1 - g.loaded_getscriptPlugin = 1 - g.loaded_vimball = 1 - g.loaded_vimballPlugin = 1 - g.loaded_matchit = 1 - -- g.loaded_matchparen = 1 - g.loaded_2html_plugin = 1 - g.loaded_logiPat = 1 - g.loaded_rrhelper = 1 - g.loaded_netrw = 1 - g.loaded_netrwPlugin = 1 - g.loaded_netrwSettings = 1 - g.loaded_netrwFileHandlers = 1 -end -- }}} - --- we change the packer.compile_path below, so we need to require it here... -local compilepath = vim.fn.stdpath('config') .. '/lua/packer_compiled.lua' -if not (vim.fn.empty(vim.fn.glob(compilepath)) > 0) then - require('packer_compiled') +-- disable distribution plugins +vim.g.loaded_gzip = 1 +vim.g.loaded_tar = 1 +vim.g.loaded_tarPlugin = 1 +vim.g.loaded_zip = 1 +vim.g.loaded_zipPlugin = 1 +vim.g.loaded_getscript = 1 +vim.g.loaded_getscriptPlugin = 1 +vim.g.loaded_vimball = 1 +vim.g.loaded_vimballPlugin = 1 +vim.g.loaded_matchit = 1 +-- vim.g.loaded_matchparen = 1 +vim.g.loaded_2html_plugin = 1 +vim.g.loaded_logiPat = 1 +vim.g.loaded_rrhelper = 1 +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +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 + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', + lazypath, + }) end - -require('packer').startup({function() - -- auto-compile on save -- {{{ - do - vim.api.nvim_create_user_command('PackerRecompile', - function() - for _, client in pairs(vim.lsp.get_active_clients()) do - if vim.tbl_contains(client.config.filetypes, 'lua') then - client.stop() +vim.opt.rtp:prepend(lazypath) + +local pluginspec = { + { + 'lewis6991/gitsigns.nvim', + lazy = false, + opts = { + signs = { + change = { hl = 'GitSignsChange', text = '▋', numhl = 'GitSignsChangeLn' }, + add = { hl = 'GitSignsAdd', text = '▋', numhl = 'GitSignsAddLn' }, + delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteLn' }, + topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteLn' }, + changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeLn' }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + preview_config = { + border = _G.floating_win_border, + }, + on_attach = function(bufnr) + local gs = require('gitsigns') + vim.keymap.set('n', ']c', function() + if vim.wo.diff then + return ']c' end - end - vim.cmd [[luafile $HOME/.vim/lua/plugins.lua]] - vim.cmd [[PackerCompile]] - vim.notify('packer: lazy-loading refreshed') + vim.schedule(gs.next_hunk) + return '<Ignore>' + end, { buffer = bufnr, expr = true, desc = 'next hunk' }) + vim.keymap.set('n', '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(gs.prev_hunk) + return '<Ignore>' + end, { buffer = bufnr, expr = true, desc = 'previous hunk' }) + vim.keymap.set('n', '<leader>hb', function() + gs.blame_line({ full = true }) + end, { buffer = bufnr, desc = 'show line blame (full)' }) + vim.keymap.set('n', '<leader>hB', function() + gs.blame_line({ full = false }) + end, { buffer = bufnr, desc = 'show line blame (compact)' }) + vim.keymap.set( + 'n', + '<leader>hp', + gs.preview_hunk, + { buffer = bufnr, desc = 'preview hunk' } + ) + vim.keymap.set('n', '<leader>hd', gs.diffthis, { buffer = bufnr, desc = 'diff this' }) + vim.keymap.set('n', '<leader>hl', function() + gs.setqflist(0, { open = false }) + vim.schedule(function() + require('telescope.builtin').quickfix() + end) + end, { buffer = bufnr, desc = 'list hunks' }) end, - {desc = 'recompile packer lazy-loading files'}) - - vim.api.nvim_create_autocmd('BufWritePost', { - pattern = 'plugins.lua', - command = [[PackerRecompile]], - group = vim.api.nvim_create_augroup('PackerAutoCompile', {}), - }) - end -- }}} - - -- run sync() if packer was just bootstrapped, usually means fresh install - if packer_bootstrapped then - -- require('packer').sync() - vim.cmd.PackerRecompile() - end - - -- disable built-in plugins - disable_distribution_plugins() - - -- manage packer itself - use {'wbthomason/packer.nvim'} - - -- improve startup time by optimizing lua `require` - use {'lewis6991/impatient.nvim'} - - -- neat helper for when you don't remember your keymap - use {'folke/which-key.nvim', -- {{{ - config = function() - require('which-key').setup { - icons = { separator = '→ ', group = '🞱 ' }, - triggers = {'<leader>', '<localleader>', ';', 'g', '[', ']'}, - } - end} -- }}} - - use {'lewis6991/gitsigns.nvim', --- {{{ - requires = {'nvim-lua/plenary.nvim'}, - config = function() - require('gitsigns').setup { - signs = { - change = {hl='GitSignsChange', text='▋', numhl='GitSignsChangeLn'}, - add = {hl='GitSignsAdd', text='▋', numhl='GitSignsAddLn'}, - delete = {hl='GitSignsDelete', text='_', numhl='GitSignsDeleteLn'}, - topdelete = {hl='GitSignsDelete', text='‾', numhl='GitSignsDeleteLn'}, - changedelete = {hl='GitSignsChange', text='~', numhl='GitSignsChangeLn'}, - }, - signcolumn = true, - numhl = false, - linehl = false, - word_diff = false, - preview_config = { - border = _G.floating_win_border, - }, - - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - vim.keymap.set('n', ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(gs.next_hunk) - return '<Ignore>' - end, {expr=true, buffer=bufnr, desc='next hunk'}) - - vim.keymap.set('n', '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(gs.prev_hunk) - return '<Ignore>' - end, {expr=true, buffer=bufnr, desc='previous hunk'}) - - vim.keymap.set('n', '<leader>hb', function() gs.blame_line {full=true} end, {buffer=bufnr, desc='show line blame (full)'}) - vim.keymap.set('n', '<leader>hB', function() gs.blame_line {full=false} end, {buffer=bufnr, desc='show line blame (compact)'}) - vim.keymap.set('n', '<leader>hp', gs.preview_hunk, {buffer=bufnr, desc='preview hunk'}) - vim.keymap.set('n', '<leader>hd', gs.diffthis, {buffer=bufnr, desc='diff this'}) - vim.keymap.set('n', '<leader>hl', function() - gs.setqflist(0, {open=false}) - vim.schedule(function() require('telescope.builtin').quickfix() end) - end, {buffer=bufnr, desc='list hunks'}) - end, - } - end} -- }}} + }, + }, - use {'lukas-reineke/indent-blankline.nvim', -- {{{ - config = function() - require('indent_blankline').setup { - char = '▏', - char_highlight_list = {'Whitespace'}, - -- space_char = ' ', - -- space_char_highlight_list = {}, - show_first_indent_level = true, - show_trailing_blankline_indent = false, - show_end_of_line = true, - use_treesitter = true, - disable_with_nolist = true, - buftype_exclude = {'terminal'}, - bufname_exclude = {'README.md'}, - strict_tabs = true, - show_current_context = true, - context_patterns = {'class', 'function', 'method', 'block'}, - -- context_highlight_list = {'Folded'}, - context_highlight_list = {'deEmph'}, - } - end} -- }}} + { + 'lukas-reineke/indent-blankline.nvim', + lazy = false, + opts = { + char = '▏', + char_highlight_list = { 'Whitespace' }, + -- space_char = ' ', + -- space_char_highlight_list = {}, + show_first_indent_level = true, + show_trailing_blankline_indent = false, + show_end_of_line = true, + use_treesitter = true, + disable_with_nolist = true, + buftype_exclude = { 'terminal' }, + bufname_exclude = { 'README.md' }, + filetype_exclude = { 'alpha' }, + strict_tabs = true, + show_current_context = true, + context_patterns = { 'class', 'function', 'method', 'block' }, + -- context_highlight_list = {'Folded'}, + context_highlight_list = { 'deEmph' }, + }, + }, - -- gcc to comment out text - use {'numToStr/Comment.nvim', -- {{{ - config = function() - require('Comment').setup { - opleader = { - block = 'gC', - } - } - end} -- }}} + { + 'numToStr/Comment.nvim', + opts = { + opleader = { block = 'gC' }, + }, + keys = { + 'gcc', + { 'gc', mode = 'v' }, + { 'gC', mode = 'v' }, + }, + }, - use {'editorconfig/editorconfig-vim', -- {{{ + { + 'editorconfig/editorconfig-vim', + event = 'VeryLazy', config = function() - local group = vim.api.nvim_create_augroup('EditorConfigDisable', { clear = true }) vim.api.nvim_create_autocmd('FileType', { - pattern = {'gitcommit'}, + pattern = { 'gitcommit' }, command = [[let b:EditorConfig_disable = 1]], - group = group, + group = vim.api.nvim_create_augroup('EditorConfigDisable', {}), }) - end} -- }}} + end, + }, - use {'windwp/nvim-autopairs', -- {{{ - config = function() - require('nvim-autopairs').setup() - end} -- }}} + { 'windwp/nvim-autopairs', priority = 40, event = 'InsertEnter', config = true }, - use {'elihunter173/dirbuf.nvim', -- {{{ + { + 'elihunter173/dirbuf.nvim', + lazy = false, config = function() - require('dirbuf').setup { + 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.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'}) + end, { buffer = 0, desc = 'open in foot terminal' }) end, group = vim.api.nvim_create_augroup('DirBufEnter', {}), }) - end} -- }}} - - _G.treesitter_enabled = { -- {{{ - 'bash', - 'bibtex', - 'c', - 'c_sharp', - 'cpp', - 'cmake', - 'comment', - 'css', - 'dockerfile', - -- 'elixir', - 'go', - 'gomod', - 'gowork', - 'hcl', - 'help', - 'html', - 'java', - 'javascript', - 'json', - 'jsonc', - 'latex', - 'ledger', - 'lua', - 'make', - 'markdown', - 'markdown_inline', - 'ninja', - 'norg', - 'regex', - 'rust', - 'scss', - 'toml', - 'typescript', - 'vim', - 'yaml', - 'zig', + end, + }, - 'org', - 'hare', - 'gotmpl', - 'vimdoc', - } -- }}} - use {'nvim-treesitter/nvim-treesitter', -- {{{ - run = ':TSUpdate', - requires = { - 'nvim-treesitter/nvim-treesitter-refactor', - 'nvim-treesitter/nvim-treesitter-textobjects', - 'nvim-treesitter/playground', - }, - config = function() + { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + build = ':TSUpdate', + config = function(_, opts) local tsconf = require('nvim-treesitter.parsers').get_parser_configs() - tsconf.org = { - install_info = { - url = 'https://github.com/milisims/tree-sitter-org', - files = {'src/parser.c', 'src/scanner.cc'}, - revision = 'main', - } - } tsconf.hare = { install_info = { url = 'https://git.sr.ht/~ecmma/tree-sitter-hare', - files = {'src/parser.c'}, - } + files = { 'src/parser.c' }, + }, } tsconf.gotmpl = { install_info = { url = 'https://github.com/ngalaiko/tree-sitter-go-template', - files = {'src/parser.c'}, + files = { 'src/parser.c' }, }, filetype = 'gotmpl', - used_by = {'gotmpl.html', 'gotmpl.yaml', 'gotmpl'}, + used_by = { 'gotmpl.html', 'gotmpl.yaml', 'gotmpl' }, } - - require('nvim-treesitter.configs').setup { - ensure_installed = _G.treesitter_enabled, - disable = {'jsonc'}, - highlight = { - enable = true, - additional_vim_regex_highlighting = {'markdown'}, - }, - indent = { - enable = true, + require('nvim-treesitter.configs').setup(opts) + end, + opts = { + ensure_installed = { + 'bash', + 'bibtex', + 'c', + 'c_sharp', + 'cpp', + 'cmake', + 'comment', + 'css', + 'dockerfile', + -- 'elixir', + 'go', + 'gomod', + 'gowork', + 'hcl', + 'help', + 'html', + 'java', + 'javascript', + 'json', + 'jsonc', + 'latex', + 'ledger', + 'lua', + 'make', + 'markdown', + 'markdown_inline', + 'ninja', + 'norg', + 'regex', + 'rust', + 'scss', + 'toml', + 'typescript', + 'vim', + 'yaml', + 'zig', + -- experimental + 'hare', + 'gotmpl', + }, + -- disable = { 'jsonc' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = { 'markdown' }, + }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = 'gnn', + node_incremental = 'grn', + node_decremental = 'grm', }, - incremental_selection = { + }, + refactor = { + navigation = { enable = true, keymaps = { - init_selection = 'gnn', - node_incremental = 'grn', - node_decremental = 'grm', + goto_definition = '<c-]>', }, }, - refactor = { - navigation = { - enable = true, - keymaps = { - goto_definition = "<c-]>", - }, - }, - smart_rename = { - enable = true, - keymaps = { - smart_rename = "grr", - }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = 'grr', }, }, - textobjects = { - select = { - enable = true, - keymaps = { - ["ib"] = '@block.inner', - ["ob"] = '@block.outer', - ["ic"] = '@conditional.inner', - ["oc"] = '@conditional.outer', - ["if"] = '@function.inner', - ["of"] = '@function.outer', - ["il"] = '@loop.inner', - ["ol"] = '@loop.outer', - ["is"] = '@scopename.inner', - ["os"] = '@scopename.outer', - }, + }, + textobjects = { + select = { + enable = true, + keymaps = { + ['ib'] = '@block.inner', + ['ob'] = '@block.outer', + ['ic'] = '@conditional.inner', + ['oc'] = '@conditional.outer', + ['if'] = '@function.inner', + ['of'] = '@function.outer', + ['il'] = '@loop.inner', + ['ol'] = '@loop.outer', + ['is'] = '@scopename.inner', + ['os'] = '@scopename.outer', }, }, - } - end} -- }}} - - use {'neovim/nvim-lspconfig', -- {{{ + }, + }, + }, + { 'nvim-treesitter/nvim-treesitter-refactor', keys = { '<c-]>', 'grr' } }, + { + 'nvim-treesitter/nvim-treesitter-textobjects', + keys = { 'ib', 'ob', 'ic', 'oc', 'if', 'of', 'il', 'ol', 'is', 'os' }, + }, + { 'nvim-treesitter/playground', cmd = 'TSPlaygroundToggle' }, + + { + 'neovim/nvim-lspconfig', + lazy = false, + -- event = 'InsertEnter', + priority = 100, + dependencies = { + { + 'nvim-lua/lsp-status.nvim', + config = function() + local lspstatus = require('lsp-status') + lspstatus.config({ + diagnostics = false, + current_function = false, + status_symbol = '', + }) + lspstatus.register_progress() + end, + }, + }, config = function() require('telescope').load_extension('lsp_handlers') require('internal.lsp').setup() - end} -- }}} - - use {'nvim-lua/lsp-status.nvim', module = {'lsp-status'}, -- {{{ - config = function() - local lspstatus = require('lsp-status') - lspstatus.config { - diagnostics = false, - current_function = false, - status_symbol = '', - } - lspstatus.register_progress() - end} -- }}} - - use {'stevearc/aerial.nvim', module = {'aerial'}, cmd = {'AerialOpen', 'AerialToggle'}, disable = false, -- {{{ - config = function() - require('aerial').setup({ - backends = { 'lsp', 'treesitter', 'markdown' }, - filter_kind = { - -- default: - 'Class', - 'Constructor', - 'Enum', - 'Function', - 'Interface', - 'Module', - 'Method', - 'Struct', - -- custom: - 'Constant', - 'Variable', - }, - icons = require('internal.lsp').symbols, - close_automatic_events = { 'unsupported' }, - placement = 'edge', - open_automatic = false, - -- open_automatic = function(bufnr) - -- return vim.api.nvim_buf_line_count(bufnr) > 200 - -- and package.loaded.aerial.num_symbols(bufnr) > 4 - -- and not package.loaded.aerial.was_closed() - -- end, - default_keybinds = false, - show_guides = true, - }) - -- TODO: https://github.com/neovim/neovim/issues/18660 - -- vim.api.nvim_create_autocmd('FileType', { pattern = 'aerial', - -- callback = function() vim.opt_local.winbar = '' end, - -- }) - end} --- }}} - - use {'SmiteshP/nvim-navic', module = 'nvim-navic', -- {{{ - requires = {'neovim/nvim-lspconfig'}, - config = function() - local navic = require('nvim-navic') - navic.setup { - icons = require('internal.lsp').symbols, - } - end} -- }}} - - use {'kosayoda/nvim-lightbulb', disable = true, -- {{{ - config = function() - require('nvim-lightbulb').setup { - ignore = {'null-ls'}, - sign = { enabled = false }, - virtual_text = { enabled = false, text = '← ' }, - status_text = { enabled = true, text = '', text_unavailable = '' }, - autocmd = { enabled = true }, - } - vim.fn.sign_define({{name='LightBulbSign', text='', texthl='LightBulbSign'}}) - end} -- }}} - - use {'weilbith/nvim-code-action-menu', - config = function() - vim.lsp.handlers['textDocument/codeAction'] = require('code_action_menu').open_code_action_menu - end} - - use {'jose-elias-alvarez/null-ls.nvim', -- {{{ - requires = {'nvim-lua/plenary.nvim'}, - config = function() - local nls = require('null-ls') - nls.setup { - -- debug = true, - sources = { - nls.builtins.diagnostics.shellcheck, - nls.builtins.formatting.shfmt, - nls.builtins.formatting.yapf, -- python - -- nls.builtins.formatting.clang_format, - -- nls.builtins.formatting.gofumpt, - -- nls.builtins.formatting.json_tool, - -- nls.builtins.formatting.rustfmt, - -- nls.builtins.formatting.stylua, - }, - on_attach = require('internal.lsp').my_attach, - } - - local h = require('null-ls.helpers') - - nls.register({ - h.make_builtin({ - name = 'html-beautify', - filetypes = {'html', 'gotmpl.html'}, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/html-beautify', - args = {'--file', '-', '--editorconfig'}, - to_stdin = true, - }, - factory = h.formatter_factory, - }), - h.make_builtin({ - name = 'html-beautify', - filetypes = {'html', 'gotmpl.html'}, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/html-beautify', - args = {'--file', '-', '--editorconfig'}, - to_stdin = true, - }, - factory = h.formatter_factory, - }), - h.make_builtin({ - name = 'css-beautify', - filetypes = {'css', 'scss'}, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/css-beautify', - args = {'--file', '-', '--editorconfig'}, - to_stdin = true, - }, - factory = h.formatter_factory, - }), - }) - end} -- }}} - - use {'mfussenegger/nvim-dap', module = {'dap'}, -- {{{ - requires = {'nvim-telescope/telescope-dap.nvim'}, - config = function() - require('telescope').load_extension('dap') - require('internal.dap') - end} -- }}} + end, + }, - use {'hrsh7th/nvim-cmp', -- {{{ - requires = { + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { -- 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', @@ -489,130 +318,102 @@ require('packer').startup({function() 'hrsh7th/cmp-nvim-lsp-signature-help', 'saadparwaiz1/cmp_luasnip', 'f3fora/cmp-spell', - 'windwp/nvim-autopairs', - 'neovim/nvim-lspconfig', }, config = function() local cmp = require('cmp') local luasnip = require('luasnip') - cmp.setup { + cmp.setup({ + experimental = { ghost_text = true }, -- disable completion in comments enabled = function() - local ctx = require('cmp.config.context') - if vim.api.nvim_get_mode().mode == 'c' then + local ok, enable = pcall(function() + local ctx = require('cmp.config.context') + if vim.api.nvim_get_mode().mode == 'i' then + if ctx.in_treesitter_capture('comment') or ctx.in_syntax_group('Comment') then + return false + end + if vim.opt.filetype:get() == 'TelescopePrompt' then + return false + end + end return true - else - return ctx.in_treesitter_capture('comment') - and not ctx.in_syntax_group('Comment') - end + end) + return not ok or enable end, preselect = cmp.PreselectMode.Item, window = { + completion = { + border = 'none', + }, documentation = { - border = _G.floating_win_border, + border = 'solid', }, }, - mapping = { -- {{{2 - ['<cr>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.mapping.confirm({ select = true }) - elseif luasnip.expandable() then - luasnip.expand() - else - fallback() - end - end), + mapping = cmp.mapping.preset.insert({ ['<c-space>'] = cmp.mapping.complete(), + ['<cr>'] = cmp.mapping(function(fallback) + if luasnip.expandable() then + luasnip.expand() + elseif cmp.visible() then + cmp.mapping.confirm({ select = true }) + else + fallback() + end + end), ['<c-n>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { 'c', 'i', 's', 'n' }), + if luasnip.locally_jumpable(1) then + luasnip.jump(1) + elseif cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end), ['<c-p>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'c', 'i', 's', 'n' }), - ['<tab>'] = cmp.mapping({ - i = function(fallback) - if cmp.visible() then - cmp.mapping.confirm({ select = true }) - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, - s = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, - c = function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, - }), - ['<s-tab>'] = cmp.mapping({ - i = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, - s = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, - c = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, - }), + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + elseif cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end), + ['<tab>'] = cmp.mapping(function(fallback) + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif cmp.visible() then + cmp.mapping.confirm({ select = true }) + else + fallback() + end + end), + ['<s-tab>'] = cmp.mapping(function(fallback) + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + elseif cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end), -- map c-j/k for luasnip choice nodes ['<c-j>'] = cmp.mapping(function(fallback) - if luasnip.choice_active() then - luasnip.change_choice(1) - else - fallback() - end - end, { 'i', 's'}), + if luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { 'i', 's' }), ['<c-k>'] = cmp.mapping(function(fallback) - if luasnip.choice_active() then - luasnip.change_choice(-1) - else - fallback() - end - end, { 'i', 's'}), + if luasnip.choice_active() then + luasnip.change_choice(-1) + else + fallback() + end + end, { 'i', 's' }), ['<s-pagedown>'] = cmp.mapping.scroll_docs(-4), ['<s-pageup>'] = cmp.mapping.scroll_docs(4), - }, -- 2}}} + }), snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) @@ -624,79 +425,100 @@ require('packer').startup({function() { name = 'luasnip' }, { name = 'nvim_lua' }, }, { - { name = 'neorg' }, + -- { name = 'neorg' }, -- { name = 'orgmode' }, { name = 'spell', keyword_length = 3, max_item_count = 5 }, { name = 'path' }, -- { name = 'buffer', keyword_length = 3 }, }), formatting = { - fields = {'kind', 'abbr', 'menu'}, + fields = { 'kind', 'abbr', 'menu' }, format = function(entry, item) local menus = { nvim_lsp = '░ lsp', - luasnip = '░ snip', + luasnip = '░ snip', nvim_lua = '░ nvim', -- orgmode = '░ org', - spell = '░ spell', - path = '░ path', - buffer = '░ buf', + spell = '░ spell', + path = '░ path', + buffer = '░ buf', } - item.kind = require('internal.lsp').symbols[item.kind] or '' + item.kind = require('internal.lsp_symbols')[item.kind] or '' item.menu = menus[entry.source.name] return item end, }, - } - cmp.setup.cmdline({'/', '?', '@'}, { + }) + cmp.setup.cmdline({ '/', '?', '@' }, { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'nvim_lsp_document_symbol' }, - { name = 'buffer' } + -- { name = 'buffer' } }), formatting = { - fields = {'abbr', 'menu'}, + fields = { 'abbr', 'menu' }, }, }) cmp.setup.cmdline(':', { mapping = vim.tbl_extend('force', cmp.mapping.preset.cmdline(), { - ['<c-r>'] = cmp.mapping({ c = function() vim.cmd.Telescope 'command_history' end}), + ['<c-r>'] = cmp.mapping({ + c = function() + vim.cmd.Telescope('command_history') + end, + }), }), sources = cmp.config.sources({ { name = 'path' }, }, { - { name = 'cmdline' } + { name = 'cmdline' }, }), formatting = { - fields = {'abbr', 'menu'}, + fields = { 'abbr', 'menu' }, }, }) - -- insert `(` after selecting function/method items - cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done { - map_char = {tex = ''} - }) - end} -- }}} + cmp.event:on( + 'confirm_done', + require('nvim-autopairs.completion.cmp').on_confirm_done({ + map_char = { tex = '' }, + }) + ) + end, + }, - use {'L3MON4D3/LuaSnip', -- {{{ + { + 'L3MON4D3/LuaSnip', config = function() require('internal.snips') - end} -- }}} + end, + }, - use {'nvim-telescope/telescope.nvim', --- {{{ - requires = { + { + 'nvim-telescope/telescope.nvim', + cmd = 'Telescope', + dependencies = { 'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim', - -- telescope plugins: - {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}, - {'nvim-telescope/telescope-ui-select.nvim'}, - {'gbrlsnchs/telescope-lsp-handlers.nvim'}, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + config = function() + require('telescope').load_extension('fzf') + end, + }, + { + 'nvim-telescope/telescope-ui-select.nvim', + config = function() + require('telescope').load_extension('ui-select') + end, + }, + 'gbrlsnchs/telescope-lsp-handlers.nvim', }, config = function() - require('telescope').setup{ + require('telescope').setup({ defaults = { - prompt_prefix = '> ', - selection_caret = '* ', + prompt_prefix = '', + selection_caret = '⯈ ', sorting_strategy = 'ascending', preview = false, @@ -707,18 +529,15 @@ require('packer').startup({function() -- preview_cutoff = 1, -- height = 20, }, - border = true, borderchars = { - preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, - prompt = { '─', ' ', ' ', ' ', '─', '─', ' ', ' ' }, + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + prompt = { '─', '', '', '', '╾', '╼', '', '' }, results = { '' }, }, - - file_previewer = require('telescope.previewers').vim_buffer_cat.new, - grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, + file_previewer = require('telescope.previewers').vim_buffer_cat.new, + grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, - mappings = { i = { ['<C-Space>'] = require('telescope.actions.layout').toggle_preview, @@ -727,341 +546,536 @@ require('packer').startup({function() ['<C-Space>'] = require('telescope.actions.layout').toggle_preview, }, }, - - extensions = { - ['fzf'] = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case', - }, - - ['lsp_handlers'] = { - disable = { - -- ['textDocument/codeAction'] = true, - }, + }, + extensions = { + ['fzf'] = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + ['lsp_handlers'] = { + disable = { + -- ['textDocument/codeAction'] = true, }, - - ['ui-select'] = { - require("telescope.themes").get_cursor { - initial_mode = 'normal', - previewer = false, - } - } - } - } - } - - -- required to get fzf-native working - require('telescope').load_extension('fzf') - require('telescope').load_extension('ui-select') - - vim.keymap.set('n', ';Q', require('telescope.builtin').quickfix, {desc='quickfix'}) - vim.keymap.set('n', ';C', require('telescope.builtin').loclist, {desc='loclist'}) - vim.keymap.set('n', ';H', require('telescope.builtin').help_tags, {desc='help_tags'}) - vim.keymap.set('n', ';b', require('telescope.builtin').buffers, {desc='buffer'}) - vim.keymap.set('n', ';c', require('telescope.builtin').commands, {desc='commands'}) - vim.keymap.set('n', ';f', require('telescope.builtin').fd, {desc='fd'}) - vim.keymap.set('n', ';g', require('telescope.builtin').live_grep, {desc='grep'}) - vim.keymap.set('n', ';h', require('telescope.builtin').command_history, {desc='command history'}) - vim.keymap.set('n', ';l', require('telescope.builtin').current_buffer_fuzzy_find, {desc='buffer'}) - vim.keymap.set('n', ';o', require('telescope.builtin').oldfiles, {desc='oldfiles'}) - vim.keymap.set('n', ';d', require('telescope.builtin').diagnostics, {desc='diagnostics'}) - vim.keymap.set('n', ';v', function() + }, + ['ui-select'] = { + require('telescope.themes').get_cursor({ + initial_mode = 'normal', + previewer = false, + }), + }, + }, + }) + end, + keys = { + { + ';Q', + function() + require('telescope.builtin').quickfix() + end, + desc = 'quickfix', + }, + { + ';C', + function() + require('telescope.builtin').loclist() + end, + desc = 'loclist', + }, + { + ';H', + function() + require('telescope.builtin').help_tags() + end, + desc = 'help_tags', + }, + { + ';b', + function() + require('telescope.builtin').buffers() + end, + desc = 'buffer', + }, + { + ';c', + function() + require('telescope.builtin').commands() + end, + desc = 'commands', + }, + { + ';f', + function() + require('telescope.builtin').fd() + end, + desc = 'fd', + }, + { + ';g', + function() + require('telescope.builtin').live_grep() + end, + desc = 'grep', + }, + { + ';h', + function() + require('telescope.builtin').command_history() + end, + desc = 'command history', + }, + { + ';l', + function() + require('telescope.builtin').current_buffer_fuzzy_find() + end, + desc = 'buffer', + }, + { + ';o', + function() + require('telescope.builtin').oldfiles() + end, + desc = 'oldfiles', + }, + { + ';d', + function() + require('telescope.builtin').diagnostics() + end, + desc = 'diagnostics', + }, + { + ';v', + function() require('telescope.builtin').find_files({ prompt_title = 'vimrc', previewer = false, cwd = vim.fn.stdpath('config'), }) - end, {desc='vim config'}) - - vim.keymap.set('n', 'gw', function() - misc.word_under_cursor(function(s) require('telescope.builtin').grep_string({ search = s }) end) - end, {desc='grep for word under cursor'}) - -- vim.keymap.set('n', '<localleader>ge', function() - -- misc.expr_under_cursor(function(s) require('telescope.builtin').grep_string({ search = s }) end) - -- end) - -- vim.keymap.set('n', '<localleader>gf', function() - -- misc.file_under_cursor(function(s) require('telescope.builtin').grep_string({ search = s }) end) - -- end) - end} -- }}} + end, + desc = 'vim config', + }, + { + 'gw', + function() + require('internal.misc').word_under_cursor(function(s) + require('telescope.builtin').grep_string({ search = s }) + end) + end, + desc = 'grep for word under cursor', + }, + }, + }, - use {'tpope/vim-surround'} - use {'tpope/vim-repeat'} -- extend '.' to plugins - use {'michaeljsmith/vim-indent-object'} -- indentation text-objects - use {'kshenoy/vim-signature', disable = true} -- toggle, display and navigate marks - use {'norcalli/nvim-colorizer.lua', -- {{{ + { + 'norcalli/nvim-colorizer.lua', + -- event = 'VeryLazy', config = function() require('colorizer').setup(nil, { - name = true; - RRGGBB = true; - RRGGBBAA = false; - rgb_fn = true; - hsl_fn = true; - mode = 'background'; + name = true, + RRGGBB = true, + RRGGBBAA = false, + rgb_fn = true, + hsl_fn = true, + mode = 'background', }) - end} -- }}} + end, + }, + + { 'gentoo/gentoo-syntax', lazy = false }, + + { + 'NMAC427/guess-indent.nvim', + opts = { + auto_cmd = true, + filetype_exclude = { 'netrw', 'tutor', 'dirbuf' }, + buftype_exclude = { 'help', 'nofile', 'terminal', 'prompt' }, + }, + }, - use {'rhysd/conflict-marker.vim', disable = true} - use {'kassio/neoterm', disable = true} + { + url = 'https://git.sr.ht/~robertgzr/spinner.nvim', + opts = { + spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, + interval = 120, -- spinner frame rate in ms + }, + }, - use {'kristijanhusak/orgmode.nvim', ft = {'org'}, module = {'orgmode'}, disable = true, -- {{{ + { + 'stevearc/aerial.nvim', + cmd = { 'AerialOpen', 'AerialToggle' }, + opts = { + backends = { 'lsp', 'treesitter', 'markdown' }, + filter_kind = { + -- default: + 'Class', + 'Constructor', + 'Enum', + 'Function', + 'Interface', + 'Module', + 'Method', + 'Struct', + -- custom: + 'Constant', + 'Variable', + }, + icons = require('internal.lsp_symbols'), + close_automatic_events = { 'unsupported' }, + placement = 'edge', + open_automatic = false, + -- open_automatic = function(bufnr) + -- return vim.api.nvim_buf_line_count(bufnr) > 200 + -- and package.loaded.aerial.num_symbols(bufnr) > 4 + -- and not package.loaded.aerial.was_closed() + -- end, + default_keybinds = false, + show_guides = true, + }, + }, + + { + 'SmiteshP/nvim-navic', + opts = { + icons = require('internal.lsp_symbols'), + }, + }, + + -- {'kosayoda/nvim-lightbulb', + -- config = { + -- ignore = {'null-ls'}, + -- sign = { enabled = false }, + -- virtual_text = { enabled = false, text = '← ' }, + -- status_text = { enabled = true, text = '', text_unavailable = '' }, + -- autocmd = { enabled = true }, + -- }, + -- init = function() + -- vim.fn.sign_define({{name='LightBulbSign', text='', texthl='LightBulbSign'}}) + -- end, + -- }, + + { + 'weilbith/nvim-code-action-menu', + event = 'VeryLazy', config = function() - require('orgmode').setup_ts_grammar() - require('orgmode').setup { - org_agenda_files = {vim.env.HOME..'/Documents/org/*.org'}, - org_default_notes_file = vim.env.HOME..'/Documents/org/todo.org', - org_todo_keywords = {'TODO', 'DONE'}, - -- org_indent_mode = 'noindent', - org_agenda_templates = { - t = { - description = 'Todo', - template = '* TODO %?', - }, - n = { - description = 'Note', - template = '* %?', - target = vim.env.HOME..'/Documents/org/notes.org', - }, - }, - mappings = { - agenda = { - org_agenda_close = nil, - } + vim.lsp.handlers['textDocument/codeAction'] = + require('code_action_menu').open_code_action_menu + end, + }, + + { + 'jose-elias-alvarez/null-ls.nvim', + ft = { 'sh', 'bash', 'lua', 'rust', 'c', 'cpp' }, + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local nls = require('null-ls') + nls.setup({ + -- debug = true, + sources = { + nls.builtins.diagnostics.shellcheck, + nls.builtins.formatting.shfmt, + nls.builtins.formatting.yapf, -- python + nls.builtins.formatting.clang_format, + nls.builtins.formatting.rustfmt, + nls.builtins.formatting.stylua, + -- nls.builtins.formatting.gofumpt, + -- nls.builtins.formatting.json_tool, }, - } + on_attach = require('internal.lsp').my_attach, + }) + + local h = require('null-ls.helpers') - local pickers = require('telescope.pickers') - local finders = require('telescope.finders') + nls.register({ + h.make_builtin({ + name = 'html-beautify', + filetypes = { 'html', 'gotmpl.html' }, + method = nls.methods.FORMATTING, + generator_opts = { + command = vim.env.HOME .. '/.yarn/bin/html-beautify', + args = { '--file', '-', '--editorconfig' }, + to_stdin = true, + }, + factory = h.formatter_factory, + }), + h.make_builtin({ + name = 'html-beautify', + filetypes = { 'html', 'gotmpl.html' }, + method = nls.methods.FORMATTING, + generator_opts = { + command = vim.env.HOME .. '/.yarn/bin/html-beautify', + args = { '--file', '-', '--editorconfig' }, + to_stdin = true, + }, + factory = h.formatter_factory, + }), + h.make_builtin({ + name = 'css-beautify', + filetypes = { 'css', 'scss' }, + method = nls.methods.FORMATTING, + generator_opts = { + command = vim.env.HOME .. '/.yarn/bin/css-beautify', + args = { '--file', '-', '--editorconfig' }, + to_stdin = true, + }, + factory = h.formatter_factory, + }), + }) + end, + }, - vim.keymap.set('s', ';O', function() - pickers.new(opts, { - prompt_title = 'Orgmode', - finder = finders.new_table(require('orgmode.config'):get_all_files()), - }):find() - end) + { + 'mfussenegger/nvim-dap', + dependencies = { 'nvim-telescope/telescope-dap.nvim' }, + config = function() + require('telescope').load_extension('dap') + require('internal.dap') + end, + keys = { '<leader>d' }, + }, - -- wk_register { - -- ['<leader>o'] = {name = '+Orgmode', - -- a = {'agenda prompt'}, - -- c = {'capture prompt'}, - -- r = {'refile'}, - -- [','] = {'set priority'}, - -- ['*'] = {'toggle headline'}, - -- ['o'] = {'follow link/date'}, - -- ['\''] = {'create source block'}, - -- ['$'] = {'archive current headline'}, - -- ['<cr>'] = {'insert heading/item/row'}, - -- t = {'set tags'}, - -- A = {'toggle ARCHIVE tag'}, - -- K = {'subtree up'}, - -- J = {'subtree down'}, - -- e = {'export'}, - -- ['i'] = { - -- name = '+Timestamp', - -- d = {'set deadline'}, - -- s = {'set scheduled'}, - -- h = {'insert heading (respect content)'}, - -- T = {'insert todo'}, - -- t = {'insert todo (respect content)'}, - -- ['.'] = {'set date'}, - -- ['!'] = {'set inactive'}, - -- }, - -- ['x'] = { - -- name = '+Clock', - -- i = {'clock in'}, - -- o = {'clock out'}, - -- q = {'cancel active clock'}, - -- j = {'jump to active clock'}, - -- e = {'set effort estimate property'}, - -- } - -- }, - -- } - end} -- }}} + { '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'}, + -- {'kassio/neoterm'}, + + { + 'kristijanhusak/orgmode.nvim', + ft = 'org', + build = function() + require('orgmode').setup_ts_grammar() + vim.cmd.TSUpdate() + end, + opts = { + org_agenda_files = { vim.env.HOME .. '/documents/org/*.org' }, + org_default_notes_file = vim.env.HOME .. '/documents/org/todo.org', + org_todo_keywords = { 'TODO', 'DONE' }, + -- org_indent_mode = 'noindent', + org_agenda_templates = { + t = { + description = 'Todo', + template = '* TODO %?', + }, + n = { + description = 'Note', + template = '* %?', + target = vim.env.HOME .. '/documents/org/notes.org', + }, + }, + mappings = { + agenda = { + org_agenda_close = nil, + }, + }, + }, + -- keys = { + -- { mode = 's', ';O', function() + -- local pickers = require('telescope.pickers') + -- local finders = require('telescope.finders') + -- pickers.new(opts, { + -- prompt_title = 'Orgmode', + -- finder = finders.new_table(require('orgmode.config'):get_all_files()), + -- }):find() + -- end }, + -- }, + }, - use {'nvim-neorg/neorg', ft = {'norg'}, module = {'neorg'}, cmd = {'Neorg'}, -- {{{ - run = ':Neorg sync-parsers', - requires = { + { + 'nvim-neorg/neorg', + enabled = false, + ft = 'norg', + cmd = { 'Neorg' }, + build = ':Neorg sync-parsers', + dependencies = { 'nvim-lua/plenary.nvim', 'nvim-neorg/neorg-telescope', 'nvim-treesitter/nvim-treesitter', }, - setup = vim.cmd [[autocmd BufRead,BufNewFile *.norg setlocal filetype=norg]], - after = {'nvim-treesitter'}, - config = function() - require('neorg').setup { - load = { - ['core.defaults'] = {}, - ['core.keybinds'] = { - config = { - default_keybinds = true, - -- NOTE: neorg uses localleader by default, see init.lua:6 - -- neorg_leader = '<leader>n', - } - }, - ['core.norg.concealer'] = { - config = { - icons = { - todo = { enabled = true } - }, - } - }, - ['core.norg.dirman'] = { - config = { - workspaces = { - default = '$HOME/Documents/neorg/default', - work = '$HOME/Documents/neorg/work', - gtd = '$HOME/Documents/neorg/gtd', - } - } - }, - ['core.norg.completion'] = { - config = { engine = 'nvim-cmp' } - }, - ['core.integrations.telescope'] = {}, - ['core.norg.qol.todo_items'] = {}, - ['core.presenter'] = {}, - ['core.gtd.base'] = { - config = { - workspace = 'gtd' - } + init = function() + -- vim.cmd [[autocmd BufRead,BufNewFile *.norg setlocal filetype=norg]], + end, + opts = { + load = { + ['core.defaults'] = {}, + ['core.keybinds'] = { + config = { default_keybinds = true }, + }, + ['core.norg.concealer'] = { + config = { icons = { todo = { enabled = true } } }, + }, + ['core.norg.dirman'] = { + config = { + workspaces = { + default = '$HOME/documents/neorg/default', + work = '$HOME/documents/neorg/work', + gtd = '$HOME/documents/neorg/gtd', + }, }, }, - } - end} -- }}} + ['core.norg.completion'] = { + config = { engine = 'nvim-cmp' }, + }, + ['core.integrations.telescope'] = {}, + ['core.norg.qol.todo_items'] = {}, + ['core.presenter'] = {}, + ['core.gtd.base'] = { + config = { workspace = 'gtd' }, + }, + }, + }, + }, - use {'mickael-menu/zk-nvim', module = {'zk', 'telescope._extensions.zk'}, -- {{{ + { + 'mickael-menu/zk-nvim', + cmd = { 'ZkNew', 'ZkNotes' }, + ft = { 'markdown', 'neorg' }, config = function() - local lsp = require('internal.lsp') - require('telescope').load_extension('zk') - require('zk').setup { + require('zk').setup({ picker = 'telescope', lsp = { config = { - cmd = {'/home/robert/devel/upstream/github.com/mickael-menu/zk/zk', 'lsp', '--log', '/tmp/zk-lsp.log'}, - on_attach = lsp.my_attach, - on_exit = lsp.my_exit, - capabilities = lsp.capabilities(), + cmd = { 'zk', 'lsp', '--log', '/tmp/zk-lsp.log' }, + on_attach = require('internal.lsp').my_attach, + on_exit = require('internal.lsp').my_exit, + capabilities = require('internal.lsp').capabilities(), }, auto_attach = { enabled = true, - filetypes = { 'markdown', 'norg' }, + filetypes = { 'markdown', 'neorg' }, }, }, - } - vim.keymap.set('n', ';z', function() require('zk').edit(nil, { multi_select = false }) end, {desc='zk'}) - end} -- }}} - - -- languages - -- NOTE: these should only be loaded when they are required... - -- use {'rhysd/vim-grammarous', - -- ft = {'markdown', 'latex', 'tex'} - -- } + }) + end, + keys = { + { + ';z', + function() + require('zk').edit(nil, { multi_select = false }) + end, + desc = 'zk', + }, + }, + }, - use {'lervag/vimtex', ft = {'latex','tex'}, -- {{{ - config = function() - vim.g.tex_flavor = 'latex' - vim.g.vimtex_compiler_enabled = 0 - vim.g.vimtex_compiler_method = 'tectonic' - vim.g.vimtex_compiler_tectonic = "{'executable': 'tectonic'}" - vim.g.vimtex_view_method = 'zathura' - -- vim.g.vimtex_view_zathura_check_libsynctex = false - -- vim.g.vimtex_view_use_temp_files = true - -- vim.g.vimtex_view_forward_search_on_start = false - end} -- }}} + -- {'rhysd/vim-grammarous', + -- ft = {'markdown', 'latex', 'tex'} + -- }, - use {'plasticboy/vim-markdown', ft = {'markdown'}, -- {{{ + { + 'lervag/vimtex', + ft = { 'latex', 'tex' }, config = function() - vim.g.vim_markdown_folding_disabled = true - vim.g.vim_markdown_math = true - vim.g.vim_markdown_frontmatter = true - vim.g.vim_markdown_json_frontmatter = true - vim.g.vim_markdown_toml_frontmatter = true - vim.g.vim_markdown_yaml_frontmatter = true - -- vim.g.vim_markdown_folding_level = 2 - vim.g.vim_markdown_strikethrough = true - vim.g.vim_markdown_auto_insert_bullets = true - vim.g.vim_markdown_new_list_item_indent = false - vim.g.vim_markdown_conceal = true - vim.g.vim_markdown_conceal_code_blocks = true - end} -- }}} - - use {'gentoo/gentoo-syntax'} + local g = vim.g + g.tex_flavor = 'latex' + g.vimtex_compiler_enabled = 0 + 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, + }, - use {'NMAC427/guess-indent.nvim', disable = false, -- {{{ + { + 'plasticboy/vim-markdown', + ft = 'markdown', config = function() - require('guess-indent').setup { - auto_cmd = true, - filetype_exclude = {'netrw', 'tutor', 'dirbuf'}, - buftype_exclude = {'help', 'nofile', 'terminal', 'prompt'}, - } - end} -- }}} + 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 + end, + }, - use {'folke/zen-mode.nvim', cmd = {'ZenMode'}, -- {{{ - module = {'zen-mode'}, - config = function() - require('zen-mode').setup { - window = { - backdrop = 1, - width = 0.3, - -- height = 1, - options = { - number = false, - list = false, + { + 'folke/zen-mode.nvim', + dependencies = { + { + 'folke/twilight.nvim', + opts = { + context = 15, + dimming = { + alpha = 0.3, + color = { 'Normal', '#ffffff' }, }, }, - plugins = { - options = { - enabled = true, - ruler = false, - showcmd = false, - }, - twilight = { enabled = true }, - } - } - end} -- }}} - - use {'folke/twilight.nvim', module = {'twilight'}, -- {{{ - config = function() - require('twilight').setup { - context = 15, - dimming = { - alpha = 0.3, - color = { 'Normal', '#ffffff' }, + }, + }, + cmd = { 'ZenMode' }, + opts = { + window = { + backdrop = 1, + width = 0.3, + -- height = 1, + options = { + number = false, + list = false, }, - } - end} -- }}} + }, + plugins = { + options = { + enabled = true, + ruler = false, + showcmd = false, + }, + twilight = { enabled = true }, + }, + }, + }, - use {'goolord/alpha-nvim', cmd = {'Alpha'}, module = {'alpha'}, -- {{{ - setup = function() - vim.keymap.set('n', '<leader>a', function() vim.cmd [[Alpha]] end, {desc='alpha'}) - end, + { + 'folke/which-key.nvim', + event = 'VeryLazy', + opts = { + icons = { separator = '→ ', group = '🞱 ' }, + triggers = { '<leader>', '<localleader>', ';', 'g', '[', ']' }, + }, + }, + + { + 'goolord/alpha-nvim', + cmd = 'Alpha', config = function() local MAX_WIDTH = 80 local alpha = require('alpha') local them = require('alpha.themes.theta') - local button = function(...) -- {{{ + local button = function(...) local b = require('alpha.themes.dashboard').button(...) b.opts = vim.tbl_extend('force', b.opts, { hl = 'Normal', width = MAX_WIDTH, }) return b - end -- }}} - local fit_path = function(path, max_width) -- {{{ + end + local fit_path = function(path, max_width) local Path = require('plenary.path') path = vim.fn.fnamemodify(path, ':.') if vim.fn.strdisplaywidth(path) > max_width then - path = Path.new(path):shorten(1, {-2, -1}) + path = Path.new(path):shorten(1, { -2, -1 }) end if vim.fn.strdisplaywidth(path) > max_width then path = '_ ' .. path:sub((vim.fn.strdisplaywidth(path) - max_width), -1) end return path - end -- }}} - local hr = function(margin, max_width, label, opts) -- {{{ - max_width = max_width - (2*margin) + end + local hr = function(margin, max_width, label, opts) + max_width = max_width - (2 * margin) label = label and (' ' .. label .. ' ') or '' opts = vim.tbl_extend('force', opts or {}, { position = 'center', hl = 'Comment' }) return { @@ -1071,46 +1085,52 @@ require('packer').startup({function() local label_len = vim.fn.strdisplaywidth(label) -- 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) + return 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) + return string.rep(' ', margin) + .. string.rep('─', max_width / 2) + .. label + .. string.rep('─', max_width / 2) + .. string.rep(' ', margin) end, } - end -- }}} - local fortune = function(margin, max_width) -- {{{ - max_width = max_width - (margin*2) - local Job = require('plenary.job') - local ok, j = pcall(Job.new, Job, { - command = 'sh', - args = {'-c', 'fortune ' .. vim.env.HOME..'/devel/projects/zig/fortune/fortunes' .. ' | fmt -w ' .. max_width}, - enable_recording = true, - }) - if not ok then return {} end - local lines, exit_code = j:sync() - if not exit_code == 0 then return {} end - local val = {} - for i = 1, #lines do - if vim.fn.strdisplaywidth(lines[i]) > max_width then - return error('overful box: ' .. lines[i]) - end - table.insert(val, - (string.rep(' ', margin) .. lines[i] .. string.rep(' ', margin))) - end - if vim.trim(val[#val]) == '' then table.remove(val, #val) end + end + local fortune = function(margin, max_width) + max_width = max_width - (margin * 2) + -- local Job = require('plenary.job') + -- local ok, j = pcall(Job.new, Job, { + -- command = 'sh', + -- args = {'-c', 'fortune ' .. vim.env.HOME..'/devel/projects/zig/fortune/fortunes' .. ' | fmt -w ' .. max_width}, + -- enable_recording = true, + -- }) + -- if not ok then return {} end + -- local lines, exit_code = j:sync() + -- if not exit_code == 0 then return {} end + -- local val = {} + -- for i = 1, #lines do + -- if vim.fn.strdisplaywidth(lines[i]) > max_width then + -- return error('overful box: ' .. lines[i]) + -- end + -- table.insert(val, + -- (string.rep(' ', margin) .. lines[i] .. string.rep(' ', margin))) + -- end + -- if vim.trim(val[#val]) == '' then table.remove(val, #val) end return { type = 'text', - val = val, + val = 'noop', opts = { position = 'center', hl = 'AlphaFortune', }, } - end -- }}} - local mru = function(max_width) -- {{{ + end + local mru = function(max_width) return { type = 'group', val = function() @@ -1120,21 +1140,29 @@ require('packer').startup({function() local oldfiles = {} local cwd = vim.loop.cwd() for _, v in pairs(vim.v.oldfiles) do - if #oldfiles == 10 then break end + if #oldfiles == 10 then + break + end if vim.startswith(v, cwd) and (vim.fn.filereadable(v) == 1) then table.insert(oldfiles, v) end end -- exit early if there's nothing to show - if not oldfiles or #oldfiles == 0 then return {} end + if not oldfiles or #oldfiles == 0 then + return {} + end table.insert(items, hr(0, max_width, 'MRU: ' .. fit_path(cwd, max_width))) table.insert(items, { type = 'padding', val = 1 }) for i, fn in pairs(oldfiles) do - table.insert(items, button( - tostring(i-1), -- keybind is <n> - fit_path(fn, max_width), - ":edit " .. fn .. " <cr>")) + table.insert( + items, + button( + tostring(i - 1), -- keybind is <n> + fit_path(fn, max_width), + ':edit ' .. fn .. ' <cr>' + ) + ) end return items end, @@ -1142,8 +1170,8 @@ require('packer').startup({function() position = 'center', }, } - end -- }}} - local buffers = function(max_width) -- {{{ + end + local buffers = function(max_width) return { type = 'group', val = function() @@ -1163,15 +1191,18 @@ require('packer').startup({function() end) -- exit early if there's nothing to show - if not bufnrs or #bufnrs == 0 then return {} end + if not bufnrs or #bufnrs == 0 then + return {} + end - table.insert(items, {type = 'padding', val = 1}) + table.insert(items, { type = 'padding', val = 1 }) table.insert(items, hr(0, max_width, 'Buffers')) - table.insert(items, {type = 'padding', val = 1}) + table.insert(items, { type = 'padding', val = 1 }) for _, bufnr in ipairs(bufnrs) do - local bufpath = require('plenary.path').new(vim.fn.getbufinfo(bufnr)[1].name):shorten(1, {-2, -1}) - table.insert(items, button('b'..bufnr, bufpath, ':b'..bufnr..'<cr>')) + local bufpath = + require('plenary.path').new(vim.fn.getbufinfo(bufnr)[1].name):shorten(1, { -2, -1 }) + table.insert(items, button('b' .. bufnr, bufpath, ':b' .. bufnr .. '<cr>')) end return items end, @@ -1179,134 +1210,184 @@ require('packer').startup({function() position = 'center', }, } - end -- }}} - them.config.layout = { -- {{{ - {type = 'padding', val = 2}, + end + them.config.layout = { + { type = 'padding', val = 2 }, require('alpha.themes.dashboard').section.header, - {type = 'padding', val = 1}, + { type = 'padding', val = 1 }, fortune(5, MAX_WIDTH), - {type = 'padding', val = 1}, + { type = 'padding', val = 1 }, hr(0, MAX_WIDTH), - {type = 'padding', val = 1}, - {type = 'group', val = { -- buttons {{{ - button('e', ' new', [[<cmd>ene <bar> startinsert<cr>]]), - button('r', ' live grep', [[<cmd>lua require('internal.misc').live_grep()<cr>]]), - button('f', ' find files', [[<cmd>lua require('internal.misc').find_files()<cr>]]), - button('m', ' mru', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]]), - -- button('o', ' orgmode', [[<cmd>lua require('packer').loader('orgmode.nvim'); require('orgmode').action('agenda.prompt')<cr>]]), - button('T', ' todos', [[<cmd>lua require('telescope._extensions.todo-comments').exports.todo {cwd=vim.env.ZK_NOTEBOOK_DIR}<cr>]]), - button('u', ' update plugins', [[<cmd>lua require('packer').sync()<cr>]]), - button('v', ' edit config', [[<cmd>lua require('telescope.builtin').find_files {search_dirs={vim.env.HOME..'/.vim/'}}<cr>]]), - button('M', ' mail', [[<cmd>K2<cr>]]), - }}, -- }}} - {type = 'padding', val = 1}, + { type = 'padding', val = 1 }, + { + type = 'group', + val = { + button('e', ' new', [[<cmd>ene <bar> startinsert<cr>]]), + button('r', ' live grep', [[<cmd>lua require('internal.misc').live_grep()<cr>]]), + button('f', ' find files', [[<cmd>lua require('internal.misc').find_files()<cr>]]), + button('m', ' mru', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]]), + button( + 'o', + ' orgmode', + [[<cmd>lua require('orgmode').action('agenda.prompt')<cr>]] + ), + button( + 't', + ' todos', + [[<cmd>lua require('telescope._extensions.todo-comments').exports.todo {cwd=vim.env.ZK_NOTEBOOK_DIR}<cr>]] + ), + button('u', ' update plugins', [[<cmd>lua require('lazy').update()<cr>]]), + button( + 'v', + ' edit config', + [[<cmd>lua require('telescope.builtin').find_files {search_dirs={vim.env.HOME..'/.vim/'}}<cr>]] + ), + }, + }, + { type = 'padding', val = 1 }, mru(MAX_WIDTH), buffers(MAX_WIDTH), - } -- }}} + } alpha.setup(them.config) - - do - local group = vim.api.nvim_create_augroup('AlphaIndent', { clear = true }) - vim.api.nvim_create_autocmd('FileType', { - pattern = 'alpha', - command = [[IndentBlanklineDisable]], - group = group, - }) - end - end} -- }}} - - use {'ruifm/gitlinker.nvim', module = {'gitlinker'}, -- {{{ - requires = {'nvim-lua/plenary.nvim'}, - setup = function() - vim.keymap.set({'n', 'v'}, '<leader>gy', function() require('gitlinker').get_buf_range_url() end, {desc='gitlinker'}) end, - config = function() - require('gitlinker').setup { - opts = { - action_callback = require('gitlinker.actions').copy_to_clipboard, - }, - } - end} -- }}} + keys = { + { '<leader>a', vim.cmd.Alpha, desc = 'alpha' }, + }, + }, - use {'rhysd/git-messenger.vim', cmd = {'GitMessenger'}, -- {{{ - setup = function() - vim.keymap.set('n', '<leader>gm', function() vim.cmd.GitMessenger() end, {desc='git-messenger'}) - end, + { + 'ruifm/gitlinker.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = { + opts = { + -- action_callback = require('gitlinker.actions').copy_to_clipboard, + }, + }, + keys = { + { + '<leader>gy', + function() + require('gitlinker').get_buf_range_url() + end, + desc = 'gitlinker', + }, + { + mode = 'v', + '<leader>gy', + function() + require('gitlinker').get_buf_range_url() + end, + desc = 'gitlinker', + }, + }, + }, + + { + 'rhysd/git-messenger.vim', + cmd = 'GitMessenger', config = function() -- vim.g.git_messenger_include_diff = false vim.g.git_messenger_always_into_popup = true vim.g.git_messenger_close_on_cursor_moved = true vim.g.git_messenger_no_default_mappings = true - end} -- }}} - - -- restore last cursor position (and handle many edge cases) - use {'farmergreg/vim-lastplace'} - - use {'folke/todo-comments.nvim', module = {'telescope._extensions.todo-comments'}, cmd = {'TodoTelescope'}, -- {{{ - setup = function() - vim.keymap.set('n', ';t', function() vim.cmd [[TodoTelescope]] end, {desc='todo-comments'}) end, - config = function() - require('todo-comments').setup {} - end} -- }}} - - -- spelling related stuff - use {'lewis6991/spellsitter.nvim', disable = true, -- {{{ - config = function() - require('spellsitter').setup { - enable = true, - -- spellchecker = 'ffi' - } - end} -- }}} - - -- TODO: experimental section + keys = { + { '<leader>gm', vim.cmd.GitMessenger, desc = 'git-messenger' }, + }, + }, - use {'tjdevries/sg.nvim', disable = true, -- {{{ - requires = {'nvim-lua/plenary.nvim'}, - config = function() - end} -- }}} + { + 'folke/todo-comments.nvim', + cmd = { 'TodoTelescope' }, + config = true, + keys = { + { ';t', vim.cmd.TodoTelescope, desc = 'todo-comments' }, + }, + }, - use {'yorik1984/newpaper.nvim', disable = true, -- {{{ - config = function() - if vim.g.night_and_day == 'day' then - require('newpaper').setup() - end - end} -- }}} + { + 'cbochs/grapple.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + cmd = 'GrapplePopup', + opts = { + popup_options = { + border = 'none', + }, + }, + keys = { + { + '<leader>m', + function() + require('grapple').popup_tags() + end, + desc = 'grapple: show tags', + }, + { + '<leader>ms', + function() + require('grapple').popup_scopes() + end, + desc = 'grapple: show scopes', + }, + { + '<leader>mm', + function() + require('grapple').toggle() + end, + desc = 'grapple: anonymous tag', + }, + { + '<leader>mn', + function() + require('grapple').cycle_forward() + end, + desc = 'grapple: next tag', + }, + { + '<leader>mp', + function() + require('grapple').cycle_backward() + end, + desc = 'grapple: prev tag', + }, + }, + }, - use {'nyoom-engineering/oxocarbon.nvim', disable = false, -- {{{ - config = function() - if vim.g.night_and_day == 'day' then - vim.opt.background = 'light' - vim.cmd.colorscheme 'oxocarbon' - end - end} -- }}} + { + url = 'https://git.sr.ht/~robertgzr/karafuru', + lazy = false, + -- build = 'make colorscheme', + priority = 1000, + cond = vim.g.night_and_day == 'night', + config = function(plugin) + vim.opt.rtp:append(plugin.dir .. '/vim') + vim.cmd.colorscheme('karafuru') + end, + }, - use {'https://git.sr.ht/~robertgzr/karafuru', rtp = 'vim', -- {{{ - run = 'make colorscheme', + { + 'yorik1984/newpaper.nvim', + lazy = false, + priority = 1000, + cond = vim.g.night_and_day == 'day', config = function() - if not vim.g.night_and_day or vim.g.night_and_day == 'night' then - vim.cmd.colorscheme "karafuru" - end - end} -- }}} + vim.cmd.colorscheme('newpaper') + end, + }, - use {'https://git.sr.ht/~robertgzr/spinner.nvim', module = {'spinner'}, -- {{{ + { + 'nyoom-engineering/oxocarbon.nvim', + lazy = false, + enabled = false, + priority = 1000, + cond = vim.g.night_and_day == 'night', config = function() - require('spinner').setup { - spinner = {'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'}, - interval = 120, -- spinner frame rate in ms - } - end} -- }}} - -end, -config = { - compile_path = compilepath, - git = { - subcommands = { - update = 'pull --ff-only --progress --rebase=true', - } + vim.opt.background = 'dark' + vim.cmd.colorscheme('oxocarbon') + end, }, - profile = { - enable = false, - threshold = 1, - } -}}) +} + +require('lazy').setup(pluginspec, { + defaults = { lazy = true }, +}) |