nvim/lua/plugs/treesitter.lua

54 lines
1.5 KiB
Lua

return {
{
-- 语法高亮 --
'nvim-treesitter/nvim-treesitter',
config = function()
local treesitter_opt = {
ensure_installed = {
-- "c",
-- "cpp",
-- "python",
-- "java",
-- "lua",
-- "bash",
-- "vimdoc",
},
indent = { enable = true },
ignore_install = {
"txt"
},
sync_install = false,
auto_install = true,
highlight = {
enable = true,
disable = function(_, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.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,
},
parsers = {
vue = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = { "src/parser.c" },
branch = "main",
},
},
},
}
require 'nvim-treesitter'.setup(treesitter_opt)
require 'nvim-treesitter.install'.prefer_git = true
if G.use_ssh then
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:")
end
end
end
},
}