diff options
Diffstat (limited to '.config/nvim/plugin/10-treesitter.lua')
| -rw-r--r-- | .config/nvim/plugin/10-treesitter.lua | 17 |
1 files changed, 5 insertions, 12 deletions
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, }) |
