Skip to content

Commit bc19d9b

Browse files
committed
feat(treesitter): add documentation for available treesitter options in AstroCore
1 parent e213abd commit bc19d9b

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

src/content/docs/configuration/v6_migration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ A few plugins have been removed due to being replaced with core Neovim functions
122122

123123
#### AstroUI
124124

125-
- TODO
125+
- No user facing changes, code updated to use new APIs in AstroNvim plugins as well as core Neovim.
126126

127127
### Other Breaking Changes
128128

src/content/docs/recipes/treesitter.mdx

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,80 @@ id: treesitter
33
title: Customize Treesitter
44
---
55

6-
TODO
6+
AstroCore v3 comes with the ability to help configure `nvim-treesitter` and `nvim-treesitter-textobjects`. These plugins have recently moved to being small utilities and leaving the configuration of features in Neovim up to the users. To alleviate the need for manual configuration for the users, we have added configuration options under a `treesitter` table in AstroCore that align very similarly with the previous configuration options of `nvim-treesitter`. Here is an overview of the available configuration options:
7+
8+
```lua title="lua/plugins/treesitter.lua"
9+
return {
10+
"AstroNvim/astrocore",
11+
---@type AstroCoreOpts
12+
opts = {
13+
-- Configuration of treesitter features in Neovim
14+
treesitter = {
15+
-- Globally enable or disable treesitter features
16+
-- can be:
17+
-- - a boolean
18+
-- - a function (`fun(lang: string, bufnr: integer): boolean`)
19+
enabled = function(lang, bufnr)
20+
return not require("astrocore.buffer").is_large(bufnr)
21+
end,
22+
-- Enable or disable treesitter based highlighting
23+
-- can be:
24+
-- - a boolean
25+
-- - a function (`fun(lang: string, bufnr: integer): boolean`)
26+
highlight = true,
27+
-- Enable or disable treesitter based indenting
28+
-- can be:
29+
-- - a boolean
30+
-- - a function (`fun(lang: string, bufnr: integer): boolean`)
31+
indent = true,
32+
-- List of treesitter parsers that should be installed automatically
33+
-- ("all" can be used to install all available parsers)
34+
ensure_installed = { "lua", "vim", "vimdoc" },
35+
-- Automatically detect missing treesitter parser and install when editing file
36+
auto_install = true,
37+
-- Configure treesitter based text objects (requires `nvim-treesitter-textobjects`)
38+
-- These options set up automatic detection of available queries for a file and creates
39+
-- only the available bindings for each buffer.
40+
textobjects = {
41+
select = {
42+
select_textobject = {
43+
["af"] = { query = "@function.outer", desc = "around function" },
44+
["if"] = { query = "@function.inner", desc = "around function" },
45+
},
46+
},
47+
move = {
48+
goto_next_start = {
49+
["]f"] = { query = "@function.outer", desc = "Next function start" },
50+
},
51+
goto_next_end = {
52+
["]F"] = { query = "@function.outer", desc = "Next function end" },
53+
},
54+
goto_previous_start = {
55+
["[f"] = {
56+
query = "@function.outer",
57+
desc = "Previous function start",
58+
},
59+
},
60+
goto_previous_end = {
61+
["[F"] = {
62+
query = "@function.outer",
63+
desc = "Previous function end",
64+
},
65+
},
66+
},
67+
swap = {
68+
swap_next = {
69+
[">F"] = { query = "@function.outer", desc = "Swap next function" },
70+
},
71+
swap_previous = {
72+
["<F"] = {
73+
query = "@function.outer",
74+
desc = "Swap previous function",
75+
},
76+
},
77+
},
78+
},
79+
},
80+
},
81+
}
82+
```

0 commit comments

Comments
 (0)