aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/treesitter.lua
blob: 7469e17724c1f0aed3ec134d8dfec2aff5af6956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
return {
  {
    -- Rama `main`: reescritura completa, es la única que soporta Neovim >= 0.12.
    -- No soporta lazy-loading.
    "nvim-treesitter/nvim-treesitter",
    branch = "main",
    lazy = false,
    build = ":TSUpdate",
    config = function()
      require("pi.treesitter").setup()
    end,
  },

  {
    "nvim-treesitter/nvim-treesitter-textobjects",
    branch = "main",
    dependencies = { "nvim-treesitter/nvim-treesitter" },
    event = { "BufReadPre", "BufNewFile" },
    config = function()
      require("nvim-treesitter-textobjects").setup {
        select = {
          lookahead = true,
        },
      }

      local select = require "nvim-treesitter-textobjects.select"
      local objects = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@conditional.outer",
        ["ic"] = "@conditional.inner",
        ["al"] = "@loop.outer",
        ["il"] = "@loop.inner",
      }

      for lhs, query in pairs(objects) do
        vim.keymap.set({ "x", "o" }, lhs, function()
          select.select_textobject(query, "textobjects")
        end, { desc = "Textobject " .. query })
      end
    end,
  },

  {
    -- Se auto-inicializa desde su plugin/; en Neovim >= 0.9 no usa el sistema de
    -- módulos de nvim-treesitter, así que funciona igual con la rama `main`.
    "RRethy/nvim-treesitter-endwise",
    dependencies = { "nvim-treesitter/nvim-treesitter" },
    event = { "BufReadPre", "BufNewFile" },
  },
}