Files
sunhat/configs/dotfiles/nvim/lua/plugins/treesitter.lua
2025-08-15 16:37:31 -05:00

85 lines
1.6 KiB
Lua

vim.pack.add({
{
src = 'https://github.com/nvim-treesitter/nvim-treesitter',
version = 'master'
},
{ src = 'https://github.com/nvim-treesitter/playground' },
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter-context' },
})
require'nvim-treesitter.install'.update({ with_sync = true })()
require'nvim-treesitter.configs'.setup({
ensure_installed = {
'bash',
'c',
'cmake',
'cpp',
'css',
'diff',
'dockerfile',
'git_config',
'git_rebase',
'gitattributes',
'gitcommit',
'gitignore',
'html',
'java',
'javascript',
'jsdoc',
'json',
'jsonc',
'kotlin',
'lua',
'luadoc',
'luap',
'make',
'markdown',
'markdown_inline',
'php',
'printf',
'python',
'query',
'regex',
'rust',
'scala',
'sql',
'svelte',
'swift',
'toml',
'tsx',
'typescript',
'vim',
'vimdoc',
'xml',
'yaml',
'zig'
},
sync_install = false,
auto_install = true,
indent = { enable = true },
highlight = {
enable = true,
disable = function(lang, buf)
local max_filesize = 500 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = false,
},
})
require'treesitter-context'.setup{
enable = true,
multiwindow = false,
max_lines = 10,
min_window_height = 0,
line_numbers = true,
multiline_threshold = 20,
trim_scope = 'outer',
mode = 'topline',
separator = nil,
zindex = 20,
on_attach = nil,
}