treesitter.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. local M = {}
  2. local Log = require "core.log"
  3. M.config = function()
  4. lvim.builtin.treesitter = {
  5. ensure_installed = {}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  6. ignore_install = {},
  7. matchup = {
  8. enable = false, -- mandatory, false will disable the whole extension
  9. -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled
  10. },
  11. highlight = {
  12. enable = true, -- false will disable the whole extension
  13. additional_vim_regex_highlighting = true,
  14. disable = { "latex" },
  15. },
  16. context_commentstring = {
  17. enable = false,
  18. config = { css = "// %s" },
  19. },
  20. -- indent = {enable = true, disable = {"python", "html", "javascript"}},
  21. -- TODO seems to be broken
  22. indent = { enable = true, disable = { "yaml" } },
  23. autotag = { enable = false },
  24. textobjects = {
  25. swap = {
  26. enable = false,
  27. -- swap_next = textobj_swap_keymaps,
  28. },
  29. -- move = textobj_move_keymaps,
  30. select = {
  31. enable = false,
  32. -- keymaps = textobj_sel_keymaps,
  33. },
  34. },
  35. textsubjects = {
  36. enable = false,
  37. keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" },
  38. },
  39. playground = {
  40. enable = false,
  41. disable = {},
  42. updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
  43. persist_queries = false, -- Whether the query persists across vim sessions
  44. keybindings = {
  45. toggle_query_editor = "o",
  46. toggle_hl_groups = "i",
  47. toggle_injected_languages = "t",
  48. toggle_anonymous_nodes = "a",
  49. toggle_language_display = "I",
  50. focus_language = "f",
  51. unfocus_language = "F",
  52. update = "R",
  53. goto_node = "<cr>",
  54. show_help = "?",
  55. },
  56. },
  57. rainbow = {
  58. enable = false,
  59. extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
  60. max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
  61. },
  62. }
  63. end
  64. M.setup = function()
  65. local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
  66. if not status_ok then
  67. Log:get_default().error "Failed to load nvim-treesitter.configs"
  68. return
  69. end
  70. treesitter_configs.setup(lvim.builtin.treesitter)
  71. end
  72. return M