A major mode for editing Jai code in Emacs, using the tree-sitter-jai parser for advanced syntax features.
- Syntax highlighting for Jai code
- Proper indentation
- Comment-aware editing (M-q works only in comments)
- Tree-sitter based syntax parsing
- Emacs 29.1 or newer (with tree-sitter support)
- Tree-sitter-jai grammar
Important: This mode requires Emacs 29.1 or newer with built-in tree-sitter support.
;; Install jai-ts-mode
(use-package jai-ts-mode
:straight (:host github :repo "luminousmonkey/jai-ts-mode")
:mode "\\.jai\\'"
:init
;; Set up tree-sitter for Jai - this must be done before loading jai-ts-mode
;; Check if treesit is available first
(when (featurep 'treesit)
(add-to-list 'treesit-language-source-alist
'(jai "https://github.com/constantitus/tree-sitter-jai"))
;; Optional: Install the grammar automatically if not present
(dolist (lang '(jai))
(unless (treesit-language-available-p lang)
(treesit-install-language-grammar lang)))))
;; Example with custom key bindings
(use-package jai-ts-mode
:straight (:host github :repo "luminousmonkey/jai-ts-mode")
:mode "\\.jai\\'"
:init
;; Check if treesit is available first
(when (featurep 'treesit)
(add-to-list 'treesit-language-source-alist
'(jai "https://github.com/constantitus/tree-sitter-jai")))
:bind (:map jai-ts-mode-map
("<f5>" . my/build-jai)
("<f7>" . my/align-jai-struct)))- Clone this repository:
git clone https://github.com/luminousmonkey/jai-ts-mode.git ~/.emacs.d/site-lisp/jai-ts-mode - Add the following to your Emacs configuration:
(add-to-list 'load-path "~/.emacs.d/site-lisp/jai-ts-mode") (require 'jai-ts-mode)
- Install the tree-sitter grammar for Jai:
;; treesit is built into Emacs 29+, not a separate package (add-to-list 'treesit-language-source-alist '(jai "https://github.com/constantitus/tree-sitter-jai")) (treesit-install-language-grammar 'jai)
Files with the .jai extension will automatically open in jai-ts-mode.
- Comment-aware editing: M-q (fill-paragraph) works only in comments and does nothing in code
- Syntax highlighting for Jai-specific constructs
- Proper indentation rules for Jai code
This package depends on the Jai tree-sitter grammar by constantitus.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.