treesitter.lua 903 B

123456789101112131415161718192021222324252627282930313233
  1. local status, configs = pcall(require, "nvim-treesitter.configs")
  2. if not status then
  3. return
  4. end
  5. require('nvim-treesitter.install').prefer_git = true
  6. configs.setup {
  7. ensure_installed = {
  8. "c", "lua", "java", "python", "bash", "html", "css", "javascript",
  9. "bibtex", "cmake", "cpp", "latex", "perl", "regex", "toml", "yaml"
  10. },
  11. highlight = {
  12. enable = true,
  13. -- Merges Treesitter with Regex highlighting for maximum color richness
  14. additional_vim_regex_highlighting = { "python" },
  15. },
  16. indent = {
  17. enable = true
  18. },
  19. }
  20. -- Force Treesitter to start for major filetypes to bypass any legacy syntax overrides
  21. vim.api.nvim_create_autocmd({ "FileType" }, {
  22. callback = function()
  23. local lang = vim.treesitter.language.get_lang(vim.bo.filetype)
  24. if lang then
  25. pcall(vim.treesitter.start)
  26. end
  27. end,
  28. })