treesitter.lua 2.5 KB

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