You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: start migrating documentation to be applicable to AstroLSP v4
* feat(advanced_lsp): migrate more of the documentation to use the new LSP configuration settings for the `vim.lsp.config` API
* feat: more documentation update of AstroNvim v6 changes
* chore: update blink.cmp repository name
* chore: update dependencies
* feat: start working on v6 migration guide
* fix: a couple typos
* feat: add page for new treesitter customization options
* feat: work on v6 migration guide
* feat(treesitter): add documentation for available treesitter options in AstroCore
* feat(v6_migration): add more v6 migration guide information
* chore: remove v5 migration guide
* fix: improve requirements list to match the latest `nvim-treesitter`
* fix(v6_migration): improve readability of treesitter diff
* fix(v6_migration): copy edits
* fix(v6_migration): copy edits
* chore: update to AstroJS 6 and Starlight 0.38
* fix: update start_url to be relative
* fix: disable sharp builds
Copy file name to clipboardExpand all lines: src/content/docs/configuration/customizing_plugins.mdx
+37-72Lines changed: 37 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,19 +78,18 @@ return {
78
78
},
79
79
},
80
80
},
81
-
-- customize treesitter parsers
81
+
-- customize enabled AstroLSP servers
82
82
{
83
-
"nvim-treesitter/nvim-treesitter",
83
+
"AstroNvim/astrolsp",
84
84
opts=function(_, opts)
85
-
-- list like portions of a table cannot be merged naturally and require the user to merge it manually
85
+
-- list like portions of a table cannot be merged naturally and may require the user to merge it manually
86
86
-- check to make sure the key exists
87
-
ifnotopts.ensure_installedthen
88
-
opts.ensure_installed= {}
87
+
ifnotopts.serversthen
88
+
opts.servers= {}
89
89
end
90
-
vim.list_extend(opts.ensure_installed, {
91
-
"lua",
92
-
"vim",
93
-
-- add more arguments for adding more treesitter parsers
90
+
vim.list_extend(opts.servers, {
91
+
"lua_ls",
92
+
-- add more arguments for manually enabling more language servers
94
93
})
95
94
end,
96
95
},
@@ -110,19 +109,19 @@ The `table` notation is the simplest method for configuration but does not cover
110
109
111
110
:::tip
112
111
113
-
Since [`lazy.nvim` v10.23.0](https://github.com/folke/lazy.nvim/releases/tag/v10.23.0) a new configuration option has been added called `opts_extend` which allows specifying that a part of the options passed to the `opts` table should be treated as a list that is extended rather than replaced completely as described below. Since [AstroNvim v4.9.0](https://github.com/AstroNvim/AstroNvim/releases/tag/v4.9.0) this option has been enabled out of the box for the `ensure_installed` tables for [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) and [`mason-tool-installer.nvim`](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim). This allows the user to use the basic table notation to simply add more items to these `ensure_installed` lists.
112
+
Since [`lazy.nvim` v10.23.0](https://github.com/folke/lazy.nvim/releases/tag/v10.23.0) a new configuration option has been added called `opts_extend` which allows specifying that a part of the options passed to the `opts` table should be treated as a list that is extended rather than replaced completely as described below. Since [AstroNvim v4.9.0](https://github.com/AstroNvim/AstroNvim/releases/tag/v4.9.0) this option has been enabled out of the box for the `ensure_installed` tables for [`mason-tool-installer.nvim`](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim). This allows the user to use the basic table notation to simply add more items to these `ensure_installed` lists.
114
113
115
114
:::
116
115
117
-
Let's take a closer look at these two notations with an example using [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter). Let's assume the default configuration for `nvim-treesitter` is:
116
+
Let's take a closer look at these two notations with an example using [`mason-tool-installer.nvim`](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim). Let's assume the default configuration for `mason-tool-installer` is:
118
117
119
118
```lua
120
119
return {
121
-
"nvim-treesitter/nvim-treesitter",
120
+
"WhoIsSethDaniel/mason-tool-installer.nvim",
122
121
opts= {
123
-
ensure_installed= { "lua", "vim" },
124
-
highlight= {
125
-
enable=true,
122
+
ensure_installed= { "lua_ls" },
123
+
integrations= {
124
+
["mason-lspconfig"]=true,
126
125
},
127
126
},
128
127
}
@@ -132,9 +131,9 @@ With this specification the current `opts` would resolve to the table:
132
131
133
132
```lua
134
133
opts= {
135
-
ensure_installed= { "lua", "vim" },
136
-
highlight= {
137
-
enable=true,
134
+
ensure_installed= { "lua_ls" },
135
+
integrations= {
136
+
["mason-lspconfig"]=true,
138
137
},
139
138
}
140
139
```
@@ -143,67 +142,36 @@ If you use the table notation to override these fields in your configuration lik
143
142
144
143
```lua
145
144
return {
146
-
"nvim-treesitter/nvim-treesitter",
145
+
"WhoIsSethDaniel/mason-tool-installer.nvim",
147
146
opts= {
148
-
ensure_installed= { "python" },
149
-
highlight= {
150
-
enable=false,
147
+
ensure_installed= { "prettier" },
148
+
integrations= {
149
+
["mason-lspconfig"] =false,
150
+
["mason-nvim-dap"] =true,
151
151
},
152
-
indent= {
153
-
enable=false,
154
-
},
155
-
},
156
-
}
157
-
```
158
-
159
-
You would end up with the `opts` resolving to:
160
-
161
-
```lua
162
-
opts= {
163
-
ensure_installed= { "python" },
164
-
highlight= {
165
-
enable=false,
166
-
},
167
-
indent= {
168
-
enable=false,
169
152
},
170
153
}
171
154
```
172
155
173
-
The `highlight.enabled` and `indent.enabled` fields work as expected, but the `ensure_installed` table does not actually extend the list and instead simply overwrites it. This is a limitation of the table merging. To resolve this we can rewrite our `opts` as a function where the first parameter is the resolve plugin specification (this is rarely used but may be useful in very advanced cases) and the second parameter which is the current `opts` table:
174
-
175
-
```lua
176
-
return {
177
-
"nvim-treesitter/nvim-treesitter",
178
-
opts=function(plugin, opts)
179
-
table.insert(opts.ensure_installed, "python")
180
-
end,
181
-
}
182
-
```
183
-
184
156
You would end up with the `opts` resolving to:
185
157
186
158
```lua
187
159
opts= {
188
-
ensure_installed= { "lua", "vim", "python" },
189
-
highlight= {
190
-
enable=true,
160
+
ensure_installed= { "prettier" },
161
+
integrations= {
162
+
["mason-lspconfig"] =false,
163
+
["mason-nvim-dap"] =true,
191
164
},
192
165
}
193
166
```
194
167
195
-
One thing to watch out for (that `table` merging handles automatically, but the function notation does not) is the creation of nested/parent keys. When using a function to modify `opts`, you’re responsible for ensuring that nested tables exist before setting any values on them. For example, if we want to set `indent.enable = true`in our `opts` with the function notation, it would look something like this:
168
+
The `integrations.mason-lspconfig` and `integrations.mason-nvim-dap` fields work as expected, but the `ensure_installed` table does not actually extend the list and instead simply overwrites it. This is a limitation of the table merging. To resolve this we can rewrite our `opts` as a function where the first parameter is the resolve plugin specification (this is rarely used but may be useful in very advanced cases) and the second parameter which is the current `opts` table:
196
169
197
170
```lua
198
171
return {
199
-
"nvim-treesitter/nvim-treesitter",
172
+
"WhoIsSethDaniel/mason-tool-installer.nvim",
200
173
opts=function(plugin, opts)
201
-
-- check if an `indent` table exists, if not, create it
202
-
ifnotopts.indentthen
203
-
opts.indent= {}
204
-
end
205
-
-- once we know it is created, we can set the sub-keys
206
-
opts.indent.enable=true
174
+
table.insert(opts.ensure_installed, "prettier")
207
175
end,
208
176
}
209
177
```
@@ -212,12 +180,9 @@ You would end up with the `opts` resolving to:
212
180
213
181
```lua
214
182
opts= {
215
-
ensure_installed= { "lua", "vim", "python" },
216
-
highlight= {
217
-
enable=true,
218
-
},
219
-
indent= {
220
-
enable=true,
183
+
ensure_installed= { "lua_ls", "prettier" },
184
+
integrations= {
185
+
["mason-lspconfig"] =true,
221
186
},
222
187
}
223
188
```
@@ -226,7 +191,7 @@ Notice how we didn't return anything from this function. In Lua, tables are pass
226
191
227
192
```lua
228
193
return {
229
-
"nvim-treesitter/nvim-treesitter",
194
+
"WhoIsSethDaniel/mason-tool-installer.nvim",
230
195
opts=function(plugin, opts)
231
196
return {}
232
197
end,
@@ -239,7 +204,7 @@ You would end up with the `opts` resolving to:
239
204
opts= {}
240
205
```
241
206
242
-
The last thing that this function notation provides is the ability to `require` modules safely even with lazy loading. `nvim-treesitter` isn't a great example of this, so here is a simple example with `nvim-cmp`. `nvim-cmp` allows the configuration of mappings and provides helper functions to make setting these mappings easy. Because `nvim-cmp` is lazy loaded, the function notation is required in this situation so that we don't break the lazy loading:
207
+
The last thing that this function notation provides is the ability to `require` modules safely even with lazy loading. `mason-tool-installer.nvim` isn't a great example of this, so here is a simple example with `nvim-cmp`. `nvim-cmp` allows the configuration of mappings and provides helper functions to make setting these mappings easy. Because `nvim-cmp` is lazy loaded, the function notation is required in this situation so that we don't break the lazy loading:
243
208
244
209
```lua
245
210
return {
@@ -293,17 +258,17 @@ return {
293
258
294
259
##### `list_insert_unique`
295
260
296
-
Other times when you do list inserting you want to safely insert new entries into a list but skip over values that already exist. This is useful if you are importing lots of language packs in AstroCommunity. Here is the previous `nvim-treesitter` example above using this function:
261
+
Other times when you do list inserting you want to safely insert new entries into a list but skip over values that already exist. This is useful if you are importing lots of language packs in AstroCommunity. Here is the previous `mason-tool-installer` example above using this function:
297
262
298
263
```lua
299
264
return {
300
-
"nvim-treesitter/nvim-treesitter",
265
+
"WhoIsSethDaniel/mason-tool-installer.nvim",
301
266
opts=function(plugin, opts)
302
267
-- `list_insert_unique` is in place, so it will modify
Copy file name to clipboardExpand all lines: src/content/docs/configuration/lua_completion.mdx
-25Lines changed: 0 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,31 +28,6 @@ return {
28
28
}
29
29
```
30
30
31
-
:::tip
32
-
33
-
AstroLSP allows for language server configuration completion by utilizing types exposed by the `nvim-lspconfig` plugin. One downside is the type does complain that "fields are missing" even though they are not actually required. To work around this, it can be useful and less noisy if you add
34
-
35
-
```
36
-
---@diagnostic disable: missing-fields
37
-
```
38
-
39
-
before the `config` table. Here is an example:
40
-
41
-
```lua title="lua/plugins/astrolsp.lua" {5}
42
-
return {
43
-
"AstroNvim/astrolsp",
44
-
---@typeAstroLSPOpts
45
-
opts= {
46
-
---@diagnosticdisable:missing-fields
47
-
config= {
48
-
-- LSP options and server configuration go here...
49
-
},
50
-
},
51
-
}
52
-
```
53
-
54
-
:::
55
-
56
31
### `opts` Function
57
32
58
33
Other times a function may be required if you want to include any sort of special logic for calculating the table or for handling cases that table merging doesn't deal with properly such as list-like tables. Here you need to specify the type of the parameter in the function.
0 commit comments