mirror of
https://github.com/neovim/neovim.git
synced 2025-11-15 14:59:20 +00:00
docs(lsp): replace formatting_sync example in lsp-faq (#19994)
`formatting_sync` is deprecated
This commit is contained in:
committed by
GitHub
parent
f9c183c0ca
commit
0368ca70c4
@@ -126,13 +126,14 @@ FAQ *lsp-faq*
|
|||||||
"after/ftplugin/python.vim".
|
"after/ftplugin/python.vim".
|
||||||
|
|
||||||
- Q: How do I run a request synchronously (e.g. for formatting on file save)?
|
- Q: How do I run a request synchronously (e.g. for formatting on file save)?
|
||||||
A: Use the `_sync` variant of the function provided by |lsp-buf|, if it
|
A: Check if the function has an `async` parameter and set the value to
|
||||||
exists.
|
false.
|
||||||
|
|
||||||
E.g. code formatting: >
|
E.g. code formatting: >
|
||||||
|
|
||||||
" Auto-format *.rs (rust) files prior to saving them
|
" Auto-format *.rs (rust) files prior to saving them
|
||||||
autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000)
|
" (async = false is the default for format)
|
||||||
|
autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
|
||||||
|
|
||||||
<
|
<
|
||||||
*lsp-vs-treesitter*
|
*lsp-vs-treesitter*
|
||||||
|
|||||||
Reference in New Issue
Block a user