You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.7 KiB

10 months ago
10 months ago
10 months ago
  1. return {
  2. {
  3. "nvim-treesitter/nvim-treesitter",
  4. event = { "BufReadPre", "BufNewFile" },
  5. build = ":TSUpdate",
  6. dependencies = {
  7. { "nvim-treesitter/nvim-treesitter-textobjects" },
  8. },
  9. config = function()
  10. -- import nvim-treesitter plugin
  11. local treesitter = require("nvim-treesitter.configs")
  12. -- configure treesitter
  13. treesitter.setup({
  14. -- ensure these language parsers are installed
  15. ensure_installed = {
  16. "json",
  17. "javascript",
  18. "typescript",
  19. "tsx",
  20. "yaml",
  21. "html",
  22. "css",
  23. "prisma",
  24. "markdown",
  25. "markdown_inline",
  26. "svelte",
  27. "graphql",
  28. "bash",
  29. "lua",
  30. "vim",
  31. "dockerfile",
  32. "gitignore",
  33. "php",
  34. "latex",
  35. },
  36. ignore_install = {},
  37. modules = {},
  38. sync_install = true,
  39. auto_install = true,
  40. highlight = {
  41. enable = true,
  42. disable = { "latex" },
  43. },
  44. indent = { enable = true },
  45. autotag = { enable = true },
  46. textobjects = {
  47. select = {
  48. enable = true,
  49. lookahead = true,
  50. keymaps = {
  51. ["af"] = "@function.outer",
  52. ["if"] = "@function.inner",
  53. ["ac"] = "@conditional.outer",
  54. ["ic"] = "@conditional.inner",
  55. ["al"] = "@loop.outer",
  56. ["il"] = "@loop.inner",
  57. },
  58. selection_modes = {
  59. ["@parameter.outer"] = "v", -- charwise
  60. ["@function.outer"] = "V", -- linewise
  61. ["@class.outer"] = "<c-v>", -- blockwise
  62. },
  63. include_surrounding_whitespace = false,
  64. },
  65. move = {
  66. enable = true,
  67. set_jumps = true,
  68. goto_next_start = {
  69. ["]f"] = "@function.outer",
  70. ["]c"] = "@conditional.outer",
  71. ["]o"] = "@loop.outer",
  72. },
  73. goto_next_end = {
  74. ["]F"] = "@function.outer",
  75. ["]C"] = "@conditional.outer",
  76. ["]O"] = "@loop.outer",
  77. },
  78. goto_previous_start = {
  79. ["[f"] = "@function.outer",
  80. ["[c"] = "@conditional.outer",
  81. ["[o"] = "@loop.outer",
  82. },
  83. goto_previous_end = {
  84. ["[F"] = "@function.outer",
  85. ["[C"] = "@conditional.outer",
  86. ["[O"] = "@loop.outer",
  87. },
  88. goto_next = {
  89. ["]b"] = "@block.outer",
  90. },
  91. goto_previous = {
  92. ["[b"] = "@block.outer",
  93. },
  94. },
  95. },
  96. })
  97. ---@class ParserConfig
  98. ---@field install_info table
  99. ---@field filetype string
  100. local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
  101. parser_config.blade = {
  102. install_info = {
  103. url = "https://github.com/EmranMR/tree-sitter-blade",
  104. files = { "src/parser.c" },
  105. branch = "main",
  106. },
  107. filetype = "blade",
  108. }
  109. vim.filetype.add({
  110. pattern = {
  111. [".*%.blade%.php"] = "blade",
  112. },
  113. })
  114. end,
  115. },
  116. }