branch: elpa/haskell-ts-mode commit 00a397204d31dd59660b0e56a63356591f61f3a7 Author: Pranshu Sharma <pranshusharma...@gmail.com> Commit: Pranshu Sharma <pranshusharma...@gmail.com>
Major changed, to indentation, font lock --- README.org | 30 +++++++++++++++++++++++++++++- haskell-ts-mode.el | 19 ++++++++++++++++--- ss.png | Bin 0 -> 23881 bytes 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 4baf9c8e2b..4cd1ddc5e8 100644 --- a/README.org +++ b/README.org @@ -1,13 +1,41 @@ * Context -A haskell mode that requires treesitter and offers: +A haskell mode that uses treesitter. + +The package is still in devlopment, please report bugs or email +them(email found it main .el file). + +* Screenshot +[[ss.png]] + +* Features +The basic features are: - Syntax highliting - Indentation - Imenu support - REPL - Prettify symbols mode support +The more interesting features are: +- Logical syntax highlighting: + - Only arguments that can be used in functions are highlighted, eg + in `f (_:(a:[])) only 'a' is highlighted + - The return type of a function is optionally highlighted, if + treesit-font-lock-level is set to 4 + - All new variabels are(or should be) highlighted, this includes + generators, lambda args. + - highlighting the '=' operaotr in guarded matches correctly, this + would be stupidly hard in regexp based syntax +- Unlike haskell-mode, quasi quotes are understood and do not confuse + the mode +- Consistant indentation: haskell-mode's indentation works in a + cyclical way, it cycles through where you might want indentation. + haskell-ts-mode, meanwhile relies on you to set the parse tree + changing whitespace. +- Significantly more perfomant than haskell(-tng)-mode, don't have a + number on this yet. + * Motivation haskell-mode contains nearly 30k lines of code, and is diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el index e5d4777cbc..267ca6d70a 100644 --- a/haskell-ts-mode.el +++ b/haskell-ts-mode.el @@ -42,7 +42,7 @@ '((comment str pragma parens) (type definition function args) (match keyword) - (otherwise))) + (otherwise signature))) (defvar haskell-ts-prettify-symbols-alits '(("\\" . "λ") @@ -51,7 +51,7 @@ (defvar haskell-ts-font-lock (treesit-font-lock-rules :language 'haskell - :feature 'parens + :feature 'parens `(["(" ")" "[" "]"] @font-lock-operator-face (infix operator: (_) @font-lock-operator-face)) :language 'haskell @@ -79,9 +79,13 @@ `((type) @font-lock-type-face (constructor) @font-lock-type-face) :language 'haskell + :override t + :feature 'signature + `((signature (function) @haskell-ts-fontify-type)) + :language 'haskell :feature 'function :override t - `((function (variable) @font-lock-function-name-face) + `((function name: (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))) @@ -286,6 +290,15 @@ 'face font-lock-variable-name-face) (mapc 'haskell-ts-fontify-arg (treesit-node-children node)))) +(defun haskell-ts-fontify-type (node &optional override start end) + (let ((last-child (treesit-node-child node -1))) + (if (string= (treesit-node-type last-child) "function") + (haskell-ts-fontify-type last-child) + (put-text-property + (treesit-node-start last-child) + (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"))) diff --git a/ss.png b/ss.png new file mode 100644 index 0000000000..4d2a168cc7 Binary files /dev/null and b/ss.png differ