[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 4b35e27148 311/417: feat: Add SQL support (#9
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 4b35e27148 311/417: feat: Add SQL support (#91) |
Date: |
Mon, 1 Jul 2024 10:02:54 -0400 (EDT) |
branch: elpa/treesit-fold
commit 4b35e27148e7f45e965752062314b7c3e7bf8dc2
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
feat: Add SQL support (#91)
---
CHANGELOG.md | 1 +
README.md | 2 +-
ts-fold-parsers.el | 11 ++++++++++-
ts-fold-summary.el | 1 +
ts-fold.el | 14 +++++++++++++-
5 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b87ced22d..4d791c0f31 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for
recommendations on how
* perf: Speed up count matches (#88)
* Add reStructuredText support (#89)
* Add Make support (#90)
+* Add SQL support (#91)
## 0.2.0
> Released Sep 01, 2023
diff --git a/README.md b/README.md
index dfda4bad6b..d914872984 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,7 @@ These languages are fairly complete:
- OCaml
- Perl / PHP / Python
- R / Ruby / Rust / reStructuredText
-- Scala / Scheme / Swift
+- Scala / Scheme / SQL / Swift
- TOML / TypeScript / TSX
- Verilog / VHDL
- XML
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 141311cc40..0b3193c472 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -70,8 +70,10 @@
(declare-function ts-fold-range-ruby-class-def "ts-fold.el")
(declare-function ts-fold-range-ruby-if "ts-fold.el")
(declare-function ts-fold-range-rust-macro "ts-fold.el")
+(declare-function ts-fold-range-sql-block "ts-fold.el")
(declare-function ts-fold-range-toml-table "ts-fold.el")
(declare-function ts-fold-range-verilog-list "ts-fold.el")
+(declare-function ts-fold-range-verilog-initial-construct "ts-fold.el")
(declare-function ts-fold-range-verilog-module "ts-fold.el")
(declare-function ts-fold-range-vhdl-package "ts-fold.el")
(declare-function ts-fold-range-vhdl-type "ts-fold.el")
@@ -432,6 +434,13 @@
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
+(defun ts-fold-parsers-sql ()
+ "Rule set for SQL."
+ '((block . ts-fold-range-sql-block)
+ (subquery . ts-fold-range-seq)
+ (list . ts-fold-range-seq)
+ (marginalia . ts-fold-range-c-like-comment))) ; This is the comment!
+
(defun ts-fold-parsers-swift ()
"Rule set for Swift."
'((switch_statement . ts-fold-range-seq)
@@ -464,7 +473,7 @@
"Rule set for Verilog."
'((module_declaration . ts-fold-range-verilog-module)
(list_of_port_connections . ts-fold-range-verilog-list)
- (initial_construct . ts-fold-range-initial-construct)
+ (initial_construct . ts-fold-range-verilog-initial-construct)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-vhdl ()
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index a9c6747f18..ee416582a8 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -270,6 +270,7 @@ type of content by checking the word boundary's existence."
(scala-mode . ts-fold-summary-javadoc)
(scheme-mode . ts-fold-summary-elisp)
(sh-mode . ts-fold-summary-javadoc)
+ (sql-mode . ts-fold-summary-c)
(swift-mode . ts-fold-summary-c)
(toml-mode . ts-fold-summary-javadoc)
(conf-toml-mode . ts-fold-summary-javadoc)
diff --git a/ts-fold.el b/ts-fold.el
index 9ee03ce68b..ad9b61eeff 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -115,6 +115,7 @@
(scheme-mode . ,(ts-fold-parsers-scheme))
(sh-mode . ,(ts-fold-parsers-bash))
(scala-mode . ,(ts-fold-parsers-scala))
+ (sql-mode . ,(ts-fold-parsers-sql))
(swift-mode . ,(ts-fold-parsers-swift))
(toml-mode . ,(ts-fold-parsers-toml))
(conf-toml-mode . ,(ts-fold-parsers-toml))
@@ -974,6 +975,17 @@ more information."
(end (1+ (tsc-node-start-position last_bracket))))
(ts-fold--cons-add (cons beg end) offset)))
+(defun ts-fold-range-sql-block (node offset)
+ "Return the fold range for `block' in SQL.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+ (when-let* ((beg-node (car (ts-fold-find-children node "keyword_begin")))
+ (end-node (car (ts-fold-find-children node "keyword_end")))
+ (beg (tsc-node-end-position beg-node))
+ (end (tsc-node-start-position end-node)))
+ (ts-fold--cons-add (cons beg end) offset)))
+
(defun ts-fold-range-toml-table (node offset)
"Return the fold range for `table' in TOML.
@@ -985,7 +997,7 @@ more information."
(end (tsc-node-end-position end-child)))
(ts-fold--cons-add (cons beg end) offset)))
-(defun ts-fold-range-initial-construct (node offset)
+(defun ts-fold-range-verilog-initial-construct (node offset)
"Return the fold range for `initial' in Verilog.
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
- [nongnu] elpa/treesit-fold befad113c9 390/417: feat: Return node when closing, (continued)
- [nongnu] elpa/treesit-fold befad113c9 390/417: feat: Return node when closing, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9d18dee909 354/417: Added a matlab parser for folding., ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold bfdba4f0a8 339/417: fix PR id, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 56c19e3b2d 351/417: chore: Update changelog and README regarding dev, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 37715b54ee 309/417: feat: Add reStructuredText support (#89), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a54a3c92fd 315/417: feat: Add GLSL support (#94), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 1827d0aa9e 319/417: perf: Render indicators in display range (#97), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 0d602a06b1 378/417: Rename ts-fold to treesit-fold, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 342eb5ee1f 324/417: fix: Don't render indicators on non foldable node, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold db6cd0ae4f 352/417: style: Ensure spaces, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 4b35e27148 311/417: feat: Add SQL support (#91),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold d1b07c7bb0 320/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d8a4bb568b 392/417: feat: Ensure indicators is refreshed after show/hide, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 11913082da 377/417: Ignore ds_store, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 731adc1607 362/417: fix(asm): Enhance assembly comment's folding, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 545ec26be1 412/417: docs: Add Vimscript to supported list, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 675e5e732c 414/417: fix: Allow error in continuous node, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 380ccb0d77 092/417: Remove macro, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e25ece59b5 114/417: Add rust macro support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold bf9a0285dc 131/417: Add todo mark, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 01d6485398 177/417: Update CI, ELPA Syncer, 2024/07/01