treesitter.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. return {
  2. {
  3. "nvim-treesitter/nvim-treesitter",
  4. build = ":TSUpdate",
  5. config = function()
  6. local configs = require("nvim-treesitter.configs")
  7. configs.setup({
  8. ensure_installed = { "c", "lua", "vim", "vimdoc", "javascript", "html", "rust", "regex", "typescript", "tsx" },
  9. sync_install = false,
  10. highlight = { enable = true },
  11. indent = { enable = true },
  12. })
  13. end,
  14. },
  15. {
  16. "nvim-treesitter/nvim-treesitter-textobjects",
  17. build = ":TSUpdate",
  18. config = function()
  19. require("nvim-treesitter.configs").setup({
  20. textobjects = {
  21. select = {
  22. enable = true,
  23. -- Automatically jump forward to textobj, similar to targets.vim
  24. lookahead = true,
  25. keymaps = {
  26. -- You can use the capture groups defined in textobjects.scm
  27. ["af"] = "@function.outer",
  28. ["if"] = "@function.inner",
  29. ["ac"] = "@class.outer",
  30. -- You can optionally set descriptions to the mappings (used in the desc parameter of
  31. -- nvim_buf_set_keymap) which plugins like which-key display
  32. ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
  33. -- You can also use captures from other query groups like `locals.scm`
  34. ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
  35. ["ap"] = "@parameter.outer",
  36. ["ip"] = "@parameter.inner",
  37. },
  38. -- You can choose the select mode (default is charwise 'v')
  39. --
  40. -- Can also be a function which gets passed a table with the keys
  41. -- * query_string: eg '@function.inner'
  42. -- * method: eg 'v' or 'o'
  43. -- and should return the mode ('v', 'V', or '<c-v>') or a table
  44. -- mapping query_strings to modes.
  45. selection_modes = {
  46. ["@parameter.outer"] = "v", -- charwise
  47. ["@function.outer"] = "V", -- linewise
  48. ["@class.outer"] = "<c-v>", -- blockwise
  49. },
  50. -- If you set this to `true` (default is `false`) then any textobject is
  51. -- extended to include preceding or succeeding whitespace. Succeeding
  52. -- whitespace has priority in order to act similarly to eg the built-in
  53. -- `ap`.
  54. --
  55. -- Can also be a function which gets passed a table with the keys
  56. -- * query_string: eg '@function.inner'
  57. -- * selection_mode: eg 'v'
  58. -- and should return true or false
  59. include_surrounding_whitespace = true,
  60. },
  61. },
  62. })
  63. end,
  64. },
  65. }