Skip to content
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

Support syntax highlighting in _ren.py files #343

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: PR Check

on:
pull_request:
types: [synchronize, opened, reopened, edited]
branches:
- master
- develop
Expand Down
17 changes: 17 additions & 0 deletions examples/test_ren.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is not included in the game. It's here so that an editor knows
# the type of strength.
strength = 100

"""renpy
init python:
"""

class BoostStrength(Action):
"""
Boosts the strength of the player by 10.
"""

def __call__(self):
global strength
strength += 10
renpy.restart_interaction()
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
},
"activationEvents": [
"onLanguage:renpy",
"workspaceContains:**/*.rpy"
"workspaceContains:**/*.rpy",
"workspaceContains:**/_ren.py"
],
"main": "./dist/extension",
"browser": "./dist/extension.js",
Expand All @@ -46,7 +47,8 @@
"id": "renpy",
"aliases": [
"Ren'Py",
"renpy"
"renpy",
"rpy"
],
"extensions": [
".rpy",
Expand Down Expand Up @@ -88,6 +90,16 @@
"scopeName": "source.renpy.python",
"path": "./syntaxes/renpy.python.tmLanguage.json"
},
{
"scopeName": "renpy.comment.injection",
"path": "./syntaxes/injection.json",
"injectTo": [
"source.python"
],
"embeddedLanguages": {
"meta.embedded.renpy": "renpy"
}
},
{
"language": "renpy-log",
"scopeName": "text.renpy-log",
Expand Down
26 changes: 26 additions & 0 deletions syntaxes/injection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"scopeName": "renpy.comment.injection",
"injectionSelector": "L:string.quoted.docstring",
"patterns": [
{
"include": "#renpy-source"
}
],
"repository": {
"renpy-source": {
"contentName": "meta.embedded.renpy",
"begin": "(?<=^\\\"\\\"\\\")renpy",
"beginCaptures": {
"0": {
"name": "keyword.renpy"
}
},
"end": "(?=^\\\"\\\"\\\")",
"patterns": [
{
"include": "source.renpy"
}
]
}
}
}