From d85d183b35f69c74e1bc5f23fe43c787497f398c Mon Sep 17 00:00:00 2001 From: "Simen A. W. Olsen" Date: Thu, 8 Oct 2026 10:02:43 +0200 Subject: fix: migrate treesitter to main branch and tidy config nvim-treesitter master is archived and its queries crash on Neovim 0.12. Move lazy-lock.json to stdpath(state) since the config dir is read-only. --- lua/simenandre/plugins/dap.lua | 2 +- lua/simenandre/plugins/harpoon.lua | 4 +- lua/simenandre/plugins/lsp.lua | 2 +- lua/simenandre/plugins/mini.lua | 2 +- lua/simenandre/plugins/telescope.lua | 2 - lua/simenandre/plugins/treesitter.lua | 100 ++++++++++++++++++++-------------- 6 files changed, 63 insertions(+), 49 deletions(-) (limited to 'lua/simenandre/plugins') diff --git a/lua/simenandre/plugins/dap.lua b/lua/simenandre/plugins/dap.lua index 686e535..642e645 100644 --- a/lua/simenandre/plugins/dap.lua +++ b/lua/simenandre/plugins/dap.lua @@ -1,4 +1,4 @@ return { "mfussenegger/nvim-dap", - "leoluz/nvim-dap-go", + { "leoluz/nvim-dap-go", dependencies = { "mfussenegger/nvim-dap" }, opts = {} }, } diff --git a/lua/simenandre/plugins/harpoon.lua b/lua/simenandre/plugins/harpoon.lua index ee2dfdb..248962c 100644 --- a/lua/simenandre/plugins/harpoon.lua +++ b/lua/simenandre/plugins/harpoon.lua @@ -1,9 +1,7 @@ return { "ThePrimeagen/harpoon", branch = "harpoon2", - requires = { - { "nvim-lua/plenary.nvim" }, - }, + dependencies = { "nvim-lua/plenary.nvim" }, config = function() local harpoon = require("harpoon") harpoon:setup() diff --git a/lua/simenandre/plugins/lsp.lua b/lua/simenandre/plugins/lsp.lua index 4161489..91626b8 100644 --- a/lua/simenandre/plugins/lsp.lua +++ b/lua/simenandre/plugins/lsp.lua @@ -5,7 +5,7 @@ return { ft = "lua", opts = { library = { - { path = "luvit-meta/library", words = { "vim%.uv" } }, + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, }, }, }, diff --git a/lua/simenandre/plugins/mini.lua b/lua/simenandre/plugins/mini.lua index de7156b..aa51e9d 100644 --- a/lua/simenandre/plugins/mini.lua +++ b/lua/simenandre/plugins/mini.lua @@ -1,6 +1,6 @@ return { { -- Collection of various small independent plugins/modules - "echasnovski/mini.nvim", + "nvim-mini/mini.nvim", config = function() -- Better Around/Inside textobjects -- diff --git a/lua/simenandre/plugins/telescope.lua b/lua/simenandre/plugins/telescope.lua index 602cac1..4c27d78 100644 --- a/lua/simenandre/plugins/telescope.lua +++ b/lua/simenandre/plugins/telescope.lua @@ -81,8 +81,6 @@ return { vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) - vim.keymap.set("n", "st", builtin.treesitter, { desc = "[S]earch [T]reesitter" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) diff --git a/lua/simenandre/plugins/treesitter.lua b/lua/simenandre/plugins/treesitter.lua index 77f617d..1eb9080 100644 --- a/lua/simenandre/plugins/treesitter.lua +++ b/lua/simenandre/plugins/treesitter.lua @@ -1,48 +1,66 @@ +local ensure_installed = { + "astro", + "bash", + "c", + "css", + "diff", + "gitcommit", + "gitignore", + "go", + "html", + "javascript", + "json", + "lua", + "luadoc", + "markdown", + "markdown_inline", + "nix", + "query", + "rust", + "ssh_config", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "yaml", + "zig", +} + +local function start(buf, lang) + if not pcall(vim.treesitter.start, buf, lang) then + return + end + vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" +end + return { - { -- Highlight, edit, and navigate code + { -- Parsers and queries; highlighting itself is native (vim.treesitter.start) "nvim-treesitter/nvim-treesitter", + branch = "main", + lazy = false, build = ":TSUpdate", - main = "nvim-treesitter.configs", -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "ssh_config", - "c", - "diff", - "html", - "css", - "gitcommit", - "gitignore", - "lua", - "luadoc", - "go", - "json", - "javascript", - "rust", - "zig", - "yaml", - "toml", - "tsx", - "typescript", - "markdown", - "markdown_inline", - "query", - "vim", - "vimdoc", - "astro", - }, - -- 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" } }, + local ts = require("nvim-treesitter") + ts.install(ensure_installed) + + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("treesitter-start", { clear = true }), + callback = function(args) + local lang = vim.treesitter.language.get_lang(args.match) + if not lang then + return + end + if vim.list_contains(ts.get_installed(), lang) then + start(args.buf, lang) + elseif vim.list_contains(ts.get_available(), lang) then + ts.install(lang):await(vim.schedule_wrap(function() + if vim.api.nvim_buf_is_valid(args.buf) then + start(args.buf, lang) + end + end)) + end + end, }) end, }, -- cgit v1.3.1