-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add syntax highlighting for Moonscript #4229
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
Open
darltrash
wants to merge
1
commit into
micro-editor:master
Choose a base branch
from
darltrash:master
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.
+80
−0
Open
Changes from all commits
Commits
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 hidden or 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,80 @@ | ||
| filetype: moonscript | ||
|
|
||
| detect: | ||
| filename: "\\.moon$" | ||
|
|
||
| rules: | ||
| # Block comments like --[[ ... ]] | ||
| - comment: | ||
| start: "--\\[\\[" | ||
| end: "\\]\\]" | ||
| rules: [] | ||
|
|
||
| # Line comments like -- ... | ||
| - comment: | ||
| start: "--" | ||
| end: "$" | ||
| rules: [] | ||
|
|
||
| # Long bracket strings like [[ ... ]] or [==[ ... ]==] | ||
| - constant.string: | ||
| start: "\\[=*\\[" | ||
| end: "\\]=*\\]" | ||
| rules: [] | ||
|
|
||
| # Double-quoted strings (with #{} interpolation and escapes) | ||
| - constant.string: | ||
| start: "\"" | ||
| end: "\"" | ||
| skip: "\\\\." | ||
| rules: | ||
| - constant.specialChar: "\\\\." | ||
| - default: | ||
| start: "#\\{" | ||
| end: "\\}" | ||
| rules: [] | ||
|
Comment on lines
+32
to
+35
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| # Single-quoted strings (no interpolation, but escapes still work) | ||
| - constant.string: | ||
| start: "'" | ||
| end: "'" | ||
| skip: "\\\\." | ||
| rules: | ||
| - constant.specialChar: "\\\\." | ||
|
|
||
| # Numbers (int, float, hex, scientific notation) | ||
| - constant.number: "\\b(0x[0-9a-fA-F]+|[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?|\\.[0-9]+)\\b" | ||
|
|
||
| # Booleans, nil | ||
| - constant.bool: "\\b(true|false|nil)\\b" | ||
|
|
||
| # self, @ references | ||
| # (using "special" instead of "identifier.var" since most colorschemes | ||
| # define a distinct color for "special" but leave subgroups like | ||
| # "identifier.var" to fall back to plain "identifier") | ||
| - special: "@@?[A-Za-z_][A-Za-z0-9_]*" | ||
| - special: "\\bself\\b" | ||
|
|
||
| # Keywords, control flow | ||
| - statement: "\\b(if|then|else|elseif|unless|switch|when|for|while|until|do|in|and|or|not|return|break|continue|export|import|from|local|using|with)\\b" | ||
|
|
||
| # Class-related keywords | ||
| - statement: "\\b(class|extends|super|new)\\b" | ||
|
|
||
| # Function definition arrows | ||
| - statement: "(->|=>)" | ||
|
|
||
| # Table, class member access | ||
| - identifier: "\\.[A-Za-z_][A-Za-z0-9_]*" | ||
|
|
||
| # Function calls: name(...) | ||
| - identifier: "[A-Za-z_][A-Za-z0-9_]*\\(" | ||
|
|
||
| # Table key shorthand, e.g. `key:` in table literals, includes the colon | ||
| - identifier: "\\b[A-Za-z_][A-Za-z0-9_]*:" | ||
|
|
||
| # Operators and punctuation | ||
| - symbol.operator: "(\\+|-|\\*|/|%|\\^|#|==|~=|<=|>=|<|>|=|:|\\\\|\\.\\.\\.?|::|!)" | ||
|
|
||
| # Braces, brackets, parens | ||
| - symbol.brackets: "[{}()\\[\\]]" | ||
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.
This would work better as separate rules for
[[ ... ]]and[==[ ... ]==]. I assume the main reason to use[==[ ... ]==]is to include]]somewhere inside so you don't want that to end the string.