fix(fold): don't include whitespace end regions

Some languages that are difficult to parse via Treesitter may
incorrectly include whitespace lines at the end of regions. This can
makes the calculated folds sub-optimal.

To recitfy, use a custom directive (trim), to calculate the range with
the trailing whitespace lines removed. Note this only works if the
region end column is 0.

Also added folds for Make.
This commit is contained in:
Lewis Russell 2022-04-21 10:48:47 +01:00 committed by Lewis Russell
parent 2bc82e814b
commit 2eaf188269
5 changed files with 59 additions and 9 deletions

7
queries/make/folds.scm Normal file
View file

@ -0,0 +1,7 @@
(
[
(conditional)
(rule)
] @fold
(#trim! @fold)
)

View file

@ -1,6 +1,9 @@
[
(fenced_code_block)
(indented_code_block)
(list)
(section)
] @fold
(
[
(fenced_code_block)
(indented_code_block)
(list)
(section)
] @fold
(#trim! @fold)
)