mirror of
https://github.com/kevinhwang91/nvim-ufo
synced 2024-09-16 14:14:02 +02:00
feat(provider): allow using tree-sitter node types as kinds (#243)
* feat(provider): allow using tree-sitter node types as kinds (adding tree-sitter support to close_fold_kinds_for_ft) * fix(provider): guard treesitter node type and add mention to README --------- Co-authored-by: 3rd <3rd@users.noreply.github.com> Co-authored-by: anon <anon@localhost>
This commit is contained in:
parent
7dcb8fea3e
commit
b23a46aa06
2 changed files with 4 additions and 2 deletions
|
@ -153,7 +153,8 @@ For example, Changing the text in a buffer will request the providers for folds.
|
|||
close_fold_kinds_for_ft = {
|
||||
description = [[After the buffer is displayed (opened for the first time), close the
|
||||
folds whose range with `kind` field is included in this option. For now,
|
||||
'lsp' provider's standardized kinds are 'comment', 'imports' and 'region'.
|
||||
'lsp' provider's standardized kinds are 'comment', 'imports' and 'region',
|
||||
and the 'treesitter' provider exposes the underlying node types.
|
||||
This option is a table with filetype as key and fold kinds as value. Use a
|
||||
default value if value of filetype is absent.
|
||||
Run `UfoInspect` for details if your provider has extended the kinds.]],
|
||||
|
|
|
@ -179,7 +179,8 @@ function Treesitter.getFolds(bufnr)
|
|||
stop = stop - 1
|
||||
end
|
||||
if stop > start then
|
||||
table.insert(ranges, foldingrange.new(start, stop))
|
||||
local type = node.type and node:type() or nil
|
||||
table.insert(ranges, foldingrange.new(start, stop, nil, nil, type))
|
||||
end
|
||||
end
|
||||
foldingrange.sortRanges(ranges)
|
||||
|
|
Loading…
Reference in a new issue