kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.3k stars 47 forks source link

Treesitter folds created with make-range! are ignored #139

Closed yads closed 1 year ago

yads commented 1 year ago

Neovim version (nvim -v | head -n1)

NVIM v0.9.1

Operating system/version

macOS 13.3.1

How to reproduce the issue

Using the following minimal configuration:

{
    provider_selector = function(bufnr, filetype, buftype)
        return {'treesitter', 'indent'}
    end
  }

I'm seeing the following fold query for ruby get ignored in nvim-ufo, but it works without nvim-ufo (i.e. foldmethod=nvim_treesitter#foldexpr())

(
 (_) @_head
 .
 (comment) @_start
 .
 (comment)*
 .
 (comment) @_end
 .
 (_) @_tail
 (#not-has-type? @_head "comment")
 (#not-has-type? @_tail "comment")
 (#make-range! "fold" @_start @_end)
)

The idea is to make a range called @fold out of a comment block of 2 or more consecutive comments.

Expected behavior

ruby block:

# comment line 1
# comment line 2

Gets marked as a fold

Actual behavior

ruby block:

# comment line 1
# comment line 2

Has no folds

yads commented 1 year ago

Thanks for such a quick turnaround on this!