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
| #! /usr/bin/env lua
--
-- treesitter.lua
-- Copyright (C) 2023 feng <feng@arch>
--
-- Distributed under terms of the MIT license.
--
for _, config in pairs(require("nvim-treesitter.parsers").get_parser_configs()) do
config.install_info.url = config.install_info.url:gsub("https://hub.yzuu.cf/", "something else")
end
require('nvim-treesitter.configs').setup({
-- 支持的语言
ensure_installed = {"bash","fortran","markdown","latex","html", "css", "vim", "lua", "javascript", "typescript", "c", "cpp", "python"},
-- 启用代码高亮
highlight = {
enable = true,
additional_vim_regex_highlighting = false
},
--启用增量选择
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<CR>',
node_incremental = '<CR>',
node_decremental = '<BS>',
scope_incremental = '<TAB>'
}
},
-- 启用基于 Treesitter 的代码格式化(=)
indent = {
enable = true
},
})
-- 开启代码折叠
vim.wo.foldmethod = 'expr'
vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'
-- 默认不折叠
vim.wo.foldlevel = 99
|