-
Notifications
You must be signed in to change notification settings - Fork 420
Micro
mart3323 edited this page Mar 13, 2025
·
1 revision
Micro (https://micro-editor.github.io/) is "a modern and intuitive terminal-based text editor"
To use micro, add it to your jj config as the ui.editor
$ jj config edit --user --config-toml 'ui-editor="micro"'
ui.editor = "micro"
# Alternatively, you can add it under the ui heading as follows
# [ui]
# editor = "micro"
Now, jj will open micro for editing change descriptions and configs
To get syntax highlighting, a custom syntax file needs to be added to micro
$ micro ~/.config/micro/syntax/jjdescription.yaml
filetype: jj-commit
detect:
filename: "(\\.(jjdescription)$)"
rules:
# Since jj v0.25.0, a `JJ: ignore-rest` line will comment out everything until the next describe block
- comment.block:
start: "^JJ: ignore-rest"
# Impl note: Cannot use lookaheads in micro, so to highlight describe at all, i need to match this series of dashes after it
# Assumption: The only lines ending in 7 dashes are the describe lines, and all describe lines will have dashes
# If this assumption is broken, the highlighting will become incorrect
end: " -------$"
rules:
- type.keyword: "describe [0-9a-f]{12}"
- diff-added: " A (.+)$"
- diff-modified: " M (.+)$"
- diff-deleted: " D (.+)$"
# Otherwise, every line starting with JJ: is also considered a comment on its own
- comment:
start: "JJ:"
end: "$"
rules:
- type.keyword: "describe [0-9a-f]{12}"
- diff-added: "^ A (.+)$"
- diff-modified: "^ M (.+)$"
- diff-deleted: "^ D (.+)$"
This syntax file is imperfect - it works fine for most cases, but the highlighting can break...:
- ...When using
JJ: ignore-rest
, if you have 7 dashes at the end of a different line other than theJJ: describe 0123456789ab -------
- ...When using
JJ: ignore-rest
, and the next describe line has been modified (dashes removed, extra spaces on the end, etc.)