summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/10-treesitter.lua
blob: 8bb9be1c185f4cbb2a7a62d186c1c4a9c113b116 (plain)
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
--
-- Treesitter parsers
--

require("nvim-treesitter").install({
	"bash",
	"diff",
	"gitcommit",
	"git_rebase",
	"ini",
	"json",
	"lua",
	"python",
	"readline",
	"vim",
	"vimdoc",
})

-- Parse the tree as early as possible, which is as soon as we know the filetype
--
-- Event handlers for the same event are triggered in the order they were created. This must be the first FileType
-- handler created so that the tree is parsed for other FileType handlers (which often need the parsed tree). To create
-- it first put this in a file that comes before alphabetically in the `plugin/` directory.
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() -- Parse once asynchronously; used by logic that needs the parsed tree (like extmarks)
		vim.treesitter.start()
	end,
})