diff options
author | Till Bungert <tillbungert@gmail.com> | 2023-10-01 21:10:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-01 14:10:51 -0500 |
commit | 9ce1623837a817c3f4f5deff9c8ba862578b6009 (patch) | |
tree | ddac08d5004967c2dcd848f4c44f6ca37fceed3a /runtime/lua/vim/treesitter.lua | |
parent | c0f4d60016676d4cde809107763a3bc51ad309b9 (diff) | |
download | rneovim-9ce1623837a817c3f4f5deff9c8ba862578b6009.tar.gz rneovim-9ce1623837a817c3f4f5deff9c8ba862578b6009.tar.bz2 rneovim-9ce1623837a817c3f4f5deff9c8ba862578b6009.zip |
feat(treesitter): add foldtext with treesitter highlighting (#25391)
Diffstat (limited to 'runtime/lua/vim/treesitter.lua')
-rw-r--r-- | runtime/lua/vim/treesitter.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index 0e34cbcbcc..f863942d3b 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -508,4 +508,16 @@ function M.foldexpr(lnum) return require('vim.treesitter._fold').foldexpr(lnum) end +--- Returns the highlighted content of the first line of the fold or falls back to |foldtext()| +--- if no treesitter parser is found. Can be set directly to 'foldtext': +--- +--- ```lua +--- vim.wo.foldtext = 'v:lua.vim.treesitter.foldtext()' +--- ``` +--- +---@return { [1]: string, [2]: string[] }[] | string +function M.foldtext() + return require('vim.treesitter._fold').foldtext() +end + return M |