Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more folding definitions #51

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ts-fold-parsers.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
(defun ts-fold-parsers-bash ()
"Rule set for Bash."
'((compound_statement . ts-fold-range-seq)
(expansion . ts-fold-range-seq)
(do_group . (ts-fold-range-seq 1 -3))
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
Expand Down Expand Up @@ -148,12 +148,14 @@
(annotation_type_body . ts-fold-range-seq)
(interface_body . ts-fold-range-seq)
(array_initializer . ts-fold-range-seq)
(comment . (ts-fold-range-seq 1 -1))))
(block_comment . (ts-fold-range-seq 1 -1))))

(defun ts-fold-parsers-javascript ()
"Rule set for JavaScript."
'((export_clause . ts-fold-range-seq)
(statement_block . ts-fold-range-seq)
(object . ts-fold-range-seq)
(array . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))

(defun ts-fold-parsers-json ()
Expand Down Expand Up @@ -207,6 +209,7 @@
'((function_definition . ts-fold-range-python)
(class_definition . ts-fold-range-python)
(list . ts-fold-range-seq)
(dictionary . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
Expand Down Expand Up @@ -264,5 +267,10 @@
"Rule set for TypeScript."
(append (ts-fold-parsers-javascript)))

(defun ts-fold-parsers-yaml ()
"Rule set for YAML."
'((comment . (lambda (node offset) (ts-fold-range-line-comment node offset "#")))
(block_mapping_pair . ((lambda (node offset) (ts-fold-range-markers node offset ":")) 0 1))))

(provide 'ts-fold-parsers)
;;; ts-fold-parsers.el ends here
3 changes: 2 additions & 1 deletion ts-fold.el
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
(scala-mode . ,(ts-fold-parsers-scala))
(swift-mode . ,(ts-fold-parsers-swift))
(tuareg-mode . ,(ts-fold-parsers-ocaml))
(typescript-mode . ,(ts-fold-parsers-typescript)))
(typescript-mode . ,(ts-fold-parsers-typescript))
(yaml-mode . ,(ts-fold-parsers-yaml)))
"An alist of (major-mode . (foldable-node-type . function)).

FUNCTION is used to determine where the beginning and end for FOLDABLE-NODE-TYPE
Expand Down