Skip to content

Made it work the way it works with other languages. (Edited module.exports) #10

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

Merged
merged 2 commits into from
May 11, 2025
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
2 changes: 1 addition & 1 deletion dist/gdscript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 34 additions & 42 deletions src/languages/gdscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,65 @@ Author: Khairul Hidayat <me@khairul.my.id>, Nelson Sylvest*r Fritsch <info@nelso
Description: Programming language for Godot Engine
*/

var module = module ? module : {}; // shim for browser use

function hljsDefineGDScript(hljs) {
function GDScript(hljs) {
var KEYWORDS = {
keyword:
'and in not or self void as assert breakpoint class class_name ' +
'extends is func setget signal tool yield const enum export ' +
'onready static var break continue if elif else for pass return ' +
'match while remote sync master puppet remotesync mastersync ' +
'puppetsync',
"and in not or self void as assert breakpoint class class_name " +
"extends is func setget signal tool yield const enum export " +
"onready static var break continue if elif else for pass return " +
"match while remote sync master puppet remotesync mastersync " +
"puppetsync",

built_in:
'Color8 ColorN abs acos asin atan atan2 bytes2var ' +
'cartesian2polar ceil char clamp convert cos cosh db2linear ' +
'decimals dectime deg2rad dict2inst ease exp floor fmod fposmod ' +
'funcref get_stack hash inst2dict instance_from_id inverse_lerp ' +
'is_equal_approx is_inf is_instance_valid is_nan is_zero_approx ' +
'len lerp lerp_angle linear2db load log max min move_toward ' +
'nearest_po2 ord parse_json polar2cartesian posmod pow preload ' +
'print_stack push_error push_warning rad2deg rand_range ' +
'rand_seed randf randi randomize range_lerp round seed sign sin ' +
'sinh smoothstep sqrt step_decimals stepify str str2var tan tanh ' +
'to_json type_exists typeof validate_json var2bytes var2str ' +
'weakref wrapf wrapi bool int float String NodePath ' +
'Vector2 Rect2 Transform2D Vector3 Rect3 Plane ' +
'Quat Basis Transform Color RID Object NodePath ' +
'Dictionary Array PoolByteArray PoolIntArray ' +
'PoolRealArray PoolStringArray PoolVector2Array ' +
'PoolVector3Array PoolColorArray',
"Color8 ColorN abs acos asin atan atan2 bytes2var " +
"cartesian2polar ceil char clamp convert cos cosh db2linear " +
"decimals dectime deg2rad dict2inst ease exp floor fmod fposmod " +
"funcref get_stack hash inst2dict instance_from_id inverse_lerp " +
"is_equal_approx is_inf is_instance_valid is_nan is_zero_approx " +
"len lerp lerp_angle linear2db load log max min move_toward " +
"nearest_po2 ord parse_json polar2cartesian posmod pow preload " +
"print_stack push_error push_warning rad2deg rand_range " +
"rand_seed randf randi randomize range_lerp round seed sign sin " +
"sinh smoothstep sqrt step_decimals stepify str str2var tan tanh " +
"to_json type_exists typeof validate_json var2bytes var2str " +
"weakref wrapf wrapi bool int float String NodePath " +
"Vector2 Rect2 Transform2D Vector3 Rect3 Plane " +
"Quat Basis Transform Color RID Object NodePath " +
"Dictionary Array PoolByteArray PoolIntArray " +
"PoolRealArray PoolStringArray PoolVector2Array " +
"PoolVector3Array PoolColorArray",

literal:
'true false null'
literal: "true false null"
};

return {
aliases: ['godot', 'gdscript'],
aliases: ["godot", "gdscript"],
keywords: KEYWORDS,
contains: [
hljs.NUMBER_MODE,
hljs.HASH_COMMENT_MODE,
{
className: 'comment',
begin: /"""/, end: /"""/
className: "comment",
begin: /"""/,
end: /"""/
},
hljs.QUOTE_STRING_MODE,
{
variants: [
{
className: 'function',
beginKeywords: 'func'
className: "function",
beginKeywords: "func"
},
{
className: 'class',
beginKeywords: 'class'
className: "class",
beginKeywords: "class"
}
],
end: /:/,
contains: [
hljs.UNDERSCORE_TITLE_MODE
]
contains: [hljs.UNDERSCORE_TITLE_MODE]
}
]
};
}

module.exports = function(hljs) {
hljs.registerLanguage('gdscript', hljsDefineGDScript);
};

module.exports.definer = hljsDefineGDScript;
module.exports = GDScript;