-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreesitter.lua
More file actions
79 lines (72 loc) · 2.6 KB
/
Copy pathtreesitter.lua
File metadata and controls
79 lines (72 loc) · 2.6 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--- Treesitter config
---
--- Author: @lararosekelley
--- Last Modified: August 27th, 2025
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local configs = require("nvim-treesitter.config")
configs.setup({
auto_install = true,
ensure_installed = "all",
ignore_install = { "ipkg" }, -- error on install as of 2025-08-27
highlight = { enable = true },
indent = { enable = true },
})
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
dependencies = { "nvim-treesitter/nvim-treesitter", "folke/which-key.nvim" },
config = function()
require("nvim-treesitter-textobjects").setup({
select = {
lookahead = true,
},
})
local select_textobject = require("nvim-treesitter-textobjects.select").select_textobject
-- Function text objects
vim.keymap.set({ "x", "o" }, "af", function()
select_textobject("@function.outer", "textobjects")
end, { desc = "Select outer function" })
vim.keymap.set({ "x", "o" }, "if", function()
select_textobject("@function.inner", "textobjects")
end, { desc = "Select inner function" })
-- Class text objects
vim.keymap.set({ "x", "o" }, "ac", function()
select_textobject("@class.outer", "textobjects")
end, { desc = "Select outer class" })
vim.keymap.set({ "x", "o" }, "ic", function()
select_textobject("@class.inner", "textobjects")
end, { desc = "Select inner class" })
-- Loop text objects
vim.keymap.set({ "x", "o" }, "al", function()
select_textobject("@loop.outer", "textobjects")
end, { desc = "Select outer loop" })
vim.keymap.set({ "x", "o" }, "il", function()
select_textobject("@loop.inner", "textobjects")
end, { desc = "Select inner loop" })
-- Register with which-key for documentation
local wk = require("which-key")
wk.add({
{ "a", group = "around", mode = { "x", "o" } },
{ "af", desc = "around function", mode = { "x", "o" } },
{ "ac", desc = "around class", mode = { "x", "o" } },
{ "al", desc = "around loop", mode = { "x", "o" } },
{ "i", group = "inner", mode = { "x", "o" } },
{ "if", desc = "inner function", mode = { "x", "o" } },
{ "ic", desc = "inner class", mode = { "x", "o" } },
{ "il", desc = "inner loop", mode = { "x", "o" } },
})
end,
},
-- automatically close tags for html, jsx, etc.
{
"windwp/nvim-ts-autotag",
event = "BufReadPost",
opts = {},
},
}