-- 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 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 vim.schedule(gs.next_hunk) return '' 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 '' end, { buffer = bufnr, expr = true, desc = 'previous hunk' }) vim.keymap.set('n', 'hb', function() gs.blame_line({ full = true }) end, { buffer = bufnr, desc = 'show line blame (full)' }) vim.keymap.set('n', 'hB', function() gs.blame_line({ full = false }) end, { buffer = bufnr, desc = 'show line blame (compact)' }) vim.keymap.set( 'n', 'hp', gs.preview_hunk, { buffer = bufnr, desc = 'preview hunk' } ) vim.keymap.set('n', 'hd', gs.diffthis, { buffer = bufnr, desc = 'diff this' }) vim.keymap.set('n', 'hl', function() gs.setqflist(0, { open = false }) vim.schedule(function() require('telescope.builtin').quickfix() end) end, { buffer = bufnr, desc = 'list hunks' }) end, }, }, { 'lukas-reineke/indent-blankline.nvim', lazy = false, 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' }, }, keys = { { 'ti', [[:IndentBlanklineToggle!]], desc = 'toggle indent-blankline', }, }, }, { 'numToStr/Comment.nvim', opts = { opleader = { block = 'gC' }, }, keys = { 'gcc', { 'gc', mode = 'v' }, { 'gC', mode = 'v' }, }, }, { '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, event = 'InsertEnter', config = true, }, { 'elihunter173/dirbuf.nvim', 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' }) end, group = vim.api.nvim_create_augroup('DirBufEnter', {}), }) end, }, { 'nvim-treesitter/nvim-treesitter', lazy = false, build = ':TSUpdate', config = function(_, opts) local tsconf = require('nvim-treesitter.parsers').get_parser_configs() tsconf.gotmpl = { install_info = { url = 'https://github.com/ngalaiko/tree-sitter-go-template', files = { 'src/parser.c' }, }, filetype = 'gotmpl', used_by = { 'gotmpl.html', 'gotmpl.yaml', 'gotmpl' }, } 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', }, }, refactor = { navigation = { enable = true, keymaps = { goto_definition = '', }, }, 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', }, }, }, }, }, { 'nvim-treesitter/nvim-treesitter-refactor', keys = { '', '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, }, { 'hrsh7th/nvim-cmp', event = { 'InsertEnter', 'CmdlineEnter' }, dependencies = { -- 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp-document-symbol', 'hrsh7th/cmp-nvim-lsp-signature-help', 'saadparwaiz1/cmp_luasnip', 'f3fora/cmp-spell', }, config = function() local cmp = require('cmp') local luasnip = require('luasnip') cmp.setup({ experimental = { ghost_text = true }, -- disable completion in comments enabled = function() 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 end) return not ok or enable end, preselect = cmp.PreselectMode.Item, window = { completion = { border = 'none', }, documentation = { border = 'solid', }, }, 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(function(fallback) if cmp.visible() then -- NOTE: poor mans replacement for cmp.confirm without expanding snippet cmp.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) cmp.close() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if luasnip.locally_jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), -- map c-j/k for luasnip choice nodes [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then luasnip.change_choice(1) else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then luasnip.change_choice(-1) else 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' }), }, snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'nvim_lsp_signature_help' }, { name = 'luasnip' }, { name = 'nvim_lua' }, }, { -- { 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' }, format = function(entry, item) local menus = { nvim_lsp = '░ lsp', luasnip = '░ snip', nvim_lua = '░ nvim', -- orgmode = '░ org', spell = '░ spell', path = '░ path', buffer = '░ buf', } item.kind = require('internal.lsp_symbols')[item.kind] or '' item.menu = menus[entry.source.name] return item end, expandable_indicator = true, }, }) cmp.setup.cmdline({ '/', '?', '@' }, { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'nvim_lsp_document_symbol' }, -- { name = 'buffer' } }), formatting = { fields = { 'abbr', 'menu' }, }, }) cmp.setup.cmdline(':', { mapping = { [''] = cmp.mapping({ c = function() vim.cmd.Telescope('command_history') end, }), [''] = cmp.mapping({ c = function() if cmp.visible() then cmp.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) end end, }), [''] = cmp.mapping({ c = function() if cmp.visible() then cmp.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) end end, }), }, sources = cmp.config.sources({ { name = 'path' }, }, { { name = 'cmdline' }, }), formatting = { 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, }, { 'L3MON4D3/LuaSnip', config = function() require('internal.snips') end, }, { 'nvim-telescope/telescope.nvim', cmd = 'Telescope', dependencies = { 'nvim-lua/popup.nvim', 'nvim-lua/plenary.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({ defaults = { prompt_prefix = '', selection_caret = '⯈ ', sorting_strategy = 'ascending', preview = false, results_title = false, layout_strategy = 'bottom_pane', layout_config = { -- preview_cutoff = 1, -- height = 20, }, border = true, borderchars = { preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, prompt = { '─', '', '', '', '╾', '╼', '', '' }, results = { '' }, }, 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 = { [''] = require('telescope.actions.layout').toggle_preview, }, n = { [''] = 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, }, }, ['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', }, { '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', }, }, }, { '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', }) end, }, { 'gentoo/gentoo-syntax', lazy = false }, { 'NMAC427/guess-indent.nvim', lazy = false, opts = { auto_cmd = true, filetype_exclude = { 'netrw', 'tutor', 'dirbuf' }, buftype_exclude = { 'help', 'nofile', 'terminal', 'prompt' }, }, }, { url = 'https://git.sr.ht/~robertgzr/spinner.nvim', opts = { spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, interval = 120, -- spinner frame rate in ms }, }, { '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() 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', 'css', 'scss', 'html', 'javascript' }, 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') 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, }, { 'mfussenegger/nvim-dap', dependencies = { 'nvim-telescope/telescope-dap.nvim' }, config = function() require('telescope').load_extension('dap') require('internal.dap') end, 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 { '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 }, -- }, }, { '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', }, 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', }, }, }, ['core.norg.completion'] = { config = { engine = 'nvim-cmp' }, }, ['core.integrations.telescope'] = {}, ['core.norg.qol.todo_items'] = {}, ['core.presenter'] = {}, ['core.gtd.base'] = { config = { workspace = 'gtd' }, }, }, }, }, { 'mickael-menu/zk-nvim', cmd = { 'ZkNew', 'ZkNotes' }, ft = { 'markdown', 'neorg' }, config = function() require('telescope').load_extension('zk') require('zk').setup({ picker = 'telescope', lsp = { config = { 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', 'neorg' }, }, }, }) end, keys = { { ';z', function() require('zk').edit(nil, { multi_select = false }) end, desc = 'zk', }, }, }, -- {'rhysd/vim-grammarous', -- ft = {'markdown', 'latex', 'tex'} -- }, { 'lervag/vimtex', ft = { 'latex', 'tex' }, config = function() 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, }, { 'plasticboy/vim-markdown', ft = 'markdown', 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 end, }, { 'folke/zen-mode.nvim', dependencies = { { 'folke/twilight.nvim', opts = { 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, }, }, plugins = { options = { enabled = true, ruler = false, showcmd = false, }, twilight = { enabled = true }, }, }, }, { 'folke/which-key.nvim', event = 'VeryLazy', opts = { icons = { separator = '→ ', group = '🞱 ' }, triggers = { '', '', ';', '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 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) 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 }) 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) label = label and (' ' .. label .. ' ') or '' opts = vim.tbl_extend('force', opts or {}, { position = 'center', hl = 'Comment' }) return { type = 'text', opts = opts, val = 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) 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) 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 = 'noop', opts = { position = 'center', hl = 'AlphaFortune', }, } end local mru = function(max_width) return { type = 'group', val = function() local items = {} -- initialize the oldfiles table local oldfiles = {} local cwd = vim.loop.cwd() for _, v in pairs(vim.v.oldfiles) do 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 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 fit_path(fn, max_width), ':edit ' .. fn .. ' ' ) ) end return items end, opts = { position = 'center', }, } end local buffers = function(max_width) return { type = 'group', val = function() local items = {} -- get listed buffers local bufnrs = vim.tbl_filter(function(bufnr) if 1 ~= vim.fn.buflisted(bufnr) then return false end return true end, vim.api.nvim_list_bufs()) --sort by last_used table.sort(bufnrs, function(a, b) return vim.fn.getbufinfo(a)[1].lastused > vim.fn.getbufinfo(b)[1].lastused end) -- exit early if there's nothing to show if not bufnrs or #bufnrs == 0 then return {} end table.insert(items, { type = 'padding', val = 1 }) table.insert(items, hr(0, max_width, 'Buffers')) 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 .. '')) end return items end, opts = { position = 'center', }, } end them.config.layout = { { type = 'padding', val = 2 }, require('alpha.themes.dashboard').section.header, { type = 'padding', val = 1 }, fortune(5, MAX_WIDTH), { type = 'padding', val = 1 }, hr(0, MAX_WIDTH), { type = 'padding', val = 1 }, { type = 'group', val = { button('e', '󰈔 new', [[ene startinsert]]), button('r', '󰈸 live grep', [[lua require('internal.misc').live_grep()]]), button('f', '󰝰 find files', [[lua require('internal.misc').find_files()]]), button('m', '󰥔 mru', [[lua require('telescope.builtin').oldfiles()]]), button( 'o', '󰃶 orgmode', [[lua require('orgmode').action('agenda.prompt')]] ), button( 't', '󰃶 todos', [[lua require('telescope._extensions.todo-comments').exports.todo {cwd=vim.env.ZK_NOTEBOOK_DIR}]] ), button('u', '󰚰 update plugins', [[lua require('lazy').update()]]), button( 'v', '󰂓 edit config', [[lua require('telescope.builtin').find_files {search_dirs={vim.env.HOME..'/.vim/'}}]] ), }, }, { type = 'padding', val = 1 }, mru(MAX_WIDTH), buffers(MAX_WIDTH), } alpha.setup(them.config) end, keys = { { 'a', vim.cmd.Alpha, desc = 'alpha' }, }, }, { 'ruifm/gitlinker.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, config = { opts = { -- action_callback = require('gitlinker.actions').copy_to_clipboard, }, }, 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', }, }, }, { '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, keys = { { 'gm', vim.cmd.GitMessenger, desc = 'git-messenger' }, }, }, { 'folke/todo-comments.nvim', cmd = { 'TodoTelescope' }, config = true, keys = { { ';t', vim.cmd.TodoTelescope, desc = 'todo-comments' }, }, }, { 'cbochs/grapple.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, cmd = 'GrapplePopup', opts = { popup_options = { border = 'none', }, }, keys = { { 'm', function() require('grapple').popup_tags() end, desc = 'grapple: show tags', }, { 'ms', function() require('grapple').popup_scopes() end, desc = 'grapple: show scopes', }, { 'mm', function() require('grapple').toggle() end, desc = 'grapple: anonymous tag', }, { 'mn', function() require('grapple').cycle_forward() end, desc = 'grapple: next tag', }, { 'mp', function() require('grapple').cycle_backward() end, desc = 'grapple: prev tag', }, }, }, { 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, }, { 'yorik1984/newpaper.nvim', lazy = false, priority = 1000, cond = vim.g.night_and_day == 'day', config = function() vim.cmd.colorscheme('newpaper') end, }, { 'nyoom-engineering/oxocarbon.nvim', lazy = false, enabled = false, priority = 1000, cond = vim.g.night_and_day == 'night', config = function() vim.opt.background = 'dark' vim.cmd.colorscheme('oxocarbon') end, }, } require('lazy').setup(pluginspec, { defaults = { lazy = true }, })