-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add Djot support #12562
Open
mmibbetson
wants to merge
6
commits into
helix-editor:master
Choose a base branch
from
mmibbetson:djot-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Djot support #12562
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5b26d79
feat: add language.toml entry for djot
mmibbetson 3287530
feat: add highlights for djot
mmibbetson 6e2f42f
feat: add injections for djot
mmibbetson db95764
docs: run cargo xtask docgen for djot entry
mmibbetson a4722b5
feat: add latex highlighting for math and fix inline code highlighting
mmibbetson d8a87af
refactor: adjust term highlighting to use the constructor scope
mmibbetson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,311 @@ | ||
[ | ||
(footnote_marker_begin) | ||
(footnote_marker_end) | ||
] @punctuation.bracket | ||
|
||
(footnote_reference (reference_label) @markup.link.label) | ||
|
||
(footnote (reference_label) @markup.link.label) | ||
|
||
[ | ||
(autolink) | ||
(inline_link_destination) | ||
(link_destination) | ||
] @markup.link.url | ||
|
||
(link_reference_definition (link_label) @markup.link.label) | ||
|
||
(link_reference_definition | ||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(image_description | ||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(image_description) @label | ||
|
||
(inline_image | ||
[ | ||
"![" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(collapsed_reference_image | ||
[ | ||
"![" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(collapsed_reference_image "[]" @punctuation.bracket) | ||
|
||
(full_reference_image | ||
[ | ||
"![" | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(full_reference_image (link_label) @markup.link.label) | ||
|
||
(inline_link (link_text) @markup.link.text) | ||
|
||
(collapsed_reference_link (link_text) @markup.link.text) | ||
|
||
(full_reference_link | ||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(collapsed_reference_link "[]" @punctuation.bracket) | ||
|
||
(full_reference_link (link_label) @markup.link.label) | ||
|
||
(full_reference_link (link_text) @markup.link.text) | ||
|
||
(link_reference_definition ":" @punctuation.delimiter) | ||
|
||
(inline_link_destination | ||
[ | ||
"(" | ||
")" | ||
] @punctuation.bracket) | ||
|
||
(autolink | ||
[ | ||
"<" | ||
">" | ||
] @punctuation.bracket) | ||
|
||
(link_text | ||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(key_value (value) @string) | ||
|
||
(key_value (key) @attribute) | ||
|
||
(key_value "=" @operator) | ||
|
||
; NOTE: Not perfectly semantically accurate, but a fair approximation. | ||
(identifier) @string.special.symbol | ||
|
||
[ | ||
(class) | ||
(class_name) | ||
] @type | ||
|
||
(block_attribute | ||
[ | ||
"{" | ||
"}" | ||
] @punctuation.bracket) | ||
|
||
(inline_attribute | ||
[ | ||
"{" | ||
"}" | ||
] @punctuation.bracket) | ||
|
||
(span | ||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket) | ||
|
||
(comment | ||
[ | ||
"{" | ||
"}" | ||
"%" | ||
] @comment.block) | ||
|
||
; INFO: djot only has block-scoped comments. | ||
(comment) @comment.block | ||
|
||
(raw_inline) @markup.raw | ||
|
||
(verbatim) @markup.raw | ||
|
||
(math) @markup.raw | ||
|
||
([ | ||
(emphasis_begin) | ||
(emphasis_end) | ||
(strong_begin) | ||
(strong_end) | ||
(verbatim_marker_begin) | ||
(verbatim_marker_end) | ||
(math_marker) | ||
(math_marker_begin) | ||
(math_marker_end) | ||
(raw_inline_attribute) | ||
(raw_inline_marker_begin) | ||
(raw_inline_marker_end) | ||
] @punctuation.bracket) | ||
|
||
(subscript | ||
[ | ||
"~" | ||
"{~" | ||
"~}" | ||
] @punctuation.bracket) | ||
|
||
(superscript | ||
[ | ||
"^" | ||
"{^" | ||
"^}" | ||
] @punctuation.bracket) | ||
|
||
(delete | ||
[ | ||
"{-" | ||
"-}" | ||
] @punctuation.bracket) | ||
|
||
(insert | ||
[ | ||
"{+" | ||
"+}" | ||
] @punctuation.bracket) | ||
|
||
; NOTE: We need to target tokens specifically because `{=` etc can exist as fallback symbols in | ||
; regular text, which we don't want to highlight or conceal. | ||
(highlighted | ||
[ | ||
"{=" | ||
"=}" | ||
] @punctuation.bracket) | ||
|
||
; TEMP: Scope not available, with no appropriate alternative. | ||
(subscript) @markup.subscript | ||
|
||
; TEMP: Scope not available, with no appropriate alternative. | ||
(superscript) @markup.superscript | ||
|
||
; TEMP: Scope not available, with no appropriate alternative. | ||
(highlighted) @markup.highlighted | ||
|
||
; TEMP: Scope not available, with no appropriate alternative. | ||
(insert) @markup.insert | ||
|
||
(delete) @markup.strikethrough | ||
|
||
; INFO: This applies to emojis. | ||
(symbol) @string.special.symbol | ||
|
||
(strong) @markup.bold | ||
|
||
(emphasis) @markup.italic | ||
|
||
(backslash_escape) @constant.character.escape | ||
|
||
(hard_line_break) @constant.character.escape | ||
|
||
((quotation_marks) @constant.character.escape | ||
(#any-of? @constant.character.escape "\\\"" "\\'")) | ||
|
||
; NOTE: Opting for this over the @punctuation.bracket used for things like | ||
; {-delete-} to emphasise the semantic significance of specified opening/closing | ||
; quotation marks. | ||
(quotation_marks) @markup.quote | ||
|
||
; INFO: `term` only matches on definition list items -- other list items won't be highlighted. | ||
(list_item (term) @constructor) | ||
|
||
[ | ||
(ellipsis) | ||
(en_dash) | ||
(em_dash) | ||
] @punctuation.special | ||
|
||
(checked | ||
[ | ||
"x" | ||
"X" | ||
] @constant.builtin.boolean) @markup.list.checked | ||
|
||
(list_marker_task (checked)) @markup.list.checked | ||
|
||
(list_marker_task (unchecked)) @markup.list.unchecked | ||
|
||
[ | ||
(list_marker_decimal_period) | ||
(list_marker_decimal_paren) | ||
(list_marker_decimal_parens) | ||
(list_marker_lower_alpha_period) | ||
(list_marker_lower_alpha_paren) | ||
(list_marker_lower_alpha_parens) | ||
(list_marker_upper_alpha_period) | ||
(list_marker_upper_alpha_paren) | ||
(list_marker_upper_alpha_parens) | ||
(list_marker_lower_roman_period) | ||
(list_marker_lower_roman_paren) | ||
(list_marker_lower_roman_parens) | ||
(list_marker_upper_roman_period) | ||
(list_marker_upper_roman_paren) | ||
(list_marker_upper_roman_parens) | ||
] @markup.list.numbered | ||
|
||
[ | ||
(list_marker_dash) | ||
(list_marker_plus) | ||
(list_marker_star) | ||
(list_marker_definition) | ||
] @markup.list.unnumbered | ||
|
||
(table_caption) @label | ||
|
||
(table_caption (marker) @punctuation.special) | ||
|
||
(table_separator) @punctuation.special | ||
|
||
(table_row "|" @punctuation.special) | ||
|
||
(table_header "|" @punctuation.special) | ||
|
||
(table_header) @markup.heading | ||
|
||
(block_quote) @markup.quote | ||
|
||
(block_quote_marker) @markup.quote | ||
|
||
(language_marker) @punctuation.delimiter | ||
|
||
(inline_attribute _ @attribute) | ||
|
||
(language) @type.enum.variant | ||
|
||
[ | ||
(code_block_marker_begin) | ||
(code_block_marker_end) | ||
(raw_block_marker_begin) | ||
(raw_block_marker_end) | ||
] @punctuation.bracket | ||
|
||
[ | ||
(code_block) | ||
(raw_block) | ||
] @markup.raw.block | ||
|
||
[ | ||
(div_marker_begin) | ||
(div_marker_end) | ||
] @tag | ||
|
||
(thematic_break) @special | ||
|
||
(heading1 (marker) @markup.heading.marker) @markup.heading.1 | ||
(heading2 (marker) @markup.heading.marker) @markup.heading.2 | ||
(heading3 (marker) @markup.heading.marker) @markup.heading.3 | ||
(heading4 (marker) @markup.heading.marker) @markup.heading.4 | ||
(heading5 (marker) @markup.heading.marker) @markup.heading.5 | ||
(heading6 (marker) @markup.heading.marker) @markup.heading.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(comment (content) @injection.content | ||
(#set! injection.language "comment")) | ||
|
||
(math (content) @injection.content | ||
(#set! injection.language "latex") (#set! injection.include-unnamed-children)) | ||
|
||
(code_block | ||
(language) @injection.language | ||
(code) @injection.content (#set! injection.include-unnamed-children)) | ||
|
||
(raw_block | ||
(raw_block_info | ||
(language) @injection.language) | ||
(content) @injection.content (#set! injection.include-unnamed-children)) | ||
|
||
(raw_inline | ||
(content) @injection.content (#set! injection.include-unnamed-children) | ||
(raw_inline_attribute | ||
(language) @injection.language)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally okay with
variable
orvariable.other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a few things for identifiers and found that using more accurate scopes like
type
orattribute
often made them indistinct from classes. Looking atvariable
andvariable.other
, there are a few themes where this looks nice but many of them have variables un-highlighted which kind of buries the identifiers by making them look like everything else.My reasoning for using
string.special.symbol
was to at least emphasise the idea that there is only one instance of this thing 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understandable! However usually themes set the
variable
to a color because of their own specific reasons, and it's always a toss-up if somebody prefers semantics over UX.I don't have any strong preference here, I'm already glad this PR is up!