-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreesitter.lua
More file actions
86 lines (83 loc) · 1.73 KB
/
Copy pathtreesitter.lua
File metadata and controls
86 lines (83 loc) · 1.73 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
return {
"nvim-treesitter/nvim-treesitter",
lazy = false,
branch = "main",
build = ":TSUpdate",
opts = function()
require("nvim-treesitter").install({
"bash",
"c",
"cpp",
"csharp",
"css",
"go",
"gomod",
"gosum",
"java",
"javascript",
"jsx",
"jinja",
"json",
"html",
"lua",
"markdown",
"python",
"scss",
"sql",
"terraform",
"toml",
"tsx",
"typescript",
"vim",
"xml",
"yaml",
"zsh",
})
-- I want to know if treesitter is enabled or not
vim.keymap.set("n", "\\t", function()
if vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()] ~= nil then
vim.treesitter.stop()
else
vim.treesitter.start()
end
end, { desc = "Toggle treesitter" })
-- Enable highlighting
vim.api.nvim_create_autocmd("FileType", {
group = require("custom.util").group,
pattern = {
"go",
"gomod",
"gosum",
"html",
"javascript",
"javascriptreact",
"json",
"lua",
"markdown",
"python",
"sh",
"terraform",
"toml",
"typescript",
"typescriptreact",
"vim",
"vimdoc",
"yaml",
},
callback = function()
vim.treesitter.start()
end,
})
-- Enable indentation from treesitter
vim.api.nvim_create_autocmd("FileType", {
group = require("custom.util").group,
pattern = {
"javascriptreact",
"typescriptreact",
},
callback = function()
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
end,
}