diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua index 7433b51..48022ab 100644 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -1,16 +1,58 @@ -require("nvim-treesitter.configs").setup({ - ensure_installed = { "typescript" }, - sync_install = true, - auto_install = true, - highlight = { - enable = true, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true, - }, +require("nvim-treesitter").install({ + "bash", + "c", + "cmake", + "comment", + "cpp", + "gitignore", + "go", + "html", + "java", + "javascript", + "json", + "jsx", + "ledger", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "rust", + "scala", + "tsx", + "typescript", + "vim", + "vimdoc", + "yaml", + "zsh", +}) + +local augroup = vim.api.nvim_create_augroup("treesitter-init", {}) +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "cpp", + "cmake", + "go", + "java", + "javascript", + "javascriptreact", + "ledger", + "lua", + "markdown", + "python", + "rust", + "typescript", + "typescriptreact", + "scala", + }, + callback = function() + vim.treesitter.start() + vim.opt.foldmethod = "expr" + vim.opt.foldlevel = 99 + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" + end, + group = augroup, }) diff --git a/init.lua b/init.lua index 3cc32c6..1817189 100644 --- a/init.lua +++ b/init.lua @@ -58,10 +58,6 @@ vim.opt.whichwrap = "b,s,<,>,[,],h,l" --vim.opt.timeout = false -vim.opt.foldmethod = "expr" -vim.opt.foldlevel = 99 -vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - vim.opt.diffopt:append("vertical") vim.opt.diffopt:append("linematch:50") -- todo visualbell needed? diff --git a/lazy-lock.json b/lazy-lock.json index 144a9b0..d94e499 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,74 +1,75 @@ { "Vim-Jinja2-Syntax": { "branch": "master", "commit": "2c17843b074b06a835f88587e1023ceff7e2c7d1" }, - "blink.cmp": { "branch": "main", "commit": "0590187042b60456edef3808cfa3a4f34b2e4027" }, - "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, - "deepl.vim": { "branch": "main", "commit": "59df8cc17bb28989ce562bf4712c724d23baadcd" }, + "blink.cmp": { "branch": "main", "commit": "5e088706d92da09949e081cc4d49e2c9ba8cfc8c" }, + "codediff.nvim": { "branch": "main", "commit": "832f1ecc5f8b15a44cf7537e31d3266d657775b1" }, + "conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" }, + "deepl.vim": { "branch": "main", "commit": "d062824f418b52bc15a373f0b282b5a3d8effea1" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "gen.nvim": { "branch": "main", "commit": "c8e1f574d4a3a839dde73a87bdc319a62ee1e559" }, "gina.vim": { "branch": "master", "commit": "ff6c2ddeca98f886b57fb42283c12e167d6ab575" }, - "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, - "hover.nvim": { "branch": "main", "commit": "15533855dcf3c6a35a09c118c4169e531847b4cc" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, + "gitsigns.nvim": { "branch": "main", "commit": "0f00d07c2c3106ba6abd594ac1c17f211141b7b5" }, + "hover.nvim": { "branch": "main", "commit": "e73c00da3a9c87a21d2a8ddf7ab4a39824bd5d56" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, "lsp-colors.nvim": { "branch": "main", "commit": "2bbe7541747fd339bdd8923fc45631a09bb4f1e5" }, - "lsp-progress.nvim": { "branch": "main", "commit": "ae52979ad412371ea6dc39ff70c8dfc681fb42b8" }, - "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "lsp-progress.nvim": { "branch": "main", "commit": "f6d5af10563b895ff846346f57cbd4451439f4c1" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, "lush.nvim": { "branch": "main", "commit": "9c60ec2279d62487d942ce095e49006af28eed6e" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "a1067cf84b4ff81b66d2bf4d01f4cbdb5de40bd0" }, - "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, - "multicursor.nvim": { "branch": "1.0", "commit": "ffe2e402e85150516d096842f7be99fd1321a72b" }, - "neoconf.nvim": { "branch": "main", "commit": "dd3cf8ac24e095e3fffc05e47497ba1a2e95af50" }, - "nvim-dap": { "branch": "master", "commit": "7367cec8e8f7a0b1e4566af9a7ef5959d11206a7" }, - "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "multicursor.nvim": { "branch": "1.0", "commit": "704b99f10a72cc05d370cfeb294ff83412a8ab55" }, + "neoconf.nvim": { "branch": "main", "commit": "2be67111f65cf677bf568cff432ddb8bc385495e" }, + "nvim-dap": { "branch": "master", "commit": "4f5deb110d9ff8994d96c21df95e2271d11214f9" }, + "nvim-dap-ui": { "branch": "master", "commit": "f5b6673f374626515401c5bc51b005f784a4f252" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, - "nvim-genghis": { "branch": "main", "commit": "cdf584d05ffc9d5c1f247079991552249e4f7487" }, - "nvim-jdtls": { "branch": "master", "commit": "b69924ca90014fef485ee153571bdcbc1ece8c2e" }, - "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, - "nvim-lspconfig": { "branch": "master", "commit": "b3cce1419ca67871ae782b3e529652f8a016f0de" }, + "nvim-genghis": { "branch": "main", "commit": "0e9ca5e104edc53110896e00466e3c6a4af1ae7d" }, + "nvim-jdtls": { "branch": "master", "commit": "77ccaeb422f8c81b647605da5ddb4a7f725cda90" }, + "nvim-lint": { "branch": "master", "commit": "4b03656c09c1561f89b6aa0665c15d292ba9499d" }, + "nvim-lspconfig": { "branch": "master", "commit": "8e2084bf5e40c79c1f42210a6ef96a0a4793a763" }, "nvim-luadev": { "branch": "master", "commit": "3ba0c02c378503739f1fdb95cff3ea2aad48db3e" }, - "nvim-metals": { "branch": "main", "commit": "db6c9ffb32ec698b96d11cba1317dccc26f5c16d" }, + "nvim-metals": { "branch": "main", "commit": "48b9d29a4e1370495db4d4b5ccbc17b285bc98eb" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-quick-switcher": { "branch": "main", "commit": "b56ba55cff165ae1551836a79313933bf4d43ae2" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-context": { "branch": "master", "commit": "41847d3dafb5004464708a3db06b14f12bde548a" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, - "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, + "nvim-treesitter": { "branch": "main", "commit": "c82bf96f0a773d85304feeb695e1e23b2207ac35" }, + "nvim-treesitter-context": { "branch": "master", "commit": "adf4b6b0420b7be6c717ef0ac7993183d6c201b1" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" }, + "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "shipwright.nvim": { "branch": "master", "commit": "e596ab48328c31873f4f4d2e070243bf9de16ff3" }, "splice.vim": { "branch": "master", "commit": "815a28e687fdf78b67e9b9cd4c21277bbe658873" }, - "suda.vim": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" }, - "table-nvim": { "branch": "main", "commit": "c044fd37169eb10376962b0d0cec5f94d58ca626" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "suda.vim": { "branch": "master", "commit": "c492741b4679b3cdd4d9e34138209784e061d916" }, + "table-nvim": { "branch": "main", "commit": "816d251963bf4c8c3d765dab40ebac3c259c7b6d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, "telescope-lsp-handlers.nvim": { "branch": "trunk", "commit": "de02085d6af1633942549a238bc7a5524fa9b201" }, - "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "trouble.nvim": { "branch": "main", "commit": "f176232e7759c4f8abd923c21e3e5a5c76cd6837" }, + "telescope.nvim": { "branch": "master", "commit": "cfb85dcf7f822b79224e9e6aef9e8c794211b20b" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "vim-abolish": { "branch": "master", "commit": "dcbfe065297d31823561ba787f51056c147aa682" }, "vim-caddyfile": { "branch": "master", "commit": "6d60d5af0d73f20b88ec388a9d70188d55ed8223" }, "vim-characterize": { "branch": "master", "commit": "a8bffac6cead6b2869d939ecad06312b187a4c79" }, "vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" }, "vim-easy-align": { "branch": "master", "commit": "9815a55dbcd817784458df7a18acacc6f82b1241" }, - "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, "vim-gitignore": { "branch": "master", "commit": "641dfa648d2581a5e5e9b0d11ffee37da8de49d7" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-highlightedyank": { "branch": "master", "commit": "285a61425e79742997bbde76a91be6189bc988fb" }, "vim-hocon": { "branch": "main", "commit": "5df6dc1b7c8f5811afe663b0441e6304a729dcaf" }, "vim-indent-object": { "branch": "master", "commit": "8ab36d5ec2a3a60468437a95e142ce994df598c6" }, - "vim-kitty": { "branch": "main", "commit": "5c3efc79af70dc2c22cad03e6a7374a5f81205d9" }, - "vim-ledger": { "branch": "master", "commit": "a0670d0c60c4933a70767033c89467631643a4c1" }, - "vim-markdown-composer": { "branch": "master", "commit": "e6f99bc20cfcb277c63041b1f766e6d5940bcc76" }, + "vim-kitty": { "branch": "main", "commit": "cd72f2d9cfee8d6aba5a180a5ac3ca265b5d3a46" }, + "vim-ledger": { "branch": "master", "commit": "4f2d93dd914f625e2d3db47d97bd9f428fedd68f" }, + "vim-markdown-composer": { "branch": "master", "commit": "4f53f1c6e41c8fb916c50b50e18284d923f0f3cd" }, "vim-mkdir": { "branch": "master", "commit": "f0ba7a7dc190a0cedf1d827958c99f3718109cf0" }, "vim-nftables": { "branch": "master", "commit": "26f8a506c6f3e41f1e4a8d6aa94c9a79a666bbff" }, - "vim-pass": { "branch": "master", "commit": "601bdc138c736b36c695eebe68e31ce82bafdff0" }, + "vim-pass": { "branch": "master", "commit": "573f3aa66ae4815965cbbc6e75072a62bd5eded8" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-textobj-comment": { "branch": "master", "commit": "58ae4571b76a5bf74850698f23d235eef991dd4b" }, "vim-textobj-user": { "branch": "master", "commit": "41a675ddbeefd6a93664a4dc52f302fe3086a933" }, "vim-theme-chroma": { "branch": "lush", "commit": "0ad7be22f2244f99a877edfd6261eaba47952b6f" }, - "vimtex": { "branch": "master", "commit": "2e1bbabeb2c34bb17d7bc8cfdf8f95b16dd0db0c" }, - "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" }, + "vimtex": { "branch": "master", "commit": "9306903316c3ddd250676b7cf97c84a84c9c8f99" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, "workspace-diagnostics.nvim": { "branch": "main", "commit": "60f9175b2501ae3f8b1aba9719c0df8827610c8e" } } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 36bc70a..493d751 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -8,7 +8,11 @@ return { "tpope/vim-sleuth", "tpope/vim-abolish", - { "chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim", opts = { trashCmd = "rm" } }, + { "chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim", opts = { + file_operations = { + trashCmd = "rm" + } + } }, -- ic / ac { diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index a85d4c3..fd7efa2 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,122 +1,7 @@ -local function ts_disable(_, bufnr) - return vim.api.nvim_buf_line_count(bufnr) > 5000 -end - return { { "nvim-treesitter/nvim-treesitter", - version = false, build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, - dependencies = { - { - "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - -- PERF: no need to load the plugin, if we only need its queries for mini.ai - local plugin = require("lazy.core.config").spec.plugins["nvim-treesitter"] - local opts = require("lazy.core.plugin").values(plugin, "opts", false) - local enabled = false - if opts.textobjects then - for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do - if opts.textobjects[mod] and opts.textobjects[mod].enable then - enabled = true - break - end - end - end - if not enabled then - require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") - end - end, - }, - }, - keys = { - { "", desc = "Increment selection" }, - { "", desc = "Decrement selection", mode = "x" }, - }, - opts = { - auto_install = true, - ignore_install = {}, - highlight = { enable = true, disable = ts_disable }, - indent = { enable = true }, - ensure_installed = { - "bash", - "gitignore", - "html", - "java", - "json", - "lua", - "luadoc", - "luap", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "scala", - "tsx", - "typescript", - "vim", - "vimdoc", - "yaml", - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - -- stylua: ignore start - ["af"] = { query = "@function.outer", desc = "outer function" }, - ["if"] = { query = "@function.inner", desc = "inner function" }, - ["ac"] = { query = "@class.outer", desc = "outer class" }, - ["ic"] = { query = "@class.inner", desc = "inner class" }, - ["ap"] = { query = "@parameter.outer", desc = "outer parameter" }, - ["ip"] = { query = "@parameter.inner", desc = "inner parameter" }, - ["ar"] = { query = "@return_type.outer", desc = "outer return type" }, - ["ir"] = { query = "@return_type.inner", desc = "inner return type" }, - -- stylua: ignore end - }, - selection_modes = { - ["@parameter.outer"] = "v", -- charwise - ["@function.outer"] = "V", -- linewise - ["@class.outer"] = "V", - }, - }, - swap = { - enable = true, - swap_next = { - ["a"] = "@parameter.inner", - }, - swap_previous = { - ["A"] = "@parameter.inner", - }, - }, - }, - }, - ---@param opts TSConfig - config = function(_, opts) - if type(opts.ensure_installed) == "table" then - ---@type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then - return false - end - added[lang] = true - return true - end, opts.ensure_installed --[[@as string[] ]]) - end - require("nvim-treesitter.configs").setup(opts) - end, }, { "nvim-treesitter/playground", @@ -145,4 +30,61 @@ return { vim.api.nvim_set_hl(0, "TreesitterContextLineNumber", { link = "Special" }) end, }, + { + "nvim-treesitter/nvim-treesitter-textobjects", + branch = "main", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + 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 + end, + config = function() + require("nvim-treesitter-textobjects").setup({ + select = { + lookahead = true, + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + ["@class.outer"] = "V", + }, + }, + }) + + vim.keymap.set("n", "a", function() + require("nvim-treesitter-textobjects.swap").swap_next("@parameter.inner") + end) + vim.keymap.set("n", "A", function() + require("nvim-treesitter-textobjects.swap").swap_previous("@parameter.outer") + end) + 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" }, "ap", function() + require("nvim-treesitter-textobjects.select").select_textobject("@parameter.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ip", function() + require("nvim-treesitter-textobjects.select").select_textobject("@parameter.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ar", function() + require("nvim-treesitter-textobjects.select").select_textobject("@return_type.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ir", function() + require("nvim-treesitter-textobjects.select").select_textobject("@return_type.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, + }, }