Add autocomplete support for preprocessor directives, implements #34

This commit is contained in:
ChaoticByte 2025-01-07 22:19:08 +01:00
parent 71394edbf1
commit ec7544cb3b
No known key found for this signature in database

View file

@ -123,6 +123,10 @@ const gdshader_builtins = [
"POINT_COORD", "POINT_COORD",
"SPECULAR_SHININESS" "SPECULAR_SHININESS"
] ]
const gdshader_preprocessor = [
"define", "undef", "include", "pragma",
"if", "elif", "ifdef", "ifndef", "else", "endif"
]
# shaderlib # shaderlib
var shaderlib_regex = { var shaderlib_regex = {
"hsv": RegEx.create_from_string(r'\s*\#include\s+\"res\:\/\/shaderlib\/hsv\.gdshaderinc\"'), "hsv": RegEx.create_from_string(r'\s*\#include\s+\"res\:\/\/shaderlib\/hsv\.gdshaderinc\"'),
@ -184,6 +188,9 @@ func _on_code_edit_code_completion_requested():
for k in gdshader_builtin_functions + gdshader_sub_functions: for k in gdshader_builtin_functions + gdshader_sub_functions:
code_editor.code_completion_prefixes.append(k) code_editor.code_completion_prefixes.append(k)
code_editor.add_code_completion_option(CodeEdit.KIND_FUNCTION, k, k+"(", Color.INDIAN_RED) code_editor.add_code_completion_option(CodeEdit.KIND_FUNCTION, k, k+"(", Color.INDIAN_RED)
for k in gdshader_preprocessor:
code_editor.code_completion_prefixes.append(k)
code_editor.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, "#" + k, k)
# shaderlib # # shaderlib #
var shader_code = code_editor.text var shader_code = code_editor.text
for key in shaderlib_regex: for key in shaderlib_regex: