完善treesitter相关配置

This commit is contained in:
a770 2025-06-08 19:08:27 +08:00
parent d1f5f0a2c8
commit 6a883b41e9
12 changed files with 207 additions and 182 deletions

View file

@ -3,38 +3,48 @@
-- ===
return {
'nvim-treesitter/nvim-treesitter',
"nvim-treesitter/nvim-treesitter",
config = function()
-- 要安装高亮的语言直接加入括号即可把sync_install设置为true下次进入vim自动安装语言列表查看treesitter的github
-- 或者执行:TSInstall <language_to_install>
local language = {
"python",
"lua",
"dart",
"markdown",
"go",
"bash",
"java",
"sql",
}
require("nvim-treesitter.configs").setup {
-- A list of parser names, or "all"
ensure_installed = language,
-- Install parsers synchronously (only applied to `ensure_installed`)
require("nvim-treesitter.configs").setup({
-- 要安装高亮的语言直接加入括号即可把sync_install设置为true下次进入vim自动安装
-- 或者手动执行:TSInstall <想要安装的语言>
-- 语言列表查看https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#supported-languages
ensure_installed = {
"json",
"rust",
"python",
"lua",
"markdown",
"bash",
"java",
-- "dart",
-- "go",
-- "sql",
},
-- 设置为true后位于ensure_installed里面的语言会自动安装
sync_install = true,
-- List of parsers to ignore installing (for "all")
ignore_install = {},
-- 这里填写不想要自动安装的语言
ignore_install = {
},
highlight = {
-- 默认开启高亮
enable = true,
-- list of language that will be disabled
disable = {},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
-- 想要禁用高亮的语言列表
-- disable = {
-- },
-- 使用function以提高灵活性禁用大型文件的高亮
disable = function(lang, buf)
local max_filesize = 100 * 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,
-- 如果您依靠启用'语法'(例如,缩进),则将其设置为“ True”。
-- 使用此选项可能会放慢编辑器,您可能会看到一些重复的高亮。
-- 除了设置为true它也可以设置成语言列表
additional_vim_regex_highlighting = false,
},
}
end
})
end,
}