Skip to content

Commit 1851cfa

Browse files
committed
Update to Godot 4 and highlight.js 11
Note that I couldn't get the ES module build to work in the browser, so maybe we should remove it.
1 parent 4b584e9 commit 1851cfa

File tree

4 files changed

+148
-55
lines changed

4 files changed

+148
-55
lines changed

dist/gdscript.es.min.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gdscript.min.js

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
22
"name": "highlightjs-gdscript",
3-
"version": "0.0.1",
3+
"version": "1.0.0",
44
"description": "highlight.js syntax definition for Godot's GDScript language",
55
"main": "src/languages/gdscript.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
9-
"repository": {
10-
"type": "git",
11-
"url": "git+ssh://[email protected]/form-follows-function/highlightjs-gdscript.git"
12-
},
139
"keywords": [
1410
"Godot",
1511
"GDScript",
@@ -20,7 +16,7 @@
2016
"author": "form-follows-function",
2117
"license": "MIT",
2218
"bugs": {
23-
"url": "https://github.com/form-follows-function/highlightjs-gdscript/issues"
19+
"url": "https://github.com/highlightjs/highlightjs-gdscript/issues"
2420
},
25-
"homepage": "https://github.com/form-follows-function/highlightjs-gdscript#readme"
21+
"homepage": "https://github.com/highlightjs/highlightjs-gdscript#readme"
2622
}

src/languages/gdscript.js

Lines changed: 107 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,128 @@
11
/*
22
Language: GDScript
3-
Author: Khairul Hidayat <[email protected]>, Nelson Sylvest*r Fritsch <[email protected]>, Hugo Locurcio <[email protected]>
4-
Description: Programming language for Godot Engine
3+
Author: Hugo Locurcio <[email protected]>, Khairul Hidayat <[email protected]>, Nelson Sylvest*r Fritsch <[email protected]>
4+
Description: Programming language for Godot Engine (supports Godot 4.x and 3.x)
55
*/
66

7-
function GDScript(hljs) {
8-
var KEYWORDS = {
9-
keyword:
10-
"and in not or self void as assert breakpoint class class_name " +
11-
"extends is func setget signal tool yield const enum export " +
12-
"onready static var break continue if elif else for pass return " +
13-
"match while remote sync master puppet remotesync mastersync " +
14-
"puppetsync",
7+
module.exports = function(hljs) {
8+
return {
9+
aliases: ['gdscript', 'godot'],
10+
keywords: {
11+
keyword:
12+
'class class_name const enum extends func namespace signal static ' +
13+
'trait var await breakpoint yield set get and in not or void as ' +
14+
'assert tool export onready break continue if elif else for pass ' +
15+
'return match when while remote sync master puppet remotesync ' +
16+
'mastersync puppetsync',
1517

16-
built_in:
17-
"Color8 ColorN abs acos asin atan atan2 bytes2var " +
18-
"cartesian2polar ceil char clamp convert cos cosh db2linear " +
19-
"decimals dectime deg2rad dict2inst ease exp floor fmod fposmod " +
20-
"funcref get_stack hash inst2dict instance_from_id inverse_lerp " +
21-
"is_equal_approx is_inf is_instance_valid is_nan is_zero_approx " +
22-
"len lerp lerp_angle linear2db load log max min move_toward " +
23-
"nearest_po2 ord parse_json polar2cartesian posmod pow preload " +
24-
"print_stack push_error push_warning rad2deg rand_range " +
25-
"rand_seed randf randi randomize range_lerp round seed sign sin " +
26-
"sinh smoothstep sqrt step_decimals stepify str str2var tan tanh " +
27-
"to_json type_exists typeof validate_json var2bytes var2str " +
28-
"weakref wrapf wrapi bool int float String NodePath " +
29-
"Vector2 Rect2 Transform2D Vector3 Rect3 Plane " +
30-
"Quat Basis Transform Color RID Object NodePath " +
31-
"Dictionary Array PoolByteArray PoolIntArray " +
32-
"PoolRealArray PoolStringArray PoolVector2Array " +
33-
"PoolVector3Array PoolColorArray",
18+
built_in:
19+
'abs absf absi acos acosh angle_difference asin asinh atan atan2 ' +
20+
'atanh bezier_derivative bezier_interpolate bytes_to_var ' +
21+
'bytes_to_var_with_objects ceil ceilf ceili clamp clampf clampi ' +
22+
'cos cosh cubic_interpolate cubic_interpolate_angle ' +
23+
'cubic_interpolate_angle_in_time cubic_interpolate_in_time ' +
24+
'db_to_linear deg_to_rad ease error_string exp floor floorf ' +
25+
'floori fmod fposmod hash instance_from_id inverse_lerp ' +
26+
'is_equal_approx is_finite is_inf is_instance_id_valid ' +
27+
'is_instance_valid is_nan is_same is_zero_approx lerp lerp_angle ' +
28+
'lerpf linear_to_db log max maxf maxi min minf mini move_toward ' +
29+
'nearest_po2 pingpong posmod pow print print_rich print_verbose ' +
30+
'printerr printraw prints printt push_error push_warning ' +
31+
'rad_to_deg rand_from_seed randf randf_range randfn randi ' +
32+
'randi_range randomize remap rid_allocate_id rid_from_int64 ' +
33+
'rotate_toward round roundf roundi seed sign signf signi sin sinh ' +
34+
'smoothstep snapped snappedf snappedi sqrt step_decimals str ' +
35+
'str_to_var tan tanh type_convert type_string typeof var_to_bytes ' +
36+
'var_to_bytes_with_objects var_to_str weakref wrap wrapf wrapi ' +
37+
'Color8 assert char convert dict_to_inst get_stack inst_to_dict ' +
38+
'is_instance_of len load preload print_debug print_stack range ' +
39+
'type_exists',
3440

35-
literal: "true false null"
36-
};
41+
type:
42+
'bool int float String Vector2 Vector2i Rect2 Rect2i Transform2D ' +
43+
'Vector3 Vector3i Vector4 Vector4i Plane AABB Quaternion Basis ' +
44+
'Transform3D Projection Color RID Object Callable Signal ' +
45+
'StringName NodePath Dictionary Array PackedByteArray ' +
46+
'PackedInt32Array PackedInt64Array PackedFloat32Array ' +
47+
'PackedFloat64Array PackedStringArray PackedVector2Array ' +
48+
'PackedVector3Array PackedColorArray PackedVector4Array Variant ' +
49+
'void',
3750

38-
return {
39-
aliases: ["godot", "gdscript"],
40-
keywords: KEYWORDS,
51+
52+
'char.escape':
53+
'\\n \\t \\r \\a \\b \\f \\v \\" \\\' \\\\ ' +
54+
'\\u{[0-9a-fA-F]{1,4}} \\U{[0-9a-fA-F]{1,6}}',
55+
56+
'variable.language': 'self super',
57+
'variable.constant': 'PI TAU INF NAN',
58+
59+
literal: 'true false null',
60+
},
4161
contains: [
4262
hljs.NUMBER_MODE,
43-
hljs.HASH_COMMENT_MODE,
4463
{
45-
className: "comment",
64+
className: 'string',
4665
begin: /"""/,
47-
end: /"""/
66+
end: /"""/,
67+
},
68+
{
69+
className: 'string',
70+
begin: /'''/,
71+
end: /'''/,
4872
},
73+
{
74+
className: 'meta',
75+
begin: /#(end)?region/,
76+
end: /\n/,
77+
},
78+
hljs.COMMENT(
79+
'#',
80+
'$',
81+
{
82+
contains: [
83+
{
84+
className: 'doctag',
85+
begin: '@(tutorial|deprecated|experimental)+',
86+
end: /$/,
87+
},
88+
],
89+
},
90+
),
4991
hljs.QUOTE_STRING_MODE,
5092
{
5193
variants: [
5294
{
53-
className: "function",
54-
beginKeywords: "func"
95+
className: 'function',
96+
beginKeywords: 'func',
5597
},
5698
{
57-
className: "class",
58-
beginKeywords: "class"
59-
}
99+
className: 'class',
100+
beginKeywords: 'class',
101+
},
60102
],
61103
end: /:/,
62-
contains: [hljs.UNDERSCORE_TITLE_MODE]
63-
}
64-
]
104+
contains: [
105+
hljs.UNDERSCORE_TITLE_MODE,
106+
],
107+
},
108+
{
109+
className: 'meta',
110+
begin: /@/,
111+
end: /[ ,\(,\n]/,
112+
keywords: {
113+
keyword:
114+
'@export @export_category @export_color_no_alpha @export_custom ' +
115+
'@export_dir @export_enum @export_exp_easing @export_file ' +
116+
'@export_flags @export_flags_2d_navigation @export_flags_2d_physics ' +
117+
'@export_flags_2d_render @export_flags_3d_navigation ' +
118+
'@export_flags_3d_physics @export_flags_3d_render ' +
119+
'@export_flags_avoidance @export_global_dir @export_global_file ' +
120+
'@export_group @export_multiline @export_node_path ' +
121+
'@export_placeholder @export_range @export_storage @export_subgroup ' +
122+
'@export_tool_button @icon @onready @rpc @static_unload @tool ' +
123+
'@warning_ignore @warning_ignore_restore @warning_ignore_start',
124+
},
125+
},
126+
],
65127
};
66-
}
67-
68-
module.exports = GDScript;
128+
};

0 commit comments

Comments
 (0)