Xinqi Bao's Git

9184684df376b8a09e41acb6aebcea7931efd762
[dotfiles.git] / .config / nvim / lua / plugin-config / nvim-treesitter.lua
1 require'nvim-treesitter.configs'.setup {
2 --[[
3 ]]
4 -- A list of parser names, or "all" (the five listed parsers should always be installed)
5 ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
6
7 -- Install parsers synchronously (only applied to `ensure_installed`)
8 sync_install = false,
9
10 -- Automatically install missing parsers when entering buffer
11 -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
12 auto_install = true,
13
14 -- List of parsers to ignore installing (or "all")
15 ignore_install = { "javascript" },
16
17 ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
18 -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
19
20 highlight = {
21 enable = true,
22
23 -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
24 -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
25 -- the name of the parser)
26 -- list of language that will be disabled
27 disable = { "c", "rust" },
28 -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
29 disable = function(lang, buf)
30 local max_filesize = 100 * 1024 -- 100 KB
31 local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
32 if ok and stats and stats.size > max_filesize then
33 return true
34 end
35 end,
36
37 -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
38 -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
39 -- Using this option may slow down your editor, and you may see some duplicate highlights.
40 -- Instead of true it can also be a list of languages
41 additional_vim_regex_highlighting = false,
42 },
43
44 -- Incremental selection based on the named nodes from the grammar.
45 incremental_selection = {
46 enable = true,
47 keymaps = {
48 init_selection = '<CR>',
49 node_incremental = '<CR>',
50 node_decremental = '<BS>',
51 scope_incremental = '<TAB>',
52 }
53 },
54
55 -- Indentation based on treesitter for the = operator. NOTE: This is an experimental feature.
56 indent = {
57 enable = false
58 }
59 }