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
Copy file name to clipboardExpand all lines: src/content/docs/recipes/advanced_lsp.mdx
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,6 +270,43 @@ return {
270
270
}
271
271
```
272
272
273
+
## LSP File Operations
274
+
275
+
AstroLSP provides a complete implementation of the file manipulation features provided by the [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_willCreateFiles) through the [`astrolsp.file_operations` module](https://github.com/AstroNvim/astrolsp/blob/main/doc/api.md#astrolspfile_operations). These operations are useful when language servers provide functionality such as automatically updating import statements when files are renamed. Currently this includes:
276
+
277
+
-`workspace/willCreateFiles`
278
+
-`workspace/didCreateFiles`
279
+
-`workspace/willRenameFiles`
280
+
-`workspace/didRenameFiles`
281
+
-`workspace/willDeleteFiles`
282
+
-`workspace/didDeleteFiles`
283
+
284
+
This functionality was introduced in AstroNvim v4 disabled by default and will be enabled by default starting in AstroNvim v5. The module is used to integrate with the Neo-tree file explorer out of the box as well as the file renaming capability provided by AstroCore (`require("astrocore").rename_file()` which is bound to `<Leader>R`).
285
+
286
+
To enable the file operations in AstroNvim v4, you can configure them through the AstroLSP plugin `opts`:
287
+
288
+
```lua title="lua/plugins/astrolsp.lua" {5-15}
289
+
return {
290
+
"AstroNvim/astrolsp",
291
+
---@typeAstroLSPOpts
292
+
opts= {
293
+
file_operations= {
294
+
timeout=10000, -- default timeout in ms for completing LSP operations
295
+
operations= { -- enable all of the file operations
296
+
willCreate=true,
297
+
didCreate=true,
298
+
willRename=true,
299
+
didRename=true,
300
+
willDelete=true,
301
+
didDelete=true,
302
+
},
303
+
},
304
+
},
305
+
}
306
+
```
307
+
308
+
The `astrolsp.file_operations` module is meant to provide a simple Lua API to allow easy integration with any file management plugins/workflows that users may have. Some example integration code can be found in the [AstroLSP Documentation](https://github.com/AstroNvim/astrolsp/tree/main#lsp-file-operations). Many of the AstroCommunity plugins such as [`mini.files`](https://astronvim.github.io/astrocommunity/#mini-files) already provide the necessary integration to execute the LSP file operations when appropriate.
0 commit comments