nvim-treesitter.lua 834 B

123456789101112131415161718192021222324252627
  1. local status, treesitter = pcall(require, "nvim-treesitter.configs")
  2. if not status then
  3. vim.notify("没有找到 nvim-treesitter")
  4. return
  5. end
  6. treesitter.setup({
  7. -- 安装 language parser
  8. -- :TSInstallInfo 命令查看支持的语言
  9. ensure_installed = {"json", "html", "css", "vim", "lua", "javascript", "typescript", "tsx", "python", "scss", "vue"},
  10. -- 启用代码高亮模块
  11. highlight = {
  12. enable = true,
  13. additional_vim_regex_highlighting = false
  14. },
  15. -- 启用代码缩进模块 (=)
  16. indent = {
  17. enable = true
  18. }
  19. })
  20. -- 开启 Folding 模块
  21. vim.opt.foldmethod = "expr"
  22. vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
  23. -- 默认不要折叠
  24. -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
  25. vim.opt.foldlevel = 99