emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/treesit-fold ac1461d364 338/417: feat: Add LLVM support


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold ac1461d364 338/417: feat: Add LLVM support
Date: Mon, 1 Jul 2024 10:03:02 -0400 (EDT)

branch: elpa/treesit-fold
commit ac1461d364a1eacb99b77b919f7ab31650b83b9d
Author: Jen-Chieh <jcs090218@gmail.com>
Commit: Jen-Chieh Shen <jcs090218@gmail.com>

    feat: Add LLVM support
---
 CHANGELOG.md       | 2 +-
 README.md          | 3 +++
 ts-fold-parsers.el | 8 ++++++++
 ts-fold-summary.el | 1 +
 ts-fold-util.el    | 5 ++++-
 ts-fold.el         | 1 +
 6 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fea738b863..3ffe356e03 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for 
recommendations on how
 ## 0.4.0 (Unreleased)
 > Released N/A
 
-* N/A
+* Add `LLVM` support (#102)
 
 ## 0.3.0
 > Released Nov 29, 2023
diff --git a/README.md b/README.md
index fd14ed0dcf..8c87de1ded 100644
--- a/README.md
+++ b/README.md
@@ -144,6 +144,9 @@ These languages are in development:
 - Pascal
 - Smithy
 
+*P.S. We don't list trivial languages here. e.g., LLVM IR (`.ll`) files, etc.
+Please see the variable `ts-fold-range-alist` for the fully supported list!*
+
 ## 📝 Customization
 
 Although ts-fold aims to have good folding out of the box for all supported
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 7bfdcbf35c..b08a7c2b2d 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -357,6 +357,14 @@
                                      (ts-fold--cons-add offset '(0 . -1))
                                      ";;")))))
 
+(defun ts-fold-parsers-llvm ()
+  "Rule set for LLVM."
+  '((function_body . ts-fold-range-seq)
+    (label         . ts-fold-range-asm-label)
+    (comment
+     . (lambda (node offset)
+         (ts-fold-range-line-comment node offset ";;")))))
+
 (defun ts-fold-parsers-lua ()
   "Rule set for Lua."
   '((expression_list      . ts-fold-range-seq)
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index d9fc5bc52c..be9bf42443 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -259,6 +259,7 @@ type of content by checking the word boundary's existence."
     (latex-mode             . ts-fold-summary-tex-doc)
     (lisp-mode              . ts-fold-summary-elisp)
     (lisp-interaction-mode  . ts-fold-summary-elisp)
+    (llvm-mode              . ts-fold-summary-elisp)
     (lua-mode               . ts-fold-summary-lua-doc)
     (makefile-mode          . ts-fold-summary-ruby-doc)
     (makefile-automake-mode . ts-fold-summary-ruby-doc)
diff --git a/ts-fold-util.el b/ts-fold-util.el
index 8d160e32cb..4f0ef253b6 100644
--- a/ts-fold-util.el
+++ b/ts-fold-util.el
@@ -96,7 +96,10 @@ Like function `s-count-matches' but faster."
 (defun ts-fold--get-face (obj trim)
   "Return face name from OBJ.
 If argument TRIM is non-nil, trim the OBJ."
-  (get-text-property 0 'face (if trim (string-trim obj) obj)))
+  (let ((obj (if trim (string-trim obj) obj))
+        (len (length obj)))
+    (or (get-text-property 0 'face obj)
+        (get-text-property (max 0 (1- len)) 'face obj))))
 
 (defun ts-fold--is-face (obj lst-face &optional trim)
   "Return non-nil if OBJ's face is define inside list LST-FACE.
diff --git a/ts-fold.el b/ts-fold.el
index c05b05ca1e..e0f3e35d42 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -100,6 +100,7 @@
     (latex-mode             . ,(ts-fold-parsers-latex))
     (lisp-mode              . ,(ts-fold-parsers-lisp))
     (lisp-interaction-mode  . ,(ts-fold-parsers-lisp))
+    (llvm-mode              . ,(ts-fold-parsers-llvm))
     (lua-mode               . ,(ts-fold-parsers-lua))
     (makefile-mode          . ,(ts-fold-parsers-make))
     (makefile-automake-mode . ,(ts-fold-parsers-make))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]