-- -- 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. -- require("nvim-treesitter").install({ "bash", "diff", "gitcommit", "git_rebase", "ini", "json", "lua", "python", "readline", "vim", "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 return end parser:parse() vim.treesitter.start() end, })