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.

114 lines
4.1 KiB

11 months ago
11 months ago
11 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. },
  89. },
  90. })
  91. ---@class ParserConfig
  92. ---@field install_info table
  93. ---@field filetype string
  94. local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
  95. parser_config.blade = {
  96. install_info = {
  97. url = "https://github.com/EmranMR/tree-sitter-blade",
  98. files = { "src/parser.c" },
  99. branch = "main",
  100. },
  101. filetype = "blade",
  102. }
  103. vim.filetype.add({
  104. pattern = {
  105. [".*%.blade%.php"] = "blade",
  106. },
  107. })
  108. end,
  109. },
  110. }