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.

117 lines
2.6 KiB

12 months ago
12 months ago
12 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. "markdown",
  24. "markdown_inline",
  25. "bash",
  26. "lua",
  27. "vim",
  28. "dockerfile",
  29. "gitignore",
  30. "php",
  31. "latex",
  32. },
  33. ignore_install = {},
  34. modules = {},
  35. sync_install = true,
  36. auto_install = true,
  37. highlight = {
  38. enable = true,
  39. disable = { "latex" },
  40. },
  41. indent = { enable = true },
  42. autotag = { enable = true },
  43. textobjects = {
  44. select = {
  45. enable = true,
  46. lookahead = true,
  47. keymaps = {
  48. ["af"] = "@function.outer",
  49. ["if"] = "@function.inner",
  50. ["ac"] = "@conditional.outer",
  51. ["ic"] = "@conditional.inner",
  52. ["al"] = "@loop.outer",
  53. ["il"] = "@loop.inner",
  54. },
  55. selection_modes = {
  56. ["@parameter.outer"] = "v", -- charwise
  57. ["@function.outer"] = "V", -- linewise
  58. ["@class.outer"] = "<c-v>", -- blockwise
  59. },
  60. include_surrounding_whitespace = false,
  61. },
  62. move = {
  63. enable = true,
  64. set_jumps = true,
  65. goto_next_start = {
  66. ["]f"] = "@function.outer",
  67. ["]c"] = "@conditional.outer",
  68. ["]o"] = "@loop.outer",
  69. },
  70. goto_next_end = {
  71. ["]F"] = "@function.outer",
  72. ["]C"] = "@conditional.outer",
  73. ["]O"] = "@loop.outer",
  74. },
  75. goto_previous_start = {
  76. ["[f"] = "@function.outer",
  77. ["[c"] = "@conditional.outer",
  78. ["[o"] = "@loop.outer",
  79. },
  80. goto_previous_end = {
  81. ["[F"] = "@function.outer",
  82. ["[C"] = "@conditional.outer",
  83. ["[O"] = "@loop.outer",
  84. },
  85. goto_next = {
  86. ["]b"] = "@block.outer",
  87. },
  88. goto_previous = {
  89. ["[b"] = "@block.outer",
  90. },
  91. },
  92. },
  93. })
  94. ---@class ParserConfig
  95. ---@field install_info table
  96. ---@field filetype string
  97. local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
  98. parser_config.blade = {
  99. install_info = {
  100. url = "https://github.com/EmranMR/tree-sitter-blade",
  101. files = { "src/parser.c" },
  102. branch = "main",
  103. },
  104. filetype = "blade",
  105. }
  106. vim.filetype.add({
  107. pattern = {
  108. [".*%.blade%.php"] = "blade",
  109. },
  110. })
  111. end,
  112. },
  113. }