From c2a92954cc386e587a84244aeda229ccde0a86b4 Mon Sep 17 00:00:00 2001 From: SL1900 <43700351+SL1900@users.noreply.github.com> Date: Sun, 2 Aug 2026 22:35:22 +0900 Subject: [PATCH] Treesitter config update --- lua/plugins/treesitter.lua | 62 ++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 43f7646..9496fc4 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,10 +1,30 @@ return { { "nvim-treesitter/nvim-treesitter", - -- build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, + lazy = false, + branch = "main", + build = ":TSUpdate", config = function() + -- vim.api.nvim_create_autocmd("BufReadPost", { + -- pattern = "*", + -- callback = function () + -- vim.treesitter.start() + -- end + -- }) -- vim.cmd("TSUpdate") + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("LazyTreesitterHighlight", { clear = true, }), + pattern = "*", + callback = function (args) + local lang = vim.treesitter.language.get_lang(args.match) + + if not lang or not vim.treesitter.language.add(lang) then + return + end + + vim.treesitter.start(args.buf) + end + }) require("nvim-treesitter.install").compilers = { "zig", "gcc", @@ -13,27 +33,25 @@ return { "clang", "g++", } - require("nvim-treesitter.config").setup({ + require("nvim-treesitter").setup({ highlight = { enable = true }, - ensure_installed = { - "c", - "lua", - "vim", - "vimdoc", - "query", - "markdown", - "markdown_inline", - "typescript", - "javascript", - "css", - "scss", - "html", - "svelte", - "json", - "yaml", - "cpp", - "glsl" - } + }) + require("nvim-treesitter").install({ + "c", + "lua", + "vim", + "vimdoc", + "query", + "markdown", + "markdown_inline", + "typescript", + "javascript", + "css", + "html", + "svelte", + "json", + "yaml", + "cpp", }) end },