From 6bef8f32b19778fdfe52f0eb39719425508dcc7b Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 24 Apr 2025 11:36:39 +0300 Subject: Refactored nvim config to make it easier and less insanely nested --- .config/nvim/init.lua | 8 +- .config/nvim/lua/cmp_helper.lua | 143 +++++++++++++++++++ .config/nvim/lua/commands.lua | 121 ++++++++++++++++ .config/nvim/lua/custom/config/cmp.lua | 143 ------------------- .config/nvim/lua/custom/config/commands.lua | 121 ---------------- .config/nvim/lua/custom/config/dap-keymaps.lua | 18 --- .config/nvim/lua/custom/config/keymaps.lua | 99 ------------- .../nvim/lua/custom/config/language-servers.lua | 155 --------------------- .config/nvim/lua/custom/config/lsp-keymaps.lua | 73 ---------- .config/nvim/lua/custom/config/lsp.lua | 73 ---------- .config/nvim/lua/custom/config/lualine.lua | 92 ------------ .config/nvim/lua/custom/config/options.lua | 61 -------- .config/nvim/lua/custom/config/rustaceanvim.lua | 37 ----- .config/nvim/lua/custom/config/telescope.lua | 41 ------ .config/nvim/lua/custom/plugins/activity-watch.lua | 9 -- .config/nvim/lua/custom/plugins/alpha.lua | 69 --------- .config/nvim/lua/custom/plugins/auto-save.lua | 33 ----- .config/nvim/lua/custom/plugins/auto-session.lua | 29 ---- .config/nvim/lua/custom/plugins/buffer-manager.lua | 13 -- .config/nvim/lua/custom/plugins/buffer-vaccum.lua | 5 - .config/nvim/lua/custom/plugins/bullets.lua | 4 - .config/nvim/lua/custom/plugins/ccc.lua | 13 -- .../nvim/lua/custom/plugins/clangd_extensions.lua | 38 ----- .../nvim/lua/custom/plugins/code-playground.lua | 7 - .config/nvim/lua/custom/plugins/colorscheme.lua | 14 -- .config/nvim/lua/custom/plugins/comment.lua | 25 ---- .config/nvim/lua/custom/plugins/conform.lua | 38 ----- .config/nvim/lua/custom/plugins/diffview.lua | 20 --- .config/nvim/lua/custom/plugins/edgy.lua | 28 ---- .config/nvim/lua/custom/plugins/gitsigns.lua | 33 ----- .config/nvim/lua/custom/plugins/gopher.lua | 9 -- .config/nvim/lua/custom/plugins/harpoon.lua | 23 --- .config/nvim/lua/custom/plugins/helpview.lua | 7 - .../nvim/lua/custom/plugins/indent-blankline.lua | 11 -- .config/nvim/lua/custom/plugins/lazydev.lua | 12 -- .config/nvim/lua/custom/plugins/leap.lua | 15 -- .config/nvim/lua/custom/plugins/lsp-signature.lua | 12 -- .config/nvim/lua/custom/plugins/lspsaga.lua | 44 ------ .config/nvim/lua/custom/plugins/lualine.lua | 8 -- .../nvim/lua/custom/plugins/markdown-toggle.lua | 12 -- .config/nvim/lua/custom/plugins/mason.lua | 38 ----- .config/nvim/lua/custom/plugins/mini.lua | 16 --- .config/nvim/lua/custom/plugins/neogen.lua | 5 - .config/nvim/lua/custom/plugins/neogit.lua | 33 ----- .config/nvim/lua/custom/plugins/nvim-autopairs.lua | 11 -- .config/nvim/lua/custom/plugins/nvim-cmp.lua | 14 -- .config/nvim/lua/custom/plugins/nvim-dap-ui.lua | 26 ---- .config/nvim/lua/custom/plugins/nvim-dap.lua | 58 -------- .config/nvim/lua/custom/plugins/nvim-dbee.lua | 12 -- .config/nvim/lua/custom/plugins/nvim-java.lua | 5 - .config/nvim/lua/custom/plugins/nvim-lint.lua | 41 ------ .config/nvim/lua/custom/plugins/nvim-lspconfig.lua | 32 ----- .config/nvim/lua/custom/plugins/nvim-scrollbar.lua | 29 ---- .config/nvim/lua/custom/plugins/nvim-spectre.lua | 7 - .config/nvim/lua/custom/plugins/nvim-surround.lua | 21 --- .../nvim/lua/custom/plugins/nvim-treesitter.lua | 87 ------------ .../nvim/lua/custom/plugins/nvim-ts-autotag.lua | 5 - .config/nvim/lua/custom/plugins/octo.lua | 23 --- .config/nvim/lua/custom/plugins/oil.lua | 40 ------ .config/nvim/lua/custom/plugins/overseer.lua | 49 ------- .config/nvim/lua/custom/plugins/pretty-hover.lua | 5 - .../nvim/lua/custom/plugins/render-markdown.lua | 16 --- .config/nvim/lua/custom/plugins/rustaceanvim.lua | 8 -- .config/nvim/lua/custom/plugins/snacks.lua | 45 ------ .config/nvim/lua/custom/plugins/sqls.lua | 3 - .config/nvim/lua/custom/plugins/suda.lua | 4 - .config/nvim/lua/custom/plugins/telescope.lua | 22 --- .../lua/custom/plugins/tiny-inline-diagnostic.lua | 24 ---- .config/nvim/lua/custom/plugins/todo-comments.lua | 95 ------------- .config/nvim/lua/custom/plugins/trouble.lua | 40 ------ .config/nvim/lua/custom/plugins/undotree.lua | 14 -- .config/nvim/lua/custom/plugins/vim-be-good.lua | 4 - .config/nvim/lua/custom/plugins/vim-illuminate.lua | 7 - .../nvim/lua/custom/plugins/vim-tmux-navigator.lua | 9 -- .config/nvim/lua/custom/plugins/vim-wakatime.lua | 4 - .config/nvim/lua/custom/snippets/go.lua | 77 ---------- .config/nvim/lua/custom/snippets/lua.lua | 37 ----- .config/nvim/lua/dap-keymaps.lua | 18 +++ .config/nvim/lua/keymaps.lua | 99 +++++++++++++ .config/nvim/lua/language-servers.lua | 155 +++++++++++++++++++++ .config/nvim/lua/lsp-keymaps.lua | 73 ++++++++++ .config/nvim/lua/lsp.lua | 73 ++++++++++ .config/nvim/lua/lualine_helper.lua | 92 ++++++++++++ .config/nvim/lua/options.lua | 61 ++++++++ .config/nvim/lua/plugins/activity-watch.lua | 9 ++ .config/nvim/lua/plugins/alpha.lua | 69 +++++++++ .config/nvim/lua/plugins/auto-save.lua | 33 +++++ .config/nvim/lua/plugins/auto-session.lua | 29 ++++ .config/nvim/lua/plugins/buffer-manager.lua | 13 ++ .config/nvim/lua/plugins/buffer-vaccum.lua | 5 + .config/nvim/lua/plugins/bullets.lua | 4 + .config/nvim/lua/plugins/ccc.lua | 13 ++ .config/nvim/lua/plugins/clangd_extensions.lua | 38 +++++ .config/nvim/lua/plugins/code-playground.lua | 7 + .config/nvim/lua/plugins/colorscheme.lua | 14 ++ .config/nvim/lua/plugins/comment.lua | 25 ++++ .config/nvim/lua/plugins/conform.lua | 38 +++++ .config/nvim/lua/plugins/diffview.lua | 20 +++ .config/nvim/lua/plugins/edgy.lua | 28 ++++ .config/nvim/lua/plugins/gitsigns.lua | 33 +++++ .config/nvim/lua/plugins/gopher.lua | 9 ++ .config/nvim/lua/plugins/harpoon.lua | 23 +++ .config/nvim/lua/plugins/helpview.lua | 7 + .config/nvim/lua/plugins/indent-blankline.lua | 11 ++ .config/nvim/lua/plugins/lazydev.lua | 12 ++ .config/nvim/lua/plugins/leap.lua | 15 ++ .config/nvim/lua/plugins/lsp-signature.lua | 12 ++ .config/nvim/lua/plugins/lspsaga.lua | 44 ++++++ .config/nvim/lua/plugins/lualine.lua | 8 ++ .config/nvim/lua/plugins/markdown-toggle.lua | 12 ++ .config/nvim/lua/plugins/mason.lua | 38 +++++ .config/nvim/lua/plugins/mini.lua | 16 +++ .config/nvim/lua/plugins/neogen.lua | 5 + .config/nvim/lua/plugins/neogit.lua | 33 +++++ .config/nvim/lua/plugins/nvim-autopairs.lua | 11 ++ .config/nvim/lua/plugins/nvim-cmp.lua | 14 ++ .config/nvim/lua/plugins/nvim-dap-ui.lua | 26 ++++ .config/nvim/lua/plugins/nvim-dap.lua | 58 ++++++++ .config/nvim/lua/plugins/nvim-dbee.lua | 12 ++ .config/nvim/lua/plugins/nvim-java.lua | 5 + .config/nvim/lua/plugins/nvim-lint.lua | 41 ++++++ .config/nvim/lua/plugins/nvim-lspconfig.lua | 32 +++++ .config/nvim/lua/plugins/nvim-scrollbar.lua | 29 ++++ .config/nvim/lua/plugins/nvim-spectre.lua | 7 + .config/nvim/lua/plugins/nvim-surround.lua | 21 +++ .config/nvim/lua/plugins/nvim-treesitter.lua | 87 ++++++++++++ .config/nvim/lua/plugins/nvim-ts-autotag.lua | 5 + .config/nvim/lua/plugins/octo.lua | 23 +++ .config/nvim/lua/plugins/oil.lua | 40 ++++++ .config/nvim/lua/plugins/overseer.lua | 49 +++++++ .config/nvim/lua/plugins/pretty-hover.lua | 5 + .config/nvim/lua/plugins/render-markdown.lua | 16 +++ .config/nvim/lua/plugins/rustaceanvim.lua | 8 ++ .config/nvim/lua/plugins/snacks.lua | 45 ++++++ .config/nvim/lua/plugins/sqls.lua | 3 + .config/nvim/lua/plugins/suda.lua | 4 + .config/nvim/lua/plugins/telescope.lua | 22 +++ .../nvim/lua/plugins/tiny-inline-diagnostic.lua | 24 ++++ .config/nvim/lua/plugins/todo-comments.lua | 95 +++++++++++++ .config/nvim/lua/plugins/trouble.lua | 40 ++++++ .config/nvim/lua/plugins/undotree.lua | 14 ++ .config/nvim/lua/plugins/vim-be-good.lua | 4 + .config/nvim/lua/plugins/vim-illuminate.lua | 7 + .config/nvim/lua/plugins/vim-tmux-navigator.lua | 9 ++ .config/nvim/lua/plugins/vim-wakatime.lua | 4 + .config/nvim/lua/rustaceanvim.lua | 37 +++++ .config/nvim/lua/snippets/go.lua | 77 ++++++++++ .config/nvim/lua/snippets/lua.lua | 37 +++++ .config/nvim/lua/telescope_helper.lua | 41 ++++++ 149 files changed, 2414 insertions(+), 2414 deletions(-) create mode 100644 .config/nvim/lua/cmp_helper.lua create mode 100644 .config/nvim/lua/commands.lua delete mode 100644 .config/nvim/lua/custom/config/cmp.lua delete mode 100644 .config/nvim/lua/custom/config/commands.lua delete mode 100644 .config/nvim/lua/custom/config/dap-keymaps.lua delete mode 100644 .config/nvim/lua/custom/config/keymaps.lua delete mode 100644 .config/nvim/lua/custom/config/language-servers.lua delete mode 100644 .config/nvim/lua/custom/config/lsp-keymaps.lua delete mode 100644 .config/nvim/lua/custom/config/lsp.lua delete mode 100644 .config/nvim/lua/custom/config/lualine.lua delete mode 100644 .config/nvim/lua/custom/config/options.lua delete mode 100644 .config/nvim/lua/custom/config/rustaceanvim.lua delete mode 100644 .config/nvim/lua/custom/config/telescope.lua delete mode 100644 .config/nvim/lua/custom/plugins/activity-watch.lua delete mode 100644 .config/nvim/lua/custom/plugins/alpha.lua delete mode 100644 .config/nvim/lua/custom/plugins/auto-save.lua delete mode 100644 .config/nvim/lua/custom/plugins/auto-session.lua delete mode 100644 .config/nvim/lua/custom/plugins/buffer-manager.lua delete mode 100644 .config/nvim/lua/custom/plugins/buffer-vaccum.lua delete mode 100644 .config/nvim/lua/custom/plugins/bullets.lua delete mode 100644 .config/nvim/lua/custom/plugins/ccc.lua delete mode 100644 .config/nvim/lua/custom/plugins/clangd_extensions.lua delete mode 100644 .config/nvim/lua/custom/plugins/code-playground.lua delete mode 100644 .config/nvim/lua/custom/plugins/colorscheme.lua delete mode 100644 .config/nvim/lua/custom/plugins/comment.lua delete mode 100644 .config/nvim/lua/custom/plugins/conform.lua delete mode 100644 .config/nvim/lua/custom/plugins/diffview.lua delete mode 100644 .config/nvim/lua/custom/plugins/edgy.lua delete mode 100644 .config/nvim/lua/custom/plugins/gitsigns.lua delete mode 100644 .config/nvim/lua/custom/plugins/gopher.lua delete mode 100644 .config/nvim/lua/custom/plugins/harpoon.lua delete mode 100644 .config/nvim/lua/custom/plugins/helpview.lua delete mode 100644 .config/nvim/lua/custom/plugins/indent-blankline.lua delete mode 100644 .config/nvim/lua/custom/plugins/lazydev.lua delete mode 100644 .config/nvim/lua/custom/plugins/leap.lua delete mode 100644 .config/nvim/lua/custom/plugins/lsp-signature.lua delete mode 100644 .config/nvim/lua/custom/plugins/lspsaga.lua delete mode 100644 .config/nvim/lua/custom/plugins/lualine.lua delete mode 100644 .config/nvim/lua/custom/plugins/markdown-toggle.lua delete mode 100644 .config/nvim/lua/custom/plugins/mason.lua delete mode 100644 .config/nvim/lua/custom/plugins/mini.lua delete mode 100644 .config/nvim/lua/custom/plugins/neogen.lua delete mode 100644 .config/nvim/lua/custom/plugins/neogit.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-autopairs.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-cmp.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-dap-ui.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-dap.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-dbee.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-java.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-lint.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-lspconfig.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-scrollbar.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-spectre.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-surround.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-treesitter.lua delete mode 100644 .config/nvim/lua/custom/plugins/nvim-ts-autotag.lua delete mode 100644 .config/nvim/lua/custom/plugins/octo.lua delete mode 100644 .config/nvim/lua/custom/plugins/oil.lua delete mode 100644 .config/nvim/lua/custom/plugins/overseer.lua delete mode 100644 .config/nvim/lua/custom/plugins/pretty-hover.lua delete mode 100644 .config/nvim/lua/custom/plugins/render-markdown.lua delete mode 100644 .config/nvim/lua/custom/plugins/rustaceanvim.lua delete mode 100644 .config/nvim/lua/custom/plugins/snacks.lua delete mode 100644 .config/nvim/lua/custom/plugins/sqls.lua delete mode 100644 .config/nvim/lua/custom/plugins/suda.lua delete mode 100644 .config/nvim/lua/custom/plugins/telescope.lua delete mode 100644 .config/nvim/lua/custom/plugins/tiny-inline-diagnostic.lua delete mode 100644 .config/nvim/lua/custom/plugins/todo-comments.lua delete mode 100644 .config/nvim/lua/custom/plugins/trouble.lua delete mode 100644 .config/nvim/lua/custom/plugins/undotree.lua delete mode 100644 .config/nvim/lua/custom/plugins/vim-be-good.lua delete mode 100644 .config/nvim/lua/custom/plugins/vim-illuminate.lua delete mode 100644 .config/nvim/lua/custom/plugins/vim-tmux-navigator.lua delete mode 100644 .config/nvim/lua/custom/plugins/vim-wakatime.lua delete mode 100644 .config/nvim/lua/custom/snippets/go.lua delete mode 100644 .config/nvim/lua/custom/snippets/lua.lua create mode 100644 .config/nvim/lua/dap-keymaps.lua create mode 100644 .config/nvim/lua/keymaps.lua create mode 100644 .config/nvim/lua/language-servers.lua create mode 100644 .config/nvim/lua/lsp-keymaps.lua create mode 100644 .config/nvim/lua/lsp.lua create mode 100644 .config/nvim/lua/lualine_helper.lua create mode 100644 .config/nvim/lua/options.lua create mode 100644 .config/nvim/lua/plugins/activity-watch.lua create mode 100644 .config/nvim/lua/plugins/alpha.lua create mode 100644 .config/nvim/lua/plugins/auto-save.lua create mode 100644 .config/nvim/lua/plugins/auto-session.lua create mode 100644 .config/nvim/lua/plugins/buffer-manager.lua create mode 100644 .config/nvim/lua/plugins/buffer-vaccum.lua create mode 100644 .config/nvim/lua/plugins/bullets.lua create mode 100644 .config/nvim/lua/plugins/ccc.lua create mode 100644 .config/nvim/lua/plugins/clangd_extensions.lua create mode 100644 .config/nvim/lua/plugins/code-playground.lua create mode 100644 .config/nvim/lua/plugins/colorscheme.lua create mode 100644 .config/nvim/lua/plugins/comment.lua create mode 100644 .config/nvim/lua/plugins/conform.lua create mode 100644 .config/nvim/lua/plugins/diffview.lua create mode 100644 .config/nvim/lua/plugins/edgy.lua create mode 100644 .config/nvim/lua/plugins/gitsigns.lua create mode 100644 .config/nvim/lua/plugins/gopher.lua create mode 100644 .config/nvim/lua/plugins/harpoon.lua create mode 100644 .config/nvim/lua/plugins/helpview.lua create mode 100644 .config/nvim/lua/plugins/indent-blankline.lua create mode 100644 .config/nvim/lua/plugins/lazydev.lua create mode 100644 .config/nvim/lua/plugins/leap.lua create mode 100644 .config/nvim/lua/plugins/lsp-signature.lua create mode 100644 .config/nvim/lua/plugins/lspsaga.lua create mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/markdown-toggle.lua create mode 100644 .config/nvim/lua/plugins/mason.lua create mode 100644 .config/nvim/lua/plugins/mini.lua create mode 100644 .config/nvim/lua/plugins/neogen.lua create mode 100644 .config/nvim/lua/plugins/neogit.lua create mode 100644 .config/nvim/lua/plugins/nvim-autopairs.lua create mode 100644 .config/nvim/lua/plugins/nvim-cmp.lua create mode 100644 .config/nvim/lua/plugins/nvim-dap-ui.lua create mode 100644 .config/nvim/lua/plugins/nvim-dap.lua create mode 100644 .config/nvim/lua/plugins/nvim-dbee.lua create mode 100644 .config/nvim/lua/plugins/nvim-java.lua create mode 100644 .config/nvim/lua/plugins/nvim-lint.lua create mode 100644 .config/nvim/lua/plugins/nvim-lspconfig.lua create mode 100644 .config/nvim/lua/plugins/nvim-scrollbar.lua create mode 100644 .config/nvim/lua/plugins/nvim-spectre.lua create mode 100644 .config/nvim/lua/plugins/nvim-surround.lua create mode 100644 .config/nvim/lua/plugins/nvim-treesitter.lua create mode 100644 .config/nvim/lua/plugins/nvim-ts-autotag.lua create mode 100644 .config/nvim/lua/plugins/octo.lua create mode 100644 .config/nvim/lua/plugins/oil.lua create mode 100644 .config/nvim/lua/plugins/overseer.lua create mode 100644 .config/nvim/lua/plugins/pretty-hover.lua create mode 100644 .config/nvim/lua/plugins/render-markdown.lua create mode 100644 .config/nvim/lua/plugins/rustaceanvim.lua create mode 100644 .config/nvim/lua/plugins/snacks.lua create mode 100644 .config/nvim/lua/plugins/sqls.lua create mode 100644 .config/nvim/lua/plugins/suda.lua create mode 100644 .config/nvim/lua/plugins/telescope.lua create mode 100644 .config/nvim/lua/plugins/tiny-inline-diagnostic.lua create mode 100644 .config/nvim/lua/plugins/todo-comments.lua create mode 100644 .config/nvim/lua/plugins/trouble.lua create mode 100644 .config/nvim/lua/plugins/undotree.lua create mode 100644 .config/nvim/lua/plugins/vim-be-good.lua create mode 100644 .config/nvim/lua/plugins/vim-illuminate.lua create mode 100644 .config/nvim/lua/plugins/vim-tmux-navigator.lua create mode 100644 .config/nvim/lua/plugins/vim-wakatime.lua create mode 100644 .config/nvim/lua/rustaceanvim.lua create mode 100644 .config/nvim/lua/snippets/go.lua create mode 100644 .config/nvim/lua/snippets/lua.lua create mode 100644 .config/nvim/lua/telescope_helper.lua (limited to '.config/nvim') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index a8d2c53..111d5c4 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -3,10 +3,10 @@ vim.loader.enable() vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -require('custom.config.options') +require('options') vim.schedule(function() - require('custom.config.keymaps') - require('custom.config.commands') + require('keymaps') + require('commands') end) local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' @@ -21,7 +21,7 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then }) end vim.opt.rtp:prepend(lazypath) -require('lazy').setup({ import = 'custom/plugins' }, { +require('lazy').setup({ import = 'plugins' }, { change_detection = { enabled = true, notify = false }, defaults = { lazy = true }, ui = { diff --git a/.config/nvim/lua/cmp_helper.lua b/.config/nvim/lua/cmp_helper.lua new file mode 100644 index 0000000..ffa3418 --- /dev/null +++ b/.config/nvim/lua/cmp_helper.lua @@ -0,0 +1,143 @@ +-- Load cmp_opts +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/snippets/*.lua', true)) do + loadfile(ft_path)() +end + +local luasnip = require('luasnip') +local lspkind = require('lspkind') +local cmp = require('cmp') + +-- Enable paretheses for function completions +cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done()) + +-- Helper functions +local function snippet_jump(jump_amount) + return cmp.mapping(function(fallback) + if luasnip.locally_jumpable(jump_amount) then + luasnip.jump(jump_amount) + else + fallback() + end + end, { 'i', 's' }) +end + +local function is_enabled() + local context = require('cmp.config.context') + + local is_in_comment = context.in_treesitter_capture('comment') or context.in_syntax_group('Comment') + if is_in_comment then + return false + end + + return true +end + +cmp.setup({ + enabled = is_enabled, + preselect = cmp.PreselectMode.None, + completion = { completeopt = 'menu,menuone,noinsert' }, + sources = cmp.config.sources({ + { name = 'luasnip' }, -- for snippets + { + name = 'nvim_lsp', + option = { + markdown_oxide = { + keyword_pattern = [[\(\k\| \|\/\|#\)\+]], + }, + }, + }, -- for lsp + { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim + { name = 'path' }, -- for filesystem + }, {}), + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + documentation = cmp.config.window.bordered(), + completion = { + border = 'rounded', + winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None', + col_offset = -3, + side_padding = 0, + }, + }, + ---@diagnostic disable-next-line: missing-fields + 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 = { + [''] = snippet_jump(1), + [''] = snippet_jump(-1), + [''] = cmp.mapping.complete(), -- invoke completion + [''] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + }, + ---@diagnostic disable-next-line: missing-fields + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item) + local strings = vim.split(kind.kind, '%s', { trimempty = true }) + kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) + kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text) + return kind + end, + }, +}) + +-- -- Customization for Pmenu +-- vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' }) +-- vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' }) +-- +vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#ff8294', bg = 'NONE', strikethrough = true }) +-- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true }) +-- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true }) +-- vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' }) +-- +-- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' }) +-- vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' }) diff --git a/.config/nvim/lua/commands.lua b/.config/nvim/lua/commands.lua new file mode 100644 index 0000000..7135eeb --- /dev/null +++ b/.config/nvim/lua/commands.lua @@ -0,0 +1,121 @@ +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking text', + group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +vim.api.nvim_create_autocmd('BufEnter', { + desc = 'Disable newlines on commented lines from continuing the comment', + group = vim.api.nvim_create_augroup('disable-comments-continuation', { clear = true }), + callback = function() + -- vim.opt_local.formatoptions:remove('r') -- no comments on enter + vim.opt_local.formatoptions:remove('o') -- no comments on `o` or `O` + end, +}) + +vim.api.nvim_create_user_command('Format', function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ['end'] = { args.line2, end_line:len() }, + } + end + require('conform').format({ async = true, lsp_format = 'fallback', range = range }) +end, { range = true }) + +vim.api.nvim_create_user_command('FormatToggle', function(args) + local is_global = not args.bang + if is_global then + vim.g.disable_autoformat = not vim.g.disable_autoformat + if vim.g.disable_autoformat then + Snacks.notify.info('Autoformat on save disabled globally', { title = 'test' }) + else + Snacks.notify.info('Autoformat on save enabled globally') + end + else + vim.b.disable_autoformat = not vim.b.disable_autoformat + if vim.b.disable_autoformat then + Snacks.notify.info('Autoformat on save disabled for this buffer') + else + Snacks.notify.info('Autoformat on save enabled for this buffer') + end + end +end, { + desc = 'Toggle autoformat on save', + bang = true, +}) + +-- NOTE: highlight %v, %s etc in go string literals +vim.api.nvim_create_autocmd({ 'BufEnter', 'TextChanged', 'InsertLeave' }, { + pattern = '*.go', + callback = function() + local query = vim.treesitter.query.parse('go', '(interpreted_string_literal) @string') + local parser = vim.treesitter.get_parser(0, 'go') + local tree = parser:parse()[1] + local root = tree:root() + local bufnr = vim.api.nvim_get_current_buf() + + for id, node in query:iter_captures(root, bufnr, 0, -1) do + if query.captures[id] == 'string' then + local start_row, start_col, end_row, end_col = node:range() + + -- Get the text of the string literal + local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] + + -- Highlight only the parts matching `%[a-z]` + for match_start, match_end in text:gmatch('()%%[a-z]()') do + vim.api.nvim_buf_add_highlight( + bufnr, + -1, + '@lsp.type.formatSpecifier.go', -- Higlight group + start_row, + start_col + match_start - 1, + start_col + match_end - 1 + ) + end + end + end + end, +}) + +-- NOTE: show unused zig variables as "DiagnosticUnnecessary" instead of error +local orig_underline_show = vim.diagnostic.handlers.underline.show +local custom_ns = vim.api.nvim_create_namespace('custom_unused_ns') + +vim.diagnostic.handlers.underline.show = function(namespace, bufnr, diagnostics, opts) + local normal_diags = {} + local custom_diags = {} + for _, diag in ipairs(diagnostics) do + if diag.message:find('unused', 1, true) then + table.insert(custom_diags, diag) + else + table.insert(normal_diags, diag) + end + end + if #normal_diags > 0 and orig_underline_show ~= nil then + orig_underline_show(namespace, bufnr, normal_diags, opts) + end + for _, diag in ipairs(custom_diags) do + vim.highlight.range( + bufnr, + custom_ns, + 'DiagnosticUnnecessary', + { diag.lnum, diag.col }, + { diag.end_lnum, diag.end_col }, + { inclusive = false } + ) + end +end + +local orig_underline_hide = vim.diagnostic.handlers.underline.hide + +vim.diagnostic.handlers.underline.hide = function(namespace, bufnr) + if orig_underline_hide ~= nil then + orig_underline_hide(namespace, bufnr) + end + vim.api.nvim_buf_clear_namespace(bufnr, custom_ns, 0, -1) +end diff --git a/.config/nvim/lua/custom/config/cmp.lua b/.config/nvim/lua/custom/config/cmp.lua deleted file mode 100644 index e9f657c..0000000 --- a/.config/nvim/lua/custom/config/cmp.lua +++ /dev/null @@ -1,143 +0,0 @@ --- Load cmp_opts -for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do - loadfile(ft_path)() -end - -local luasnip = require('luasnip') -local lspkind = require('lspkind') -local cmp = require('cmp') - --- Enable paretheses for function completions -cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done()) - --- Helper functions -local function snippet_jump(jump_amount) - return cmp.mapping(function(fallback) - if luasnip.locally_jumpable(jump_amount) then - luasnip.jump(jump_amount) - else - fallback() - end - end, { 'i', 's' }) -end - -local function is_enabled() - local context = require('cmp.config.context') - - local is_in_comment = context.in_treesitter_capture('comment') or context.in_syntax_group('Comment') - if is_in_comment then - return false - end - - return true -end - -cmp.setup({ - enabled = is_enabled, - preselect = cmp.PreselectMode.None, - completion = { completeopt = 'menu,menuone,noinsert' }, - sources = cmp.config.sources({ - { name = 'luasnip' }, -- for snippets - { - name = 'nvim_lsp', - option = { - markdown_oxide = { - keyword_pattern = [[\(\k\| \|\/\|#\)\+]], - }, - }, - }, -- for lsp - { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim - { name = 'path' }, -- for filesystem - }, {}), - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - window = { - documentation = cmp.config.window.bordered(), - completion = { - border = 'rounded', - winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None', - col_offset = -3, - side_padding = 0, - }, - }, - ---@diagnostic disable-next-line: missing-fields - 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 = { - [''] = snippet_jump(1), - [''] = snippet_jump(-1), - [''] = cmp.mapping.complete(), -- invoke completion - [''] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), - [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), - }, - ---@diagnostic disable-next-line: missing-fields - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item) - local strings = vim.split(kind.kind, '%s', { trimempty = true }) - kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) - kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text) - return kind - end, - }, -}) - --- -- Customization for Pmenu --- vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' }) --- vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' }) --- -vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#ff8294', bg = 'NONE', strikethrough = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' }) diff --git a/.config/nvim/lua/custom/config/commands.lua b/.config/nvim/lua/custom/config/commands.lua deleted file mode 100644 index 7135eeb..0000000 --- a/.config/nvim/lua/custom/config/commands.lua +++ /dev/null @@ -1,121 +0,0 @@ -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking text', - group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - -vim.api.nvim_create_autocmd('BufEnter', { - desc = 'Disable newlines on commented lines from continuing the comment', - group = vim.api.nvim_create_augroup('disable-comments-continuation', { clear = true }), - callback = function() - -- vim.opt_local.formatoptions:remove('r') -- no comments on enter - vim.opt_local.formatoptions:remove('o') -- no comments on `o` or `O` - end, -}) - -vim.api.nvim_create_user_command('Format', function(args) - local range = nil - if args.count ~= -1 then - local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] - range = { - start = { args.line1, 0 }, - ['end'] = { args.line2, end_line:len() }, - } - end - require('conform').format({ async = true, lsp_format = 'fallback', range = range }) -end, { range = true }) - -vim.api.nvim_create_user_command('FormatToggle', function(args) - local is_global = not args.bang - if is_global then - vim.g.disable_autoformat = not vim.g.disable_autoformat - if vim.g.disable_autoformat then - Snacks.notify.info('Autoformat on save disabled globally', { title = 'test' }) - else - Snacks.notify.info('Autoformat on save enabled globally') - end - else - vim.b.disable_autoformat = not vim.b.disable_autoformat - if vim.b.disable_autoformat then - Snacks.notify.info('Autoformat on save disabled for this buffer') - else - Snacks.notify.info('Autoformat on save enabled for this buffer') - end - end -end, { - desc = 'Toggle autoformat on save', - bang = true, -}) - --- NOTE: highlight %v, %s etc in go string literals -vim.api.nvim_create_autocmd({ 'BufEnter', 'TextChanged', 'InsertLeave' }, { - pattern = '*.go', - callback = function() - local query = vim.treesitter.query.parse('go', '(interpreted_string_literal) @string') - local parser = vim.treesitter.get_parser(0, 'go') - local tree = parser:parse()[1] - local root = tree:root() - local bufnr = vim.api.nvim_get_current_buf() - - for id, node in query:iter_captures(root, bufnr, 0, -1) do - if query.captures[id] == 'string' then - local start_row, start_col, end_row, end_col = node:range() - - -- Get the text of the string literal - local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] - - -- Highlight only the parts matching `%[a-z]` - for match_start, match_end in text:gmatch('()%%[a-z]()') do - vim.api.nvim_buf_add_highlight( - bufnr, - -1, - '@lsp.type.formatSpecifier.go', -- Higlight group - start_row, - start_col + match_start - 1, - start_col + match_end - 1 - ) - end - end - end - end, -}) - --- NOTE: show unused zig variables as "DiagnosticUnnecessary" instead of error -local orig_underline_show = vim.diagnostic.handlers.underline.show -local custom_ns = vim.api.nvim_create_namespace('custom_unused_ns') - -vim.diagnostic.handlers.underline.show = function(namespace, bufnr, diagnostics, opts) - local normal_diags = {} - local custom_diags = {} - for _, diag in ipairs(diagnostics) do - if diag.message:find('unused', 1, true) then - table.insert(custom_diags, diag) - else - table.insert(normal_diags, diag) - end - end - if #normal_diags > 0 and orig_underline_show ~= nil then - orig_underline_show(namespace, bufnr, normal_diags, opts) - end - for _, diag in ipairs(custom_diags) do - vim.highlight.range( - bufnr, - custom_ns, - 'DiagnosticUnnecessary', - { diag.lnum, diag.col }, - { diag.end_lnum, diag.end_col }, - { inclusive = false } - ) - end -end - -local orig_underline_hide = vim.diagnostic.handlers.underline.hide - -vim.diagnostic.handlers.underline.hide = function(namespace, bufnr) - if orig_underline_hide ~= nil then - orig_underline_hide(namespace, bufnr) - end - vim.api.nvim_buf_clear_namespace(bufnr, custom_ns, 0, -1) -end diff --git a/.config/nvim/lua/custom/config/dap-keymaps.lua b/.config/nvim/lua/custom/config/dap-keymaps.lua deleted file mode 100644 index 8c3d540..0000000 --- a/.config/nvim/lua/custom/config/dap-keymaps.lua +++ /dev/null @@ -1,18 +0,0 @@ -local keymaps = { - { 'n', 'dr', 'DapContinue', { desc = '[D]ebug [R]esume (or start)' } }, - { 'n', 'dR', 'DapRestartFrame', { desc = '[D]ebug [R]estart' } }, - { 'n', 'dt', 'DapRestartFrame', { desc = '[D]ebug [R]estart' } }, - { 'n', 'dp', 'DapToggleBreakpoint', { desc = '[D]ebug Break[p]oint' } }, - { 'n', 'dh', 'lua require("dap.ui.widgets").hover()', { desc = '[D]ebug [H]over' } }, - { 'n', 'si', 'DapStepInto', { desc = '[S]tep [I]nto' } }, - { 'n', 'so', 'DapStepOver', { desc = '[S]tep [O]ver' } }, - { 'n', 'sO', 'DapStepOut', { desc = '[S]tep [O]ut' } }, -} - -for _, keymap in ipairs(keymaps) do - local mode = keymap[1] - local lhs = keymap[2] - local rhs = keymap[3] - local opts = keymap[4] or {} - vim.keymap.set(mode, lhs, rhs, opts) -end diff --git a/.config/nvim/lua/custom/config/keymaps.lua b/.config/nvim/lua/custom/config/keymaps.lua deleted file mode 100644 index 36134dd..0000000 --- a/.config/nvim/lua/custom/config/keymaps.lua +++ /dev/null @@ -1,99 +0,0 @@ -local set = vim.keymap.set -local silent = { silent = true } ----@param mode string|table ----@param keymap string -local function unbind(mode, keymap) - set(mode, keymap, function() end) -end - -local function toggle_zen() - vim.cmd('Neotree close') - vim.cmd('Trouble todo close') - vim.cmd('UndotreeHide') -end - -local function yank_filepath_to_clipboard(os) - return function() - local filepath = vim.fn.expand('%:p') - if os == 'linux' then - local home_dir = vim.fn.expand('~') - filepath = filepath:gsub(home_dir, '~') - elseif os == 'windows' then - local mnt = '/mnt/' - if filepath:sub(1, #mnt) == mnt then - filepath = filepath:sub(#mnt + 1, #mnt + 1) .. ':' .. filepath:sub(#mnt + 2) - else - filepath = '//wsl.localhost/openSUSE-Tumbleweed' .. filepath - end - filepath = filepath:gsub('/', '\\') - end - vim.fn.setreg('+', filepath) - end -end - -function RemoveClipboardCR() - local clipboard = vim.fn.getreg('+'):gsub('\r', '') - vim.fn.setreg('+', clipboard) -end - -local function paste() - RemoveClipboardCR() - local value = vim.fn.getreg('+') - if vim.fn.mode() == 'c' then - -- value = vim.split(value, '\n')[1] -- only use first line (default with normal pasting) - value = value:gsub('\n', ' ') -- replace newlines with spaces - vim.api.nvim_feedkeys(value, 'c', false) - else - vim.api.nvim_put(vim.split(value, '\n'), 'c', false, true) - end -end - --- "Greatest Keymap ever" - ThePrimeagen --- https://www.youtube.com/watch?v=qZO9A5F6BZs&list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&index=4 -set('x', 'p', 'lua RemoveClipboardCR()"_dP') - -set({ 'n', 'x' }, 'p', 'lua RemoveClipboardCR()p', { noremap = true }) -set({ 'n', 'x' }, 'P', 'lua RemoveClipboardCR()P', { noremap = true }) - --- Move lines around -set('n', '', ":m .+1", { noremap = true }) -set('n', '', ":m .-2", { noremap = true }) -set('v', '', ":m '>+1gv", { noremap = true }) -set('v', '', ":m '<-2gv", { noremap = true }) - --- Misc -set({ 'n', 'i' }, '', 'ggVG', { desc = 'Visually Highlight [A]ll' }) -set('i', '', '', { desc = 'Ctrl + Backspace to delete word' }) -set('n', '', 'nohlsearch', silent) -set({ 'i', 'c' }, '', paste) -set('n', 'z', toggle_zen, { desc = '[Z]en Mode', silent = true }) -unbind({ 'i', 'n', 'v' }, '') - -set('n', 'U', 'redo') -set('i', '', 'undo') -set({ 'i', 'n', 'v' }, '', 'wqa') -set('n', 'yp', yank_filepath_to_clipboard('linux'), { desc = '[Y]oink File [P]ath (linux)' }) -set('n', 'yP', yank_filepath_to_clipboard('windows'), { desc = '[Y]oink File [P]ath (windows)' }) - --- Window Navigation - NO NEED BECAUSE IT CONFLICTS WITH TMUX --- set('n', '', '', { desc = 'Move focus to the left window' }) --- set('n', '', '', { desc = 'Move focus to the down window' }) --- set('n', '', '', { desc = 'Move focus to the up window' }) --- set('n', '', '', { desc = 'Move focus to the right window' }) - --- Window resizing -local resize = 2 -set({ 'n', 't' }, '', string.format('vertical resize -%d', resize), { desc = 'Resize Left' }) -set({ 'n', 't' }, '', string.format('resize -%d', resize), { desc = 'Resize Up' }) -set({ 'n', 't' }, '', string.format('resize +%d', resize), { desc = 'Resize Down' }) -set({ 'n', 't' }, '', string.format('vertical resize +%d', resize), { desc = 'Resize Right' }) - --- Keep selection after < and > in visual mode -set('v', '<', '', '>gv') --- Execute lua file or line -set('n', 'x', '.lua', { desc = 'Execute the current line' }) -set('n', 'x', 'source %', { desc = 'Execute the current file' }) - --- Reformats file using lsp -set('n', '=', vim.lsp.buf.format, { desc = 'Format File' }) diff --git a/.config/nvim/lua/custom/config/language-servers.lua b/.config/nvim/lua/custom/config/language-servers.lua deleted file mode 100644 index f7e28c1..0000000 --- a/.config/nvim/lua/custom/config/language-servers.lua +++ /dev/null @@ -1,155 +0,0 @@ --- NOTE: a table or true to enable, false to disable -return { - lua_ls = { - settings = { - diagnostics = { globals = { 'vim' } }, - telemetry = { enabled = false }, - hint = { enable = true }, - workspace = { - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.stdpath('config') .. '/lua'] = true, - }, - }, - }, - }, -- lua - clangd = { - mason = false, - cmd = { - 'clangd', - '--background-index', - '--clang-tidy', - '--header-insertion=iwyu', - '--completion-style=detailed', - '--function-arg-placeholders', - '--fallback-style=llvm', - }, - root_dir = function(filename) - return require('lspconfig/util').root_pattern( - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - '.git' - )(filename) or vim.fn.getcwd() - end, - init_options = { - usePlaceholders = true, - completeUnimported = true, - clangdFileStatus = true, - }, - }, -- c/cpp - neocmake = { - root_dir = function(filename) - return require('lspconfig/util').root_pattern( - 'CMakePresets.json', - 'CTestConfig.cmake', - 'build', - 'cmake', - '.git' -- NOTE: git is last due to monorepos (so it tries to use build/cmake first) - )(filename) or vim.fn.getcwd() - end, - }, - pyright = { - settings = { - python = { - pythonPath = '~/python/venv/bin/python', - }, - }, - }, -- python - bashls = true, -- bash - taplo = true, -- toml - lemminx = true, -- xml - yamlls = true, -- yaml - jsonls = true, -- json - html = true, -- html - cssls = true, -- css - ts_ls = true, -- javascript/typescript - astro = true, -- astro framework - mdx_analyzer = true, -- markdown with JS I think - -- marksman = true, -- Markdown LSP - markdown_oxide = true, -- Markdown LSP but better - gopls = { - cmd = { 'gopls' }, - filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, - root_dir = function(filename) - return require('lspconfig/util').root_pattern('go.work', 'go.mod', '.git')(filename) - end, - settings = { - gopls = { - gofumpt = true, - codelenses = { - gc_details = false, - generate = true, - regenerate_cgo = true, - run_govulncheck = true, - test = true, - tidy = true, - upgrade_dependency = true, - vendor = true, - }, - hints = { - assignVariableTypes = false, - compositeLiteralFields = false, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = false, - parameterNames = false, - rangeVariableTypes = true, - }, - analyses = { - fieldalignment = true, - nilness = true, - unusedparams = true, - unusedwrite = true, - useany = true, - }, - usePlaceholders = false, - completeUnimported = true, - staticcheck = true, - directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' }, - semanticTokens = true, - }, - }, - }, -- Go LSP - jdtls = true, -- java - -- sqlls = true, - -- sqls = { - -- on_attach = function(client, bufnr) - -- require('sqls').on_attach(client, bufnr) - -- end, - -- settings = { - -- sqls = { - -- connections = { - -- { - -- driver = 'sqlite3', - -- dataSourceName = '/home/kyren/projects/eko/server.db', - -- }, - -- }, - -- }, - -- }, - -- }, - zls = { - mason = false, - cmd = { 'zls' }, - settings = { - zls = { - enable_build_on_save = true, - build_on_save_args = {}, - enable_argument_placeholders = false, - warn_style = true, - - inlay_hints_show_variable_type_hints = true, - inlay_hints_show_struct_literal_field_type = true, - inlay_hints_show_parameter_name = true, - inlay_hints_show_builtin = true, - inlay_hints_hide_redundant_param_names = true, - inlay_hints_hide_redundant_param_names_last_token = true, - }, - }, - }, -- zig - nil_ls = {}, -- nix - asm_lsp = { - mason = false, - cmd = { 'asm-lsp' }, - }, -} diff --git a/.config/nvim/lua/custom/config/lsp-keymaps.lua b/.config/nvim/lua/custom/config/lsp-keymaps.lua deleted file mode 100644 index 7bbc2e8..0000000 --- a/.config/nvim/lua/custom/config/lsp-keymaps.lua +++ /dev/null @@ -1,73 +0,0 @@ -local severity = vim.diagnostic.severity -local function next_diagnostic(diagnostic_severity) - return function() - require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity }) - end -end -local function prev_diagnostic(diagnostic_severity) - return function() - require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity }) - end -end -local function cursor_diagnostics() - vim.diagnostic.open_float({ - scope = 'cursor', - border = 'single', - }) -end - -local keymaps = { - { 'n', 'gd', 'Lspsaga goto_definition', { desc = '[G]oto [D]efinition' } }, - -- { 'n', 'gu', 'Telescope lsp_references', { desc = '[G]oto [U]sages' } }, - { 'n', 'gu', 'Lspsaga finder', { desc = '[G]oto [U]sages' } }, - { 'n', 'gi', 'Telescope lsp_implementations', { desc = '[G]oto [I]mplementations' } }, - { 'n', 'gt', 'Telescope lsp_type_definitions', { desc = '[G]oto [T]ype Definitions' } }, - { 'n', 'ds', 'Telescope lsp_document_symbols', { desc = '[D]ocument [S]symbols' } }, - { 'n', 'ps', 'Telescope lsp_workspace_symbols', { desc = '[P]roject [S]ymbols' } }, - { { 'n', 'i' }, '', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } }, - { 'n', 'K', 'Lspsaga hover_doc', { desc = 'Documentation' } }, - { 'n', 'R', 'Lspsaga rename', { desc = '[R]ename' } }, - { { 'n', 'i' }, '', 'Lspsaga code_action', { desc = 'Code Actions' } }, - { 'n', 'ca', 'Lspsaga code_action', { desc = '[C]ode [A]ctions' } }, - { 'n', 'e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } }, - { 'n', 'E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } }, - { 'n', 'w', next_diagnostic(severity.WARN), { desc = 'Goto [W]arning' } }, - { 'n', 'W', prev_diagnostic(severity.WARN), { desc = 'Goto [W]arning (prev)' } }, - { 'n', 'D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } }, -} - -for _, ft in ipairs({ 'c', 'h', 'cpp', 'hpp' }) do - keymaps[ft] = { - { 'n', 'H', 'ClangdSwitchSourceHeader', { desc = '[H]eader and Source Switcher' } }, - { 'n', 'K', 'lua require("pretty_hover").hover()', { desc = 'Documentation Hover' } }, - } -end - -local function set_keymaps(tbl, bufnr) - for _, keymap in ipairs(tbl) do - local mode = keymap[1] - local lhs = keymap[2] - local rhs = keymap[3] - local opts = keymap[4] or {} - opts.buffer = bufnr - vim.keymap.set(mode, lhs, rhs, opts) - end -end - -local M = {} - ---- Registers LSP keymaps for the given buffer ----@param bufnr number: the id of the buffer -M.setup = function(bufnr) - local filetype = vim.bo[bufnr].filetype - set_keymaps(keymaps, bufnr) - for ft, tbl in pairs(keymaps) do - if type(ft) == 'number' or ft ~= filetype then - goto continue - end - set_keymaps(tbl, bufnr) - ::continue:: - end -end - -return M diff --git a/.config/nvim/lua/custom/config/lsp.lua b/.config/nvim/lua/custom/config/lsp.lua deleted file mode 100644 index 02ff31f..0000000 --- a/.config/nvim/lua/custom/config/lsp.lua +++ /dev/null @@ -1,73 +0,0 @@ -local lspconfig = require('lspconfig') -local capabilities = require('cmp_nvim_lsp').default_capabilities() - -local servers = require('custom.config.language-servers') -for name, config in pairs(servers) do - if config == false then - goto continue - end - if config == true then - ---@diagnostic disable-next-line: cast-local-type - config = {} - end - - -- NOTE: there must be a better way to do it, but it will do for now - if name == 'markdown_oxide' then - ---@diagnostic disable-next-line: cast-local-type - config = vim.tbl_deep_extend('force', {}, { - capabilities = vim.tbl_deep_extend('force', capabilities, { - workspace = { - didChangeWatchedFiles = { - dynamicRegistration = true, - }, - }, - }), - }, config) - else - ---@diagnostic disable-next-line: cast-local-type - config = vim.tbl_deep_extend('force', {}, { - capabilities = capabilities, - }, config) - end - - lspconfig[name].setup(config) - ::continue:: -end - -vim.api.nvim_create_autocmd('LspAttach', { - callback = function(args) - local bufnr = args.buf - local client = assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client') - - local settings = servers[client.name] - if type(settings) ~= 'table' then - ---@diagnostic disable-next-line: cast-local-type - settings = {} - end - - -- Override server capabilities - if settings.server_capabilities then - for k, v in pairs(settings.server_capabilities) do - if v == vim.NIL then - v = nil - end - client.server_capabilities[k] = v - end - end - - -- Workaround for semantic tokens apparently? - -- https://www.lazyvim.org/extras/lang/go - -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 - if client.name == 'gopls' and not client.server_capabilities.semanticTokensProvider then - local semantic = client.config.capabilities.textDocument.semanticTokens - client.server_capabilities.semanticTokensProvider = { - full = true, - legend = { tokenModifiers = semantic.tokenModifiers, tokenTypes = semantic.tokenTypes }, - range = true, - } - end - - -- Register buffer local LSP keymaps - require('custom.config.lsp-keymaps').setup(bufnr) - end, -}) diff --git a/.config/nvim/lua/custom/config/lualine.lua b/.config/nvim/lua/custom/config/lualine.lua deleted file mode 100644 index 53cd7fe..0000000 --- a/.config/nvim/lua/custom/config/lualine.lua +++ /dev/null @@ -1,92 +0,0 @@ -local lualine = require('lualine') -local lsp_progress = require('lsp-progress') - -local progress_filled = '█' -local progress_empty = '░' -local function progress_bar(percentage, width) - -- Ensure i is an integer between 0 and width (inclusive) - local i = math.max(0, math.min(math.floor(width * percentage), width)) - return string.rep(progress_filled, i) .. string.rep(progress_empty, width - i) -end - -local progress_bar_width = 10 -lsp_progress.setup({ - format = function(client_messages) -- global - local sign = ' LSP' - if #client_messages > 0 then - return sign .. ' ' .. table.concat(client_messages, ' ') - end - if #require('lsp-progress.api').lsp_clients() > 0 then - return sign - end - return '' - end, - client_format = function(_, _, series_messages) -- per lsp - return #series_messages > 0 and table.concat(series_messages, ', ') or nil - end, - series_format = function(title, message, percentage, done) -- per progress - local builder = {} - local has_title = false - local has_message = false - if type(title) == 'string' and string.len(title) > 0 then - table.insert(builder, title .. ':') - has_title = true - end - if percentage then - table.insert(builder, string.format('%.0f%%', percentage)) - table.insert(builder, 1, progress_bar(percentage / 100, progress_bar_width)) - end - if type(message) == 'string' and string.len(message) > 0 then - table.insert(builder, string.format('(%s)', message)) - has_message = true - end - if done and (has_title or has_message) then - table.insert(builder, ' ') - end - return table.concat(builder, ' ') - end, -}) - -lualine.setup({ - options = { - globalstatus = true, - theme = 'auto', - }, - sections = { - lualine_a = { { 'mode', icon = '' } }, - lualine_b = { - -- require('auto-session.lib').current_session_name, - { 'branch', icon = '' }, - { - 'diagnostics', - symbols = { - error = '󰅙 ', - warn = '󰀦 ', - info = '󰋼 ', - hint = '󰌵 ', - }, - }, - }, - lualine_c = { - function() - return lsp_progress.progress() - end, - }, - lualine_x = { - 'searchcount', - 'encoding', - 'fileformat', - 'filetype', - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, - }, - extensions = { 'oil', 'trouble' }, -}) - --- Refresh lualine when lsp progress is updated -vim.api.nvim_create_autocmd('User', { - group = vim.api.nvim_create_augroup('lualine_augroup', { clear = true }), - pattern = 'LspProgressStatusUpdated', - callback = require('lualine').refresh, -}) diff --git a/.config/nvim/lua/custom/config/options.lua b/.config/nvim/lua/custom/config/options.lua deleted file mode 100644 index 3e77e0f..0000000 --- a/.config/nvim/lua/custom/config/options.lua +++ /dev/null @@ -1,61 +0,0 @@ --- System -vim.g.have_nerd_font = true -vim.opt.mouse = 'a' -- enable mouse -vim.opt.clipboard = 'unnamedplus' -- use system clipboard -vim.opt.undofile = true -- persist undo history by saving it to a file -vim.opt.exrc = true -- WARNING: runs .nvim.lua in cwd, which may execute arbitrary code - --- Tab -vim.opt.expandtab = true -- convert tabs to spaces -vim.opt.tabstop = 4 -- number of visual spaces per TAB -vim.opt.softtabstop = 4 -- number of idfk tab when editing -vim.opt.shiftwidth = 4 -- number of spaces to insert on tab - --- UI -vim.opt.colorcolumn = '80' -vim.opt.signcolumn = 'auto:9' -vim.opt.number = true -vim.opt.relativenumber = true -vim.opt.cursorline = true -- highlight current line -vim.opt.splitright = true -vim.opt.splitbelow = true -vim.opt.showmode = false -- don't show mode, because lualine already does -vim.opt.list = true -vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' } -vim.diagnostic.config({ signs = false }) -- disable signcolumn diagnostics -vim.opt.fillchars:append({ diff = '╱' }) -- nicer diff view for filled spaces - --- Searching -vim.opt.hlsearch = true -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Misc -vim.opt_local.wrap = false -vim.opt.wrap = false -vim.opt.scrolloff = 8 -vim.opt.termguicolors = true -vim.opt.laststatus = 3 -- views can only be fully collapsed with the global statusline -vim.opt.splitkeep = 'screen' -- for edgy.nvim -vim.opt.inccommand = 'split' -- shows preview for commands like :%s/from/to - --- Disable warnings for missing language providers -vim.g.loaded_node_provider = 0 -vim.g.loaded_perl_provider = 0 -vim.g.loaded_ruby_provider = 0 -vim.g.loaded_python3_provider = 0 - --- LSP -vim.lsp.inlay_hint.enable() -vim.diagnostic.config({ virtual_text = false, update_in_insert = true }) - --- Add support for mdx files -vim.filetype.add({ - extension = { - mdx = 'markdown', - }, -}) - --- Zig LSP settings -vim.g.zig_fmt_parse_errors = 0 -vim.g.zig_fmt_autosave = 0 diff --git a/.config/nvim/lua/custom/config/rustaceanvim.lua b/.config/nvim/lua/custom/config/rustaceanvim.lua deleted file mode 100644 index 91b1092..0000000 --- a/.config/nvim/lua/custom/config/rustaceanvim.lua +++ /dev/null @@ -1,37 +0,0 @@ ----@type RustaceanOpts -vim.g.rustaceanvim = { - ---@type RustaceanToolsOpts - tools = { - float_win_config = { - border = 'rounded', - }, - }, - ---@type RustaceanLspClientOpts - server = { - on_attach = function(_, bufnr) - local keymaps = { - { { 'n', 'i' }, '', 'RustLsp codeAction', { desc = 'Code Action' } }, - } - - for _, keymap in ipairs(keymaps) do - local modes = keymap[1] - local lhs = keymap[2] - local rhs = keymap[3] - local opts = keymap[4] - opts.buffer = bufnr - - vim.keymap.set(modes, lhs, rhs, opts) - end - end, - default_settings = { - ['rust-analyzer'] = { - semanticHighlighting = { - operator = { specialization = { enable = true } }, - punctuation = { enable = true, specialization = { enable = true } }, - }, - }, - }, - }, - ---@type RustaceanDapOpts - dap = {}, -} diff --git a/.config/nvim/lua/custom/config/telescope.lua b/.config/nvim/lua/custom/config/telescope.lua deleted file mode 100644 index 5a84121..0000000 --- a/.config/nvim/lua/custom/config/telescope.lua +++ /dev/null @@ -1,41 +0,0 @@ -local telescope = require('telescope') -telescope.setup({ - pickers = { - find_files = { follow = true, hidden = true }, - grep_string = { additional_args = '--follow' }, - live_grep = { additional_args = '--follow' }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case', -- default "smart_case" or "ignore_case" or "respect_case" - }, - ['ui-select'] = { - require('telescope.themes').get_dropdown({}), - }, - }, -}) - -pcall(telescope.load_extension('ui-select')) -pcall(telescope.load_extension('fzf')) - -local builtin = require('telescope.builtin') -local function find_all() - builtin.find_files({ - cwd = '~', - hidden = true, - no_ignore = true, - no_ignore_parent = true, - }) -end - -vim.keymap.set('n', 'fs', builtin.find_files, { desc = '[F]ile [S]ystem' }) -vim.keymap.set('n', 'fa', find_all, { desc = '[F]ind [A]ll files' }) -vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) -vim.keymap.set('n', 'fm', builtin.man_pages, { desc = '[F]ind [M]an Pages' }) -vim.keymap.set('n', 'lv', builtin.live_grep, { desc = '[L]ive [G]rep' }) -vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files' }) -vim.keymap.set('n', 'th', builtin.colorscheme, { desc = 'List [Th]eme' }) -vim.keymap.set('n', 'hi', builtin.highlights, { desc = '[Hi]light Groups' }) diff --git a/.config/nvim/lua/custom/plugins/activity-watch.lua b/.config/nvim/lua/custom/plugins/activity-watch.lua deleted file mode 100644 index 1fef86c..0000000 --- a/.config/nvim/lua/custom/plugins/activity-watch.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - 'lowitea/aw-watcher.nvim', - opts = { - aw_server = { - host = '127.0.0.1', - port = 5600, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/alpha.lua b/.config/nvim/lua/custom/plugins/alpha.lua deleted file mode 100644 index 00a7d56..0000000 --- a/.config/nvim/lua/custom/plugins/alpha.lua +++ /dev/null @@ -1,69 +0,0 @@ -return { - 'goolord/alpha-nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - cmd = "Alpha", - config = function() - local alpha = require('alpha') - local dashboard = require('alpha.themes.dashboard') - - local function get_natural_day(day) - local suffix = 'th' - local day_mod = day % 10 - - if day_mod == 1 and day ~= 11 then - suffix = 'st' - elseif day_mod == 2 and day ~= 12 then - suffix = 'nd' - elseif day_mod == 3 and day ~= 13 then - suffix = 'rd' - end - - return tostring(day) .. suffix - end - - local find_file_path = '$HOME' - local date = os.date('  %A, %B ') .. get_natural_day(tonumber(os.date('%d'))) - local plugins = '  ' .. require('lazy').stats().count .. ' plugins ' - local v = vim.version() - local version = '  v' .. v.major .. '.' .. v.minor .. '.' .. v.patch - local info_line = date .. plugins .. version - - -- WARN: Just hardcoded the length of the first line in the header - local header_length = #'  ' - local padding = (header_length - #info_line) / 2 - info_line = string.rep(' ', padding) .. info_line - - dashboard.section.header.val = { - [[  ]], - [[ ████ ██████ █████ ██ ██ ]], - [[ ███████████ █████ ███ ]], - [[ █████████ ███████████████████ ███ ███████████ ]], - [[ █████████ ███ █████████████ █████ ██████████████ ]], - [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], - [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], - [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], - [[ ]], - info_line, - } - - dashboard.section.buttons.opts.spacing = 0 - dashboard.section.buttons.val = { - dashboard.button('e', ' > New file', 'ene startinsert'), - dashboard.button('f', ' > Find file', 'cd ' .. find_file_path .. ' | Telescope find_files'), - dashboard.button('r', ' > Recent', 'Telescope oldfiles'), - dashboard.button('c', ' > Configuration', 'e $MYVIMRC | cd %:p:h'), - -- FIX: doesn't seem to work so great, probably just use a project manager - -- will most likely make my own project manager plugin - -- dashboard.button( - -- 's', - -- '󱎠 > Last Session', - -- 'lua require("auto-session.session-lens.actions").alternate_session()' - -- ), - dashboard.button('q', '󰈆 > Quit NVIM', 'qa'), - } - - dashboard.section.footer.val = require('alpha.fortune')() - - alpha.setup(dashboard.opts) - end, -} diff --git a/.config/nvim/lua/custom/plugins/auto-save.lua b/.config/nvim/lua/custom/plugins/auto-save.lua deleted file mode 100644 index 5da836b..0000000 --- a/.config/nvim/lua/custom/plugins/auto-save.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - 'okuuva/auto-save.nvim', - cmd = 'ASToggle', - event = { 'InsertLeave', 'TextChanged' }, - opts = function() - -- Disable autoformat between automatic saves - vim.api.nvim_create_autocmd('User', { - pattern = 'AutoSaveWritePre', - group = vim.api.nvim_create_augroup('autosave-pre', { clear = true }), - callback = function(opts) - local bufnr = opts.data.saved_buffer - vim.b[bufnr].disable_autoformat = true - end, - }) - - vim.api.nvim_create_autocmd('User', { - pattern = 'AutoSaveWritePost', - group = vim.api.nvim_create_augroup('autosave-post', { clear = true }), - callback = function(opts) - local bufnr = opts.data.saved_buffer - vim.b[bufnr].disable_autoformat = false - end, - }) - - return { - -- execution_message = { enabled = false }, removed - condition = function(buf) - -- Save only if the buffer is not a "special buffer" - return vim.fn.getbufvar(buf, '&buftype') == '' - end, - } - end, -} diff --git a/.config/nvim/lua/custom/plugins/auto-session.lua b/.config/nvim/lua/custom/plugins/auto-session.lua deleted file mode 100644 index cd8d7a4..0000000 --- a/.config/nvim/lua/custom/plugins/auto-session.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - 'rmagatti/auto-session', - lazy = false, - config = function() - vim.opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions' - require('auto-session').setup({ - log_level = 'error', - auto_session_suppress_dirs = { '~/', '/' }, - session_lens = { load_on_setup = false }, - no_restore_cmds = { - function() - if vim.fn.argc() == 0 then - vim.cmd('Alpha') - end - end, - }, - }) - - local session_lens_setup_done = false - local function search_session() - if not session_lens_setup_done then - require('auto-session').setup_session_lens() - session_lens_setup_done = true - end - require('auto-session.session-lens').search_session() - end - vim.keymap.set('n', '', search_session, { desc = '[S]ession Manager' }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/buffer-manager.lua b/.config/nvim/lua/custom/plugins/buffer-manager.lua deleted file mode 100644 index 6bce4b8..0000000 --- a/.config/nvim/lua/custom/plugins/buffer-manager.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - 'j-morano/buffer_manager.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, - keys = { - { - 'bl', - function() - require('buffer_manager.ui').toggle_quick_menu() - end, - desc = '[B]uffer [L]ist', - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/buffer-vaccum.lua b/.config/nvim/lua/custom/plugins/buffer-vaccum.lua deleted file mode 100644 index b064b45..0000000 --- a/.config/nvim/lua/custom/plugins/buffer-vaccum.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'ChuufMaster/buffer-vacuum', - opts = { max_buffers = 6 }, - event = 'VeryLazy', -} diff --git a/.config/nvim/lua/custom/plugins/bullets.lua b/.config/nvim/lua/custom/plugins/bullets.lua deleted file mode 100644 index 5c81e75..0000000 --- a/.config/nvim/lua/custom/plugins/bullets.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - -- 'bullets-vim/bullets.vim', - -- event = { 'BufReadPre', 'BufNewFile' }, -} diff --git a/.config/nvim/lua/custom/plugins/ccc.lua b/.config/nvim/lua/custom/plugins/ccc.lua deleted file mode 100644 index 74c033e..0000000 --- a/.config/nvim/lua/custom/plugins/ccc.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - 'uga-rosa/ccc.nvim', - opts = { - highlighter = { auto_enable = true }, - -- highlight_mode = 'virtual', - -- virtual_pos = 'inline-right', - }, - event = 'VeryLazy', - keys = { - { 'cp', 'CccPick', desc = '[C]olor [P]icker' }, - { 'ct', 'CccHighlighterToggle', desc = '[C]olor [T]oggle' }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/clangd_extensions.lua b/.config/nvim/lua/custom/plugins/clangd_extensions.lua deleted file mode 100644 index 07f9dc0..0000000 --- a/.config/nvim/lua/custom/plugins/clangd_extensions.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - 'p00f/clangd_extensions.nvim', - dependencies = { 'microsoft/vscode-codicons' }, -- NOTE: for the ast icons - cmd = { - 'ClangdSwitchSourceHeader', - 'ClangdSetInlayHints', - 'ClangdDisableInlayHints', - 'ClangdToggleInlayHints', - 'ClangdAST', - 'ClangdSymbolInfo', - 'ClangdTypeHierarchy', - 'ClangdMemoryUsage', - }, - opts = { - inlay_hints = { - inline = false, - }, - ast = { - role_icons = { - type = '', - declaration = '', - expression = '', - specifier = '', - statement = '', - ['template argument'] = '', - }, - kind_icons = { - Compound = '', - Recovery = '', - TranslationUnit = '', - PackExpansion = '', - TemplateTypeParm = '', - TemplateTemplateParm = '', - TemplateParamObject = '', - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/code-playground.lua b/.config/nvim/lua/custom/plugins/code-playground.lua deleted file mode 100644 index 751de5b..0000000 --- a/.config/nvim/lua/custom/plugins/code-playground.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'GustavEikaas/code-playground.nvim', - lazy = false, - config = function() - require('code-playground').setup() - end, -} diff --git a/.config/nvim/lua/custom/plugins/colorscheme.lua b/.config/nvim/lua/custom/plugins/colorscheme.lua deleted file mode 100644 index 916eae2..0000000 --- a/.config/nvim/lua/custom/plugins/colorscheme.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - { - 'folke/tokyonight.nvim', - lazy = false, - priority = 1000, - config = function() - -- vim.cmd.colorscheme('tokyonight-night') - -- require('colorschemes.dapui').set() - -- vim.cmd.colorscheme('carbonight-tokyo') - vim.cmd.colorscheme('carbonight') - end, - }, - { dir = '~/projects/carbonight.nvim' }, -} diff --git a/.config/nvim/lua/custom/plugins/comment.lua b/.config/nvim/lua/custom/plugins/comment.lua deleted file mode 100644 index b61675a..0000000 --- a/.config/nvim/lua/custom/plugins/comment.lua +++ /dev/null @@ -1,25 +0,0 @@ -return { - -- 'numToStr/Comment.nvim', - 'os-mey/Comment.nvim', - branch = 'fix-inline-visual-linewise-comment', - keys = { - { 'gc', mode = { 'n', 'v' } }, - { 'gb', mode = { 'n', 'v' } }, - { '', mode = { 'n', 'v' } }, - { 'gcc', mode = 'n' }, - { 'gcb', mode = 'n' }, - }, - config = function() - require('Comment').setup() - local api = require('Comment.api') - local esc = vim.api.nvim_replace_termcodes('', true, false, true) - local toggle_linewise_selection = function() - vim.api.nvim_feedkeys(esc, 'nx', false) - api.toggle.linewise(vim.fn.visualmode()) - end - - -- means Ctrl slash, `_` is a `/` - vim.keymap.set('n', '', api.toggle.linewise.current, { noremap = true, silent = true }) - vim.keymap.set('v', '', toggle_linewise_selection, { noremap = true, silent = true }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/conform.lua b/.config/nvim/lua/custom/plugins/conform.lua deleted file mode 100644 index fe3356f..0000000 --- a/.config/nvim/lua/custom/plugins/conform.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { 'ft', 'FormatToggle', desc = '[F]ormat [T]oggle Globally' }, - { 'fT', 'FormatToggle!', desc = '[F]ormat [T]oggle Locally' }, - { 'ff', 'Format', desc = '[F]ormat [F]ile' }, - { 'f', 'Format', desc = '[F]ormat', mode = 'v' }, - }, - ---@module "conform" - ---@type conform.setupOpts - opts = { - formatters_by_ft = { - ['lua'] = { 'stylua' }, - ['c'] = { 'clang-format' }, - -- ['python'] = { 'isort', 'black' }, - -- ['rust'] = { 'rustfmt' }, - ['go'] = { 'gofumpt', 'goimports-reviser' }, - ['markdown'] = { 'prettierd', 'prettier', stop_after_first = true }, - ['yaml'] = { 'prettierd' }, - ['json'] = { 'jq' }, - ['html'] = { 'prettierd', 'prettier', stop_after_first = true }, - ['css'] = { 'prettierd', 'prettier', stop_after_first = true }, - ['javascript'] = { 'prettierd', 'prettier', stop_after_first = true }, - ['typescript'] = { 'prettierd', 'prettier', stop_after_first = true }, - }, - format_on_save = function(bufnr) - -- Disable with a global or buffer local variable - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { timeout_ms = 500, lsp_fallback = true } - end, - notify_on_error = true, - lsp_fallback = true, - }, -} diff --git a/.config/nvim/lua/custom/plugins/diffview.lua b/.config/nvim/lua/custom/plugins/diffview.lua deleted file mode 100644 index 875e458..0000000 --- a/.config/nvim/lua/custom/plugins/diffview.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - 'sindrets/diffview.nvim', - cmd = { 'DiffviewOpen', 'DiffviewClose', 'DiffviewFileHistory' }, - keys = { - { 'gd', 'DiffviewOpen' }, - { 'gl', 'DiffviewFileHistory' }, - }, - opts = function() - local quit_keymap = { 'n', 'q', 'DiffviewClose', { desc = 'Quit the diffview' } } - return { - enhanced_diff_hl = true, - default = { winbar_info = true }, - keymaps = { - view = { quit_keymap }, - file_panel = { quit_keymap }, - file_history_panel = { quit_keymap }, - }, - } - end, -} diff --git a/.config/nvim/lua/custom/plugins/edgy.lua b/.config/nvim/lua/custom/plugins/edgy.lua deleted file mode 100644 index 872247f..0000000 --- a/.config/nvim/lua/custom/plugins/edgy.lua +++ /dev/null @@ -1,28 +0,0 @@ -return { - 'folke/edgy.nvim', - event = 'VeryLazy', - opts = { - bottom = { - 'Trouble', - { ft = 'qf', title = 'QuickFix' }, - { - ft = 'help', - size = { height = 20 }, - filter = function(buf) -- only show help buffers - return vim.bo[buf].buftype == 'help' - end, - }, - { ft = 'spectre_panel', size = { height = 0.4 } }, - }, - left = { - { - title = 'Neo-Tree', - ft = 'neo-tree', - filter = function(buf) - return vim.b[buf].neo_tree_source == 'filesystem' - end, - size = { height = 0.5 }, - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/gitsigns.lua b/.config/nvim/lua/custom/plugins/gitsigns.lua deleted file mode 100644 index 953cd80..0000000 --- a/.config/nvim/lua/custom/plugins/gitsigns.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - 'lewis6991/gitsigns.nvim', - cmd = 'Gitsigns', - -- INFO: Disabled lazy loading to see if the errors stop - -- Not sure if it's an issue with lazy loading or just a gitsigns bug - lazy = false, - config = function() - require('gitsigns').setup() - - local function stage_visual_chunk() - require('gitsigns').stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) - end - local function reset_visual_chunk() - require('gitsigns').reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) - end - - vim.keymap.set('n', 'gD', 'Gitsigns toggle_deleted', { desc = '[G]it [D]eleted' }) - vim.keymap.set('n', 'hp', 'Gitsigns preview_hunk', { desc = '[H]unk [P]review' }) - vim.keymap.set('n', 'hs', 'Gitsigns stage_hunk', { desc = '[H]unk [S]tage' }) - vim.keymap.set('n', 'hr', 'Gitsigns reset_hunk', { desc = '[H]unk [R]eset' }) - vim.keymap.set('v', 'hs', stage_visual_chunk, { desc = '[H]unk [S]tage' }) - vim.keymap.set('v', 'hr', reset_visual_chunk, { desc = '[H]unk [S]tage' }) - vim.keymap.set('n', 'hS', 'Gitsigns stage_buffer', { desc = '[S]tage Buffer' }) - vim.keymap.set('n', 'hR', 'Gitsigns reset_buffer', { desc = '[R]eset Buffer' }) - vim.keymap.set('n', 'hu', 'Gitsigns undo_stage_hunk', { desc = '[H]unk [U]ndo' }) - vim.keymap.set( - 'n', - 'gB', - 'Gitsigns toggle_current_line_blame', - { desc = '[G]it [B]lame Line' } - ) - end, -} diff --git a/.config/nvim/lua/custom/plugins/gopher.lua b/.config/nvim/lua/custom/plugins/gopher.lua deleted file mode 100644 index 4bbcc92..0000000 --- a/.config/nvim/lua/custom/plugins/gopher.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - 'olexsmir/gopher.nvim', - ft = 'go', - build = function() - vim.cmd.GoInstallDeps() - end, - ---@type gopher.Config - opts = {}, -} diff --git a/.config/nvim/lua/custom/plugins/harpoon.lua b/.config/nvim/lua/custom/plugins/harpoon.lua deleted file mode 100644 index 5627e2f..0000000 --- a/.config/nvim/lua/custom/plugins/harpoon.lua +++ /dev/null @@ -1,23 +0,0 @@ -return { - 'ThePrimeagen/harpoon', - branch = 'harpoon2', - dependencies = { 'nvim-lua/plenary.nvim' }, - keys = { '', 'a', '1', '2', '3', '4', '5' }, - config = function() - local harpoon = require('harpoon') - harpoon:setup() - - vim.keymap.set('n', 'a', function() - harpoon:list():add() - end) - vim.keymap.set('n', '', function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end) - - for i = 1, 9 do - vim.keymap.set('n', string.format('%d', i), function() - harpoon:list():select(i) - end) - end - end, -} diff --git a/.config/nvim/lua/custom/plugins/helpview.lua b/.config/nvim/lua/custom/plugins/helpview.lua deleted file mode 100644 index 098548b..0000000 --- a/.config/nvim/lua/custom/plugins/helpview.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'OXY2DEV/helpview.nvim', - ft = 'help', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - }, -} diff --git a/.config/nvim/lua/custom/plugins/indent-blankline.lua b/.config/nvim/lua/custom/plugins/indent-blankline.lua deleted file mode 100644 index fb18add..0000000 --- a/.config/nvim/lua/custom/plugins/indent-blankline.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'lukas-reineke/indent-blankline.nvim', - main = 'ibl', - event = 'VeryLazy', - opts = { - scope = { - show_start = false, - show_end = false, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/lazydev.lua b/.config/nvim/lua/custom/plugins/lazydev.lua deleted file mode 100644 index 59d2366..0000000 --- a/.config/nvim/lua/custom/plugins/lazydev.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'folke/lazydev.nvim', - ft = 'lua', - cmd = 'LazyDev', - opts = { - library = { - { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, - { path = 'snacks.nvim', words = { 'Snacks' } }, - { path = 'lazy.nvim', words = { 'LazyVim' } }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/leap.lua b/.config/nvim/lua/custom/plugins/leap.lua deleted file mode 100644 index 6d1eeeb..0000000 --- a/.config/nvim/lua/custom/plugins/leap.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 'ggandor/leap.nvim', - lazy = false, - dependencies = { 'tpope/vim-repeat' }, - config = function() - require('leap').opts.equivalence_classes = { ' \t\r\n', '([{', ')]}', '\'"`' } - vim.api.nvim_set_hl(0, 'LeapBackdrop', { fg = '#777777' }) - - vim.keymap.set({ 'n', 'x' }, 's', '(leap)') - vim.keymap.set('n', 'S', '(leap-from-window)') - vim.keymap.set('n', 's', require('leap.remote').action) - vim.keymap.set('o', 'z', '(leap-forward)') - vim.keymap.set('o', 'Z', '(leap-backward)') - end, -} diff --git a/.config/nvim/lua/custom/plugins/lsp-signature.lua b/.config/nvim/lua/custom/plugins/lsp-signature.lua deleted file mode 100644 index 718cd62..0000000 --- a/.config/nvim/lua/custom/plugins/lsp-signature.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - -- FIXME: fork the repo and fix the following issues - -- Make both insert and normal be toggelable rather than insert always showing and normal toggleable - 'ray-x/lsp_signature.nvim', - event = 'LspAttach', - opts = { - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { border = 'single' }, - doc_lines = 0, - hint_enable = false, - }, -} diff --git a/.config/nvim/lua/custom/plugins/lspsaga.lua b/.config/nvim/lua/custom/plugins/lspsaga.lua deleted file mode 100644 index a8fe588..0000000 --- a/.config/nvim/lua/custom/plugins/lspsaga.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - -- 'nvimdev/lspsaga.nvim', - 'Kyren223/lspsaga.nvim', - dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, - event = 'LspAttach', - opts = { - ui = { - border = 'rounded', - foldericon = false, - title = false, - kind = nil, - }, - hover = { open_cmd = '!firefox.exe' }, - diagnostic = { - show_layout = 'float', - keys = { - exec_action = 'o', - quit = 'q', - toggle_or_jump = '', - quit_in_show = { 'q', '' }, - }, - }, - code_action = { show_preview = false }, - lightbulb = { enable = false }, - rename = { - pre_hook = function() - pcall(function() - vim.cmd('IlluminateToggle') - end) - end, - post_hook = function() - pcall(function() - vim.cmd('IlluminateToggle') - end) - end, - keys = { - quit = '', - exec = '', - select = 'x', - }, - }, - symbol_in_winbar = { enable = false }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/lualine.lua b/.config/nvim/lua/custom/plugins/lualine.lua deleted file mode 100644 index f1e5ec5..0000000 --- a/.config/nvim/lua/custom/plugins/lualine.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons', 'linrongbin16/lsp-progress.nvim' }, - event = 'VeryLazy', - config = function() - require('custom.config.lualine') - end, -} diff --git a/.config/nvim/lua/custom/plugins/markdown-toggle.lua b/.config/nvim/lua/custom/plugins/markdown-toggle.lua deleted file mode 100644 index 39a932c..0000000 --- a/.config/nvim/lua/custom/plugins/markdown-toggle.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'roodolv/markdown-toggle.nvim', - event = 'VeryLazy', - config = function() - require('markdown-toggle').setup() - local opts = { silent = true, noremap = true } - local toggle = require('markdown-toggle') - vim.keymap.set({ 'n', 'x' }, 'tu', toggle.list, opts) - vim.keymap.set({ 'n', 'x' }, 'to', toggle.olist, opts) - vim.keymap.set({ 'n', 'x' }, 'tm', toggle.checkbox, opts) - end, -} diff --git a/.config/nvim/lua/custom/plugins/mason.lua b/.config/nvim/lua/custom/plugins/mason.lua deleted file mode 100644 index 9bbb01b..0000000 --- a/.config/nvim/lua/custom/plugins/mason.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - { - 'williamboman/mason.nvim', - lazy = false, - opts = { - ui = { - icons = { - package_installed = '✓', - package_pending = '➜', - package_uninstalled = '✗', - }, - }, - }, - }, - { - 'WhoIsSethDaniel/mason-tool-installer.nvim', - lazy = false, - opts = { - ensure_installed = { - 'stylua', -- lua formatting - 'clang-format', -- C/C++ formatter - 'codelldb', -- C/C++ debugger - 'cpplint', -- C/C++ linter - -- 'black', -- python formatter - -- 'isort', -- python formatter for imports - -- 'flake8', -- python linter - 'gofumpt', -- go formatter - 'golangci-lint', -- go linter - 'prettierd', -- multi-lang formatter - 'prettier', -- prettierd but slower, used as a fallback - 'jq', -- json formatter - 'jsonlint', -- json linter - 'shellcheck', -- bash linter - 'beautysh', -- shell formatter - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/mini.lua b/.config/nvim/lua/custom/plugins/mini.lua deleted file mode 100644 index 61d04b6..0000000 --- a/.config/nvim/lua/custom/plugins/mini.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - 'echasnovski/mini.nvim', - version = false, - keys = { - { - 'Q', - function() - if vim.bo.modified then - vim.cmd.write() - end - require('mini.bufremove').delete(0) - end, - desc = '[Q]uit Buffer', - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/neogen.lua b/.config/nvim/lua/custom/plugins/neogen.lua deleted file mode 100644 index fdefdbd..0000000 --- a/.config/nvim/lua/custom/plugins/neogen.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'danymat/neogen', - keys = { { 'ng', '<Neogen', desc = '[N]eo[G]en' } }, - opts = { snippet_engine = 'luasnip' }, -} diff --git a/.config/nvim/lua/custom/plugins/neogit.lua b/.config/nvim/lua/custom/plugins/neogit.lua deleted file mode 100644 index e1e164f..0000000 --- a/.config/nvim/lua/custom/plugins/neogit.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - 'NeogitOrg/neogit', - cmd = 'Neogit', - keys = { - { 'gb', 'Neogit branch' }, - { 'gs', 'Neogit' }, - { 'gL', 'Neogit log' }, - { 'gc', 'Neogit commit' }, - { 'gp', 'Neogit push' }, - { 'gP', 'Neogit pull' }, - { 'gr', 'Neogit rebase' }, - { 'gm', 'Neogit merge' }, - }, - opts = function() - return { - commit_editor = { spell_check = false }, - mappings = { - commit_editor = { - [''] = 'Submit', - [''] = 'Abort', - }, - commit_editor_I = { - [''] = 'Submit', - [''] = 'Abort', - }, - popup = { - ['p'] = 'PushPopup', - ['P'] = 'PullPopup', - }, - }, - } - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-autopairs.lua b/.config/nvim/lua/custom/plugins/nvim-autopairs.lua deleted file mode 100644 index 264004a..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-autopairs.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - opts = { - check_ts = true, - ts_config = { - lua = { 'string' }, -- don't add pairs inside lua strings - javascript = { 'template_string' }, -- FIX: remove me - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-cmp.lua b/.config/nvim/lua/custom/plugins/nvim-cmp.lua deleted file mode 100644 index 4860338..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-cmp.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 'hrsh7th/nvim-cmp', - event = "InsertEnter", - dependencies = { - 'onsails/lspkind.nvim', -- icons for completion type - 'hrsh7th/cmp-path', -- complete filepaths - 'hrsh7th/cmp-nvim-lsp', -- lsp source for nvim-cmp - 'saadparwaiz1/cmp_luasnip', -- snippets source for nvim-cmp - { 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' }, -- snippets plugin - }, - config = function() - require('custom.config.cmp') - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-dap-ui.lua b/.config/nvim/lua/custom/plugins/nvim-dap-ui.lua deleted file mode 100644 index cddad45..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-dap-ui.lua +++ /dev/null @@ -1,26 +0,0 @@ -return { - 'rcarriga/nvim-dap-ui', - dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }, - event = 'VeryLazy', - config = function() - local dap = require('dap') - local dapui = require('dapui') - dapui.setup() - dap.listeners.before.attach.dapui_config = function() - dapui.open() - vim.cmd.Hardtime('disable') - end - dap.listeners.after.event_initialized['dapui_config'] = function() - dapui.open() - vim.cmd.Hardtime('disable') - end - dap.listeners.before.event_terminated['dapui_config'] = function() - dapui.close() - vim.cmd.Hardtime('enable') - end - dap.listeners.before.event_exited['dapui_config'] = function() - dapui.close() - vim.cmd.Hardtime('enable') - end - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-dap.lua b/.config/nvim/lua/custom/plugins/nvim-dap.lua deleted file mode 100644 index a6387dc..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-dap.lua +++ /dev/null @@ -1,58 +0,0 @@ -return { - 'mfussenegger/nvim-dap', - dependencies = { 'williamboman/mason.nvim' }, - -- NOTE:nvim-dap has no setup function - -- if there is just opts, lazy will attempt to call setup which causes an error - -- Having an empty config function makes lazy not call setup which fixes the issue - config = function() end, - opts = function() - -- Load dap keymaps - require('custom.config.dap-keymaps') - local dap = require('dap') - - -- Setup C/C++ dap - if not dap.adapters['codelldb'] then - dap.adapters['codelldb'] = { - type = 'server', - host = 'localhost', - port = '${port}', - executable = { - command = 'codelldb', - args = { - '--port', - '${port}', - }, - }, - } - end - for _, lang in ipairs({ 'c', 'cpp' }) do - dap.configurations[lang] = { - { - type = 'codelldb', - request = 'launch', - name = 'Launch file', - program = function() - if vim.g.dap_codelldb_exe then - return vim.fn.getcwd() .. '/' .. vim.g.dap_codelldb_exe - end - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - args = function() - if vim.g.dap_codelldb_args then - return vim.g.dap_codelldb_args - end - return {} - end, - cwd = '${workspaceFolder}', - }, - { - type = 'codelldb', - request = 'attach', - name = 'Attach to process', - pid = require('dap.utils').pick_process, - cwd = '${workspaceFolder}', - }, - } - end - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-dbee.lua b/.config/nvim/lua/custom/plugins/nvim-dbee.lua deleted file mode 100644 index 43baa80..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-dbee.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'kndndrj/nvim-dbee', - dependencies = { 'MunifTanjim/nui.nvim' }, - build = function() - -- Install tries to automatically detect the install method. - -- if it fails, try calling it with one of these parameters: - -- "curl", "wget", "bitsadmin", "go" - require('dbee').install() - end, - cmd = 'Dbee', - opts = {}, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-java.lua b/.config/nvim/lua/custom/plugins/nvim-java.lua deleted file mode 100644 index 4bd321d..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-java.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'nvim-java/nvim-java', - lazy = false, - opts = {} -} diff --git a/.config/nvim/lua/custom/plugins/nvim-lint.lua b/.config/nvim/lua/custom/plugins/nvim-lint.lua deleted file mode 100644 index 7bb3a16..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-lint.lua +++ /dev/null @@ -1,41 +0,0 @@ -return { - 'mfussenegger/nvim-lint', - lazy = false, - config = function() - local lint = require('lint') - lint.linters_by_ft = { - -- c = { 'clangtidy' }, - -- cpp = { 'clangtidy' }, - go = { 'golangcilint' }, - -- python = { 'flake8' }, - json = { 'jsonlint' }, - bash = { 'shellcheck' }, - } - - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave', 'TextChanged', 'TextChangedI' }, { - group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }), - callback = function() - require('lint').try_lint() - end, - }) - - -- NOTE: most if not all of clangt-idy warnings are - -- also reported by clangd, so this function filters clang-tidy warnings - -- to avoid duplication of warnings - -- local clangtidy_parser = lint.linters.clangtidy.parser - -- lint.linters.clangtidy.parser = function(output, bufnr, linter_cwd) - -- local diagnostics = clangtidy_parser(output, bufnr, linter_cwd) - -- diagnostics = vim.tbl_filter(function(diagnostic) - -- if diagnostic.severity == vim.diagnostic.severity.WARN then - -- return false - -- end - -- if diagnostic.severity == vim.diagnostic.severity.ERROR then - -- return false - -- end - -- - -- return true - -- end, diagnostics) - -- return diagnostics - -- end - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-lspconfig.lua b/.config/nvim/lua/custom/plugins/nvim-lspconfig.lua deleted file mode 100644 index 0b358fe..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-lspconfig.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - -- NOTE: Make sure the order is as follows: - -- Mason loads -> Mason lspconfig loads -> Lspconfig loads - 'neovim/nvim-lspconfig', - event = { 'BufReadPre', 'BufNewFile' }, - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - { 'antosha417/nvim-lsp-file-operations', conifg = true }, - { - 'williamboman/mason-lspconfig.nvim', - build = ':MasonUpdate', - config = function() - local language_servers = require('custom.config.language-servers') - local ensure_installed = vim.tbl_filter(function(key) - local server = language_servers[key] - if type(server) == 'table' then - if server.mason ~= nil then - return server.mason - end - return true - else - return server - end - end, vim.tbl_keys(language_servers)) - require('mason-lspconfig').setup({ ensure_installed = ensure_installed, auto_install = true }) - end, - }, - }, - config = function() - require('custom.config.lsp') - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-scrollbar.lua b/.config/nvim/lua/custom/plugins/nvim-scrollbar.lua deleted file mode 100644 index f475ac7..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-scrollbar.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - 'petertriho/nvim-scrollbar', - event = 'VeryLazy', - opts = { - marks = { - Search = { - text = { '', '' }, - }, - Error = { - text = { '', '' }, - }, - Warn = { - text = { '', '' }, - }, - Info = { - text = { '', '' }, - }, - Hint = { - text = { '', '' }, - }, - Misc = { - text = { '', '' }, - }, - }, - handlers = { - cursor = false, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-spectre.lua b/.config/nvim/lua/custom/plugins/nvim-spectre.lua deleted file mode 100644 index df58de9..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-spectre.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - -- NOTE: No keybindings, use `:Spectre` or `:Spectre ` - -- Spectre has no undo, so it should be rarely used, which is why no keybindings are defined - 'nvim-pack/nvim-spectre', - cmd = 'Spectre', - config = true, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-surround.lua b/.config/nvim/lua/custom/plugins/nvim-surround.lua deleted file mode 100644 index 54d8754..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-surround.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - 'kylechui/nvim-surround', - version = '*', - keys = { - { 'ys' }, - { 'yss' }, - { 'S' }, - { 'cs' }, - { 'ds' }, - { '(', '(nvim-surround-visual)(', mode = 'v' }, - { ')', '(nvim-surround-visual))', mode = 'v' }, - { '{', '(nvim-surround-visual){', mode = 'v' }, - { '}', '(nvim-surround-visual)}', mode = 'v' }, - { '[', '(nvim-surround-visual)[', mode = 'v' }, - { ']', '(nvim-surround-visual)]', mode = 'v' }, - { '`', '(nvim-surround-visual)`', mode = 'v' }, - { '"', '(nvim-surround-visual)"', mode = 'v' }, - { "'", "(nvim-surround-visual)'", mode = 'v' }, - }, - opts = {}, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-treesitter.lua b/.config/nvim/lua/custom/plugins/nvim-treesitter.lua deleted file mode 100644 index 96ac728..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-treesitter.lua +++ /dev/null @@ -1,87 +0,0 @@ -return { - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - config = function() - ---@type userdata - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup({ - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - rainbow = { - enable = true, - extended_mode = true, - max_file_lines = nil, - }, - }) - - -- HACK: Workaround to have syntax highlighting in zsh until a zsh parser is added - -- https://github.com/nvim-treesitter/nvim-treesitter/issues/655 - local ft_to_lang = require('nvim-treesitter.parsers').ft_to_lang - ---@diagnostic disable-next-line: duplicate-set-field - require('nvim-treesitter.parsers').ft_to_lang = function(ft) - if ft == 'zsh' then - return 'bash' - end - return ft_to_lang(ft) - end - end, - }, - { - 'nvim-treesitter/nvim-treesitter-textobjects', - event = 'VeryLazy', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, - config = function() - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup({ - textobjects = { - select = { - enable = true, - lookahead = true, -- automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['af'] = { query = '@function.outer', desc = 'Select entire function' }, - ['if'] = { query = '@function.inner', desc = 'Select function body' }, - ['ac'] = { query = '@class.outer', desc = 'Select entire class' }, - ['ic'] = { query = '@class.inner', desc = 'Select class body' }, - -- ['as'] = { query = '@scope', query_group = 'locals', desc = 'Select language scope' }, - ['ia'] = { query = '@assignment.rhs', desc = 'Select assignment rhs' }, - ['ip'] = { query = '@parameter.inner', desc = 'Select parameter' }, - }, - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - ['@class.outer'] = '', -- blockwise - ['@assignment.rhs'] = 'v', -- charwise - }, - }, - swap = { - enable = true, - swap_next = { - ['sa'] = { query = '@parameter.inner', desc = 'Swap Argument (next)' }, - }, - swap_previous = { - ['sA'] = { query = '@parameter.inner', desc = 'Swap Argument (prev)' }, - }, - }, - }, - }) - - local ts_repeat_move = require('nvim-treesitter.textobjects.repeatable_move') - -- Repeat movement with ; and , - vim.keymap.set({ 'n', 'x', 'o' }, ';', ts_repeat_move.repeat_last_move_next) - vim.keymap.set({ 'n', 'x', 'o' }, ',', ts_repeat_move.repeat_last_move_previous) - - -- NOTE: You need this, otherwise the normal ; and , won't work for fFtT - vim.keymap.set({ 'n', 'x', 'o' }, 'f', ts_repeat_move.builtin_f_expr, { expr = true }) - vim.keymap.set({ 'n', 'x', 'o' }, 'F', ts_repeat_move.builtin_F_expr, { expr = true }) - vim.keymap.set({ 'n', 'x', 'o' }, 't', ts_repeat_move.builtin_t_expr, { expr = true }) - vim.keymap.set({ 'n', 'x', 'o' }, 'T', ts_repeat_move.builtin_T_expr, { expr = true }) - end, - }, - -- NOTE: Might conflict with treeobj but it adds IQ and AQ for any quotes which is cool - -- The rest can probably be disabled, but I will try it out and only disable if it annoys me - -- Also it does (/{ etc ignore whitespace but )/} don't, which is interesting ig - -- { 'echasnovski/mini.ai', version = false, opts = {}, lazy = false }, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-ts-autotag.lua b/.config/nvim/lua/custom/plugins/nvim-ts-autotag.lua deleted file mode 100644 index e806a45..0000000 --- a/.config/nvim/lua/custom/plugins/nvim-ts-autotag.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'windwp/nvim-ts-autotag', - event = { 'BufReadPre', 'BufNewFile' }, - opts = { opts = { enable_close_on_slash = true } }, -} diff --git a/.config/nvim/lua/custom/plugins/octo.lua b/.config/nvim/lua/custom/plugins/octo.lua deleted file mode 100644 index 26c1dbb..0000000 --- a/.config/nvim/lua/custom/plugins/octo.lua +++ /dev/null @@ -1,23 +0,0 @@ -return { - 'pwntester/octo.nvim', - cmd = 'Octo', - keys = { - { 'gi', 'Octo issue search', desc = '[G]ithub [I]ssues (local)' }, - { 'pr', 'Octo pr search', desc = 'Github [PR]s (local)' }, - { 'gI', 'Octo search is:issue is:open author:@me', desc = '[G]ithub [I]ssues (global)' }, - { 'pR', 'Octo search is:pr author:@me', desc = 'Github [PR]s (global)' }, - }, - config = function() - require('octo').setup({ suppress_missing_scope = { projects_v2 = true } }) - - vim.treesitter.language.register('markdown', 'octo') - vim.api.nvim_create_autocmd('FileType', { - pattern = 'octo', - callback = function() - -- Autocomplete for @ (user mention) and # (issue) - vim.keymap.set('i', '@', '@', { silent = true, buffer = true }) - vim.keymap.set('i', '#', '#', { silent = true, buffer = true }) - end, - }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/oil.lua b/.config/nvim/lua/custom/plugins/oil.lua deleted file mode 100644 index 7b7521d..0000000 --- a/.config/nvim/lua/custom/plugins/oil.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - 'stevearc/oil.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - keys = { { 'fo', 'Oil', desc = '[F]ilesystem [O]il' } }, - opts = { - delete_to_trash = true, - default_file_explorer = true, - skip_confirm_for_simple_edits = true, - keymaps = { - ['gs'] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = 'actions.select_split', - [''] = 'actions.select_vsplit', - [''] = 'actions.refresh', - ['Q'] = 'actions.close', - ['gS'] = 'actions.change_sort', - ['gy'] = 'actions.copy_to_system_clipboard', - ['gp'] = 'actions.paste_from_system_clipboard', - }, - view_options = { - show_hidden = true, - natural_order = true, - }, - - lsp_file_methods = { - -- Enable or disable LSP file operations - enabled = true, - -- Time to wait for LSP file operations to complete before skipping - timeout_ms = 1000, - -- Set to true to autosave buffers that are updated with LSP willRenameFiles - -- Set to "unmodified" to only save unmodified buffers - autosave_changes = false, - }, - }, - cmd = 'Oil', - event = 'VimEnter', -} diff --git a/.config/nvim/lua/custom/plugins/overseer.lua b/.config/nvim/lua/custom/plugins/overseer.lua deleted file mode 100644 index bd27efc..0000000 --- a/.config/nvim/lua/custom/plugins/overseer.lua +++ /dev/null @@ -1,49 +0,0 @@ -return { - 'stevearc/overseer.nvim', - -- NOTE: without telescope the UI is not custom, so making sure telescope is loaded first - dependencies = { 'nvim-telescope/telescope.nvim' }, - -- event = 'VeryLazy', - keys = function() - local overseer = require('overseer') - local RUN_TAG = overseer.TAG.RUN - local BUILD_TAG = overseer.TAG.BUILD - local TEST_TAG = overseer.TAG.TEST - local function run_template(tag, show_prompt) - return function() - local prompt = show_prompt and 'always' or 'avoid' - overseer.run_template({ tags = { tag }, first = true, prompt = prompt }) - -- overseer.open({ enter = false }) -- don't focus - end - end - return { - { 'or', run_template(RUN_TAG, false), desc = '[O]verseer [R]un' }, - { 'oR', run_template(RUN_TAG, true), desc = '[O]verseer [R]un (with params)' }, - - { 'ob', run_template(BUILD_TAG, false), desc = '[O]verseer [B]uild' }, - { 'oB', run_template(BUILD_TAG, true), desc = '[O]verseer [B]uild (with params)' }, - - { 'ot', run_template(TEST_TAG, false), desc = '[O]verseer [T]est' }, - { 'oT', run_template(TEST_TAG, true), desc = '[O]verseer [T]est (with params)' }, - - { 'ow', 'OverseerToggle!', desc = '[O]verseer [W]indow (toggle)' }, - { 'oW', 'OverseerQuickAction open float', desc = '[O]verseer [W]indow (terminal float)' }, - } - end, - opts = { - templates = { 'builtin', 'custom' }, - task_list = { - min_height = 0.5, - bindings = { - ['o'] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = false, - [''] = 'ScrollOutputUp', - [''] = 'ScrollOutputDown', - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/pretty-hover.lua b/.config/nvim/lua/custom/plugins/pretty-hover.lua deleted file mode 100644 index 5be5381..0000000 --- a/.config/nvim/lua/custom/plugins/pretty-hover.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'Fildo7525/pretty_hover', - event = 'LspAttach', - opts = {}, -} diff --git a/.config/nvim/lua/custom/plugins/render-markdown.lua b/.config/nvim/lua/custom/plugins/render-markdown.lua deleted file mode 100644 index a7ae2b7..0000000 --- a/.config/nvim/lua/custom/plugins/render-markdown.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - 'MeanderingProgrammer/render-markdown.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - keys = { - { 'mt', '<RenderMarkdown toggle'} - }, - opts = { - render_modes = true, - sign = { enabled = false }, - bullet = { icons = { '', '◆' } }, - checkbox = { - unchecked = { icon = ' ' }, - checked = { icon = ' ' }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/rustaceanvim.lua b/.config/nvim/lua/custom/plugins/rustaceanvim.lua deleted file mode 100644 index 4f509a2..0000000 --- a/.config/nvim/lua/custom/plugins/rustaceanvim.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - 'mrcjkb/rustaceanvim', - version = '^5', - lazy = false, -- already lazy - init = function () - require("custom.config.rustaceanvim") - end -} diff --git a/.config/nvim/lua/custom/plugins/snacks.lua b/.config/nvim/lua/custom/plugins/snacks.lua deleted file mode 100644 index 50f4ff2..0000000 --- a/.config/nvim/lua/custom/plugins/snacks.lua +++ /dev/null @@ -1,45 +0,0 @@ -return { - 'folke/snacks.nvim', - priority = 1000, - lazy = false, - ---@type snacks.Config - opts = { - image = {}, - ---@class snacks.notifier.Config - notifier = { - ---@type snacks.notifier.style - style = 'compact', - filter = function(notif) - local filtered_messages = { 'No information available', 'No code actions available' } - for _, msg in ipairs(filtered_messages) do - if notif.msg == msg then - return false - end - end - return true - end, - }, - }, - keys = { - { - 'si', - function() - Snacks.image.hover() - end, - }, - { - 'nd', - function() - Snacks.notifier.hide() - end, - desc = '[N]otifications [D]ismiss All', - }, - { - 'nh', - function() - Snacks.notifier.show_history() - end, - desc = '[N]otifications [D]ismiss All', - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/sqls.lua b/.config/nvim/lua/custom/plugins/sqls.lua deleted file mode 100644 index a060415..0000000 --- a/.config/nvim/lua/custom/plugins/sqls.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'nanotee/sqls.nvim', -} diff --git a/.config/nvim/lua/custom/plugins/suda.lua b/.config/nvim/lua/custom/plugins/suda.lua deleted file mode 100644 index 39866cd..0000000 --- a/.config/nvim/lua/custom/plugins/suda.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'lambdalisue/vim-suda', - event = { 'BufReadPre', 'BufNewFile' }, -} diff --git a/.config/nvim/lua/custom/plugins/telescope.lua b/.config/nvim/lua/custom/plugins/telescope.lua deleted file mode 100644 index af0534b..0000000 --- a/.config/nvim/lua/custom/plugins/telescope.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - 'nvim-telescope/telescope.nvim', - tag = '0.1.5', - dependencies = { - 'nvim-lua/plenary.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - 'nvim-telescope/telescope-ui-select.nvim', - }, - cmd = 'Telescope', - config = function() - require('custom.config.telescope') - end, - keys = { - 'fs', - 'fa', - 'fh', - 'fm', - 'lv', - 'f.', - 'th', - }, -} diff --git a/.config/nvim/lua/custom/plugins/tiny-inline-diagnostic.lua b/.config/nvim/lua/custom/plugins/tiny-inline-diagnostic.lua deleted file mode 100644 index 620f20f..0000000 --- a/.config/nvim/lua/custom/plugins/tiny-inline-diagnostic.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - 'rachartier/tiny-inline-diagnostic.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - opts = { - options = { - -- Throttle the update of the diagnostic when moving cursor, in milliseconds. - -- You can increase it if you have performance issues. - -- Or set it to 0 to have better visuals. - throttle = 0, - - -- The minimum length of the message, otherwise it will be on a new line. - softwrap = 15, - - -- If multiple diagnostics are under the cursor, display all of them. - multiple_diag_under_cursor = true, - - --- Enable it if you want to always have message with `after` characters length. - break_line = { - enabled = false, - after = 30, - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/todo-comments.lua b/.config/nvim/lua/custom/plugins/todo-comments.lua deleted file mode 100644 index 799afd8..0000000 --- a/.config/nvim/lua/custom/plugins/todo-comments.lua +++ /dev/null @@ -1,95 +0,0 @@ --- NORMAL: lorem ipsum --- TODO: lorem ipsum --- FIX: lorem ipsum --- OPTIMIZE: lorem ipsum --- WARN: lorem ipsum --- PERF: lorem ipsum --- HACK: lorem ipsum --- NOTE: lorem ipsum --- TEST: lorem ipsum --- UNSAFE: lorem ipsum -return { - 'folke/todo-comments.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, - event = 'VeryLazy', - keys = { - { 'st', 'TodoTelescope keywords=TODO,FIX', desc = '[S]earch [T]odos' }, - { 'lt', 'TodoTrouble', desc = '[L]ist [T]odos' }, - }, - config = function() - require('todo-comments').setup({ - signs = false, -- show icons in the signs column - sign_priority = 8, -- sign priority - keywords = { - -- NOTE: These are "todos" - TODO = { icon = ' ', color = 'info', alt = { 'todo' } }, - FIX = { icon = ' ', color = 'error', alt = { 'FIXME', 'BUG', 'ISSUE' } }, - OPTIMIZE = { icon = ' ', color = 'performance' }, - -- NOTE: These are "notes" - WARN = { icon = ' ', color = 'warning', alt = { 'WARNING' } }, - PERF = { icon = ' ', color = 'performance', alt = { 'PERFORMANCE' } }, - HACK = { icon = ' ', color = 'warning', alt = { 'SMELL', 'CODE SMELL', 'BAD', 'BAD PRACTICE' } }, - NOTE = { icon = ' ', color = 'hint', alt = { 'INFO' } }, - TEST = { icon = '󰙨 ', color = 'test', alt = { 'TESTING', 'PASSED', 'FAILED' } }, - UNSAFE = { icon = '󰍛 ', color = 'error', alt = { 'SAFETY' } }, - }, - gui_style = { - fg = 'NONE', - bg = 'BOLD', - }, - merge_keywords = true, -- when true, custom keywords will be merged with the defaults - -- highlighting of the line containing the todo comment - -- * before: highlights before the keyword (typically comment characters) - -- * keyword: highlights of the keyword - -- * after: highlights after the keyword (todo text) - highlight = { - multiline = true, - multiline_pattern = '^.', -- lua pattern to match the next multiline from the start of the matched keyword - multiline_context = 10, -- extra lines that will be re-evaluated when changing a line - before = '', -- "fg" or "bg" or empty - keyword = 'wide', -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg) - after = 'fg', -- "fg" or "bg" or empty - -- TODO(): - pattern = { - -- [[.*<(KEYWORDS)\s*(.*)?\s*:]], -- default - [[.*<(KEYWORDS)\s*:]], -- default - [[.*<(KEYWORDS)\s*!?\(\):]], -- keyword!() syntax - -- [[.*<(KEYWORDS)\s*\(.*\):]], -- keyword(anything) syntax - [[.*<(KEYWORDS)\s* ?\(.*\):]], -- keyword(anything) syntax - [[.*<(KEYWORDSky)\s*:]], -- keyword(anything) syntax - }, -- pattern or table of patterns, used for highlighting (vim regex) - comments_only = false, - max_line_len = 400, - exclude = {}, -- list of excluded filetypes - }, - -- list of named colors where we try to extract the gui fg from the - -- list of highlight groups or use the hex color if hl not found as a fallback - colors = { - default = { 'Identifier', '#7C3AED' }, - error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' }, - warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' }, - info = { 'DiagnosticInfo', '#2563EB' }, - hint = { '#10B981' }, - test = { 'Identifier', '#FF00FF' }, - performance = { '#7C3AED' }, - }, - search = { - command = 'rg', - args = { - '--color=never', - '--no-heading', - '--with-filename', - '--line-number', - '--column', - -- "--hidden", -- show todos in hidden directories and files - '--follow', -- follow symlinks - }, - -- regex that will be used to match keywords. - -- don't replace the (KEYWORDS) placeholder - pattern = [[\b(KEYWORDS)(?:\(([^)]*)\))?:]], -- supports optional `(anything)` before colon - -- pattern = [[\b(KEYWORDS):]], -- default - -- pattern = [[\b(KEYWORDS)\b]], -- no colon - }, - }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/trouble.lua b/.config/nvim/lua/custom/plugins/trouble.lua deleted file mode 100644 index 3239aa7..0000000 --- a/.config/nvim/lua/custom/plugins/trouble.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - 'folke/trouble.nvim', - opts = {}, - cmd = 'Trouble', - -- TODO: Consider maybe using this for outlines (code structure) - -- and also configuring some of the keys to better fit me - -- and probably removing most of them in the process - keys = { - { - 'xx', - 'Trouble diagnostics toggle', - desc = 'Diagnostics (Trouble)', - }, - { - 'xX', - 'Trouble diagnostics toggle filter.buf=0', - desc = 'Buffer Diagnostics (Trouble)', - }, - { - 'cs', - 'Trouble symbols toggle focus=false', - desc = 'Symbols (Trouble)', - }, - { - 'cl', - 'Trouble lsp toggle focus=false win.position=right', - desc = 'LSP Definitions / references / ... (Trouble)', - }, - { - 'xL', - 'Trouble loclist toggle', - desc = 'Location List (Trouble)', - }, - { - 'xQ', - 'Trouble qflist toggle', - desc = 'Quickfix List (Trouble)', - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/undotree.lua b/.config/nvim/lua/custom/plugins/undotree.lua deleted file mode 100644 index cbbeffb..0000000 --- a/.config/nvim/lua/custom/plugins/undotree.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 'mbbill/undotree', - keys = { { 'ut', vim.cmd.UndotreeToggle } }, - config = function() - vim.g.undotree_DiffAutoOpen = false - vim.g.undotree_DiffpanelHeight = 0 - vim.g.undotree_SetFocusWhenToggle = false - vim.g.undotree_HelpLine = false - vim.g.undotree_TreeNodeShape = '' - vim.g.undotree_TreeVertShape = '│' - vim.g.undotree_TreeSplitShape = '─┘' - vim.g.undotree_TreeReturnShape = '─┐' - end, -} diff --git a/.config/nvim/lua/custom/plugins/vim-be-good.lua b/.config/nvim/lua/custom/plugins/vim-be-good.lua deleted file mode 100644 index 03fd98f..0000000 --- a/.config/nvim/lua/custom/plugins/vim-be-good.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'ThePrimeagen/vim-be-good', - cmd = 'VimBeGood', -} diff --git a/.config/nvim/lua/custom/plugins/vim-illuminate.lua b/.config/nvim/lua/custom/plugins/vim-illuminate.lua deleted file mode 100644 index 69091db..0000000 --- a/.config/nvim/lua/custom/plugins/vim-illuminate.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'RRethy/vim-illuminate', - event = 'LspAttach', - keys = { - { 'it', 'IlluminateToggle', desc = '[I]lluminate [Tloggle]' }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/vim-tmux-navigator.lua b/.config/nvim/lua/custom/plugins/vim-tmux-navigator.lua deleted file mode 100644 index de08d82..0000000 --- a/.config/nvim/lua/custom/plugins/vim-tmux-navigator.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - 'christoomey/vim-tmux-navigator', - keys = { - { '', 'TmuxNavigateLeft', mode = { 'n', 'i' } }, - { '', 'TmuxNavigateDown', mode = { 'n', 'i' } }, - { '', 'TmuxNavigateUp', mode = { 'n', 'i' } }, - { '', 'TmuxNavigateRight', mode = { 'n', 'i' } }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/vim-wakatime.lua b/.config/nvim/lua/custom/plugins/vim-wakatime.lua deleted file mode 100644 index 515c6d0..0000000 --- a/.config/nvim/lua/custom/plugins/vim-wakatime.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'wakatime/vim-wakatime', - event = 'VeryLazy', -} diff --git a/.config/nvim/lua/custom/snippets/go.lua b/.config/nvim/lua/custom/snippets/go.lua deleted file mode 100644 index d6b7114..0000000 --- a/.config/nvim/lua/custom/snippets/go.lua +++ /dev/null @@ -1,77 +0,0 @@ -require('luasnip.session.snippet_collection').clear_snippets('go') -local ls = require('luasnip') -local s = ls.snippet -local t = ls.text_node -local i = ls.insert_node -local d = ls.dynamic_node - ----@param abbr string ----@param expansion string ----@param args table -local function snip(abbr, expansion, args) - return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args)) -end - -local tea_model = [=[ -import ( - "fmt" - - tea "github.com/charmbracelet/bubbletea" -) - -type Model struct{{ - {} -}} - -func New() Model {{ - return Model{{ - }} -}} - -func (m Model) Init() tea.Cmd {{ - return nil -}} - -func (m Model) View() string {{ - return fmt.Sprintf( - "%s", - "", - ) -}} - -func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {{ - switch msg := msg.(type) {{ - default: - return m, nil - }} -}} -]=] - -local server_api = [=[ -func {}(ctx context.Context, sess *session.Session, request packet{}) packet.Payload {{ -}} -]=] - -ls.add_snippets('go', { - snip('tmod', tea_model, { i(0) }), - snip('sapi', server_api, { i(1), i(0) }), - - s('iferr', { - t({ 'if err != nil {', '' }), - i(1, ' return'), - t({ '', '}' }), - }), - - s('fmterr', { - t('fmt.Errorf("'), - i(1, 'msg'), - t(': %w", err)'), - }), - - s('dberr', { - t({ 'if err != nil {', '' }), - i(2, { ' log.Println("database error ', 'x', ':", err)', '' }), - i(2, ' return ', '&ErrInternalError'), - t({ '', '}' }), - }), -}) diff --git a/.config/nvim/lua/custom/snippets/lua.lua b/.config/nvim/lua/custom/snippets/lua.lua deleted file mode 100644 index 194f776..0000000 --- a/.config/nvim/lua/custom/snippets/lua.lua +++ /dev/null @@ -1,37 +0,0 @@ -require('luasnip.session.snippet_collection').clear_snippets('lua') -local ls = require('luasnip') -local i = ls.insert_node - ----@param abbr string ----@param expansion string ----@param args table -local function s(abbr, expansion, args) - return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args)) -end - -local carbonight_group = [=[ ---[[ -Copyright (C) 2024 Kyren223 -This file is licensed under the GPL-3.0-or-later license, see https://fsf.org/licenses/gpl-3.0 ---]] - -local utils = require("carbonight.utils") - -local M = {{}} - ----@param c Colors -function M.get(c) - return {{ - {} - }} -end - -return M -]=] - -ls.add_snippets('lua', { - s('desc', "{{ desc = '{}' }}", { i(0) }), - s('cmd', '{}', { i(0) }), - s('scmd', "'{}'", { i(0) }), - s('cng', carbonight_group, { i(0) }), -}) diff --git a/.config/nvim/lua/dap-keymaps.lua b/.config/nvim/lua/dap-keymaps.lua new file mode 100644 index 0000000..8c3d540 --- /dev/null +++ b/.config/nvim/lua/dap-keymaps.lua @@ -0,0 +1,18 @@ +local keymaps = { + { 'n', 'dr', 'DapContinue', { desc = '[D]ebug [R]esume (or start)' } }, + { 'n', 'dR', 'DapRestartFrame', { desc = '[D]ebug [R]estart' } }, + { 'n', 'dt', 'DapRestartFrame', { desc = '[D]ebug [R]estart' } }, + { 'n', 'dp', 'DapToggleBreakpoint', { desc = '[D]ebug Break[p]oint' } }, + { 'n', 'dh', 'lua require("dap.ui.widgets").hover()', { desc = '[D]ebug [H]over' } }, + { 'n', 'si', 'DapStepInto', { desc = '[S]tep [I]nto' } }, + { 'n', 'so', 'DapStepOver', { desc = '[S]tep [O]ver' } }, + { 'n', 'sO', 'DapStepOut', { desc = '[S]tep [O]ut' } }, +} + +for _, keymap in ipairs(keymaps) do + local mode = keymap[1] + local lhs = keymap[2] + local rhs = keymap[3] + local opts = keymap[4] or {} + vim.keymap.set(mode, lhs, rhs, opts) +end diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua new file mode 100644 index 0000000..36134dd --- /dev/null +++ b/.config/nvim/lua/keymaps.lua @@ -0,0 +1,99 @@ +local set = vim.keymap.set +local silent = { silent = true } +---@param mode string|table +---@param keymap string +local function unbind(mode, keymap) + set(mode, keymap, function() end) +end + +local function toggle_zen() + vim.cmd('Neotree close') + vim.cmd('Trouble todo close') + vim.cmd('UndotreeHide') +end + +local function yank_filepath_to_clipboard(os) + return function() + local filepath = vim.fn.expand('%:p') + if os == 'linux' then + local home_dir = vim.fn.expand('~') + filepath = filepath:gsub(home_dir, '~') + elseif os == 'windows' then + local mnt = '/mnt/' + if filepath:sub(1, #mnt) == mnt then + filepath = filepath:sub(#mnt + 1, #mnt + 1) .. ':' .. filepath:sub(#mnt + 2) + else + filepath = '//wsl.localhost/openSUSE-Tumbleweed' .. filepath + end + filepath = filepath:gsub('/', '\\') + end + vim.fn.setreg('+', filepath) + end +end + +function RemoveClipboardCR() + local clipboard = vim.fn.getreg('+'):gsub('\r', '') + vim.fn.setreg('+', clipboard) +end + +local function paste() + RemoveClipboardCR() + local value = vim.fn.getreg('+') + if vim.fn.mode() == 'c' then + -- value = vim.split(value, '\n')[1] -- only use first line (default with normal pasting) + value = value:gsub('\n', ' ') -- replace newlines with spaces + vim.api.nvim_feedkeys(value, 'c', false) + else + vim.api.nvim_put(vim.split(value, '\n'), 'c', false, true) + end +end + +-- "Greatest Keymap ever" - ThePrimeagen +-- https://www.youtube.com/watch?v=qZO9A5F6BZs&list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&index=4 +set('x', 'p', 'lua RemoveClipboardCR()"_dP') + +set({ 'n', 'x' }, 'p', 'lua RemoveClipboardCR()p', { noremap = true }) +set({ 'n', 'x' }, 'P', 'lua RemoveClipboardCR()P', { noremap = true }) + +-- Move lines around +set('n', '', ":m .+1", { noremap = true }) +set('n', '', ":m .-2", { noremap = true }) +set('v', '', ":m '>+1gv", { noremap = true }) +set('v', '', ":m '<-2gv", { noremap = true }) + +-- Misc +set({ 'n', 'i' }, '', 'ggVG', { desc = 'Visually Highlight [A]ll' }) +set('i', '', '', { desc = 'Ctrl + Backspace to delete word' }) +set('n', '', 'nohlsearch', silent) +set({ 'i', 'c' }, '', paste) +set('n', 'z', toggle_zen, { desc = '[Z]en Mode', silent = true }) +unbind({ 'i', 'n', 'v' }, '') + +set('n', 'U', 'redo') +set('i', '', 'undo') +set({ 'i', 'n', 'v' }, '', 'wqa') +set('n', 'yp', yank_filepath_to_clipboard('linux'), { desc = '[Y]oink File [P]ath (linux)' }) +set('n', 'yP', yank_filepath_to_clipboard('windows'), { desc = '[Y]oink File [P]ath (windows)' }) + +-- Window Navigation - NO NEED BECAUSE IT CONFLICTS WITH TMUX +-- set('n', '', '', { desc = 'Move focus to the left window' }) +-- set('n', '', '', { desc = 'Move focus to the down window' }) +-- set('n', '', '', { desc = 'Move focus to the up window' }) +-- set('n', '', '', { desc = 'Move focus to the right window' }) + +-- Window resizing +local resize = 2 +set({ 'n', 't' }, '', string.format('vertical resize -%d', resize), { desc = 'Resize Left' }) +set({ 'n', 't' }, '', string.format('resize -%d', resize), { desc = 'Resize Up' }) +set({ 'n', 't' }, '', string.format('resize +%d', resize), { desc = 'Resize Down' }) +set({ 'n', 't' }, '', string.format('vertical resize +%d', resize), { desc = 'Resize Right' }) + +-- Keep selection after < and > in visual mode +set('v', '<', '', '>gv') +-- Execute lua file or line +set('n', 'x', '.lua', { desc = 'Execute the current line' }) +set('n', 'x', 'source %', { desc = 'Execute the current file' }) + +-- Reformats file using lsp +set('n', '=', vim.lsp.buf.format, { desc = 'Format File' }) diff --git a/.config/nvim/lua/language-servers.lua b/.config/nvim/lua/language-servers.lua new file mode 100644 index 0000000..f7e28c1 --- /dev/null +++ b/.config/nvim/lua/language-servers.lua @@ -0,0 +1,155 @@ +-- NOTE: a table or true to enable, false to disable +return { + lua_ls = { + settings = { + diagnostics = { globals = { 'vim' } }, + telemetry = { enabled = false }, + hint = { enable = true }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.stdpath('config') .. '/lua'] = true, + }, + }, + }, + }, -- lua + clangd = { + mason = false, + cmd = { + 'clangd', + '--background-index', + '--clang-tidy', + '--header-insertion=iwyu', + '--completion-style=detailed', + '--function-arg-placeholders', + '--fallback-style=llvm', + }, + root_dir = function(filename) + return require('lspconfig/util').root_pattern( + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + '.git' + )(filename) or vim.fn.getcwd() + end, + init_options = { + usePlaceholders = true, + completeUnimported = true, + clangdFileStatus = true, + }, + }, -- c/cpp + neocmake = { + root_dir = function(filename) + return require('lspconfig/util').root_pattern( + 'CMakePresets.json', + 'CTestConfig.cmake', + 'build', + 'cmake', + '.git' -- NOTE: git is last due to monorepos (so it tries to use build/cmake first) + )(filename) or vim.fn.getcwd() + end, + }, + pyright = { + settings = { + python = { + pythonPath = '~/python/venv/bin/python', + }, + }, + }, -- python + bashls = true, -- bash + taplo = true, -- toml + lemminx = true, -- xml + yamlls = true, -- yaml + jsonls = true, -- json + html = true, -- html + cssls = true, -- css + ts_ls = true, -- javascript/typescript + astro = true, -- astro framework + mdx_analyzer = true, -- markdown with JS I think + -- marksman = true, -- Markdown LSP + markdown_oxide = true, -- Markdown LSP but better + gopls = { + cmd = { 'gopls' }, + filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, + root_dir = function(filename) + return require('lspconfig/util').root_pattern('go.work', 'go.mod', '.git')(filename) + end, + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = false, + compositeLiteralFields = false, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = false, + parameterNames = false, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = false, + completeUnimported = true, + staticcheck = true, + directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' }, + semanticTokens = true, + }, + }, + }, -- Go LSP + jdtls = true, -- java + -- sqlls = true, + -- sqls = { + -- on_attach = function(client, bufnr) + -- require('sqls').on_attach(client, bufnr) + -- end, + -- settings = { + -- sqls = { + -- connections = { + -- { + -- driver = 'sqlite3', + -- dataSourceName = '/home/kyren/projects/eko/server.db', + -- }, + -- }, + -- }, + -- }, + -- }, + zls = { + mason = false, + cmd = { 'zls' }, + settings = { + zls = { + enable_build_on_save = true, + build_on_save_args = {}, + enable_argument_placeholders = false, + warn_style = true, + + inlay_hints_show_variable_type_hints = true, + inlay_hints_show_struct_literal_field_type = true, + inlay_hints_show_parameter_name = true, + inlay_hints_show_builtin = true, + inlay_hints_hide_redundant_param_names = true, + inlay_hints_hide_redundant_param_names_last_token = true, + }, + }, + }, -- zig + nil_ls = {}, -- nix + asm_lsp = { + mason = false, + cmd = { 'asm-lsp' }, + }, +} diff --git a/.config/nvim/lua/lsp-keymaps.lua b/.config/nvim/lua/lsp-keymaps.lua new file mode 100644 index 0000000..7bbc2e8 --- /dev/null +++ b/.config/nvim/lua/lsp-keymaps.lua @@ -0,0 +1,73 @@ +local severity = vim.diagnostic.severity +local function next_diagnostic(diagnostic_severity) + return function() + require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity }) + end +end +local function prev_diagnostic(diagnostic_severity) + return function() + require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity }) + end +end +local function cursor_diagnostics() + vim.diagnostic.open_float({ + scope = 'cursor', + border = 'single', + }) +end + +local keymaps = { + { 'n', 'gd', 'Lspsaga goto_definition', { desc = '[G]oto [D]efinition' } }, + -- { 'n', 'gu', 'Telescope lsp_references', { desc = '[G]oto [U]sages' } }, + { 'n', 'gu', 'Lspsaga finder', { desc = '[G]oto [U]sages' } }, + { 'n', 'gi', 'Telescope lsp_implementations', { desc = '[G]oto [I]mplementations' } }, + { 'n', 'gt', 'Telescope lsp_type_definitions', { desc = '[G]oto [T]ype Definitions' } }, + { 'n', 'ds', 'Telescope lsp_document_symbols', { desc = '[D]ocument [S]symbols' } }, + { 'n', 'ps', 'Telescope lsp_workspace_symbols', { desc = '[P]roject [S]ymbols' } }, + { { 'n', 'i' }, '', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } }, + { 'n', 'K', 'Lspsaga hover_doc', { desc = 'Documentation' } }, + { 'n', 'R', 'Lspsaga rename', { desc = '[R]ename' } }, + { { 'n', 'i' }, '', 'Lspsaga code_action', { desc = 'Code Actions' } }, + { 'n', 'ca', 'Lspsaga code_action', { desc = '[C]ode [A]ctions' } }, + { 'n', 'e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } }, + { 'n', 'E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } }, + { 'n', 'w', next_diagnostic(severity.WARN), { desc = 'Goto [W]arning' } }, + { 'n', 'W', prev_diagnostic(severity.WARN), { desc = 'Goto [W]arning (prev)' } }, + { 'n', 'D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } }, +} + +for _, ft in ipairs({ 'c', 'h', 'cpp', 'hpp' }) do + keymaps[ft] = { + { 'n', 'H', 'ClangdSwitchSourceHeader', { desc = '[H]eader and Source Switcher' } }, + { 'n', 'K', 'lua require("pretty_hover").hover()', { desc = 'Documentation Hover' } }, + } +end + +local function set_keymaps(tbl, bufnr) + for _, keymap in ipairs(tbl) do + local mode = keymap[1] + local lhs = keymap[2] + local rhs = keymap[3] + local opts = keymap[4] or {} + opts.buffer = bufnr + vim.keymap.set(mode, lhs, rhs, opts) + end +end + +local M = {} + +--- Registers LSP keymaps for the given buffer +---@param bufnr number: the id of the buffer +M.setup = function(bufnr) + local filetype = vim.bo[bufnr].filetype + set_keymaps(keymaps, bufnr) + for ft, tbl in pairs(keymaps) do + if type(ft) == 'number' or ft ~= filetype then + goto continue + end + set_keymaps(tbl, bufnr) + ::continue:: + end +end + +return M diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua new file mode 100644 index 0000000..89fbc58 --- /dev/null +++ b/.config/nvim/lua/lsp.lua @@ -0,0 +1,73 @@ +local lspconfig = require('lspconfig') +local capabilities = require('cmp_nvim_lsp').default_capabilities() + +local servers = require('language-servers') +for name, config in pairs(servers) do + if config == false then + goto continue + end + if config == true then + ---@diagnostic disable-next-line: cast-local-type + config = {} + end + + -- NOTE: there must be a better way to do it, but it will do for now + if name == 'markdown_oxide' then + ---@diagnostic disable-next-line: cast-local-type + config = vim.tbl_deep_extend('force', {}, { + capabilities = vim.tbl_deep_extend('force', capabilities, { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + }), + }, config) + else + ---@diagnostic disable-next-line: cast-local-type + config = vim.tbl_deep_extend('force', {}, { + capabilities = capabilities, + }, config) + end + + lspconfig[name].setup(config) + ::continue:: +end + +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local bufnr = args.buf + local client = assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client') + + local settings = servers[client.name] + if type(settings) ~= 'table' then + ---@diagnostic disable-next-line: cast-local-type + settings = {} + end + + -- Override server capabilities + if settings.server_capabilities then + for k, v in pairs(settings.server_capabilities) do + if v == vim.NIL then + v = nil + end + client.server_capabilities[k] = v + end + end + + -- Workaround for semantic tokens apparently? + -- https://www.lazyvim.org/extras/lang/go + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + if client.name == 'gopls' and not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { tokenModifiers = semantic.tokenModifiers, tokenTypes = semantic.tokenTypes }, + range = true, + } + end + + -- Register buffer local LSP keymaps + require('lsp-keymaps').setup(bufnr) + end, +}) diff --git a/.config/nvim/lua/lualine_helper.lua b/.config/nvim/lua/lualine_helper.lua new file mode 100644 index 0000000..53cd7fe --- /dev/null +++ b/.config/nvim/lua/lualine_helper.lua @@ -0,0 +1,92 @@ +local lualine = require('lualine') +local lsp_progress = require('lsp-progress') + +local progress_filled = '█' +local progress_empty = '░' +local function progress_bar(percentage, width) + -- Ensure i is an integer between 0 and width (inclusive) + local i = math.max(0, math.min(math.floor(width * percentage), width)) + return string.rep(progress_filled, i) .. string.rep(progress_empty, width - i) +end + +local progress_bar_width = 10 +lsp_progress.setup({ + format = function(client_messages) -- global + local sign = ' LSP' + if #client_messages > 0 then + return sign .. ' ' .. table.concat(client_messages, ' ') + end + if #require('lsp-progress.api').lsp_clients() > 0 then + return sign + end + return '' + end, + client_format = function(_, _, series_messages) -- per lsp + return #series_messages > 0 and table.concat(series_messages, ', ') or nil + end, + series_format = function(title, message, percentage, done) -- per progress + local builder = {} + local has_title = false + local has_message = false + if type(title) == 'string' and string.len(title) > 0 then + table.insert(builder, title .. ':') + has_title = true + end + if percentage then + table.insert(builder, string.format('%.0f%%', percentage)) + table.insert(builder, 1, progress_bar(percentage / 100, progress_bar_width)) + end + if type(message) == 'string' and string.len(message) > 0 then + table.insert(builder, string.format('(%s)', message)) + has_message = true + end + if done and (has_title or has_message) then + table.insert(builder, ' ') + end + return table.concat(builder, ' ') + end, +}) + +lualine.setup({ + options = { + globalstatus = true, + theme = 'auto', + }, + sections = { + lualine_a = { { 'mode', icon = '' } }, + lualine_b = { + -- require('auto-session.lib').current_session_name, + { 'branch', icon = '' }, + { + 'diagnostics', + symbols = { + error = '󰅙 ', + warn = '󰀦 ', + info = '󰋼 ', + hint = '󰌵 ', + }, + }, + }, + lualine_c = { + function() + return lsp_progress.progress() + end, + }, + lualine_x = { + 'searchcount', + 'encoding', + 'fileformat', + 'filetype', + }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + extensions = { 'oil', 'trouble' }, +}) + +-- Refresh lualine when lsp progress is updated +vim.api.nvim_create_autocmd('User', { + group = vim.api.nvim_create_augroup('lualine_augroup', { clear = true }), + pattern = 'LspProgressStatusUpdated', + callback = require('lualine').refresh, +}) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..3e77e0f --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,61 @@ +-- System +vim.g.have_nerd_font = true +vim.opt.mouse = 'a' -- enable mouse +vim.opt.clipboard = 'unnamedplus' -- use system clipboard +vim.opt.undofile = true -- persist undo history by saving it to a file +vim.opt.exrc = true -- WARNING: runs .nvim.lua in cwd, which may execute arbitrary code + +-- Tab +vim.opt.expandtab = true -- convert tabs to spaces +vim.opt.tabstop = 4 -- number of visual spaces per TAB +vim.opt.softtabstop = 4 -- number of idfk tab when editing +vim.opt.shiftwidth = 4 -- number of spaces to insert on tab + +-- UI +vim.opt.colorcolumn = '80' +vim.opt.signcolumn = 'auto:9' +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true -- highlight current line +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.showmode = false -- don't show mode, because lualine already does +vim.opt.list = true +vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' } +vim.diagnostic.config({ signs = false }) -- disable signcolumn diagnostics +vim.opt.fillchars:append({ diff = '╱' }) -- nicer diff view for filled spaces + +-- Searching +vim.opt.hlsearch = true +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Misc +vim.opt_local.wrap = false +vim.opt.wrap = false +vim.opt.scrolloff = 8 +vim.opt.termguicolors = true +vim.opt.laststatus = 3 -- views can only be fully collapsed with the global statusline +vim.opt.splitkeep = 'screen' -- for edgy.nvim +vim.opt.inccommand = 'split' -- shows preview for commands like :%s/from/to + +-- Disable warnings for missing language providers +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_python3_provider = 0 + +-- LSP +vim.lsp.inlay_hint.enable() +vim.diagnostic.config({ virtual_text = false, update_in_insert = true }) + +-- Add support for mdx files +vim.filetype.add({ + extension = { + mdx = 'markdown', + }, +}) + +-- Zig LSP settings +vim.g.zig_fmt_parse_errors = 0 +vim.g.zig_fmt_autosave = 0 diff --git a/.config/nvim/lua/plugins/activity-watch.lua b/.config/nvim/lua/plugins/activity-watch.lua new file mode 100644 index 0000000..1fef86c --- /dev/null +++ b/.config/nvim/lua/plugins/activity-watch.lua @@ -0,0 +1,9 @@ +return { + 'lowitea/aw-watcher.nvim', + opts = { + aw_server = { + host = '127.0.0.1', + port = 5600, + }, + }, +} diff --git a/.config/nvim/lua/plugins/alpha.lua b/.config/nvim/lua/plugins/alpha.lua new file mode 100644 index 0000000..00a7d56 --- /dev/null +++ b/.config/nvim/lua/plugins/alpha.lua @@ -0,0 +1,69 @@ +return { + 'goolord/alpha-nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + cmd = "Alpha", + config = function() + local alpha = require('alpha') + local dashboard = require('alpha.themes.dashboard') + + local function get_natural_day(day) + local suffix = 'th' + local day_mod = day % 10 + + if day_mod == 1 and day ~= 11 then + suffix = 'st' + elseif day_mod == 2 and day ~= 12 then + suffix = 'nd' + elseif day_mod == 3 and day ~= 13 then + suffix = 'rd' + end + + return tostring(day) .. suffix + end + + local find_file_path = '$HOME' + local date = os.date('  %A, %B ') .. get_natural_day(tonumber(os.date('%d'))) + local plugins = '  ' .. require('lazy').stats().count .. ' plugins ' + local v = vim.version() + local version = '  v' .. v.major .. '.' .. v.minor .. '.' .. v.patch + local info_line = date .. plugins .. version + + -- WARN: Just hardcoded the length of the first line in the header + local header_length = #'  ' + local padding = (header_length - #info_line) / 2 + info_line = string.rep(' ', padding) .. info_line + + dashboard.section.header.val = { + [[  ]], + [[ ████ ██████ █████ ██ ██ ]], + [[ ███████████ █████ ███ ]], + [[ █████████ ███████████████████ ███ ███████████ ]], + [[ █████████ ███ █████████████ █████ ██████████████ ]], + [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], + [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], + [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], + [[ ]], + info_line, + } + + dashboard.section.buttons.opts.spacing = 0 + dashboard.section.buttons.val = { + dashboard.button('e', ' > New file', 'ene startinsert'), + dashboard.button('f', ' > Find file', 'cd ' .. find_file_path .. ' | Telescope find_files'), + dashboard.button('r', ' > Recent', 'Telescope oldfiles'), + dashboard.button('c', ' > Configuration', 'e $MYVIMRC | cd %:p:h'), + -- FIX: doesn't seem to work so great, probably just use a project manager + -- will most likely make my own project manager plugin + -- dashboard.button( + -- 's', + -- '󱎠 > Last Session', + -- 'lua require("auto-session.session-lens.actions").alternate_session()' + -- ), + dashboard.button('q', '󰈆 > Quit NVIM', 'qa'), + } + + dashboard.section.footer.val = require('alpha.fortune')() + + alpha.setup(dashboard.opts) + end, +} diff --git a/.config/nvim/lua/plugins/auto-save.lua b/.config/nvim/lua/plugins/auto-save.lua new file mode 100644 index 0000000..5da836b --- /dev/null +++ b/.config/nvim/lua/plugins/auto-save.lua @@ -0,0 +1,33 @@ +return { + 'okuuva/auto-save.nvim', + cmd = 'ASToggle', + event = { 'InsertLeave', 'TextChanged' }, + opts = function() + -- Disable autoformat between automatic saves + vim.api.nvim_create_autocmd('User', { + pattern = 'AutoSaveWritePre', + group = vim.api.nvim_create_augroup('autosave-pre', { clear = true }), + callback = function(opts) + local bufnr = opts.data.saved_buffer + vim.b[bufnr].disable_autoformat = true + end, + }) + + vim.api.nvim_create_autocmd('User', { + pattern = 'AutoSaveWritePost', + group = vim.api.nvim_create_augroup('autosave-post', { clear = true }), + callback = function(opts) + local bufnr = opts.data.saved_buffer + vim.b[bufnr].disable_autoformat = false + end, + }) + + return { + -- execution_message = { enabled = false }, removed + condition = function(buf) + -- Save only if the buffer is not a "special buffer" + return vim.fn.getbufvar(buf, '&buftype') == '' + end, + } + end, +} diff --git a/.config/nvim/lua/plugins/auto-session.lua b/.config/nvim/lua/plugins/auto-session.lua new file mode 100644 index 0000000..cd8d7a4 --- /dev/null +++ b/.config/nvim/lua/plugins/auto-session.lua @@ -0,0 +1,29 @@ +return { + 'rmagatti/auto-session', + lazy = false, + config = function() + vim.opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions' + require('auto-session').setup({ + log_level = 'error', + auto_session_suppress_dirs = { '~/', '/' }, + session_lens = { load_on_setup = false }, + no_restore_cmds = { + function() + if vim.fn.argc() == 0 then + vim.cmd('Alpha') + end + end, + }, + }) + + local session_lens_setup_done = false + local function search_session() + if not session_lens_setup_done then + require('auto-session').setup_session_lens() + session_lens_setup_done = true + end + require('auto-session.session-lens').search_session() + end + vim.keymap.set('n', '', search_session, { desc = '[S]ession Manager' }) + end, +} diff --git a/.config/nvim/lua/plugins/buffer-manager.lua b/.config/nvim/lua/plugins/buffer-manager.lua new file mode 100644 index 0000000..6bce4b8 --- /dev/null +++ b/.config/nvim/lua/plugins/buffer-manager.lua @@ -0,0 +1,13 @@ +return { + 'j-morano/buffer_manager.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + keys = { + { + 'bl', + function() + require('buffer_manager.ui').toggle_quick_menu() + end, + desc = '[B]uffer [L]ist', + }, + }, +} diff --git a/.config/nvim/lua/plugins/buffer-vaccum.lua b/.config/nvim/lua/plugins/buffer-vaccum.lua new file mode 100644 index 0000000..b064b45 --- /dev/null +++ b/.config/nvim/lua/plugins/buffer-vaccum.lua @@ -0,0 +1,5 @@ +return { + 'ChuufMaster/buffer-vacuum', + opts = { max_buffers = 6 }, + event = 'VeryLazy', +} diff --git a/.config/nvim/lua/plugins/bullets.lua b/.config/nvim/lua/plugins/bullets.lua new file mode 100644 index 0000000..5c81e75 --- /dev/null +++ b/.config/nvim/lua/plugins/bullets.lua @@ -0,0 +1,4 @@ +return { + -- 'bullets-vim/bullets.vim', + -- event = { 'BufReadPre', 'BufNewFile' }, +} diff --git a/.config/nvim/lua/plugins/ccc.lua b/.config/nvim/lua/plugins/ccc.lua new file mode 100644 index 0000000..74c033e --- /dev/null +++ b/.config/nvim/lua/plugins/ccc.lua @@ -0,0 +1,13 @@ +return { + 'uga-rosa/ccc.nvim', + opts = { + highlighter = { auto_enable = true }, + -- highlight_mode = 'virtual', + -- virtual_pos = 'inline-right', + }, + event = 'VeryLazy', + keys = { + { 'cp', 'CccPick', desc = '[C]olor [P]icker' }, + { 'ct', 'CccHighlighterToggle', desc = '[C]olor [T]oggle' }, + }, +} diff --git a/.config/nvim/lua/plugins/clangd_extensions.lua b/.config/nvim/lua/plugins/clangd_extensions.lua new file mode 100644 index 0000000..07f9dc0 --- /dev/null +++ b/.config/nvim/lua/plugins/clangd_extensions.lua @@ -0,0 +1,38 @@ +return { + 'p00f/clangd_extensions.nvim', + dependencies = { 'microsoft/vscode-codicons' }, -- NOTE: for the ast icons + cmd = { + 'ClangdSwitchSourceHeader', + 'ClangdSetInlayHints', + 'ClangdDisableInlayHints', + 'ClangdToggleInlayHints', + 'ClangdAST', + 'ClangdSymbolInfo', + 'ClangdTypeHierarchy', + 'ClangdMemoryUsage', + }, + opts = { + inlay_hints = { + inline = false, + }, + ast = { + role_icons = { + type = '', + declaration = '', + expression = '', + specifier = '', + statement = '', + ['template argument'] = '', + }, + kind_icons = { + Compound = '', + Recovery = '', + TranslationUnit = '', + PackExpansion = '', + TemplateTypeParm = '', + TemplateTemplateParm = '', + TemplateParamObject = '', + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/code-playground.lua b/.config/nvim/lua/plugins/code-playground.lua new file mode 100644 index 0000000..751de5b --- /dev/null +++ b/.config/nvim/lua/plugins/code-playground.lua @@ -0,0 +1,7 @@ +return { + 'GustavEikaas/code-playground.nvim', + lazy = false, + config = function() + require('code-playground').setup() + end, +} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..916eae2 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,14 @@ +return { + { + 'folke/tokyonight.nvim', + lazy = false, + priority = 1000, + config = function() + -- vim.cmd.colorscheme('tokyonight-night') + -- require('colorschemes.dapui').set() + -- vim.cmd.colorscheme('carbonight-tokyo') + vim.cmd.colorscheme('carbonight') + end, + }, + { dir = '~/projects/carbonight.nvim' }, +} diff --git a/.config/nvim/lua/plugins/comment.lua b/.config/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..b61675a --- /dev/null +++ b/.config/nvim/lua/plugins/comment.lua @@ -0,0 +1,25 @@ +return { + -- 'numToStr/Comment.nvim', + 'os-mey/Comment.nvim', + branch = 'fix-inline-visual-linewise-comment', + keys = { + { 'gc', mode = { 'n', 'v' } }, + { 'gb', mode = { 'n', 'v' } }, + { '', mode = { 'n', 'v' } }, + { 'gcc', mode = 'n' }, + { 'gcb', mode = 'n' }, + }, + config = function() + require('Comment').setup() + local api = require('Comment.api') + local esc = vim.api.nvim_replace_termcodes('', true, false, true) + local toggle_linewise_selection = function() + vim.api.nvim_feedkeys(esc, 'nx', false) + api.toggle.linewise(vim.fn.visualmode()) + end + + -- means Ctrl slash, `_` is a `/` + vim.keymap.set('n', '', api.toggle.linewise.current, { noremap = true, silent = true }) + vim.keymap.set('v', '', toggle_linewise_selection, { noremap = true, silent = true }) + end, +} diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..fe3356f --- /dev/null +++ b/.config/nvim/lua/plugins/conform.lua @@ -0,0 +1,38 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { 'ft', 'FormatToggle', desc = '[F]ormat [T]oggle Globally' }, + { 'fT', 'FormatToggle!', desc = '[F]ormat [T]oggle Locally' }, + { 'ff', 'Format', desc = '[F]ormat [F]ile' }, + { 'f', 'Format', desc = '[F]ormat', mode = 'v' }, + }, + ---@module "conform" + ---@type conform.setupOpts + opts = { + formatters_by_ft = { + ['lua'] = { 'stylua' }, + ['c'] = { 'clang-format' }, + -- ['python'] = { 'isort', 'black' }, + -- ['rust'] = { 'rustfmt' }, + ['go'] = { 'gofumpt', 'goimports-reviser' }, + ['markdown'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['yaml'] = { 'prettierd' }, + ['json'] = { 'jq' }, + ['html'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['css'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['javascript'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['typescript'] = { 'prettierd', 'prettier', stop_after_first = true }, + }, + format_on_save = function(bufnr) + -- Disable with a global or buffer local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, + notify_on_error = true, + lsp_fallback = true, + }, +} diff --git a/.config/nvim/lua/plugins/diffview.lua b/.config/nvim/lua/plugins/diffview.lua new file mode 100644 index 0000000..875e458 --- /dev/null +++ b/.config/nvim/lua/plugins/diffview.lua @@ -0,0 +1,20 @@ +return { + 'sindrets/diffview.nvim', + cmd = { 'DiffviewOpen', 'DiffviewClose', 'DiffviewFileHistory' }, + keys = { + { 'gd', 'DiffviewOpen' }, + { 'gl', 'DiffviewFileHistory' }, + }, + opts = function() + local quit_keymap = { 'n', 'q', 'DiffviewClose', { desc = 'Quit the diffview' } } + return { + enhanced_diff_hl = true, + default = { winbar_info = true }, + keymaps = { + view = { quit_keymap }, + file_panel = { quit_keymap }, + file_history_panel = { quit_keymap }, + }, + } + end, +} diff --git a/.config/nvim/lua/plugins/edgy.lua b/.config/nvim/lua/plugins/edgy.lua new file mode 100644 index 0000000..872247f --- /dev/null +++ b/.config/nvim/lua/plugins/edgy.lua @@ -0,0 +1,28 @@ +return { + 'folke/edgy.nvim', + event = 'VeryLazy', + opts = { + bottom = { + 'Trouble', + { ft = 'qf', title = 'QuickFix' }, + { + ft = 'help', + size = { height = 20 }, + filter = function(buf) -- only show help buffers + return vim.bo[buf].buftype == 'help' + end, + }, + { ft = 'spectre_panel', size = { height = 0.4 } }, + }, + left = { + { + title = 'Neo-Tree', + ft = 'neo-tree', + filter = function(buf) + return vim.b[buf].neo_tree_source == 'filesystem' + end, + size = { height = 0.5 }, + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..953cd80 --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,33 @@ +return { + 'lewis6991/gitsigns.nvim', + cmd = 'Gitsigns', + -- INFO: Disabled lazy loading to see if the errors stop + -- Not sure if it's an issue with lazy loading or just a gitsigns bug + lazy = false, + config = function() + require('gitsigns').setup() + + local function stage_visual_chunk() + require('gitsigns').stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end + local function reset_visual_chunk() + require('gitsigns').reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end + + vim.keymap.set('n', 'gD', 'Gitsigns toggle_deleted', { desc = '[G]it [D]eleted' }) + vim.keymap.set('n', 'hp', 'Gitsigns preview_hunk', { desc = '[H]unk [P]review' }) + vim.keymap.set('n', 'hs', 'Gitsigns stage_hunk', { desc = '[H]unk [S]tage' }) + vim.keymap.set('n', 'hr', 'Gitsigns reset_hunk', { desc = '[H]unk [R]eset' }) + vim.keymap.set('v', 'hs', stage_visual_chunk, { desc = '[H]unk [S]tage' }) + vim.keymap.set('v', 'hr', reset_visual_chunk, { desc = '[H]unk [S]tage' }) + vim.keymap.set('n', 'hS', 'Gitsigns stage_buffer', { desc = '[S]tage Buffer' }) + vim.keymap.set('n', 'hR', 'Gitsigns reset_buffer', { desc = '[R]eset Buffer' }) + vim.keymap.set('n', 'hu', 'Gitsigns undo_stage_hunk', { desc = '[H]unk [U]ndo' }) + vim.keymap.set( + 'n', + 'gB', + 'Gitsigns toggle_current_line_blame', + { desc = '[G]it [B]lame Line' } + ) + end, +} diff --git a/.config/nvim/lua/plugins/gopher.lua b/.config/nvim/lua/plugins/gopher.lua new file mode 100644 index 0000000..4bbcc92 --- /dev/null +++ b/.config/nvim/lua/plugins/gopher.lua @@ -0,0 +1,9 @@ +return { + 'olexsmir/gopher.nvim', + ft = 'go', + build = function() + vim.cmd.GoInstallDeps() + end, + ---@type gopher.Config + opts = {}, +} diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 0000000..5627e2f --- /dev/null +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,23 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + keys = { '', 'a', '1', '2', '3', '4', '5' }, + config = function() + local harpoon = require('harpoon') + harpoon:setup() + + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end) + vim.keymap.set('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + for i = 1, 9 do + vim.keymap.set('n', string.format('%d', i), function() + harpoon:list():select(i) + end) + end + end, +} diff --git a/.config/nvim/lua/plugins/helpview.lua b/.config/nvim/lua/plugins/helpview.lua new file mode 100644 index 0000000..098548b --- /dev/null +++ b/.config/nvim/lua/plugins/helpview.lua @@ -0,0 +1,7 @@ +return { + 'OXY2DEV/helpview.nvim', + ft = 'help', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + }, +} diff --git a/.config/nvim/lua/plugins/indent-blankline.lua b/.config/nvim/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..fb18add --- /dev/null +++ b/.config/nvim/lua/plugins/indent-blankline.lua @@ -0,0 +1,11 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + event = 'VeryLazy', + opts = { + scope = { + show_start = false, + show_end = false, + }, + }, +} diff --git a/.config/nvim/lua/plugins/lazydev.lua b/.config/nvim/lua/plugins/lazydev.lua new file mode 100644 index 0000000..59d2366 --- /dev/null +++ b/.config/nvim/lua/plugins/lazydev.lua @@ -0,0 +1,12 @@ +return { + 'folke/lazydev.nvim', + ft = 'lua', + cmd = 'LazyDev', + opts = { + library = { + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + { path = 'snacks.nvim', words = { 'Snacks' } }, + { path = 'lazy.nvim', words = { 'LazyVim' } }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/leap.lua b/.config/nvim/lua/plugins/leap.lua new file mode 100644 index 0000000..6d1eeeb --- /dev/null +++ b/.config/nvim/lua/plugins/leap.lua @@ -0,0 +1,15 @@ +return { + 'ggandor/leap.nvim', + lazy = false, + dependencies = { 'tpope/vim-repeat' }, + config = function() + require('leap').opts.equivalence_classes = { ' \t\r\n', '([{', ')]}', '\'"`' } + vim.api.nvim_set_hl(0, 'LeapBackdrop', { fg = '#777777' }) + + vim.keymap.set({ 'n', 'x' }, 's', '(leap)') + vim.keymap.set('n', 'S', '(leap-from-window)') + vim.keymap.set('n', 's', require('leap.remote').action) + vim.keymap.set('o', 'z', '(leap-forward)') + vim.keymap.set('o', 'Z', '(leap-backward)') + end, +} diff --git a/.config/nvim/lua/plugins/lsp-signature.lua b/.config/nvim/lua/plugins/lsp-signature.lua new file mode 100644 index 0000000..718cd62 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp-signature.lua @@ -0,0 +1,12 @@ +return { + -- FIXME: fork the repo and fix the following issues + -- Make both insert and normal be toggelable rather than insert always showing and normal toggleable + 'ray-x/lsp_signature.nvim', + event = 'LspAttach', + opts = { + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { border = 'single' }, + doc_lines = 0, + hint_enable = false, + }, +} diff --git a/.config/nvim/lua/plugins/lspsaga.lua b/.config/nvim/lua/plugins/lspsaga.lua new file mode 100644 index 0000000..a8fe588 --- /dev/null +++ b/.config/nvim/lua/plugins/lspsaga.lua @@ -0,0 +1,44 @@ +return { + -- 'nvimdev/lspsaga.nvim', + 'Kyren223/lspsaga.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, + event = 'LspAttach', + opts = { + ui = { + border = 'rounded', + foldericon = false, + title = false, + kind = nil, + }, + hover = { open_cmd = '!firefox.exe' }, + diagnostic = { + show_layout = 'float', + keys = { + exec_action = 'o', + quit = 'q', + toggle_or_jump = '', + quit_in_show = { 'q', '' }, + }, + }, + code_action = { show_preview = false }, + lightbulb = { enable = false }, + rename = { + pre_hook = function() + pcall(function() + vim.cmd('IlluminateToggle') + end) + end, + post_hook = function() + pcall(function() + vim.cmd('IlluminateToggle') + end) + end, + keys = { + quit = '', + exec = '', + select = 'x', + }, + }, + symbol_in_winbar = { enable = false }, + }, +} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..e331310 --- /dev/null +++ b/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,8 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons', 'linrongbin16/lsp-progress.nvim' }, + event = 'VeryLazy', + config = function() + require('lualine_helper') + end, +} diff --git a/.config/nvim/lua/plugins/markdown-toggle.lua b/.config/nvim/lua/plugins/markdown-toggle.lua new file mode 100644 index 0000000..39a932c --- /dev/null +++ b/.config/nvim/lua/plugins/markdown-toggle.lua @@ -0,0 +1,12 @@ +return { + 'roodolv/markdown-toggle.nvim', + event = 'VeryLazy', + config = function() + require('markdown-toggle').setup() + local opts = { silent = true, noremap = true } + local toggle = require('markdown-toggle') + vim.keymap.set({ 'n', 'x' }, 'tu', toggle.list, opts) + vim.keymap.set({ 'n', 'x' }, 'to', toggle.olist, opts) + vim.keymap.set({ 'n', 'x' }, 'tm', toggle.checkbox, opts) + end, +} diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..9bbb01b --- /dev/null +++ b/.config/nvim/lua/plugins/mason.lua @@ -0,0 +1,38 @@ +return { + { + 'williamboman/mason.nvim', + lazy = false, + opts = { + ui = { + icons = { + package_installed = '✓', + package_pending = '➜', + package_uninstalled = '✗', + }, + }, + }, + }, + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + lazy = false, + opts = { + ensure_installed = { + 'stylua', -- lua formatting + 'clang-format', -- C/C++ formatter + 'codelldb', -- C/C++ debugger + 'cpplint', -- C/C++ linter + -- 'black', -- python formatter + -- 'isort', -- python formatter for imports + -- 'flake8', -- python linter + 'gofumpt', -- go formatter + 'golangci-lint', -- go linter + 'prettierd', -- multi-lang formatter + 'prettier', -- prettierd but slower, used as a fallback + 'jq', -- json formatter + 'jsonlint', -- json linter + 'shellcheck', -- bash linter + 'beautysh', -- shell formatter + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..61d04b6 --- /dev/null +++ b/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,16 @@ +return { + 'echasnovski/mini.nvim', + version = false, + keys = { + { + 'Q', + function() + if vim.bo.modified then + vim.cmd.write() + end + require('mini.bufremove').delete(0) + end, + desc = '[Q]uit Buffer', + }, + }, +} diff --git a/.config/nvim/lua/plugins/neogen.lua b/.config/nvim/lua/plugins/neogen.lua new file mode 100644 index 0000000..fdefdbd --- /dev/null +++ b/.config/nvim/lua/plugins/neogen.lua @@ -0,0 +1,5 @@ +return { + 'danymat/neogen', + keys = { { 'ng', '<Neogen', desc = '[N]eo[G]en' } }, + opts = { snippet_engine = 'luasnip' }, +} diff --git a/.config/nvim/lua/plugins/neogit.lua b/.config/nvim/lua/plugins/neogit.lua new file mode 100644 index 0000000..e1e164f --- /dev/null +++ b/.config/nvim/lua/plugins/neogit.lua @@ -0,0 +1,33 @@ +return { + 'NeogitOrg/neogit', + cmd = 'Neogit', + keys = { + { 'gb', 'Neogit branch' }, + { 'gs', 'Neogit' }, + { 'gL', 'Neogit log' }, + { 'gc', 'Neogit commit' }, + { 'gp', 'Neogit push' }, + { 'gP', 'Neogit pull' }, + { 'gr', 'Neogit rebase' }, + { 'gm', 'Neogit merge' }, + }, + opts = function() + return { + commit_editor = { spell_check = false }, + mappings = { + commit_editor = { + [''] = 'Submit', + [''] = 'Abort', + }, + commit_editor_I = { + [''] = 'Submit', + [''] = 'Abort', + }, + popup = { + ['p'] = 'PushPopup', + ['P'] = 'PullPopup', + }, + }, + } + end, +} diff --git a/.config/nvim/lua/plugins/nvim-autopairs.lua b/.config/nvim/lua/plugins/nvim-autopairs.lua new file mode 100644 index 0000000..264004a --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-autopairs.lua @@ -0,0 +1,11 @@ +return { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + opts = { + check_ts = true, + ts_config = { + lua = { 'string' }, -- don't add pairs inside lua strings + javascript = { 'template_string' }, -- FIX: remove me + }, + }, +} diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..221c756 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,14 @@ +return { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + 'onsails/lspkind.nvim', -- icons for completion type + 'hrsh7th/cmp-path', -- complete filepaths + 'hrsh7th/cmp-nvim-lsp', -- lsp source for nvim-cmp + 'saadparwaiz1/cmp_luasnip', -- snippets source for nvim-cmp + { 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' }, -- snippets plugin + }, + config = function() + require('cmp_helper') + end, +} diff --git a/.config/nvim/lua/plugins/nvim-dap-ui.lua b/.config/nvim/lua/plugins/nvim-dap-ui.lua new file mode 100644 index 0000000..cddad45 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dap-ui.lua @@ -0,0 +1,26 @@ +return { + 'rcarriga/nvim-dap-ui', + dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }, + event = 'VeryLazy', + config = function() + local dap = require('dap') + local dapui = require('dapui') + dapui.setup() + dap.listeners.before.attach.dapui_config = function() + dapui.open() + vim.cmd.Hardtime('disable') + end + dap.listeners.after.event_initialized['dapui_config'] = function() + dapui.open() + vim.cmd.Hardtime('disable') + end + dap.listeners.before.event_terminated['dapui_config'] = function() + dapui.close() + vim.cmd.Hardtime('enable') + end + dap.listeners.before.event_exited['dapui_config'] = function() + dapui.close() + vim.cmd.Hardtime('enable') + end + end, +} diff --git a/.config/nvim/lua/plugins/nvim-dap.lua b/.config/nvim/lua/plugins/nvim-dap.lua new file mode 100644 index 0000000..dd4bbee --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dap.lua @@ -0,0 +1,58 @@ +return { + 'mfussenegger/nvim-dap', + dependencies = { 'williamboman/mason.nvim' }, + -- NOTE:nvim-dap has no setup function + -- if there is just opts, lazy will attempt to call setup which causes an error + -- Having an empty config function makes lazy not call setup which fixes the issue + config = function() end, + opts = function() + -- Load dap keymaps + require('dap-keymaps') + local dap = require('dap') + + -- Setup C/C++ dap + if not dap.adapters['codelldb'] then + dap.adapters['codelldb'] = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'codelldb', + args = { + '--port', + '${port}', + }, + }, + } + end + for _, lang in ipairs({ 'c', 'cpp' }) do + dap.configurations[lang] = { + { + type = 'codelldb', + request = 'launch', + name = 'Launch file', + program = function() + if vim.g.dap_codelldb_exe then + return vim.fn.getcwd() .. '/' .. vim.g.dap_codelldb_exe + end + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + args = function() + if vim.g.dap_codelldb_args then + return vim.g.dap_codelldb_args + end + return {} + end, + cwd = '${workspaceFolder}', + }, + { + type = 'codelldb', + request = 'attach', + name = 'Attach to process', + pid = require('dap.utils').pick_process, + cwd = '${workspaceFolder}', + }, + } + end + end, +} diff --git a/.config/nvim/lua/plugins/nvim-dbee.lua b/.config/nvim/lua/plugins/nvim-dbee.lua new file mode 100644 index 0000000..43baa80 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dbee.lua @@ -0,0 +1,12 @@ +return { + 'kndndrj/nvim-dbee', + dependencies = { 'MunifTanjim/nui.nvim' }, + build = function() + -- Install tries to automatically detect the install method. + -- if it fails, try calling it with one of these parameters: + -- "curl", "wget", "bitsadmin", "go" + require('dbee').install() + end, + cmd = 'Dbee', + opts = {}, +} diff --git a/.config/nvim/lua/plugins/nvim-java.lua b/.config/nvim/lua/plugins/nvim-java.lua new file mode 100644 index 0000000..4bd321d --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-java.lua @@ -0,0 +1,5 @@ +return { + 'nvim-java/nvim-java', + lazy = false, + opts = {} +} diff --git a/.config/nvim/lua/plugins/nvim-lint.lua b/.config/nvim/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..7bb3a16 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-lint.lua @@ -0,0 +1,41 @@ +return { + 'mfussenegger/nvim-lint', + lazy = false, + config = function() + local lint = require('lint') + lint.linters_by_ft = { + -- c = { 'clangtidy' }, + -- cpp = { 'clangtidy' }, + go = { 'golangcilint' }, + -- python = { 'flake8' }, + json = { 'jsonlint' }, + bash = { 'shellcheck' }, + } + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave', 'TextChanged', 'TextChangedI' }, { + group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }), + callback = function() + require('lint').try_lint() + end, + }) + + -- NOTE: most if not all of clangt-idy warnings are + -- also reported by clangd, so this function filters clang-tidy warnings + -- to avoid duplication of warnings + -- local clangtidy_parser = lint.linters.clangtidy.parser + -- lint.linters.clangtidy.parser = function(output, bufnr, linter_cwd) + -- local diagnostics = clangtidy_parser(output, bufnr, linter_cwd) + -- diagnostics = vim.tbl_filter(function(diagnostic) + -- if diagnostic.severity == vim.diagnostic.severity.WARN then + -- return false + -- end + -- if diagnostic.severity == vim.diagnostic.severity.ERROR then + -- return false + -- end + -- + -- return true + -- end, diagnostics) + -- return diagnostics + -- end + end, +} diff --git a/.config/nvim/lua/plugins/nvim-lspconfig.lua b/.config/nvim/lua/plugins/nvim-lspconfig.lua new file mode 100644 index 0000000..1dd0a77 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-lspconfig.lua @@ -0,0 +1,32 @@ +return { + -- NOTE: Make sure the order is as follows: + -- Mason loads -> Mason lspconfig loads -> Lspconfig loads + 'neovim/nvim-lspconfig', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + { 'antosha417/nvim-lsp-file-operations', conifg = true }, + { + 'williamboman/mason-lspconfig.nvim', + build = ':MasonUpdate', + config = function() + local language_servers = require('language-servers') + local ensure_installed = vim.tbl_filter(function(key) + local server = language_servers[key] + if type(server) == 'table' then + if server.mason ~= nil then + return server.mason + end + return true + else + return server + end + end, vim.tbl_keys(language_servers)) + require('mason-lspconfig').setup({ ensure_installed = ensure_installed, auto_install = true }) + end, + }, + }, + config = function() + require('lsp') + end, +} diff --git a/.config/nvim/lua/plugins/nvim-scrollbar.lua b/.config/nvim/lua/plugins/nvim-scrollbar.lua new file mode 100644 index 0000000..f475ac7 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-scrollbar.lua @@ -0,0 +1,29 @@ +return { + 'petertriho/nvim-scrollbar', + event = 'VeryLazy', + opts = { + marks = { + Search = { + text = { '', '' }, + }, + Error = { + text = { '', '' }, + }, + Warn = { + text = { '', '' }, + }, + Info = { + text = { '', '' }, + }, + Hint = { + text = { '', '' }, + }, + Misc = { + text = { '', '' }, + }, + }, + handlers = { + cursor = false, + }, + }, +} diff --git a/.config/nvim/lua/plugins/nvim-spectre.lua b/.config/nvim/lua/plugins/nvim-spectre.lua new file mode 100644 index 0000000..df58de9 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-spectre.lua @@ -0,0 +1,7 @@ +return { + -- NOTE: No keybindings, use `:Spectre` or `:Spectre ` + -- Spectre has no undo, so it should be rarely used, which is why no keybindings are defined + 'nvim-pack/nvim-spectre', + cmd = 'Spectre', + config = true, +} diff --git a/.config/nvim/lua/plugins/nvim-surround.lua b/.config/nvim/lua/plugins/nvim-surround.lua new file mode 100644 index 0000000..54d8754 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-surround.lua @@ -0,0 +1,21 @@ +return { + 'kylechui/nvim-surround', + version = '*', + keys = { + { 'ys' }, + { 'yss' }, + { 'S' }, + { 'cs' }, + { 'ds' }, + { '(', '(nvim-surround-visual)(', mode = 'v' }, + { ')', '(nvim-surround-visual))', mode = 'v' }, + { '{', '(nvim-surround-visual){', mode = 'v' }, + { '}', '(nvim-surround-visual)}', mode = 'v' }, + { '[', '(nvim-surround-visual)[', mode = 'v' }, + { ']', '(nvim-surround-visual)]', mode = 'v' }, + { '`', '(nvim-surround-visual)`', mode = 'v' }, + { '"', '(nvim-surround-visual)"', mode = 'v' }, + { "'", "(nvim-surround-visual)'", mode = 'v' }, + }, + opts = {}, +} diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..96ac728 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,87 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + ---@type userdata + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup({ + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + }, + }) + + -- HACK: Workaround to have syntax highlighting in zsh until a zsh parser is added + -- https://github.com/nvim-treesitter/nvim-treesitter/issues/655 + local ft_to_lang = require('nvim-treesitter.parsers').ft_to_lang + ---@diagnostic disable-next-line: duplicate-set-field + require('nvim-treesitter.parsers').ft_to_lang = function(ft) + if ft == 'zsh' then + return 'bash' + end + return ft_to_lang(ft) + end + end, + }, + { + 'nvim-treesitter/nvim-treesitter-textobjects', + event = 'VeryLazy', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup({ + textobjects = { + select = { + enable = true, + lookahead = true, -- automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['af'] = { query = '@function.outer', desc = 'Select entire function' }, + ['if'] = { query = '@function.inner', desc = 'Select function body' }, + ['ac'] = { query = '@class.outer', desc = 'Select entire class' }, + ['ic'] = { query = '@class.inner', desc = 'Select class body' }, + -- ['as'] = { query = '@scope', query_group = 'locals', desc = 'Select language scope' }, + ['ia'] = { query = '@assignment.rhs', desc = 'Select assignment rhs' }, + ['ip'] = { query = '@parameter.inner', desc = 'Select parameter' }, + }, + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise + ['@assignment.rhs'] = 'v', -- charwise + }, + }, + swap = { + enable = true, + swap_next = { + ['sa'] = { query = '@parameter.inner', desc = 'Swap Argument (next)' }, + }, + swap_previous = { + ['sA'] = { query = '@parameter.inner', desc = 'Swap Argument (prev)' }, + }, + }, + }, + }) + + local ts_repeat_move = require('nvim-treesitter.textobjects.repeatable_move') + -- Repeat movement with ; and , + vim.keymap.set({ 'n', 'x', 'o' }, ';', ts_repeat_move.repeat_last_move_next) + vim.keymap.set({ 'n', 'x', 'o' }, ',', ts_repeat_move.repeat_last_move_previous) + + -- NOTE: You need this, otherwise the normal ; and , won't work for fFtT + vim.keymap.set({ 'n', 'x', 'o' }, 'f', ts_repeat_move.builtin_f_expr, { expr = true }) + vim.keymap.set({ 'n', 'x', 'o' }, 'F', ts_repeat_move.builtin_F_expr, { expr = true }) + vim.keymap.set({ 'n', 'x', 'o' }, 't', ts_repeat_move.builtin_t_expr, { expr = true }) + vim.keymap.set({ 'n', 'x', 'o' }, 'T', ts_repeat_move.builtin_T_expr, { expr = true }) + end, + }, + -- NOTE: Might conflict with treeobj but it adds IQ and AQ for any quotes which is cool + -- The rest can probably be disabled, but I will try it out and only disable if it annoys me + -- Also it does (/{ etc ignore whitespace but )/} don't, which is interesting ig + -- { 'echasnovski/mini.ai', version = false, opts = {}, lazy = false }, +} diff --git a/.config/nvim/lua/plugins/nvim-ts-autotag.lua b/.config/nvim/lua/plugins/nvim-ts-autotag.lua new file mode 100644 index 0000000..e806a45 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-ts-autotag.lua @@ -0,0 +1,5 @@ +return { + 'windwp/nvim-ts-autotag', + event = { 'BufReadPre', 'BufNewFile' }, + opts = { opts = { enable_close_on_slash = true } }, +} diff --git a/.config/nvim/lua/plugins/octo.lua b/.config/nvim/lua/plugins/octo.lua new file mode 100644 index 0000000..26c1dbb --- /dev/null +++ b/.config/nvim/lua/plugins/octo.lua @@ -0,0 +1,23 @@ +return { + 'pwntester/octo.nvim', + cmd = 'Octo', + keys = { + { 'gi', 'Octo issue search', desc = '[G]ithub [I]ssues (local)' }, + { 'pr', 'Octo pr search', desc = 'Github [PR]s (local)' }, + { 'gI', 'Octo search is:issue is:open author:@me', desc = '[G]ithub [I]ssues (global)' }, + { 'pR', 'Octo search is:pr author:@me', desc = 'Github [PR]s (global)' }, + }, + config = function() + require('octo').setup({ suppress_missing_scope = { projects_v2 = true } }) + + vim.treesitter.language.register('markdown', 'octo') + vim.api.nvim_create_autocmd('FileType', { + pattern = 'octo', + callback = function() + -- Autocomplete for @ (user mention) and # (issue) + vim.keymap.set('i', '@', '@', { silent = true, buffer = true }) + vim.keymap.set('i', '#', '#', { silent = true, buffer = true }) + end, + }) + end, +} diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua new file mode 100644 index 0000000..7b7521d --- /dev/null +++ b/.config/nvim/lua/plugins/oil.lua @@ -0,0 +1,40 @@ +return { + 'stevearc/oil.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + keys = { { 'fo', 'Oil', desc = '[F]ilesystem [O]il' } }, + opts = { + delete_to_trash = true, + default_file_explorer = true, + skip_confirm_for_simple_edits = true, + keymaps = { + ['gs'] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = 'actions.select_split', + [''] = 'actions.select_vsplit', + [''] = 'actions.refresh', + ['Q'] = 'actions.close', + ['gS'] = 'actions.change_sort', + ['gy'] = 'actions.copy_to_system_clipboard', + ['gp'] = 'actions.paste_from_system_clipboard', + }, + view_options = { + show_hidden = true, + natural_order = true, + }, + + lsp_file_methods = { + -- Enable or disable LSP file operations + enabled = true, + -- Time to wait for LSP file operations to complete before skipping + timeout_ms = 1000, + -- Set to true to autosave buffers that are updated with LSP willRenameFiles + -- Set to "unmodified" to only save unmodified buffers + autosave_changes = false, + }, + }, + cmd = 'Oil', + event = 'VimEnter', +} diff --git a/.config/nvim/lua/plugins/overseer.lua b/.config/nvim/lua/plugins/overseer.lua new file mode 100644 index 0000000..bd27efc --- /dev/null +++ b/.config/nvim/lua/plugins/overseer.lua @@ -0,0 +1,49 @@ +return { + 'stevearc/overseer.nvim', + -- NOTE: without telescope the UI is not custom, so making sure telescope is loaded first + dependencies = { 'nvim-telescope/telescope.nvim' }, + -- event = 'VeryLazy', + keys = function() + local overseer = require('overseer') + local RUN_TAG = overseer.TAG.RUN + local BUILD_TAG = overseer.TAG.BUILD + local TEST_TAG = overseer.TAG.TEST + local function run_template(tag, show_prompt) + return function() + local prompt = show_prompt and 'always' or 'avoid' + overseer.run_template({ tags = { tag }, first = true, prompt = prompt }) + -- overseer.open({ enter = false }) -- don't focus + end + end + return { + { 'or', run_template(RUN_TAG, false), desc = '[O]verseer [R]un' }, + { 'oR', run_template(RUN_TAG, true), desc = '[O]verseer [R]un (with params)' }, + + { 'ob', run_template(BUILD_TAG, false), desc = '[O]verseer [B]uild' }, + { 'oB', run_template(BUILD_TAG, true), desc = '[O]verseer [B]uild (with params)' }, + + { 'ot', run_template(TEST_TAG, false), desc = '[O]verseer [T]est' }, + { 'oT', run_template(TEST_TAG, true), desc = '[O]verseer [T]est (with params)' }, + + { 'ow', 'OverseerToggle!', desc = '[O]verseer [W]indow (toggle)' }, + { 'oW', 'OverseerQuickAction open float', desc = '[O]verseer [W]indow (terminal float)' }, + } + end, + opts = { + templates = { 'builtin', 'custom' }, + task_list = { + min_height = 0.5, + bindings = { + ['o'] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = false, + [''] = 'ScrollOutputUp', + [''] = 'ScrollOutputDown', + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/pretty-hover.lua b/.config/nvim/lua/plugins/pretty-hover.lua new file mode 100644 index 0000000..5be5381 --- /dev/null +++ b/.config/nvim/lua/plugins/pretty-hover.lua @@ -0,0 +1,5 @@ +return { + 'Fildo7525/pretty_hover', + event = 'LspAttach', + opts = {}, +} diff --git a/.config/nvim/lua/plugins/render-markdown.lua b/.config/nvim/lua/plugins/render-markdown.lua new file mode 100644 index 0000000..a7ae2b7 --- /dev/null +++ b/.config/nvim/lua/plugins/render-markdown.lua @@ -0,0 +1,16 @@ +return { + 'MeanderingProgrammer/render-markdown.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + keys = { + { 'mt', '<RenderMarkdown toggle'} + }, + opts = { + render_modes = true, + sign = { enabled = false }, + bullet = { icons = { '', '◆' } }, + checkbox = { + unchecked = { icon = ' ' }, + checked = { icon = ' ' }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/rustaceanvim.lua b/.config/nvim/lua/plugins/rustaceanvim.lua new file mode 100644 index 0000000..564e046 --- /dev/null +++ b/.config/nvim/lua/plugins/rustaceanvim.lua @@ -0,0 +1,8 @@ +return { + 'mrcjkb/rustaceanvim', + version = '^5', + lazy = false, -- already lazy + init = function() + require('rustaceanvim') + end, +} diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua new file mode 100644 index 0000000..50f4ff2 --- /dev/null +++ b/.config/nvim/lua/plugins/snacks.lua @@ -0,0 +1,45 @@ +return { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + image = {}, + ---@class snacks.notifier.Config + notifier = { + ---@type snacks.notifier.style + style = 'compact', + filter = function(notif) + local filtered_messages = { 'No information available', 'No code actions available' } + for _, msg in ipairs(filtered_messages) do + if notif.msg == msg then + return false + end + end + return true + end, + }, + }, + keys = { + { + 'si', + function() + Snacks.image.hover() + end, + }, + { + 'nd', + function() + Snacks.notifier.hide() + end, + desc = '[N]otifications [D]ismiss All', + }, + { + 'nh', + function() + Snacks.notifier.show_history() + end, + desc = '[N]otifications [D]ismiss All', + }, + }, +} diff --git a/.config/nvim/lua/plugins/sqls.lua b/.config/nvim/lua/plugins/sqls.lua new file mode 100644 index 0000000..a060415 --- /dev/null +++ b/.config/nvim/lua/plugins/sqls.lua @@ -0,0 +1,3 @@ +return { + 'nanotee/sqls.nvim', +} diff --git a/.config/nvim/lua/plugins/suda.lua b/.config/nvim/lua/plugins/suda.lua new file mode 100644 index 0000000..39866cd --- /dev/null +++ b/.config/nvim/lua/plugins/suda.lua @@ -0,0 +1,4 @@ +return { + 'lambdalisue/vim-suda', + event = { 'BufReadPre', 'BufNewFile' }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..b3e09af --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,22 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + 'nvim-telescope/telescope-ui-select.nvim', + }, + cmd = 'Telescope', + config = function() + require('telescope_helper') + end, + keys = { + 'fs', + 'fa', + 'fh', + 'fm', + 'lv', + 'f.', + 'th', + }, +} diff --git a/.config/nvim/lua/plugins/tiny-inline-diagnostic.lua b/.config/nvim/lua/plugins/tiny-inline-diagnostic.lua new file mode 100644 index 0000000..620f20f --- /dev/null +++ b/.config/nvim/lua/plugins/tiny-inline-diagnostic.lua @@ -0,0 +1,24 @@ +return { + 'rachartier/tiny-inline-diagnostic.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + opts = { + options = { + -- Throttle the update of the diagnostic when moving cursor, in milliseconds. + -- You can increase it if you have performance issues. + -- Or set it to 0 to have better visuals. + throttle = 0, + + -- The minimum length of the message, otherwise it will be on a new line. + softwrap = 15, + + -- If multiple diagnostics are under the cursor, display all of them. + multiple_diag_under_cursor = true, + + --- Enable it if you want to always have message with `after` characters length. + break_line = { + enabled = false, + after = 30, + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/todo-comments.lua b/.config/nvim/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..799afd8 --- /dev/null +++ b/.config/nvim/lua/plugins/todo-comments.lua @@ -0,0 +1,95 @@ +-- NORMAL: lorem ipsum +-- TODO: lorem ipsum +-- FIX: lorem ipsum +-- OPTIMIZE: lorem ipsum +-- WARN: lorem ipsum +-- PERF: lorem ipsum +-- HACK: lorem ipsum +-- NOTE: lorem ipsum +-- TEST: lorem ipsum +-- UNSAFE: lorem ipsum +return { + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + event = 'VeryLazy', + keys = { + { 'st', 'TodoTelescope keywords=TODO,FIX', desc = '[S]earch [T]odos' }, + { 'lt', 'TodoTrouble', desc = '[L]ist [T]odos' }, + }, + config = function() + require('todo-comments').setup({ + signs = false, -- show icons in the signs column + sign_priority = 8, -- sign priority + keywords = { + -- NOTE: These are "todos" + TODO = { icon = ' ', color = 'info', alt = { 'todo' } }, + FIX = { icon = ' ', color = 'error', alt = { 'FIXME', 'BUG', 'ISSUE' } }, + OPTIMIZE = { icon = ' ', color = 'performance' }, + -- NOTE: These are "notes" + WARN = { icon = ' ', color = 'warning', alt = { 'WARNING' } }, + PERF = { icon = ' ', color = 'performance', alt = { 'PERFORMANCE' } }, + HACK = { icon = ' ', color = 'warning', alt = { 'SMELL', 'CODE SMELL', 'BAD', 'BAD PRACTICE' } }, + NOTE = { icon = ' ', color = 'hint', alt = { 'INFO' } }, + TEST = { icon = '󰙨 ', color = 'test', alt = { 'TESTING', 'PASSED', 'FAILED' } }, + UNSAFE = { icon = '󰍛 ', color = 'error', alt = { 'SAFETY' } }, + }, + gui_style = { + fg = 'NONE', + bg = 'BOLD', + }, + merge_keywords = true, -- when true, custom keywords will be merged with the defaults + -- highlighting of the line containing the todo comment + -- * before: highlights before the keyword (typically comment characters) + -- * keyword: highlights of the keyword + -- * after: highlights after the keyword (todo text) + highlight = { + multiline = true, + multiline_pattern = '^.', -- lua pattern to match the next multiline from the start of the matched keyword + multiline_context = 10, -- extra lines that will be re-evaluated when changing a line + before = '', -- "fg" or "bg" or empty + keyword = 'wide', -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg) + after = 'fg', -- "fg" or "bg" or empty + -- TODO(): + pattern = { + -- [[.*<(KEYWORDS)\s*(.*)?\s*:]], -- default + [[.*<(KEYWORDS)\s*:]], -- default + [[.*<(KEYWORDS)\s*!?\(\):]], -- keyword!() syntax + -- [[.*<(KEYWORDS)\s*\(.*\):]], -- keyword(anything) syntax + [[.*<(KEYWORDS)\s* ?\(.*\):]], -- keyword(anything) syntax + [[.*<(KEYWORDSky)\s*:]], -- keyword(anything) syntax + }, -- pattern or table of patterns, used for highlighting (vim regex) + comments_only = false, + max_line_len = 400, + exclude = {}, -- list of excluded filetypes + }, + -- list of named colors where we try to extract the gui fg from the + -- list of highlight groups or use the hex color if hl not found as a fallback + colors = { + default = { 'Identifier', '#7C3AED' }, + error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' }, + warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' }, + info = { 'DiagnosticInfo', '#2563EB' }, + hint = { '#10B981' }, + test = { 'Identifier', '#FF00FF' }, + performance = { '#7C3AED' }, + }, + search = { + command = 'rg', + args = { + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + -- "--hidden", -- show todos in hidden directories and files + '--follow', -- follow symlinks + }, + -- regex that will be used to match keywords. + -- don't replace the (KEYWORDS) placeholder + pattern = [[\b(KEYWORDS)(?:\(([^)]*)\))?:]], -- supports optional `(anything)` before colon + -- pattern = [[\b(KEYWORDS):]], -- default + -- pattern = [[\b(KEYWORDS)\b]], -- no colon + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..3239aa7 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,40 @@ +return { + 'folke/trouble.nvim', + opts = {}, + cmd = 'Trouble', + -- TODO: Consider maybe using this for outlines (code structure) + -- and also configuring some of the keys to better fit me + -- and probably removing most of them in the process + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', + }, + }, +} diff --git a/.config/nvim/lua/plugins/undotree.lua b/.config/nvim/lua/plugins/undotree.lua new file mode 100644 index 0000000..cbbeffb --- /dev/null +++ b/.config/nvim/lua/plugins/undotree.lua @@ -0,0 +1,14 @@ +return { + 'mbbill/undotree', + keys = { { 'ut', vim.cmd.UndotreeToggle } }, + config = function() + vim.g.undotree_DiffAutoOpen = false + vim.g.undotree_DiffpanelHeight = 0 + vim.g.undotree_SetFocusWhenToggle = false + vim.g.undotree_HelpLine = false + vim.g.undotree_TreeNodeShape = '' + vim.g.undotree_TreeVertShape = '│' + vim.g.undotree_TreeSplitShape = '─┘' + vim.g.undotree_TreeReturnShape = '─┐' + end, +} diff --git a/.config/nvim/lua/plugins/vim-be-good.lua b/.config/nvim/lua/plugins/vim-be-good.lua new file mode 100644 index 0000000..03fd98f --- /dev/null +++ b/.config/nvim/lua/plugins/vim-be-good.lua @@ -0,0 +1,4 @@ +return { + 'ThePrimeagen/vim-be-good', + cmd = 'VimBeGood', +} diff --git a/.config/nvim/lua/plugins/vim-illuminate.lua b/.config/nvim/lua/plugins/vim-illuminate.lua new file mode 100644 index 0000000..69091db --- /dev/null +++ b/.config/nvim/lua/plugins/vim-illuminate.lua @@ -0,0 +1,7 @@ +return { + 'RRethy/vim-illuminate', + event = 'LspAttach', + keys = { + { 'it', 'IlluminateToggle', desc = '[I]lluminate [Tloggle]' }, + }, +} diff --git a/.config/nvim/lua/plugins/vim-tmux-navigator.lua b/.config/nvim/lua/plugins/vim-tmux-navigator.lua new file mode 100644 index 0000000..de08d82 --- /dev/null +++ b/.config/nvim/lua/plugins/vim-tmux-navigator.lua @@ -0,0 +1,9 @@ +return { + 'christoomey/vim-tmux-navigator', + keys = { + { '', 'TmuxNavigateLeft', mode = { 'n', 'i' } }, + { '', 'TmuxNavigateDown', mode = { 'n', 'i' } }, + { '', 'TmuxNavigateUp', mode = { 'n', 'i' } }, + { '', 'TmuxNavigateRight', mode = { 'n', 'i' } }, + }, +} diff --git a/.config/nvim/lua/plugins/vim-wakatime.lua b/.config/nvim/lua/plugins/vim-wakatime.lua new file mode 100644 index 0000000..515c6d0 --- /dev/null +++ b/.config/nvim/lua/plugins/vim-wakatime.lua @@ -0,0 +1,4 @@ +return { + 'wakatime/vim-wakatime', + event = 'VeryLazy', +} diff --git a/.config/nvim/lua/rustaceanvim.lua b/.config/nvim/lua/rustaceanvim.lua new file mode 100644 index 0000000..91b1092 --- /dev/null +++ b/.config/nvim/lua/rustaceanvim.lua @@ -0,0 +1,37 @@ +---@type RustaceanOpts +vim.g.rustaceanvim = { + ---@type RustaceanToolsOpts + tools = { + float_win_config = { + border = 'rounded', + }, + }, + ---@type RustaceanLspClientOpts + server = { + on_attach = function(_, bufnr) + local keymaps = { + { { 'n', 'i' }, '', 'RustLsp codeAction', { desc = 'Code Action' } }, + } + + for _, keymap in ipairs(keymaps) do + local modes = keymap[1] + local lhs = keymap[2] + local rhs = keymap[3] + local opts = keymap[4] + opts.buffer = bufnr + + vim.keymap.set(modes, lhs, rhs, opts) + end + end, + default_settings = { + ['rust-analyzer'] = { + semanticHighlighting = { + operator = { specialization = { enable = true } }, + punctuation = { enable = true, specialization = { enable = true } }, + }, + }, + }, + }, + ---@type RustaceanDapOpts + dap = {}, +} diff --git a/.config/nvim/lua/snippets/go.lua b/.config/nvim/lua/snippets/go.lua new file mode 100644 index 0000000..d6b7114 --- /dev/null +++ b/.config/nvim/lua/snippets/go.lua @@ -0,0 +1,77 @@ +require('luasnip.session.snippet_collection').clear_snippets('go') +local ls = require('luasnip') +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node +local d = ls.dynamic_node + +---@param abbr string +---@param expansion string +---@param args table +local function snip(abbr, expansion, args) + return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args)) +end + +local tea_model = [=[ +import ( + "fmt" + + tea "github.com/charmbracelet/bubbletea" +) + +type Model struct{{ + {} +}} + +func New() Model {{ + return Model{{ + }} +}} + +func (m Model) Init() tea.Cmd {{ + return nil +}} + +func (m Model) View() string {{ + return fmt.Sprintf( + "%s", + "", + ) +}} + +func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {{ + switch msg := msg.(type) {{ + default: + return m, nil + }} +}} +]=] + +local server_api = [=[ +func {}(ctx context.Context, sess *session.Session, request packet{}) packet.Payload {{ +}} +]=] + +ls.add_snippets('go', { + snip('tmod', tea_model, { i(0) }), + snip('sapi', server_api, { i(1), i(0) }), + + s('iferr', { + t({ 'if err != nil {', '' }), + i(1, ' return'), + t({ '', '}' }), + }), + + s('fmterr', { + t('fmt.Errorf("'), + i(1, 'msg'), + t(': %w", err)'), + }), + + s('dberr', { + t({ 'if err != nil {', '' }), + i(2, { ' log.Println("database error ', 'x', ':", err)', '' }), + i(2, ' return ', '&ErrInternalError'), + t({ '', '}' }), + }), +}) diff --git a/.config/nvim/lua/snippets/lua.lua b/.config/nvim/lua/snippets/lua.lua new file mode 100644 index 0000000..194f776 --- /dev/null +++ b/.config/nvim/lua/snippets/lua.lua @@ -0,0 +1,37 @@ +require('luasnip.session.snippet_collection').clear_snippets('lua') +local ls = require('luasnip') +local i = ls.insert_node + +---@param abbr string +---@param expansion string +---@param args table +local function s(abbr, expansion, args) + return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args)) +end + +local carbonight_group = [=[ +--[[ +Copyright (C) 2024 Kyren223 +This file is licensed under the GPL-3.0-or-later license, see https://fsf.org/licenses/gpl-3.0 +--]] + +local utils = require("carbonight.utils") + +local M = {{}} + +---@param c Colors +function M.get(c) + return {{ + {} + }} +end + +return M +]=] + +ls.add_snippets('lua', { + s('desc', "{{ desc = '{}' }}", { i(0) }), + s('cmd', '{}', { i(0) }), + s('scmd', "'{}'", { i(0) }), + s('cng', carbonight_group, { i(0) }), +}) diff --git a/.config/nvim/lua/telescope_helper.lua b/.config/nvim/lua/telescope_helper.lua new file mode 100644 index 0000000..5a84121 --- /dev/null +++ b/.config/nvim/lua/telescope_helper.lua @@ -0,0 +1,41 @@ +local telescope = require('telescope') +telescope.setup({ + pickers = { + find_files = { follow = true, hidden = true }, + grep_string = { additional_args = '--follow' }, + live_grep = { additional_args = '--follow' }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', -- default "smart_case" or "ignore_case" or "respect_case" + }, + ['ui-select'] = { + require('telescope.themes').get_dropdown({}), + }, + }, +}) + +pcall(telescope.load_extension('ui-select')) +pcall(telescope.load_extension('fzf')) + +local builtin = require('telescope.builtin') +local function find_all() + builtin.find_files({ + cwd = '~', + hidden = true, + no_ignore = true, + no_ignore_parent = true, + }) +end + +vim.keymap.set('n', 'fs', builtin.find_files, { desc = '[F]ile [S]ystem' }) +vim.keymap.set('n', 'fa', find_all, { desc = '[F]ind [A]ll files' }) +vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) +vim.keymap.set('n', 'fm', builtin.man_pages, { desc = '[F]ind [M]an Pages' }) +vim.keymap.set('n', 'lv', builtin.live_grep, { desc = '[L]ive [G]rep' }) +vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files' }) +vim.keymap.set('n', 'th', builtin.colorscheme, { desc = 'List [Th]eme' }) +vim.keymap.set('n', 'hi', builtin.highlights, { desc = '[Hi]light Groups' }) -- cgit v1.3.1