diff --git a/lazy-lock.json b/lazy-lock.json index 9f350b40eb3..4bd035522e0 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,78 +2,76 @@ "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" }, - "avante.nvim": { "branch": "main", "commit": "476f342fe6bc1e120ba3e334b5d9cf3ef66de56a" }, + "avante.nvim": { "branch": "main", "commit": "7a9fbbd4ddc9affc6a33bff644b1af7c0f908e74" }, "blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" }, "blink-cmp-git": { "branch": "master", "commit": "e3ad0ffaaa3b3b7e2158cc72cd6dad2d19842c46" }, "blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" }, "blink.compat": { "branch": "main", "commit": "1454f14a8d855a578ceeba77c62538fa1459a67c" }, - "conform.nvim": { "branch": "master", "commit": "5420c4b5ea0aeb99c09cfbd4fd0b70d257b44f25" }, + "conform.nvim": { "branch": "master", "commit": "8314f4c9e205e7f30b62147069729f9a1227d8bf" }, "copilot.vim": { "branch": "release", "commit": "dfe0a3a1c256167d181488a73ec6ccab8d8931a9" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "emoji.nvim": { "branch": "main", "commit": "9f9214537b12bfcebcd3d3de78f0f8f8db41ab88" }, "fidget.nvim": { "branch": "main", "commit": "b61e8af9b8b68ee0ec7da5fb7a8c203aae854f2e" }, "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, - "fzf": { "branch": "master", "commit": "603240122e300d146cbae6f0bc9c52a1017ac3c8" }, - "fzf-lua": { "branch": "main", "commit": "9d579feab4d3035627150e5e9b6e8fbf5e814ef6" }, + "fzf": { "branch": "master", "commit": "b29e2ee2d16bce269c4675a2030e7e550e13fb5c" }, + "fzf-lua": { "branch": "main", "commit": "19d7020b700879759d7f834fc717dde086f673a7" }, "fzf-lua-lazy.nvim": { "branch": "main", "commit": "e813f5df261ff5b781204c108af8f071bf0e1b00" }, - "gh-co.nvim": { "branch": "master", "commit": "024a0197184ff56fa73929ae45ce5c6cd38361b5" }, - "gitsigns.nvim": { "branch": "main", "commit": "5813e4878748805f1518cee7abb50fd7205a3a48" }, - "grug-far.nvim": { "branch": "main", "commit": "bc589a1ba340a00ae40bf1436401eac5b1454687" }, - "gruvbox.nvim": { "branch": "main", "commit": "dfc89cf5ce9a5ac149dd5d4b347fc1db3c1b2fa4" }, + "gh-co.nvim": { "branch": "master", "commit": "73fb5c730af0b2d2b46e46005cb42fcbf47ddfc2" }, + "gitsigns.nvim": { "branch": "main", "commit": "6bd29494e3f79ff08be1d35bc1926ed23c22ed9a" }, + "grug-far.nvim": { "branch": "main", "commit": "74eef260e1142264ab994fb9c88e4f420e9486d7" }, "harpoon": { "branch": "harpoon2_custom", "commit": "14eda8299e45d66f2c34624297b2be290e73ecda" }, "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, - "kulala.nvim": { "branch": "main", "commit": "9fc4831a116fb32b0fd420ed483f5102a873446a" }, + "kulala.nvim": { "branch": "main", "commit": "cd3eaa83b8d60533837202dede73238334d71832" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, "lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "8f1a3e6eecb638817e8999aaa16ada27cd54d867" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4cfe411526a7a99c18281135e8b4765ae6330d15" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" }, - "mini.nvim": { "branch": "main", "commit": "6170f606fbdb94bf461635c47962f61dceffe496" }, + "mini.nvim": { "branch": "main", "commit": "43ec25063430196d36f5fff5758c9101775f3d57" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neogit": { "branch": "master", "commit": "d8bf9102692250193b855acd9025a826f1af2729" }, "neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" }, - "neotest-jest": { "branch": "main", "commit": "b76a5354b6c332e24f18e96d0713abeaf13c3f3c" }, - "neotest-vitest": { "branch": "main", "commit": "8bc784d319889a39c7ed8045ff7b0f12770c7b54" }, + "neotest-jest": { "branch": "main", "commit": "3f0cc2cff1ee05394081805c622dc2551b54d8c4" }, + "neotest-vitest": { "branch": "main", "commit": "f01addc6f07b79ef1be5f4297eafbee9e0959018" }, "notepad.nvim": { "branch": "main", "commit": "a8e3f0247f93d6af942641ae62bc4eb0c2fd07c4" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, "nvim-bqf": { "branch": "main", "commit": "ba2b365969d7c2c6301d48e13aeee59568765529" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lightbulb": { "branch": "master", "commit": "aa3a8b0f4305b25cfe368f6c9be9923a7c9d0805" }, - "nvim-lint": { "branch": "master", "commit": "7a64f4067065c16a355d40d0d599b8ca6b25de6d" }, - "nvim-lspconfig": { "branch": "master", "commit": "d20d83b3f24f5884da73a9fc92fdc47e778b8d0d" }, + "nvim-lint": { "branch": "master", "commit": "1f19dacd945a7b1a57f29f32b2d7168384df3d36" }, + "nvim-lspconfig": { "branch": "master", "commit": "41ceb6bba3a40128b7841f5b7f5a9dae7201e823" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter": { "branch": "main", "commit": "c6dd314086f7b471bf6c9110092a94ce1c06d220" }, "nvim-treesitter-context": { "branch": "master", "commit": "64dd4cf3f6fd0ab17622c5ce15c91fc539c3f24a" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "ecd03f5811eb5c66d2fa420b79121b866feecd82" }, "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" }, - "obsidian.nvim": { "branch": "main", "commit": "de60246baec087aaf5bbf95e3f976e0897548d89" }, - "octo.nvim": { "branch": "master", "commit": "09ff70efd885fe1cdf62505dce3a9bc6baeb85e1" }, - "oil.nvim": { "branch": "master", "commit": "756dec855b4811f2d27f067a3aca477f368d99f5" }, - "overseer.nvim": { "branch": "master", "commit": "20660642c99a3d3bfb301a29156bd20963961342" }, + "obsidian.nvim": { "branch": "main", "commit": "30d477c8f2c1c0575032c3022cd3baead19dca97" }, + "octo.nvim": { "branch": "master", "commit": "4a3a4fc5a9d3a372c91041f5b846f33b8d6b31fa" }, + "oil.nvim": { "branch": "master", "commit": "81b8a91735ad5cd24a6b3137f14a89f19176364f" }, + "overseer.nvim": { "branch": "master", "commit": "aebd76e175090d14fe48476ded4671c44db1b2d2" }, "persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "previm": { "branch": "master", "commit": "4e46b0512e2d159ec5a04ba79c5f23f9597bbafd" }, "ranger.nvim": { "branch": "main", "commit": "fd2cc999f3ef88f7cdcbcad5f26000c52b16c489" }, "refactoring.nvim": { "branch": "master", "commit": "6784b54587e6d8a6b9ea199318512170ffb9e418" }, "render-markdown.nvim": { "branch": "main", "commit": "07d088bf8bdadd159eb807b90eaee86a4778383f" }, - "rose-pine": { "branch": "main", "commit": "491a0c77abc7ecb955c27a974091a5968232995f" }, "snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" }, "snipe.nvim": { "branch": "main", "commit": "d2d196c335919767803f905d573ce66340e33ee6" }, - "solarized-osaka.nvim": { "branch": "main", "commit": "f796014c14b1910e08d42cc2077fef34f08e0295" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, "treesj": { "branch": "main", "commit": "186084dee5e9c8eec40f6e39481c723dd567cb05" }, - "undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" }, + "undotree": { "branch": "master", "commit": "178d19e00a643f825ea11d581b1684745d0c4eda" }, "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, + "vim-matchup": { "branch": "master", "commit": "0fb1e6b7cea34e931a2af50b8ad565c5c4fd8f4d" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, "vim-rhubarb": { "branch": "master", "commit": "5496d7c94581c4c9ad7430357449bb57fc59f501" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, @@ -81,6 +79,7 @@ "vim-test": { "branch": "master", "commit": "aa619692ff48a3cf3e6bdb893765039488d4e5f3" }, "vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, + "wildfire.nvim": { "branch": "master", "commit": "918a1873c2b8010baa034f373cf28c53ce4f038f" }, "workspaces.nvim": { "branch": "master", "commit": "55a1eb6f5b72e07ee8333898254e113e927180ca" }, "yanky.nvim": { "branch": "main", "commit": "04fc42b94305d94948c9c197f679336668af3292" } } diff --git a/lua/carlos/plugins/nvim-treesitter.lua b/lua/carlos/plugins/nvim-treesitter.lua index 7c04bf0a086..891ce67011a 100644 --- a/lua/carlos/plugins/nvim-treesitter.lua +++ b/lua/carlos/plugins/nvim-treesitter.lua @@ -1,109 +1,188 @@ -return { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - branch = 'master', - -- According to the docs treesitter doesn't support lazy loading - -- event = { 'BufReadPre', 'BufNewFile', 'VeryLazy' }, - -- lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline - dependencies = { - { - 'nvim-treesitter/nvim-treesitter-textobjects', - branch = 'master', +return { + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + branch = 'main', + -- According to the docs treesitter doesn't support lazy loading + lazy = false, + build = ':TSUpdate', + opts = { + -- Custom opt to be used in the config function + ensure_installed = { + 'bash', + 'c', + 'cpp', + 'css', + 'diff', + 'html', + 'javascript', + 'json', + 'json5', + 'jsonc', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'tsx', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', + }, }, + opts_extend = { 'ensure_installed' }, + config = function(_, opts) + local ts = require 'nvim-treesitter' + + -- Install core parsers at startup + ts.install(opts.ensure_installed) + + local group = vim.api.nvim_create_augroup('TreesitterSetup', { clear = true }) + + local ignore_filetypes = {} + + --- Attempt to attach treesitter to a buffer if the parser can be loaded + ---@param buf number + ---@param lang string + local function treesitter_try_attach(buf, lang) + if vim.treesitter.language.add(lang) then + -- Enable treesitter highlighting + pcall(vim.treesitter.start, buf, lang) + -- Enable treesitter indentation + vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end + + -- Auto-install parsers and enable highlighting on FileType + vim.api.nvim_create_autocmd('FileType', { + group = group, + desc = 'Enable treesitter highlighting and indentation', + callback = function(event) + local buf, filetype = event.buf, event.match + + if vim.tbl_contains(ignore_filetypes, filetype) then + return + end + + local lang = vim.treesitter.language.get_lang(filetype) + + if not lang then + return + end + + if vim.tbl_contains(ts.get_installed(), lang) then + treesitter_try_attach(buf, lang) + elseif vim.tbl_contains(ts.get_available(), lang) then + ts.install({ lang }):await(function(err) + if err then + vim.notify('Error installing parser for ' .. lang .. ': ' .. tostring(err), vim.log.levels.ERROR) + return + end + treesitter_try_attach(buf, lang) + end) + else + -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, lang) + end + end, + }) + end, }, - build = ':TSUpdate', - opts = { - ensure_installed = { - 'bash', - 'c', - 'cpp', - 'css', - 'diff', - 'html', - 'javascript', - 'json', - 'json5', - 'jsonc', - 'lua', - 'luadoc', - 'markdown', - 'markdown_inline', - 'query', - 'tsx', - 'typescript', - 'vim', - 'vimdoc', - 'yaml', - }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { - enable = true, - disable = { 'ruby' }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, - include_surrounding_whitespace = false, - keymaps = { - ['af'] = { - query = '@function.outer', - desc = 'select around a function', - }, - ['if'] = { - query = '@function.inner', - desc = 'select inner part of a function', - }, - ['aC'] = { - query = '@class.outer', - desc = 'select around a class', - }, - ['iC'] = { - query = '@class.inner', - desc = 'select inner part of a class', - }, - ['ac'] = { - query = '@comment.outer', - desc = 'select around a comment', - }, - ['ic'] = { - query = '@comment.inner', - desc = 'select inner part of a comment', - }, - ['as'] = { - query = '@local.scope', - query_group = 'locals', - desc = 'Select language scope', + + { + 'nvim-treesitter/nvim-treesitter-textobjects', + branch = 'main', + init = function() + -- Disable entire built-in ftplugin mappings to avoid conflicts. + -- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins. + vim.g.no_plugin_maps = true + + -- Or, disable per filetype (add as you like) + -- vim.g.no_python_maps = true + -- vim.g.no_ruby_maps = true + -- vim.g.no_rust_maps = true + -- vim.g.no_go_maps = true + end, + config = function() + -- put your config here + require('nvim-treesitter-textobjects').setup { + select = { + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '') or a table + -- mapping query_strings to modes. + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true of false + include_surrounding_whitespace = false, }, + } + + -- keymaps + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ 'x', 'o' }, 'af', function() + require('nvim-treesitter-textobjects.select').select_textobject('@function.outer', 'textobjects') + end) + vim.keymap.set({ 'x', 'o' }, 'if', function() + require('nvim-treesitter-textobjects.select').select_textobject('@function.inner', 'textobjects') + end) + vim.keymap.set({ 'x', 'o' }, 'aC', function() + require('nvim-treesitter-textobjects.select').select_textobject('@class.outer', 'textobjects') + end) + vim.keymap.set({ 'x', 'o' }, 'iC', function() + require('nvim-treesitter-textobjects.select').select_textobject('@class.inner', 'textobjects') + end) + vim.keymap.set({ 'x', 'o' }, 'ac', function() + require('nvim-treesitter-textobjects.select').select_textobject('@comment.outer', 'textobjects') + end) + vim.keymap.set({ 'x', 'o' }, 'ic', function() + require('nvim-treesitter-textobjects.select').select_textobject('@comment.inner', 'textobjects') + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ 'x', 'o' }, 'as', function() + require('nvim-treesitter-textobjects.select').select_textobject('@local.scope', 'locals') + end) + end, + }, + + { + 'sustech-data/wildfire.nvim', + event = 'VeryLazy', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + opts = { + surrounds = { + { '(', ')' }, + { '{', '}' }, + { '<', '>' }, + { '[', ']' }, }, - }, - incremental_selection = { - enable = true, keymaps = { - -- maps in normal mode to init the node/scope selection with space init_selection = ',', - -- increment to the upper named parent node_incremental = ',', - -- decrement to the previous node node_decremental = '', - -- increment to the upper scope (as defined in locals.scm) - scope_incremental = '', }, + filetype_exclude = { 'qf' }, --keymaps will be unset in excluding filetypes }, }, - opts_extend = { 'ensure_installed' }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup(opts) - end, + { + 'andymass/vim-matchup', + opts = {}, + }, }