From 2e42bf1ef8c27173ed3a540135eada4c24abbaaf Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Fri, 12 Jun 2026 16:58:39 +0200 Subject: refactor(nvim): rewrite the highlight and extended marks plugins --- .config/nvim/plugin/10-treesitter.lua | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to '.config/nvim/plugin/10-treesitter.lua') diff --git a/.config/nvim/plugin/10-treesitter.lua b/.config/nvim/plugin/10-treesitter.lua index c0879b6..941614c 100644 --- a/.config/nvim/plugin/10-treesitter.lua +++ b/.config/nvim/plugin/10-treesitter.lua @@ -2,9 +2,7 @@ -- 10-treesitter.lua -- -- * Installs treesitter parsers. --- * Sets up an autocommand to parse the tree synchronously on 'FileType'. --- This file should sort early (alphabetically) in plugin/ so that this autcommand triggers before other autcommands --- that use the tree. +-- * Creates an autocommand to start treesitter automatically. -- require("nvim-treesitter").install({ @@ -21,19 +19,14 @@ require("nvim-treesitter").install({ "vimdoc", }) --- Parse the tree synchronously as early as possible (which is as soon as we know the filetype) --- This can be useful for example so that the tree is ready before any other code calls vim.treesitter.get_node(), which --- returns nil when the tree is not parsed. --- TODO actually test it vim.api.nvim_create_autocmd("FileType", { desc = "Start treesitter", group = vim.g.dotfiles.augroup, - callback = function() - local parser = vim.treesitter.get_parser(0) - if parser == nil then + callback = function(ev) + local parser = vim.treesitter.get_parser(ev.buf) + if not parser then return end - parser:parse() - vim.treesitter.start() + vim.treesitter.start(ev.buf) end, }) -- cgit v1.3.1