diff options
author | Yi Ming <ofseed@foxmail.com> | 2025-03-15 08:31:59 +0800 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2025-03-16 11:21:44 +0100 |
commit | 1862d3210d7fe8967b28afcb85f69701e6827580 (patch) | |
tree | 525e3652513e91233bf5fde03770bd30f48730ff /runtime/doc | |
parent | f5714994bc4fc578b5f07bca403e7067e6d9b5a0 (diff) | |
download | rneovim-1862d3210d7fe8967b28afcb85f69701e6827580.tar.gz rneovim-1862d3210d7fe8967b28afcb85f69701e6827580.tar.bz2 rneovim-1862d3210d7fe8967b28afcb85f69701e6827580.zip |
docs(lsp): simplify example of enabling LSP folding
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/lsp.txt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index f13a17cbef..16ea9c18a0 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -882,14 +882,23 @@ foldexpr({lnum}) *vim.lsp.foldexpr()* Provides an interface between the built-in client and a `foldexpr` function. - To use, check for the "textDocument/foldingRange" capability in an - |LspAttach| autocommand. Example: >lua + To use, set 'foldmethod' to "expr" and set the value of 'foldexpr': >lua + vim.o.foldmethod = 'expr' + vim.o.foldexpr = 'v:lua.vim.lsp.foldexpr()' +< + + Or use it only when supported by checking for the + "textDocument/foldingRange" capability in an |LspAttach| autocommand. + Example: >lua + vim.o.foldmethod = 'expr' + -- Default to treesitter folding + vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + -- Prefer LSP folding if client supports it vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) if client:supports_method('textDocument/foldingRange') then local win = vim.api.nvim_get_current_win() - vim.wo[win][0].foldmethod = 'expr' vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()' end end, |