diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-12 16:58:39 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-12 22:57:30 +0200 |
| commit | 2e42bf1ef8c27173ed3a540135eada4c24abbaaf (patch) | |
| tree | a7e04f70f47b82e44a0e4721505a315867aac854 /.config/nvim/plugin/10-treesitter.lua | |
| parent | 9236e1f700b028da61302be8371401fe0fd86f0c (diff) | |
| download | dotfiles-2e42bf1ef8c27173ed3a540135eada4c24abbaaf.tar.gz dotfiles-2e42bf1ef8c27173ed3a540135eada4c24abbaaf.zip | |
refactor(nvim): rewrite the highlight and extended marks plugins
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, }) |
