diff options
| author | Yi Ming <ofseed@foxmail.com> | 2024-11-29 20:40:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-29 12:40:32 +0000 |
| commit | a1e313ded6e4c46c58012639e5c0c6d0b009d52a (patch) | |
| tree | 891bcc418369607060b599f4b224b41a46fc86e7 /runtime/doc | |
| parent | c867a4f5e335a1e62e699c01056f9553c0ce151a (diff) | |
| download | rneovim-a1e313ded6e4c46c58012639e5c0c6d0b009d52a.tar.gz rneovim-a1e313ded6e4c46c58012639e5c0c6d0b009d52a.tar.bz2 rneovim-a1e313ded6e4c46c58012639e5c0c6d0b009d52a.zip | |
feat(lsp): support `textDocument/foldingRange` (#31311)
* refactor(shared): extract `vim._list_insert` and `vim._list_remove`
* feat(lsp): add `vim.lsp.foldexpr()`
* docs(lsp): add a todo for state management
* feat(lsp): add `vim.lsp.folding_range.foldclose()`
* feat(lsp): schedule `foldclose()` if the buffer is not up-to-date
* feat(lsp): add `vim.lsp.foldtext()`
* feat(lsp): support multiple folding range providers
* refactor(lsp): expose all folding related functions under `vim.lsp.*`
* perf(lsp): add `lsp.MultiHandler` for do `foldupdate()` only once
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/lsp.txt | 30 | ||||
| -rw-r--r-- | runtime/doc/news.txt | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 1693ff5e4f..f7157df0f2 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -204,6 +204,7 @@ won't run if your server doesn't support them. - `'textDocument/diagnostic'` - `'textDocument/documentHighlight'` - `'textDocument/documentSymbol'` +- `'textDocument/foldingRange'` - `'textDocument/formatting'` - `'textDocument/hover'` - `'textDocument/implementation'` @@ -697,6 +698,35 @@ commands *vim.lsp.commands* The second argument is the `ctx` of |lsp-handler| +foldclose({kind}, {winid}) *vim.lsp.foldclose()* + Close all {kind} of folds in the the window with {winid}. + + To automatically fold imports when opening a file, you can use an autocmd: >lua + vim.api.nvim_create_autocmd('LspNotify', { + callback = function(args) + if args.data.method == 'textDocument/didOpen' then + vim.lsp.foldclose('imports', vim.fn.bufwinid(args.buf)) + end + end, + }) +< + + Parameters: ~ + • {kind} (`lsp.FoldingRangeKind`) Kind to close, one of "comment", + "imports" or "region". + • {winid} (`integer?`) Defaults to the current window. + +foldexpr({lnum}) *vim.lsp.foldexpr()* + Provides an interface between the built-in client and a `foldexpr` + function. + + Parameters: ~ + • {lnum} (`integer`) line number + +foldtext() *vim.lsp.foldtext()* + Provides a `foldtext` function that shows the `collapsedText` retrieved, + defaults to the first folded line if `collapsedText` is not provided. + formatexpr({opts}) *vim.lsp.formatexpr()* Provides an interface between the built-in client and a `formatexpr` function. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 98782bfd15..ad3f2c0a6a 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -230,6 +230,8 @@ LSP • |vim.lsp.buf.hover()| now highlights hover ranges using the |hl-LspReferenceTarget| highlight group. • Functions in |vim.lsp.Client| can now be called as methods. +• Implemented LSP folding: |vim.lsp.foldexpr()| + https://microsoft.github.io/language-server-protocol/specification/#textDocument_foldingRange LUA |