Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LuminousMonkey/jai-ts-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jai-ts-mode

jai-ts-mode

A major mode for editing Jai code in Emacs, using the tree-sitter-jai parser for advanced syntax features.

Features

  • Syntax highlighting for Jai code
  • Proper indentation
  • Comment-aware editing (M-q works only in comments)
  • Tree-sitter based syntax parsing

Requirements

  • Emacs 29.1 or newer (with tree-sitter support)
  • Tree-sitter-jai grammar

Installation

Using straight.el and use-package

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)))

Manual installation

  1. Clone this repository:
    git clone https://github.com/luminousmonkey/jai-ts-mode.git ~/.emacs.d/site-lisp/jai-ts-mode
        
  2. Add the following to your Emacs configuration:
    (add-to-list 'load-path "~/.emacs.d/site-lisp/jai-ts-mode")
    (require 'jai-ts-mode)
        
  3. 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)
        

Usage

Files with the .jai extension will automatically open in jai-ts-mode.

Key Features

  • 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

Tree-sitter Grammar

This package depends on the Jai tree-sitter grammar by constantitus.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Tree-sitter based Emacs major mode for the Jai programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published