From 76e71ac03f57391eb3288cf69d2413891ec5c3f1 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Mon, 26 May 2025 02:48:43 +0200 Subject: [PATCH] Update treesitter to main --- nvim/dot-config/nvim/lua/autocmds.lua | 12 +++++++++ .../nvim/lua/plugins/treesitter.lua | 26 ++++--------------- nvim/dot-config/nvim/lua/tools/highlight.lua | 16 ++++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 nvim/dot-config/nvim/lua/tools/highlight.lua diff --git a/nvim/dot-config/nvim/lua/autocmds.lua b/nvim/dot-config/nvim/lua/autocmds.lua index d303cb4..fe6eb83 100644 --- a/nvim/dot-config/nvim/lua/autocmds.lua +++ b/nvim/dot-config/nvim/lua/autocmds.lua @@ -32,3 +32,15 @@ vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { group = cursor_group, pattern = "*", }) + +vim.api.nvim_create_autocmd("FileType", { + pattern = require("tools.highlight"), + callback = function() + -- syntax highlighting, provided by Neovim + vim.treesitter.start() + -- folds, provided by Neovim + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + -- indentation, provided by nvim-treesitter + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, +}) diff --git a/nvim/dot-config/nvim/lua/plugins/treesitter.lua b/nvim/dot-config/nvim/lua/plugins/treesitter.lua index 7b3556e..dd68e1f 100644 --- a/nvim/dot-config/nvim/lua/plugins/treesitter.lua +++ b/nvim/dot-config/nvim/lua/plugins/treesitter.lua @@ -4,27 +4,15 @@ return { "nvim-treesitter/nvim-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter-context", - "nvim-treesitter/nvim-treesitter-textobjects", + { "nvim-treesitter/nvim-treesitter-textobjects", branch = "main" }, "windwp/nvim-ts-autotag", }, + lazy = false, + branch = "main", + build = ":TSUpdate", opts = { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { - "c", - "cpp", - "go", - "lua", - "python", - "rust", - "tsx", - "typescript", - "vimdoc", - "vim", - "markdown", - "markdown_inline", - "bash", - "sql", - }, + ensure_installed = require("tools.highlight"), -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, @@ -91,10 +79,6 @@ return { enable = true, }, }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - require("nvim-treesitter.install").update({ with_sync = true }) - end, }, { "nvim-treesitter/nvim-treesitter-context", diff --git a/nvim/dot-config/nvim/lua/tools/highlight.lua b/nvim/dot-config/nvim/lua/tools/highlight.lua new file mode 100644 index 0000000..076580a --- /dev/null +++ b/nvim/dot-config/nvim/lua/tools/highlight.lua @@ -0,0 +1,16 @@ +return { + "c", + "cpp", + "go", + "lua", + "python", + "rust", + "tsx", + "typescript", + "vimdoc", + "vim", + "markdown", + "markdown_inline", + "bash", + "sql", +}