Skip to content

Commit

Permalink
live templates
Browse files Browse the repository at this point in the history
  • Loading branch information
van800 committed Jan 10, 2024
1 parent 65cf4df commit d5b5776
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.jetbrains.rider.plugins.godot.textMate

import com.intellij.codeInsight.template.TemplateActionContext
import com.intellij.codeInsight.template.TemplateContextType

class GdScriptTemplateContextType : TemplateContextType("GdScript") {

override fun isInContext(context: TemplateActionContext): Boolean =
context.editor?.virtualFile?.extension.equals("gd", true);

}
2 changes: 2 additions & 0 deletions rider/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</extensions>

<extensions defaultExtensionNs="com.intellij">
<liveTemplateContext contextId="GDSCRIPT" implementation="com.jetbrains.rider.plugins.godot.textMate.GdScriptTemplateContextType" order="first" />
<defaultLiveTemplates file="templates/GdScript.xml" />

<postStartupActivity implementation="com.jetbrains.rider.plugins.godot.MetadataMonoFileWatcher"/>
<postStartupActivity implementation="com.jetbrains.rider.plugins.godot.MetadataCoreFileWatcher"/>
Expand Down
74 changes: 74 additions & 0 deletions rider/src/main/resources/templates/GdScript.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<templateSet group="GDScript">

<template name="for" value="for $VAR$ in $ITERABLE$:&#10;&#9;$END$" description="for loop" toReformat="false">
<variable name="ITERABLE" expression="" alwaysStopAt="true" />
<variable name="VAR" expression="" alwaysStopAt="true" />
<context>
<option name="GDSCRIPT" value="true" />
</context>
</template>
<template name="forrange" value="for $VAR$ in range($RANGE_START$, $RANGE_END$):&#10;&#9;$END$"
description="for range loop" toReformat="false">
<variable name="RANGE_START" alwaysStopAt="true" />
<variable name="RANGE_END" alwaysStopAt="true" />
<variable name="VAR" alwaysStopAt="true" />
<context>
<option name="GDSCRIPT" value="true" />
</context>
</template>
<template name="while" value="while $CONDITION$:&#10;&#9;$END$" description="while">
<variable name="CONDITION" expression="condition()" defaultValue="expr" alwaysStopAt="true" />
<context>
<option name="GDSCRIPT" value="true" />
</context>
</template>
<template name="if" value="if $CONDITION$:&#10;&#9;$END$" description="if" toReformat="false">
<variable name="CONDITION" expression="" defaultValue="expr" alwaysStopAt="true" />
<context>
<option name="GDSCRIPT" value="true"/>
</context>
</template>

<!-- <template name="Inner class" value="class $1 extends ${2:Reference}&#10;&#9;$3" description="Inner class"/>-->
<!-- <template name="Print messages to console" value="print($1)" description="Print messages to console"/>-->
<!-- <template name="_ready method of Node" value="func _ready():&#10;&#9;${1:pass}" description="_ready method of Node"/>-->
<!-- <template name="_init method of Object" value="func _init():&#10;&#9;${1:pass}" description="_init method of Object"/>-->
<!-- <template name="_process method of Node" value="func _process(delta):&#10;&#9;${1:pass}"-->
<!-- description="_process method of Node"/>-->
<!-- <template name="_physics_process method of Node" value="func _physics_process(delta):&#10;&#9;${1:pass}"-->
<!-- description="_physics_process method of Node"/>-->
<!-- <template name="_input method of Node" value="func _input(event):&#10;&#9;${1:pass}"-->
<!-- description="_input method of Node"/>-->
<!-- <template name="_input_event method of Node" value="func _input_event(event):&#10;&#9;${1:pass}"-->
<!-- description="_input_event method of Node"/>-->
<!-- <template name="_unhandled_input method of Node" value="func _unhandled_input(event):&#10;&#9;${1:pass}"-->
<!-- description="_unhandled_input method of Node"/>-->
<!-- <template name="_draw method of Node" value="func _draw():&#10;&#9;${1:pass}" description="_draw method of Node"/>-->
<!-- <template name="_gui_input method of Node" value="func _gui_input(event):&#10;&#9;${1:pass}"-->
<!-- description="_gui_input method of Node"/>-->
<!-- <template name="if elif else"-->
<!-- value="if ${1:condition}:&#10;&#9;${3:pass}&#10;elif ${2:condition}:&#10;&#9;${4:pass}&#10;else:&#10;&#9;${5:pass}"-->
<!-- description="if elif else"/>-->
<!-- <template name="if else" value="if ${1:condition}:&#10;&#9;${2:pass}&#10;else:&#10;&#9;${3:pass}"-->
<!-- description="if else"/>-->
<!-- <template name="if" value="if ${1:condition}:&#10;&#9;${2:pass}" description="if"/>-->
<!-- <template name="function define" value="func ${1:method}(${2:args}):&#10;&#9;${3:pass}"-->
<!-- description="function define"/>-->
<!-- <template name="match"-->
<!-- value="match ${1:expression}:&#10;&#9;${2:pattern}:&#10;&#9;&#9;${3}&#10;\t_:\n\t\t${0:default}"-->
<!-- description="match"/>-->
<!-- <template name="signal declaration" value="signal ${1:signalname}(${2:args})" description="signal declaration"/>-->
<!-- <template name="export variables"-->
<!-- value="export(${1:type}${2:,other_configs}) var ${3:name}${4: = default}${5: setget }"-->
<!-- description="export variables"/>-->
<!-- <template name="define variables" value="var ${1:name}${2: = default}${3: setget }" description="define variables"/>-->
<!-- <template name="define onready variables" value="onready var ${1:name} = get_node($2)"-->
<!-- description="define onready variables"/>-->
<!-- <template name="Is instance of a class or script" value="${1:instance} is ${2:class}"-->
<!-- description="Is instance of a class or script"/>-->
<!-- <template name="element in array" value="${1:element} in ${$2:array}" description="element in array"/>-->
<!-- <template name="GDScript template"-->
<!-- value="extends ${1:BaseClass}&#10;&#10;# class member variables go here, for example:&#10;# var a = 2&#10;# var b = &quot;textvar&quot;&#10;&#10;func _ready():&#10;&#9;# Called every time the node is added to the scene.&#10;&#9;# Initialization here&#10;&#9;pass&#10;"-->
<!-- description="GDScript template"/>-->
<!-- <template name="pass statement" value="pass" description="pass statement"/>-->
</templateSet>

0 comments on commit d5b5776

Please sign in to comment.