45 lines
1.7 KiB
Lua
45 lines
1.7 KiB
Lua
|
return {
|
||
|
'nvim-treesitter/nvim-treesitter',
|
||
|
dependencies = {
|
||
|
"https://github.com/TheZoq2/tree-sitter-typst",
|
||
|
"luckasRanarison/tree-sitter-hyprlang"
|
||
|
},
|
||
|
build = ":TSUpdate",
|
||
|
opts = {
|
||
|
ensure_installed = { "cpp", "c", "lua", "vim", "dockerfile", "python", "java", "cmake", "diff", "gitcommit", "html", "css", "javascript", "json", "rust", "sql", "yaml", "markdown", "markdown_inline", "nix" },
|
||
|
auto_install = true,
|
||
|
highlight = {
|
||
|
enable = true,
|
||
|
additional_vim_regex_highlighting = false,
|
||
|
disable = function(lang, buf) -- Disable if file size is too big
|
||
|
if lang == "ini" or lang == "markdown" then
|
||
|
return true
|
||
|
end
|
||
|
local max_filesize = 2000 * 1024 -- 2MB
|
||
|
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,
|
||
|
},
|
||
|
indent = {
|
||
|
enable = true
|
||
|
},
|
||
|
},
|
||
|
config = function (_, opts)
|
||
|
require("nvim-treesitter.configs").setup(opts)
|
||
|
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
|
||
|
require'nvim-treesitter.install'.prefer_git = true
|
||
|
parser_config.typst = {
|
||
|
install_info = {
|
||
|
url = "https://github.com/frozolotl/tree-sitter-typst.git", -- local path or git repo
|
||
|
files = {"src/parser.c", "src/scanner.cc"},
|
||
|
},
|
||
|
filetype = "typst", -- if filetype does not match the parser name
|
||
|
}
|
||
|
vim.filetype.add({
|
||
|
pattern = { [".*.typ"] = "typst" },
|
||
|
})
|
||
|
end
|
||
|
}
|