branch: elpa/haskell-ts-mode commit 2cc6c0c4b071738ff8723712ed9def80f13a2f87 Author: Pranshu Sharma <pran...@bauherren.ovh> Commit: Pranshu Sharma <pran...@bauherren.ovh>
Massive indentatino changes Proper indentations for stuff { }, including fields/strcuts --- haskell-ts-mode.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el index 6954842937..4eb14d3907 100644 --- a/haskell-ts-mode.el +++ b/haskell-ts-mode.el @@ -254,7 +254,7 @@ when `haskell-ts-prettify-words' is non-nil.") nil))))) (defvar haskell-ts--ignore-types - (regexp-opt '("comment" "cpp" "haddock")) + (regexp-opt '("comment" "cpp" "haddock" ";")) "Node types that will be ignored by indentation.") (defvar haskell-ts-indent-rules @@ -306,6 +306,19 @@ when `haskell-ts-prettify-words' is non-nil.") ((node-is "^]$") parent 0) ((parent-is "^list$") standalone-parent 2) + ;; Structs + ((parent-is "^field$") standalone-parent 2) + ((node-is "^}$") + (lambda (_ parent bol) + (let ((sib (treesit-node-child parent 0))) + (while (and sib (not (string= (treesit-node-type sib) + "{"))) ; } Srry for ocd + (setq sib (treesit-node-next-sibling sib))) + (if sib + (treesit-node-start sib) + bol))) + 0) + ;; If then else ((node-is "^then$") parent 2) ((node-is "^else$") parent 2) @@ -319,7 +332,7 @@ when `haskell-ts-prettify-words' is non-nil.") (setq n (treesit-node-prev-sibling n))) (string= "do" (treesit-node-type n)))) haskell-ts--stand-alone-parent - 3) + 2) ((parent-is "^do$") ,p-prev-sib 0) ((parent-is "^alternatives$") ,p-prev-sib 0)