From b57f38bb9a9f34cb27d557b28f140250782f2c45 Mon Sep 17 00:00:00 2001 From: afonso Date: Sat, 27 Apr 2024 16:02:41 +0100 Subject: [PATCH] [nvim] harpoon and other efficiency stuff --- .config/nvim/lazy-lock.json | 52 +++++++------- .config/nvim/lua/core/variables.lua | 6 +- .config/nvim/lua/plugins/cmp.lua | 68 ++++-------------- .config/nvim/lua/plugins/lazy.lua | 91 ++++++++++--------------- .config/nvim/lua/plugins/lspconfig.lua | 20 ++++-- .config/nvim/lua/plugins/telescope.lua | 36 ++++++++++ .config/nvim/lua/plugins/treesitter.lua | 25 +++++-- 7 files changed, 151 insertions(+), 147 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 9af777b..25a788c 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,6 +1,7 @@ { - "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, - "catppuccin": { "branch": "main", "commit": "07679af1af4f446655682ee2557b5840ac551504" }, + "LuaSnip": { "branch": "master", "commit": "be7be2ca7f55bb881a7ffc16b2efa5af034ab06b" }, + "ale": { "branch": "master", "commit": "6db58b33795430a6165f27c7f796c420c0e098e4" }, + "catppuccin": { "branch": "main", "commit": "a1439ad7c584efb3d0ce14ccb835967f030450fe" }, "cinnamon.nvim": { "branch": "master", "commit": "559fe02fae00ffd78377e9c242b2faa25a428592" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, @@ -9,49 +10,54 @@ "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "f9523f75134614fc0eff29c2377ed36603a1b0aa" }, - "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, + "conform.nvim": { "branch": "master", "commit": "820eec990d5f332d30cf939954c8672a43a0459e" }, "dressing.nvim": { "branch": "master", "commit": "18e5beb3845f085b6a33c24112b37988f3f93c06" }, - "fidget.nvim": { "branch": "main", "commit": "933db4596e4bab1b09b6d48a10e21819e4cc458f" }, - "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, - "gruvbox-material": { "branch": "master", "commit": "c7c95a97702038e83c73e207f937263d4e7a2be8" }, + "fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" }, + "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" }, + "fzf": { "branch": "master", "commit": "d8bfb6712d514fd6715135fd0e60df188831b566" }, + "gruvbox-material": { "branch": "master", "commit": "80331fbbec9ba18590a17bc6b7d277d96c05c2b6" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "impatient.nvim": { "branch": "main", "commit": "47302af74be7b79f002773011f0d8e85679a7618" }, "instant.nvim": { "branch": "master", "commit": "294b6d08143b3db8f9db7f606829270149e1a786" }, "jq.nvim": { "branch": "master", "commit": "b9879798f25a9318894456dc7464af0904c08958" }, - "lazy.nvim": { "branch": "main", "commit": "08954f723bf2d442ea020551e3acc956f4dc6dc7" }, + "keylab.nvim": { "branch": "main", "commit": "9686b09253b5dde40e18554d189deb1b0c47f437" }, + "lazy.nvim": { "branch": "main", "commit": "31ddbea7c10b6920c9077b66c97951ca8682d5c8" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "ltex-extra.nvim": { "branch": "master", "commit": "42dd3572cb09b52a137e91e515f2dff5eb631b1e" }, - "lualine.nvim": { "branch": "master", "commit": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" }, + "ltex-extra.nvim": { "branch": "master", "commit": "4296c2c7aefbca721d02a011366a1de30598046c" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "44509689b9bf3984d729cc264aacb31cb7f41668" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "67210c0e775adec55de9826b038e8b62de554afc" }, "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, - "nvim-autopairs": { "branch": "master", "commit": "dbfc1c34bed415906395db8303c71039b3a3ffb4" }, - "nvim-cmp": { "branch": "main", "commit": "97dc716fc914c46577a4f254035ebef1aa72558a" }, + "nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" }, + "nvim-bqf": { "branch": "main", "commit": "52703d7adc3be3f7c09eea9a80c5b8caa615fb25" }, + "nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, "nvim-dap": { "branch": "master", "commit": "405df1dcc2e395ab5173a9c3d00e03942c023074" }, + "nvim-dap-go": { "branch": "main", "commit": "36abe1d320cb61bfdf094d4e0fe815ef58f2302a" }, "nvim-dap-ui": { "branch": "master", "commit": "edfa93f60b189e5952c016eee262d0685d838450" }, "nvim-ghost.nvim": { "branch": "main", "commit": "a1ca0b2dac59881066d7ac9373cf64d59ba29d6a" }, - "nvim-lspconfig": { "branch": "master", "commit": "6e5c78ebc9936ca74add66bda22c566f951b6ee5" }, - "nvim-nio": { "branch": "master", "commit": "33c62b3eadd8154169e42144de16ba4db6784bec" }, + "nvim-lspconfig": { "branch": "master", "commit": "9266dc26862d8f3556c2ca77602e811472b4c5b8" }, + "nvim-nio": { "branch": "master", "commit": "5800f585def265d52f1d8848133217c800bcb25d" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, - "nvim-treesitter": { "branch": "master", "commit": "1c3fb9eac2a04230e4af23715fa2c190cbeacd70" }, - "nvim-treesitter-context": { "branch": "master", "commit": "f19766163c18515fb4d3c12d572bf9cba6cdb990" }, - "nvim-web-devicons": { "branch": "master", "commit": "3ee60deaa539360518eaab93a6c701fe9f4d82ef" }, + "nvim-treesitter": { "branch": "master", "commit": "2a95ff14764af20d32ec1edb27e11c38a84b9478" }, + "nvim-treesitter-context": { "branch": "master", "commit": "ba05c6b753130d96b284d3e8ba8f54c28c0fb6d1" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" }, + "nvim-web-devicons": { "branch": "master", "commit": "b3468391470034353f0e5110c70babb5c62967d3" }, "oil.nvim": { "branch": "master", "commit": "e462a3446505185adf063566f5007771b69027a1" }, "pastify.nvim": { "branch": "main", "commit": "47317b9bb7bf5fb7dfd994a6eb9bec8f00628dc0" }, "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, "tla.nvim": { "branch": "master", "commit": "e419c75e805ab6d9967c7325bf35734c372d3d4b" }, - "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, - "typst.vim": { "branch": "main", "commit": "86e4fa8dcddd032f9fdbf04602417a8baac8fed3" }, + "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, "undotree": { "branch": "master", "commit": "aa93a7e5890dbbebbc064cd22260721a6db1a196" }, "vim-alloy": { "branch": "master", "commit": "5bd57c4890be39e221dd3e1f6735457dce454bbd" }, "vim-be-good": { "branch": "master", "commit": "4fa57b7957715c91326fcead58c1fa898b9b3625" }, - "vim-commentary": { "branch": "master", "commit": "f67e3e67ea516755005e6cccb178bc8439c6d402" }, "vim-jukit": { "branch": "master", "commit": "73214c9a8abc4b6aa7a6266b5bc2ddbf8b3e3c00" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-tpipeline": { "branch": "master", "commit": "649f079a0bee19565978b82b672d831c6641d952" }, - "vimtex": { "branch": "master", "commit": "73605f8b7655301ea47a2c355500ab4984f41b91" }, + "vim-tpipeline": { "branch": "master", "commit": "5dd3832bd6e239feccb11cadca583cdcf9d5bda1" }, + "vimtex": { "branch": "master", "commit": "ac0a41b297a70c101df89bc9c8d43341ba00fd4f" }, "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } } \ No newline at end of file diff --git a/.config/nvim/lua/core/variables.lua b/.config/nvim/lua/core/variables.lua index b0669b5..4ad5e79 100644 --- a/.config/nvim/lua/core/variables.lua +++ b/.config/nvim/lua/core/variables.lua @@ -25,8 +25,8 @@ vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true --quickfix keybinds -vim.keymap.set("n", "", "cnextzz") -vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "", "cnextzz") --buffer keybinds vim.keymap.set("n", "", "bp") vim.keymap.set("n", "", "bn") @@ -46,4 +46,4 @@ vim.g.jukit_pdf_viewer = 'zathura' vim.g.jukit_mappings = 0 --Format Options vim.opt.formatoptions:remove("ro") - +--Sign gutter always on diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index fa390ac..80b163b 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -19,38 +19,6 @@ if not lspkind_status_ok then return end --- 󰃐 󰆩 󰙅 󰛡  󰅲 some other good icons -local kind_icons = { - Text = "󰉿", - Method = "m", - Function = "󰊕", - Constructor = "", - Field = "", - Variable = "󰆧", - Class = "󰌗", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "󰎠", - Enum = "", - Keyword = "󰌋", - Snippet = "", - Color = "󰏘", - File = "󰈙", - Reference = "", - Folder = "󰉋", - EnumMember = "", - Constant = "󰇽", - Struct = "", - Event = "", - Operator = "󰆕", - TypeParameter = "󰊄", - Copilot = "", - DB = "󰆼", -} --- find more here: https://www.nerdfonts.com/cheat-sheet - cmp.setup({ snippet = { expand = function(args) @@ -71,38 +39,25 @@ cmp.setup({ { "i", "c" } ), [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - -- Accept currently selected item. If none selected, do nothing. - [""] = cmp.mapping(function(fallback) - if luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then + [""] = cmp.mapping(function() + if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() end end), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function() if luasnip.jumpable(-1) then luasnip.jump(-1) - else - fallback() end end), }, formatting = { fields = { "kind", "abbr", "menu" }, format = lspkind.cmp_format({ - mode = "symbol_text", -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - -- can also be a function to dynamically calculate max width such as - -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, - ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - show_labelDetails = true, -- show labelDetails in menu. Disabled by default + mode = "symbol_text", + maxwidth = 50, + ellipsis_char = "...", + show_labelDetails = true, - -- The function below will be called before any actual modifications from lspkind - -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) before = function(entry, vim_item) vim_item.menu = ({ nvim_lsp = "[LSP]", @@ -113,11 +68,16 @@ cmp.setup({ end, }), }, + preselect = cmp.PreselectMode.None, sorting = { + priority_weight = 2, comparators = { - cmp.config.compare.exact, cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.kind, cmp.config.compare.recently_used, + cmp.config.compare.locality, --Make entries that start with underline appear after function(entry1, entry2) @@ -134,8 +94,8 @@ cmp.setup({ }, }, sources = cmp.config.sources({ - { name = "nvim_lsp" }, { name = "nvim_lua" }, + { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, }, { diff --git a/.config/nvim/lua/plugins/lazy.lua b/.config/nvim/lua/plugins/lazy.lua index 8b1079c..efd8d00 100644 --- a/.config/nvim/lua/plugins/lazy.lua +++ b/.config/nvim/lua/plugins/lazy.lua @@ -29,6 +29,15 @@ lazy.setup({ end, }, + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("plugins.harpoon") + end + }, + "vimpostor/vim-tpipeline", { @@ -61,7 +70,15 @@ lazy.setup({ "folke/todo-comments.nvim", event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim" }, - opts = {}, + opts = { + vim.keymap.set("n", "]t", function() + require("todo-comments").jump_next() + end, { desc = "Next todo comment" }), + + vim.keymap.set("n", "[t", function() + require("todo-comments").jump_prev() + end, { desc = "Previous todo comment" }) + }, }, { @@ -181,6 +198,11 @@ lazy.setup({ end, }, + { + 'leoluz/nvim-dap-go', + opts = {} + }, + { "williamboman/mason.nvim", config = function() @@ -196,61 +218,12 @@ lazy.setup({ require("plugins.lspconfig") end, }, + --Better quick fix { - "folke/trouble.nvim", - branch = "dev", - 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)", - }, - }, - opts = { - modes = { - mydiags = { - mode = "diagnostics", -- inherit from diagnostics mode - filter = { - any = { - buf = 0, -- current buffer - { - severity = vim.diagnostic.severity.ERROR, -- errors only - -- limit to files in the current project - function(item) - return item.filename:find(vim.loop.cwd(), 1, true) - end, - }, - }, - }, - } - } - } + 'kevinhwang91/nvim-bqf', + ft = 'qf' }, + 'junegunn/fzf', { "stevearc/conform.nvim", @@ -293,12 +266,14 @@ lazy.setup({ -- Syntax Highlighting { "nvim-treesitter/nvim-treesitter", + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects' + }, config = function() require("plugins.treesitter") end, }, - "kaarmu/typst.vim", --Sticky headers { @@ -315,7 +290,11 @@ lazy.setup({ "nvim-telescope/telescope.nvim", tag = "0.1.4", -- or , branch = '0.1.x', - dependencies = { "nvim-lua/plenary.nvim" }, + dependencies = { + "nvim-lua/plenary.nvim", + 'nvim-telescope/telescope-ui-select.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } + }, config = function() require("plugins.telescope") end, diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 615ab54..bde13ae 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -12,6 +12,8 @@ vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) -- Enable completion triggered by vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + vim.opt_local.signcolumn=numbers + local telescope = require("telescope.builtin") local conform = require("conform") @@ -28,13 +30,13 @@ vim.api.nvim_create_autocmd("LspAttach", { vim.keymap.set("n", "q", vim.diagnostic.setloclist, bufopts) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) vim.keymap.set("n", "gd", telescope.lsp_definitions, bufopts) + vim.keymap.set("n", "gr", telescope.lsp_references, bufopts) vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) vim.keymap.set("n", "gi", telescope.lsp_implementations, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "k", vim.lsp.buf.signature_help, bufopts) vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "gr", telescope.lsp_references, bufopts) vim.keymap.set("n", "ge", function() vim.diagnostic.goto_next() end, bufopts) vim.keymap.set("n", "gE", function() vim.diagnostic.goto_prev() end, bufopts) vim.keymap.set("n", "fo", function() conform.format({ lsp_fallback = true }) end, bufopts) @@ -54,7 +56,7 @@ mason_lspconfig.setup_handlers({ capabilities = capabilities, }) end, - ["gopls"] = function () + ["gopls"] = function() lspconfig["gopls"].setup({ capabilities = capabilities, settings = { @@ -79,11 +81,17 @@ mason_lspconfig.setup_handlers({ capabilities = capabilities, settings = { Lua = { - library = { - unpack(vim.api.nvim_get_runtime_file('', true)) + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", }, diagnostics = { - globals = { 'vim' }, + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), }, hint = { enable = true } }, diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index c55f118..49aaf80 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,5 +1,41 @@ +local telescope = require('telescope') +local actions = require("telescope.actions") + +telescope.setup { + defaults = { + layout_strategy = "horizontal", + mappings = { + i = { + [""] = actions.close, + }, + }, + }, + pickers = { + find_files = { + previewer = false, + layout_strategy = "vertical", + layout_config = { + height = 0.7, + width = 0.5 + }, + }, + live_grep = { + only_sort_text = true, + previewer = true, + } + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_cursor {} + } + } +} +telescope.load_extension('fzf') +telescope.load_extension("ui-select") + local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', builtin.find_files, {}) vim.keymap.set('n', 'fg', builtin.live_grep, {}) vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fs', builtin.treesitter, {}) vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index d4a6fec..995a448 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -4,11 +4,6 @@ if not present then end require('nvim-treesitter.install').update({ with_sync = true }) -local present, orgmode = pcall(require, "orgmode") -if present then - require('orgmode').setup_ts_grammar() -end - local options = { @@ -22,6 +17,26 @@ local options = { indent = { enable = true, }, + textobjects = { + select = { + enable = true, + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ab"] = "@block.outer", + ["ib"] = "@block.inner", + }, + selection_modes = { + ['@block.outer'] = 'v', -- charwise + ['@block.inner'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + }, + include_surrounding_whitespace = true, + }, + }, } treesitter.setup(options)