1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
--
-- 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,
})
|