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
|
table.contains = function(self, string)
for _, v in pairs(self) do
if v == string then
return true
end
end
return false
end
return { "nvim-treesitter/nvim-treesitter",
disable = not vim.fn.has("nvim-0.10.0"),
config = function()
vim.cmd("TSUpdate")
end,
function()
require("nvim-treesitter.configs").setup {
-- good default parsers
ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown",
"markdown_inline", "java", "bash", "css", "html", "luadoc",
"make"
},
-- indentation
indent = {
enable = true,
disable = function(lang, _)
-- disable indenting in php (it"s more broken with than without)
return table.contains(({
"php"
}), lang)
end
},
-- enable highlighting
highlight = {
enable = true,
-- use vim highlighting in addition to treesitter
additional_vim_regex_highlighting = true,
disable = function(lang, buf)
-- disable in some files where vim"s builtin highlighting is better
if table.contains(({
"diff", "tex"
}), lang) then
return true
end
-- disable in big files
-- TODO: update before nvim 1.0 when vim.loop is removed
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
return true
end
end
}
}
end
}
|