From d384ced6db6de95b81389688c48d2901c9ddd8d2 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Tue, 24 Feb 2026 16:50:17 +0800 Subject: [PATCH] feat(nvim): migrate nvim-treesitter --- modules/coding/editor/neovim/default.nix | 8 +++- .../coding/editor/neovim/nvim/lazy-lock.json | 42 +++++++++---------- .../editor/neovim/nvim/lua/core/options.lua | 1 + .../neovim/nvim/lua/plugins/plugins-setup.lua | 14 +++++-- .../neovim/nvim/lua/plugins/treesitter.lua | 22 ++++------ 5 files changed, 47 insertions(+), 40 deletions(-) diff --git a/modules/coding/editor/neovim/default.nix b/modules/coding/editor/neovim/default.nix index a9fb6e4..1cefa57 100644 --- a/modules/coding/editor/neovim/default.nix +++ b/modules/coding/editor/neovim/default.nix @@ -22,8 +22,14 @@ in viAlias = true; vimAlias = true; vimdiffAlias = true; + withPython3 = false; + withRuby = false; extraPackages = with pkgs; [ - gcc # treesitter + # treesitter + tree-sitter + gnutar + curl + gcc ripgrep # telescope diff --git a/modules/coding/editor/neovim/nvim/lazy-lock.json b/modules/coding/editor/neovim/nvim/lazy-lock.json index 7d50d7e..d5eaadf 100644 --- a/modules/coding/editor/neovim/nvim/lazy-lock.json +++ b/modules/coding/editor/neovim/nvim/lazy-lock.json @@ -1,43 +1,43 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, - "blink.cmp": { "branch": "main", "commit": "b4d379393882561f9055abe780342ee00f02c573" }, + "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "blink.cmp": { "branch": "main", "commit": "456d38d1cd3743926f329204c2340f3e7840aad6" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "9f3c6dd7868bcc116e9c1c1929ce063b978fa519" }, + "gitsigns.nvim": { "branch": "main", "commit": "8d82c240f190fc33723d48c308ccc1ed8baad69d" }, "glance.nvim": { "branch": "master", "commit": "bf86d8b79dce808e65fdb6e9269d0b4ed6d2eefc" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "inlay-hints.nvim": { "branch": "master", "commit": "11be32be3761c6263df2311afb6baa0de0863967" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, - "leap.nvim": { "branch": "main", "commit": "eda0138a408a5600c45e324c69fe73c9df30939c" }, + "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, + "leap.nvim": { "branch": "main", "commit": "b960d5038c5c505c52e56a54490f9bbb1f0e6ef6" }, "lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, - "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, - "mini.nvim": { "branch": "main", "commit": "0a6fe4ec57377526e9056fffb4204dbdfe860ebc" }, - "neo-tree.nvim": { "branch": "main", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, + "lualine.nvim": { "branch": "master", "commit": "f5d2a8570f8b736ddb9bb4be504355bcd6e15ec8" }, + "mini.nvim": { "branch": "main", "commit": "69b7433355664cf76898eb86a12a019f39bd86d1" }, + "neo-tree.nvim": { "branch": "main", "commit": "84c75e7a7e443586f60508d12fc50f90d9aee14e" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-lspconfig": { "branch": "master", "commit": "5a855bcfec7973767a1a472335684bbd71d2fa2b" }, + "nvim-lspconfig": { "branch": "master", "commit": "cb5bc0b2b35a6d513e3298d285db81453e791f4f" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" }, - "nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" }, - "outline.nvim": { "branch": "main", "commit": "ead1820d49c8e79ce89cab1c2c318981b695c9d2" }, - "pest.vim": { "branch": "master", "commit": "7cfcb43f824e74d13dfe631359fff2ec23836a77" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "e2858c43caafec291f915ef25fbed27bbe78abbd" }, + "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" }, + "nvim-web-devicons": { "branch": "master", "commit": "c72328a5494b4502947a022fe69c0c47e53b6aa6" }, + "outline.nvim": { "branch": "main", "commit": "c293eb56db880a0539bf9d85b4a27816960b863e" }, + "pest.vim": { "branch": "master", "commit": "60cae7ea1beb644ed40081a3ec213ea9061aba09" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "aab6caaffd79b8def22ec4320a5344f7c42f58d2" }, "registers": { "branch": "main", "commit": "c217f8f369e0886776cda6c94eab839b30a8940d" }, - "render-markdown.nvim": { "branch": "main", "commit": "48b4175dbca8439d30c1f52231cbe5a712c8f9d9" }, - "ripgrep": { "branch": "master", "commit": "cb66736f146f093497f4dc537b33d0826f9af33c" }, - "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "render-markdown.nvim": { "branch": "main", "commit": "54d4b5431e9634ee3d8d30784e017239b5b89d41" }, + "ripgrep": { "branch": "master", "commit": "4519153e5e461527f4bca45b042fff45c4ec6fb9" }, + "telescope.nvim": { "branch": "master", "commit": "f7c673b8e46e8f233ff581d3624a517d33a7e264" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, - "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, - "tree-sitter-nu": { "branch": "main", "commit": "bb3f533e5792260291945e1f329e1f0a779def6e" }, + "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, + "treesitter-autoinstall.nvim": { "branch": "main", "commit": "b60bd6b84ec9bd3ce6447e51bff6ffc6142f60b7" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "vim-floaterm": { "branch": "master", "commit": "0ab5eb8135dc884bc543a819ac7033c15e72a76b" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" } diff --git a/modules/coding/editor/neovim/nvim/lua/core/options.lua b/modules/coding/editor/neovim/nvim/lua/core/options.lua index 1badfe9..ffecfbf 100644 --- a/modules/coding/editor/neovim/nvim/lua/core/options.lua +++ b/modules/coding/editor/neovim/nvim/lua/core/options.lua @@ -6,6 +6,7 @@ opt.shiftwidth = 4 opt.softtabstop = 4 opt.expandtab = true opt.autoindent = true +opt.smartindent = true -- Linenumber setting opt.number = true diff --git a/modules/coding/editor/neovim/nvim/lua/plugins/plugins-setup.lua b/modules/coding/editor/neovim/nvim/lua/plugins/plugins-setup.lua index fc83166..5b9443b 100644 --- a/modules/coding/editor/neovim/nvim/lua/plugins/plugins-setup.lua +++ b/modules/coding/editor/neovim/nvim/lua/plugins/plugins-setup.lua @@ -81,12 +81,15 @@ local plugins = { }, { "nvim-treesitter/nvim-treesitter", + branch = "main", dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - "nushell/tree-sitter-nu", + { + branch = "main", + "nvim-treesitter/nvim-treesitter-textobjects", + }, }, config = function() - require("nvim-treesitter.configs").setup(require("plugins.treesitter")) + require("nvim-treesitter").setup(require("plugins.treesitter")) end, build = ":TSUpdate", }, @@ -277,7 +280,10 @@ local plugins = { }, { "MeanderingProgrammer/render-markdown.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons", + }, event = "BufEnter *.md", --- @type render.md.UserConfig opts = { diff --git a/modules/coding/editor/neovim/nvim/lua/plugins/treesitter.lua b/modules/coding/editor/neovim/nvim/lua/plugins/treesitter.lua index 67ca241..e32310c 100644 --- a/modules/coding/editor/neovim/nvim/lua/plugins/treesitter.lua +++ b/modules/coding/editor/neovim/nvim/lua/plugins/treesitter.lua @@ -1,21 +1,15 @@ --- @type TSConfig M = { - auto_install = true, - parser_install_dir = "$HOME/.local/share/nvim/lazy/nvim-treesitter", - sync_install = true, - modules = {}, - ignore_install = {}, - ensure_installed = {}, - - highlight = { enable = true }, - indent = { enable = true }, + install_dir = vim.fn.stdpath('data') .. '/site', } -vim.filetype.add({ - pattern = { - [".*/hypr/.*%.conf"] = "hyprlang", - [".*%.hl"] = "hyprlang", - }, +vim.api.nvim_create_autocmd('FileType', { + callback = function() + -- Enable treesitter highlighting and disable regex syntax + pcall(vim.treesitter.start) + -- Enable treesitter-based indentation + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, }) return M