Function: haskell-ts-mode
haskell-ts-mode is an interactive and natively compiled function
defined in haskell-ts-mode.el.
Signature
(haskell-ts-mode)
Documentation
Major mode for Haskell files using tree-sitter.
In addition to any hooks its parent mode prog-mode might have run,
this mode runs the hook haskell-ts-mode-hook, as the final or
penultimate step during initialization.
C-c C-c haskell-ts-compile-region-and-go
C-c C-f haskell-ts-format
C-c C-r run-haskell
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/84k99g1lc4gz6zw2djcsyzr9zviz842h-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-ts-mode-1.3.5/haskell-ts-mode.el
;;;###autoload
(define-derived-mode haskell-ts-mode prog-mode "haskell ts mode"
"Major mode for Haskell files using tree-sitter."
:table haskell-ts-mode-syntax-table
(unless (treesit-ready-p 'haskell)
(error "Tree-sitter for Haskell is not available"))
(setq treesit-primary-parser (treesit-parser-create 'haskell))
(setq treesit-language-at-point-function
(lambda (&rest _) 'haskell))
(setq-local treesit-defun-type-regexp "\\(?:\\(?:function\\|struct\\)_definition\\)")
;; Indent
(when haskell-ts-use-indent
(setq-local treesit-simple-indent-rules haskell-ts-indent-rules)
(setq-local indent-tabs-mode nil))
(setq-local electric-indent-functions '(haskell-ts-indent-after-newline))
;; Comment
(setq-local comment-start "-- ")
(setq-local comment-use-syntax t)
(setq-local comment-start-skip "\\(?: \\|^\\)--+")
;; Electric
(setq-local electric-pair-pairs
'((?` . ?`) (?\( . ?\)) (?{ . ?}) (?\" . ?\") (?\[ . ?\])))
;; Navigation
(setq-local treesit-defun-name-function 'haskell-ts-defun-name)
(setq-local treesit-thing-settings haskell-ts-thing-settings)
(setq-local treesit-defun-type-regexp
;; Since haskell is strict functional, any 2nd level
;; entity is defintion
(cons ".+"
(lambda (node)
(and (not (string-match haskell-ts--ignore-types (treesit-node-type node)))
(string= "declarations" (treesit-node-type (treesit-node-parent node)))))))
(setq-local prettify-symbols-alist
(append (and haskell-ts-prettify-symbols
haskell-ts-prettify-symbols-alist)
(and haskell-ts-prettify-words
haskell-ts-prettify-words-alist)))
;; Imenu
(setq-local treesit-simple-imenu-settings
`((nil haskell-ts-imenu-func-node-p nil
,(haskell-ts-imenu-name-function #'haskell-ts-imenu-func-node-p))
("Signatures.." haskell-ts-imenu-sig-node-p nil
,(haskell-ts-imenu-name-function #'haskell-ts-imenu-sig-node-p))
("Data..." haskell-ts-imenu-data-type-p nil
(lambda (node)
(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-feature-list
haskell-ts-font-lock-feature-list)
(treesit-major-mode-setup))