[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-ts-mode 9c032dc8c4 44/61: Better formating and gen
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-ts-mode 9c032dc8c4 44/61: Better formating and general code quality changes |
Date: |
Wed, 4 Sep 2024 04:00:30 -0400 (EDT) |
branch: elpa/haskell-ts-mode
commit 9c032dc8c47b87d644d2b087d2e713431fa311ef
Author: Pranshu Sharma <pranshusharma366@gmail.com>
Commit: Pranshu Sharma <pranshusharma366@gmail.com>
Better formating and general code quality changes
---
haskell-ts-mode.el | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el
index 63857317c5..6d367c2e6d 100644
--- a/haskell-ts-mode.el
+++ b/haskell-ts-mode.el
@@ -26,9 +26,7 @@
;;; Code:
-(eval-when-compile
- (require 'treesit)
- (require 'comint))
+(eval-when-compile (require 'comint) (require 'treesit))
(declare-function treesit-parser-create "treesit.c")
(declare-function treesit-induce-sparse-tree "treesit.c")
@@ -45,10 +43,10 @@
(otherwise signature)))
(defvar haskell-ts-use-indent t
- "Set to nil if you don't want to use emacs indent")
+ "Set to nil if you don't want to use Emacs indent.")
(defvar haskell-ts-font-lock-level 4
- "Level of font lock, 1 for minimum highlghting and 4 for maximum")
+ "Level of font lock, 1 for minimum highlghting and 4 for maximum.")
(defvar haskell-ts-prettify-symbols-alits
'(("\\" . "λ")
@@ -59,8 +57,8 @@
("<=" . "≥")
(">=" . "≤")))
-(defvar haskell-ts-font-lock
- (treesit-font-lock-rules
+(defun haskell-ts-font-lock ()
+ (treesit-font-lock-rules
:language 'haskell
:feature 'keyword
`(["module" "import" "data" "let" "where" "case"
@@ -126,21 +124,20 @@
(infix operator: (_) @font-lock-operator-face))))
(defvar haskell-ts-indent-rules
- (let ((bind-reg "local_binds\\|instance_declarations")
- (p-prev-sib
- (lambda (node parent bol)
+ (let ((p-prev-sib
+ (lambda (node _ _)
(let ((n (treesit-node-prev-sibling node)))
(while (string= "comment" (treesit-node-type n))
(setq n (treesit-node-prev-sibling n)))
(treesit-node-start n)))))
`((haskell
((node-is "comment") column-0 0)
+ ((node-is "cpp") column-0 0)
((parent-is "comment") column-0 0)
((parent-is "imports") column-0 0)
;; Infix
((parent-is "infix") standalone-parent 1)
((node-is "infix") standalone-parent 2)
-
;; Lambda
((parent-is "lambda") standalone-parent 2)
@@ -157,7 +154,7 @@
((parent-is "apply") parent -1)
((node-is "quasiquote") grand-parent 2)
- ((parent-is "quasiquote_body") (lambda (a b c) c) 0)
+ ((parent-is "quasiquote_body") (lambda (_ _ c) c) 0)
;; Do Hg
((lambda (node parent bol)
(let ((n (treesit-node-prev-sibling node)))
@@ -168,7 +165,7 @@
((parent-is "do") ,p-prev-sib 0)
((node-is "alternatives")
- (lambda (a b c)
+ (lambda (_ b _)
(treesit-node-start (treesit-node-child b 0)))
4)
((parent-is "alternatives") ,p-prev-sib 0)
@@ -178,12 +175,12 @@
((parent-is "data_constructors") parent 0)
;; where
- ((lambda (node parent bol)
+ ((lambda (node _ _)
(let ((n (treesit-node-prev-sibling node)))
(while (string= "comment" (treesit-node-type n))
(setq n (treesit-node-prev-sibling n)))
(string= "where" (treesit-node-type n))))
- (lambda (a b c)
+ (lambda (_ b _)
(+ 1 (treesit-node-start (treesit-node-prev-sibling b))))
3)
((parent-is "local_binds\\|instance_declarations") ,p-prev-sib 0)
@@ -191,7 +188,7 @@
;; Match
;; ((match "match" nil 2 2 nil) ,p-prev-sib 0)
- ((lambda (node parent bol)
+ ((lambda (node _ _)
(and (string= (treesit-node-type node) "match")
(let ((pos 3)
(n node)
@@ -204,7 +201,7 @@
(and (null n) (eq pos 0)))))
parent 2)
;; ((match "match" nil nil 3 nil) ,p-prev-sib 0)
- ((lambda (node parent bol)
+ ((lambda (node _ _)
(and (string= (treesit-node-type node) "match")
(let ((pos 4)
(n node)
@@ -224,7 +221,7 @@
((parent-is "record") grand-parent 0)
((parent-is "exports")
- (lambda (a b c) (treesit-node-start (treesit-node-prev-sibling b)))
+ (lambda (_ b _) (treesit-node-start (treesit-node-prev-sibling b)))
0)
((n-p-gp nil "signature" "foreign_import") grand-parent 3)
@@ -296,7 +293,7 @@
(setq-local comment-start-skip "\\(?: \\|^\\)-+")
;; Elecric
(setq-local electric-pair-pairs
- (list (cons ?` ?`) (cons ?( ?)) (cons ?{ ?}) (cons ?" ?") (cons
?[ ?])))
+ (list (cons ?` ?`) (cons ?\( ?\)) (cons ?{ ?}) (cons ?\" ?\")
(cons ?\[ ?\])))
;; Nav
(setq-local treesit-defun-name-function 'haskell-ts-defun-name)
(setq-local treesit-defun-type-regexp "function")
@@ -312,7 +309,7 @@
(treesit-node-text (treesit-node-child node 1))))))
;; font-lock.
(setq-local treesit-font-lock-level haskell-ts-font-lock-level)
- (setq-local treesit-font-lock-settings haskell-ts-font-lock)
+ (setq-local treesit-font-lock-settings (haskell-ts-font-lock))
(setq-local treesit-font-lock-feature-list
haskell-ts-font-lock-feature-list)
(treesit-major-mode-setup))
@@ -334,10 +331,6 @@
(treesit-node-end last-child)
'face font-lock-variable-name-face))))
-(defun haskell-ts-imenu-node-p (regex node)
- (and (string-match-p regex (treesit-node-type node))
- (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
-
(defmacro haskell-ts-imenu-name-function (check-func)
`(lambda (node)
(let ((name (treesit-node-text node)))
@@ -345,6 +338,10 @@
(haskell-ts-defun-name node)
nil))))
+(defun haskell-ts-imenu-node-p (regex node)
+ (and (string-match-p regex (treesit-node-type node))
+ (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
+
(defun haskell-ts-imenu-func-node-p (node)
(haskell-ts-imenu-node-p "function\\|bind" node))
@@ -384,3 +381,6 @@
(add-to-list 'auto-mode-alist '("\\.hs\\'" . haskell-ts-mode)))
(provide 'haskell-ts-mode)
+
+;;; haskell-ts-mode.el ends here
+
- [nongnu] elpa/haskell-ts-mode cc627feca3 05/61: added 'instance' to be highlighted, (continued)
- [nongnu] elpa/haskell-ts-mode cc627feca3 05/61: added 'instance' to be highlighted, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode a0fbb19e80 18/61: Added installation instructions, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 38595a001e 12/61: Major indent fixes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 00a397204d 32/61: Major changed, to indentation, font lock, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 5178ff240f 13/61: nl indent fix, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 98660f4cce 28/61: Major changes to comment and indent, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode b6426584ca 15/61: Major updates, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 3e2e2aa769 14/61: fix comment, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 155bf79867 33/61: more indent fixes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 113e443752 26/61: Fix quasiquotes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 9c032dc8c4 44/61: Better formating and general code quality changes,
ELPA Syncer <=
- [nongnu] elpa/haskell-ts-mode 1525dc1dc7 06/61: ic, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 020175db62 16/61: Major changes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 9f450166d8 39/61: better docu, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 02f280400c 34/61: Added eglot supprt, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 59c4c2a5a6 40/61: pattern matching docu, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 58d158bef4 45/61: More linting, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 998fc309bd 50/61: General code changes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 834f15a29d 42/61: temp, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 4cf9f99d93 51/61: More changes, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode dd16b23b60 56/61: Fixed comment problems, ELPA Syncer, 2024/09/04