0
0

text-objects.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. return {
  2. {
  3. "kylechui/nvim-surround",
  4. config = function() require("nvim-surround").setup({}) end
  5. -- Surround selection / text objects with characters
  6. -- Surround a word in single quotes: viwS'
  7. -- Visual mode: S
  8. -- Normal mode: ys
  9. -- Surrounds: ( { [ < ' " [t]ag [f]unction
  10. }, {
  11. "tpope/vim-commentary",
  12. enabled = true,
  13. lazy = false
  14. -- Toggle line comments
  15. -- Normal mode: gcc
  16. -- Visual mode: gc
  17. }, {
  18. "nvim-treesitter/nvim-treesitter-textobjects",
  19. enabled = true,
  20. lazy = false,
  21. dependencies = { "nvim-treesitter/nvim-treesitter" },
  22. config = function()
  23. require("nvim-treesitter.configs").setup({
  24. textobjects = {
  25. select = {
  26. enable = true,
  27. lookahead = true,
  28. keymaps = {
  29. ["af"] = "@function.outer",
  30. ["if"] = "@function.inner",
  31. ["ac"] = "@class.outer",
  32. ["ic"] = "@class.inner",
  33. ["ap"] = "@parameter.outer",
  34. ["ip"] = "@parameter.inner",
  35. ["aa"] = "@parameter.outer",
  36. ["ia"] = "@parameter.inner",
  37. ["al"] = "@loop.outer",
  38. ["il"] = "@loop.inner",
  39. ["at"] = "@attribute.outer",
  40. ["it"] = "@attribute.inner",
  41. ["a="] = "@assignment.outer",
  42. ["i="] = "@assignment.inner",
  43. ["ab"] = "@block.outer",
  44. ["ib"] = "@block.inner"
  45. },
  46. include_surrounding_whitespace = true
  47. },
  48. swap = {
  49. enable = true,
  50. swap_next = {
  51. ["csf"] = "@function.inner",
  52. ["csc"] = "@class.inner",
  53. ["csp"] = "@parameter.inner",
  54. ["csa"] = "@parameter.inner",
  55. ["csl"] = "@loop.inner",
  56. ["cst"] = "@attribute.inner",
  57. ["cs="] = "@assignment.inner",
  58. ["csb"] = "@block.inner"
  59. },
  60. swap_previous = {
  61. ["cSf"] = "@function.inner",
  62. ["cSc"] = "@class.inner",
  63. ["cSp"] = "@parameter.inner",
  64. ["cSa"] = "@parameter.inner",
  65. ["cSl"] = "@loop.inner",
  66. ["cSt"] = "@attribute.inner",
  67. ["cS="] = "@assignment.inner",
  68. ["cSb"] = "@block.inner"
  69. }
  70. }
  71. }
  72. })
  73. end
  74. }
  75. }