[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-ts-mode 38595a001e 12/61: Major indent fixes
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-ts-mode 38595a001e 12/61: Major indent fixes |
Date: |
Wed, 4 Sep 2024 04:00:26 -0400 (EDT) |
branch: elpa/haskell-ts-mode
commit 38595a001eb8562ea464e49df721a109da7f970d
Author: Pranshu Sharma <pranshusharma366@gmail.com>
Commit: Pranshu Sharma <pranshusharma366@gmail.com>
Major indent fixes
---
haskell.el | 189 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 99 insertions(+), 90 deletions(-)
diff --git a/haskell.el b/haskell.el
index 9c57f1852f..6b594aa5f7 100644
--- a/haskell.el
+++ b/haskell.el
@@ -5,84 +5,93 @@
;; TODO change to defvar
(setq haskell-ts-font-lock
- (treesit-font-lock-rules
- :language 'haskell
- :feature 'keyword
- `(["module" "import" "data" "let" "where" "case"
- "if" "then" "else" "of" "do" "in" "instance"]
- @font-lock-keyword-face
- ["(" ")" "[" "]"] @font-lock-operator-face)
- :language 'haskell
- :feature 'type
- `((type) @font-lock-type-face
- (constructor) @font-lock-type-face)
- :language 'haskell
- :feature 'function
- `((function (variable) @font-lock-function-name-face)
- (function (infix (operator) @font-lock-function-name-face))
- (bind (variable) @font-lock-function-name-face)
- (function (infix (infix_id (variable)
@font-lock-function-name-face))))
- :language 'haskell
- :feature 'args
- `((function (patterns) @font-lock-variable-name-face)
- (function (infix (variable) @font-lock-variable-name-face))
- (lambda (patterns (variable) @font-lock-variable-name-face)))
- :language 'haskell
- :feature 'match
- `((match ("|" @font-lock-doc-face) ("=" @font-lock-doc-face))
- (match ("->" @font-lock-doc-face)))
- :language 'haskell
- :feature 'comment
- `(((comment) @font-lock-comment-face))
- :language 'haskell
- :feature 'pragma
- `((pragma) @font-lock-preprocessor-face)
- :language 'haskell
- :feature 'str
- `((char) @font-lock-string-face
- (string) @font-lock-string-face)))
+ (treesit-font-lock-rules
+ :language 'haskell
+ :feature 'keyword
+ `(["module" "import" "data" "let" "where" "case"
+ "if" "then" "else" "of" "do" "in" "instance"]
+ @font-lock-keyword-face
+ ["(" ")" "[" "]"] @font-lock-operator-face)
+ :language 'haskell
+ :feature 'type
+ `((type) @font-lock-type-face
+ (constructor) @font-lock-type-face)
+ :language 'haskell
+ :feature 'function
+ `((function (variable) @font-lock-function-name-face)
+ (function (infix (operator) @font-lock-function-name-face))
+ (bind (variable) @font-lock-function-name-face)
+ (function (infix (infix_id (variable) @font-lock-function-name-face))))
+ :language 'haskell
+ :feature 'args
+ `((function (patterns) @font-lock-variable-name-face)
+ (function (infix (variable) @font-lock-variable-name-face))
+ (lambda (patterns (variable) @font-lock-variable-name-face)))
+ :language 'haskell
+ :feature 'match
+ `((match ("|" @font-lock-doc-face) ("=" @font-lock-doc-face))
+ (match ("->" @font-lock-doc-face)))
+ :language 'haskell
+ :feature 'comment
+ `(((comment) @font-lock-comment-face))
+ :language 'haskell
+ :feature 'pragma
+ `((pragma) @font-lock-preprocessor-face)
+ :language 'haskell
+ :feature 'str
+ `((char) @font-lock-string-face
+ (string) @font-lock-string-face)))
;; TODO change to defvar
(setq haskell-ts-indent-rules
- `((haskell
- ((node-is "comment") column-0 0)
- ((parent-is "haskell") column-0 0)
- ((parent-is "declarations") column-0 0)
- ((parent-is "imports") column-0 0)
- ((parent-is "local_binds") prev-sibling 0)
- ((parent-is "apply") parent 2)
- ;; Match
- ((match "match" nil nil 2 2) parent 2)
- ((node-is "match") prev-sibling 0)
- ;; Do Hg
- ((parent-is "do") prev-sibling 0)
- ((match nil "do" nil 1 1) great-grand-parent 2)
- ((node-is "alternatives") grand-parent 0)
- ((parent-is "alternatives") grand-parent 2)
-
- ;; Infix
- ((node-is "infix") grand-parent 2)
- ((parent-is "infix") parent 0)
- ;; Where PS TODO 2nd
-
- ((lambda (node parent bol)
- (string= "where" (treesit-node-type
(treesit-node-prev-sibling node))))
- (lambda (a b c)
- (+ 1 (treesit-node-start (treesit-node-prev-sibling b))))
- 3)
- ((parent-is "local_binds") prev-sibling 2)
- ((node-is "^where$") parent 2)
- ;; If statement
- ((node-is "then") parent 2)
- ((node-is "else") parent 2)
-
- ;; lists
- ((node-is "^in$") parent 2)
- ((lambda (a b c)
- (save-excursion
- (goto-char c)
- (re-search-forward "^[ \t]*$" (line-end-position) t)))
- prev-adaptive-prefix 0))))
+ `((haskell
+ ((node-is "comment") column-0 0)
+ ((parent-is "haskell") column-0 0)
+ ((parent-is "declarations") column-0 0)
+ ((parent-is "imports") column-0 0)
+
+ ;; If then else
+ ((node-is "then") parent 2)
+ ((node-is "^else$") parent 2)
+
+ ;; lists
+ ((node-is "^in$") parent 2)
+
+ ((parent-is "apply") parent 2)
+ ;; Match
+ ((match "match" nil nil 2 2) parent 2)
+ ((node-is "match") prev-sibling 0)
+ ;; Do Hg
+ ((lambda (node parent bol)
+ (string= "do" (treesit-node-type (treesit-node-prev-sibling node))))
+ grand-parent 0)
+ ((parent-is "do") prev-sibling 0)
+
+ ((node-is "alternatives") grand-parent 0)
+ ((parent-is "alternatives") grand-parent 2)
+
+ ;; Infix
+ ((node-is "infix") grand-parent 2)
+ ((parent-is "infix") parent 0)
+
+ ((parent-is "data_constructors") parent 0)
+
+ ;; where
+ ((lambda (node parent bol)
+ (string= "where" (treesit-node-type (treesit-node-prev-sibling
node))))
+ (lambda (a b c)
+ (+ 1 (treesit-node-start (treesit-node-prev-sibling b))))
+ 3)
+ ((parent-is "local_binds") prev-sibling 0)
+ ((node-is "^where$") parent 2)
+
+ ;; Backup
+ ((lambda (a b c)
+ (save-excursion
+ (goto-char c)
+ (message "ee")
+ (re-search-forward "^[ \t]*$" (line-end-position) t)))
+ prev-adaptive-prefix 0))))
;;;###autoload
@@ -90,7 +99,7 @@
"Mjaor mode for Haskell files using tree-sitter"
:group 'haskell
(unless (treesit-ready-p 'haskell)
- (error "Tree-sitter for Haskell is not available"))
+ (error "Tree-sitter for Haskell is not available"))
(treesit-parser-create 'haskell)
(setq-local treesit-defun-type-regexp
"\\(?:\\(?:function\\|struct\\)_definition\\)")
;; Indent
@@ -99,38 +108,38 @@
(setq-local comment-start "--")
(setq-local indent-tabs-mode nil)
(setq-local electric-pair-pairs
- (list (cons ?` ?`) (cons ?( ?)) (cons ?{ ?}) (cons ?'
?') (cons ?" ?")))
+ (list (cons ?` ?`) (cons ?( ?)) (cons ?{ ?}) (cons ?' ?') (cons
?" ?")))
(setq-local treesit-defun-name-function 'haskell-ts-defun-name)
(setq-local treesit-defun-type-regexp "function")
;; Imenu
(setq-local treesit-simple-imenu-settings
- `((nil haskell-ts-imenu-func-node-p nil
haskell-ts-imenu-name-function)
- ("Signatures.." haskell-ts-imenu-sig-node-p nil
haskell-ts-imenu-sig-name-function)))
+ `((nil haskell-ts-imenu-func-node-p nil
haskell-ts-imenu-name-function)
+ ("Signatures.." haskell-ts-imenu-sig-node-p nil
haskell-ts-imenu-sig-name-function)))
;; font-lock.
(setq-local treesit-font-lock-settings haskell-ts-font-lock)
(setq-local treesit-font-lock-feature-list
- '(( comment str pragma type keyword definition
function args match)))
+ '(( comment str pragma type keyword definition function args
match)))
(treesit-major-mode-setup))
(defun haskell-ts-imenu-func-node-p (node)
(and (string-match-p "function\\|bind" (treesit-node-type node))
- (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
+ (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
(defun haskell-ts-imenu-sig-node-p (node)
(and (string-match-p "signature" (treesit-node-type node))
- (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
+ (string= (treesit-node-type (treesit-node-parent node))
"declarations")))
(defun haskell-ts-imenu-sig-name-function (node)
(let ((name (treesit-node-text node)))
- (if (haskell-ts-imenu-sig-node-p node)
- (haskell-ts-defun-name node)
- nil)))
+ (if (haskell-ts-imenu-sig-node-p node)
+ (haskell-ts-defun-name node)
+ nil)))
(defun haskell-ts-imenu-name-function (node)
(let ((name (treesit-node-text node)))
- (if (haskell-ts-imenu-func-node-p node)
- (haskell-ts-defun-name node)
- nil)))
+ (if (haskell-ts-imenu-func-node-p node)
+ (haskell-ts-defun-name node)
+ nil)))
(defun haskell-ts-defun-name (node)
(treesit-node-text (treesit-node-child node 0)))
@@ -144,8 +153,8 @@
(defun run-haskell()
(interactive)
(when (not (comint-check-proc "*haskell*"))
- (set-buffer (apply (function make-comint)
- "haskell" "ghci" nil
`(,buffer-file-name))))
+ (set-buffer (apply (function make-comint)
+ "haskell" "ghci" nil `(,buffer-file-name))))
(pop-to-buffer-same-window "*haskell*"))
(defun haskellsession ()
- [nongnu] elpa/haskell-ts-mode f798439f8a 35/61: Major indent edits(again), (continued)
- [nongnu] elpa/haskell-ts-mode f798439f8a 35/61: Major indent edits(again), ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 09a1d6647f 19/61: Fixed argument indenting, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode ebc222940f 24/61: typo, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode edc4f1dfc9 31/61: quasi quote body no indent, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 6a3c2d27e9 52/61: fixed electric pair, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode c0fe26d991 53/61: fixed defgroup error, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 1c017f310e 07/61: at, ELPA Syncer, 2024/09/04
- [nongnu] elpa/haskell-ts-mode 78b685d6ea 01/61: first commit, ELPA Syncer, 2024/09/04
- [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 <=
- [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, 2024/09/04
- [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