Skip to content

Commit

Permalink
feat: Trying some TextMate Grammar for JBang directives
Browse files Browse the repository at this point in the history
I have no idea what I'm doing. It'ts most likely wrong, certainly suboptimal, but looks half decent in java files
Can't figure out how to enable it properly in build.jbang files though.

Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon committed Feb 26, 2024
1 parent 3c8ac36 commit cc46dca
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "JBang",
"scopeName": "source.jbang",
"name": "Build JBang",
"scopeName": "source.build.jbang",
"patterns": [
{
"comment": "source.java is defined in https://github.com/microsoft/vscode/blob/main/extensions/java/syntaxes/java.tmLanguage.json",
"include": "source.java"
},
{
"include": "inline.jbang"
}
],
"uuid": "b67884ea-cc0a-4f99-b680-7ee7c3bb04d8"
]
}
25 changes: 25 additions & 0 deletions language-support/inline-jbang.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "jbang",
"scopeName": "inline.jbang",
"injectionSelector": "L:source.java -comment -string",
"patterns": [
{
"contentName": "meta.embedded.block.jbang",
"match": "^(//)(DEPS|JAVA|MAIN|FILES|SOURCES|PREVIEW|MODULE|DESCRIPTION|GAV|COMPILE_OPTIONS|JAVAC_OPTIONS|RUNTIME_OPTIONS|JAVA_OPTIONS|NATIVE_OPTIONS|REPOS|MANIFEST|CDS|KOTLIN|GROOVY|JAVAAGENT)\\s+(.*)$",
"captures": {
"0":{
"name":"directive.jbang"
},
"1":{
"name":"comment.line.double-slash.java"
},
"2": {
"name": "keyword.directive.jbang"
},
"3": {
"name": "string.directive.jbang"
}
}
}
]
}
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,18 @@
"grammars": [
{
"language": "jbang",
"scopeName": "source.jbang",
"path": "./language-support/jbang.tmLanguage.json"
"scopeName": "source.build.jbang",
"path": "./language-support/build.jbang.tmLanguage.json"
},
{
"injectTo": [
"source.java"
],
"scopeName": "inline.jbang",
"path": "./language-support/inline-jbang.tmLanguage.json",
"embeddedLanguages": {
"meta.embedded.block.jbang": "jbang"
}
}
],
"javaExtensions": [
Expand Down

0 comments on commit cc46dca

Please sign in to comment.