nvim-treesitter.lua 891 B

1234567891011121314151617181920212223242526272829303132
  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. -- autotags
  20. autotag = {
  21. enable = true
  22. }
  23. })
  24. -- 开启 Folding 模块
  25. vim.opt.foldmethod = "expr"
  26. vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
  27. -- 默认不要折叠
  28. -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
  29. vim.opt.foldlevel = 99