Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 

Repository files navigation

MAJOR-mode for ObjectScript in EMACs

This is a major-mode for editing .cls files in ObjectScript using treesitter.

Preliminaries

  1. Emacs Version: You will need Emacs version 29.1 or greater. This version should ship with tree-sitter, but you will need to install it if it is missing.

  2. Get objectscript-major-mode. You'll need to download our major mode for emacs here: https://github.com/intersystems/emacs-objectscript-ts-mode.git

  3. Tree-sitter Library Files: You need the library files generated by tree-sitter-objectscript. You can configure Emacs to fetch these automatically from the repository.

    • Add the ObjectScript languages to treesit-language-source-alist. This tells tree-sitter where to find the parser source files. Run the following Elisp for each required language (objectscript, objectscript_core, and objectscript_expr).

      For udl:

      (add-to-list 'treesit-language-source-alist
           '(objectscript . ("https://github.com/intersystems/tree-sitter-objectscript.git"
                             "main" "udl/src")))

You can also add the languages to the alist directly in your configuration file. This should compile the language into a .SO/.dylib (depending on your operating) file which EMACS treesitter uses for its parsing.

  1. Additional Grammars: If you plan to write embedded Python, Java, or JavaScript within .cls files and want syntax highlighting, you will also need their respective tree-sitter grammars. You can install these using the treesit-install-language-grammar command, as they are officially supported.

  2. Install Grammars: After configuring the sources, run the command M-x treesit-install-language-grammar for each of the following grammars:

    • objectscript
    • objectscript_core
    • objectscript_expr

    This will compile and install the grammars, making them available to the tree-sitter parser.

Installation

Once the preliminary steps are complete, installing the major-mode file is straightforward.

  1. Place the objectscript_udl-ts-mode.el file in your Emacs lisp/progmodes/ directory and append .gz to the end so EMACS can read it properly. (Note: MELPA support coming soon so this step will be unnecessary). The location of this directory can vary based on your setup:

    • macOS: /Applications/Emacs.app/Contents/Resources/lisp/progmodes/
    • Windows/Linux: The path may differ.
  2. With the file in place, you can now open a relevant file and enable the major-mode by running M-x objectscript_udl-ts-mode.

Default Configuration

To make this major-mode the default for all .cls files, add the following two lines to your init.el file:

(autoload 'objectscript_udl-ts-mode "/Applications/Emacs.app/Contents/Resources/lisp/progmodes/objectscript_udl-ts-mode.el.gz" "A major mode for objectscript." t)
(add-to-list 'auto-mode-alist '("\\.cls\\'" . objectscript_udl-ts-mode))

This configuration will ensure that objectscript_udl-ts-mode is automatically activated when you open a .cls file, overriding the default mode for LaTeX files which can also use the .cls extension.

License

This project provided as-is and is licensed under the MIT License.

About

A tree-sitter based Emacs major mode for InterSystems ObjectScript

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages