Skip to content

feat: defines a tree-sitter based Motoko mode for Emacs #5043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 15, 2025

Conversation

christoph-dfinity
Copy link
Contributor

Motivation

The existing motoko-model.el in this repo is based on swift-mode, which is a bit sad.

With Emacs 29+ we finally got built-in tree-sitter support, so now it's relatively easy to get nice syntax highlighting and auto-indentation behaviour. Most of the actual work was done by this grammar author: https://github.com/polychromatist/tree-sitter-motoko

This is pretty bare-bones, but I intend on adding a few rules here or there as I spot things that don't highlight or indent nicely.

Setup

Add this line to your config:

(load "/path/to/motoko-ts-mode.el")

and run treesit-install-language-grammar, pass motoko as the grammar name and https://github.com/christoph-dfinity/tree-sitter-motoko as the grammar repo. The remaining prompts can stay as defaults.

Afterwards opening .mo files should give you highlighted files with basic indentation support.

There are dozens of us

@christoph-dfinity christoph-dfinity requested a review from a team as a code owner April 15, 2025 04:17
@ggreif
Copy link
Contributor

ggreif commented Apr 15, 2025

I have GNU Emacs 29.2, very much welcoming this addition!

Copy link
Contributor

@ggreif ggreif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubber-stamping! I see a surprisingly small amount of code, but I'm happy to test it. (Looks like the grammar repo has the meat.)

@christoph-dfinity christoph-dfinity added the automerge-squash When ready, merge (using squash) label Apr 15, 2025
@christoph-dfinity christoph-dfinity force-pushed the christoph/emacs-motoko-ts-mode branch from e61ee69 to 41225a4 Compare April 15, 2025 06:19
Copy link

github-actions bot commented Apr 15, 2025

Comparing from b29193b to ebd2652:
The produced WebAssembly code seems to be completely unchanged.

@christoph-dfinity christoph-dfinity removed the request for review from crusso April 15, 2025 06:42
@ggreif
Copy link
Contributor

ggreif commented Apr 15, 2025

@Mergifyio refresh

Copy link
Contributor

mergify bot commented Apr 15, 2025

refresh

✅ Pull request refreshed

@crusso
Copy link
Contributor

crusso commented Apr 15, 2025

Good stuff!

@christoph-dfinity
Copy link
Contributor Author

@Mergifyio refresh

Copy link
Contributor

mergify bot commented Apr 15, 2025

refresh

✅ Pull request refreshed

@mergify mergify bot merged commit 229c0a5 into master Apr 15, 2025
17 checks passed
@mergify mergify bot deleted the christoph/emacs-motoko-ts-mode branch April 15, 2025 09:21
@mergify mergify bot removed the automerge-squash When ready, merge (using squash) label Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants