aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Lhuillier <alexandre.lhuillier@orange.fr>2020-05-25 17:19:36 +0200
committerAlexandre Lhuillier <alexandre.lhuillier@orange.fr>2020-05-25 17:19:36 +0200
commit98eb3a0e7765d9bd14964eaf368cf46888b6ec9c (patch)
treeab6b77c5cb6e21450f9b0df3a30c7806dc753482
parenta6056db6510565af2d04b95af486fe033ab7376a (diff)
downloadlite-xl-plugins-98eb3a0e7765d9bd14964eaf368cf46888b6ec9c.tar.gz
lite-xl-plugins-98eb3a0e7765d9bd14964eaf368cf46888b6ec9c.zip
Added language_glsl and language_hlsl plugin files, and their links in README.md
-rw-r--r--README.md2
-rw-r--r--plugins/language_glsl.lua484
-rw-r--r--plugins/language_hlsl.lua297
3 files changed, 783 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4c503b5..750d72a 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,9 @@ Plugin | Description
[`language_fe`](plugins/language_fe.lua?raw=1) | Syntax for the [fe](https://github.com/rxi/fe) programming language
[`language_fennel`](plugins/language_fennel.lua?raw=1) | Syntax for the [fennel](https://fennel-lang.org) programming language
[`language_gdscript`](plugins/language_gdscript.lua?raw=1) | Syntax for the [Godot Engine](https://godotengine.org/)'s GDScript scripting language
+[`language_cpp`](plugins/language_glsl.lua?raw=1) | Syntax for the [GLSL](https://www.khronos.org/registry/OpenGL/specs/gl/) programming language. Also highlights commonly-used HLSL keywords, to easily detect mistypes or copy-pasting mistakes between languages.
[`language_go`](plugins/language_go.lua?raw=1) | Syntax for the [Go](https://golang.org/) programming language
+[`language_cpp`](plugins/language_hlsl.lua?raw=1) | Syntax for the [HLSL](https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl) programming language. Also highlights commonly-used GLSL keywords, to easily detect mistypes or copy-pasting mistakes between languages.
[`language_hs`](plugins/language_hs.lua?raw=1) | Syntax for the [Haskell](https://www.haskell.org/) programming language
[`language_jiyu`](plugins/language_jiyu.lua?raw=1) | Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language
[`language_odin`](plugins/language_odin.lua?raw=1) | Syntax for the [Odin](https://github.com/odin-lang/Odin) programming language
diff --git a/plugins/language_glsl.lua b/plugins/language_glsl.lua
new file mode 100644
index 0000000..f8983d4
--- /dev/null
+++ b/plugins/language_glsl.lua
@@ -0,0 +1,484 @@
+
+local style = require "core.style"
+local common = require "core.common"
+
+style.syntax["forbiddenbuiltin"] = { common.color "#ee0000" }
+style.syntax["builtin"] = { common.color "#77eecc" }
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.glsl$", "%.frag$", "%.vert$", },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { "#", "[^\\]\n" }, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "-?0x%x+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*f?", type = "number" },
+ { pattern = "-?%.?%d+f?", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+
+ { pattern = "int[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "int1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "int[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "int1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "int[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "uint[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "uint1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "uint[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "uint1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "uint[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "dword[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "dword1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "dword[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "dword1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "dword[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "half[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "half1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "half[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "half1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "half[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "float[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "float1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "float[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "float1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "float[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "double[1-9]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "double1[0-6]x[1-9]", type = "forbiddenbuiltin" },
+ { pattern = "double[1-9]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "double1[0-6]x1[0-6]", type = "forbiddenbuiltin" },
+ { pattern = "double[1-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "ivec[2-4]", type = "keyword2" },
+ { pattern = "bvec[2-4]", type = "keyword2" },
+ { pattern = "uvec[2-4]", type = "keyword2" },
+ { pattern = "vec[2-4]", type = "keyword2" },
+ { pattern = "dmat[2-4]x[2-4]", type = "keyword2" },
+ { pattern = "dmat[2-4]", type = "keyword2" },
+ { pattern = "mat[2-4]x[2-4]", type = "keyword2" },
+ { pattern = "mat[2-4]", type = "keyword2" },
+
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ --https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf
+ --The symbols are added here in the order they appear in the spec
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["do"] = "keyword",
+ ["while"] = "keyword",
+ ["for"] = "keyword",
+ ["break"] = "keyword",
+ ["continue"] = "keyword",
+ ["return"] = "keyword",
+ ["const"] = "keyword",
+ ["switch"] = "keyword",
+ ["case"] = "keyword",
+ ["default"] = "keyword",
+ ["const"] = "keyword",
+ ["void"] = "keyword",
+ ["bool"] = "keyword2",
+ ["int"] = "keyword2",
+ ["uint"] = "keyword2",
+ ["float"] = "keyword2",
+ ["double"] = "keyword2",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["NULL"] = "literal",
+
+ ["attribute"] = "keyword",
+ ["varying"] = "keyword",
+ ["uniform"] = "keyword",
+ ["buffer"] = "keyword",
+ ["shared"] = "keyword",
+ ["layout"] = "keyword",
+ ["centroid"] = "keyword",
+ ["flat"] = "keyword",
+ ["smooth"] = "keyword",
+ ["noperspective"]= "keyword",
+ ["patch"] = "keyword",
+ ["sample"] = "keyword",
+ ["in"] = "keyword",
+ ["out"] = "keyword",
+ ["inout"] = "keyword",
+ ["invariant"] = "keyword",
+ ["precise"] = "keyword",
+ ["lowp"] = "keyword",
+ ["mediump"] = "keyword",
+ ["highp"] = "keyword",
+ ["precision"] = "keyword",
+ ["struct"] = "keyword",
+ ["subroutine"] = "keyword",
+
+ ["coherent"] = "keyword",
+ ["volatile"] = "keyword",
+ ["readonly"] = "keyword",
+ ["writeonly"] = "keyword",
+
+ ["sampler1D"] = "keyword2",
+ ["sampler2D"] = "keyword2",
+ ["sampler3D"] = "keyword2",
+ ["samplerCube"] = "keyword2",
+ ["sampler1DShadow"] = "keyword2",
+ ["sampler2DShadow"] = "keyword2",
+ ["samplerCubeShadow"] = "keyword2",
+ ["sampler1DArray"] = "keyword2",
+ ["sampler2DArray"] = "keyword2",
+ ["samplerCubeArray"] = "keyword2",
+ ["sampler1DArrayShadow"] = "keyword2",
+ ["sampler2DArrayShadow"] = "keyword2",
+ ["samplerCubeArrayShadow"]= "keyword2",
+ ["isampler1D"] = "keyword2",
+ ["isampler2D"] = "keyword2",
+ ["isampler3D"] = "keyword2",
+ ["isamplerCube"] = "keyword2",
+ ["sampler2DMS"] = "keyword2",
+ ["isampler2DMS"] = "keyword2",
+ ["usampler2DMS"] = "keyword2",
+ ["sampler2DMSArray"] = "keyword2",
+ ["isampler2DMSArray"] = "keyword2",
+ ["usampler2DMSArray"] = "keyword2",
+ ["isampler1DArray"] = "keyword2",
+ ["isampler2DArray"] = "keyword2",
+ ["usampler1D"] = "keyword2",
+ ["usampler2D"] = "keyword2",
+ ["usampler3D"] = "keyword2",
+ ["usamplerCube"] = "keyword2",
+ ["usampler1DArray"] = "keyword2",
+ ["usampler2DArray"] = "keyword2",
+ ["sampler2DRect"] = "keyword2",
+ ["sampler2DRectShadow"] = "keyword2",
+ ["isampler2DRect"] = "keyword2",
+ ["usampler2DRect"] = "keyword2",
+ ["samplerBuffer"] = "keyword2",
+ ["isamplerBuffer"] = "keyword2",
+ ["usamplerBuffer"] = "keyword2",
+
+ ["image1D"] = "keyword2",
+ ["iimage1D"] = "keyword2",
+ ["uimage1D"] = "keyword2",
+ ["image1DArray"] = "keyword2",
+ ["iimage1DArray"] = "keyword2",
+ ["uimage1DArray"] = "keyword2",
+ ["image2D"] = "keyword2",
+ ["iimage2D"] = "keyword2",
+ ["uimage2D"] = "keyword2",
+ ["image2DArray"] = "keyword2",
+ ["iimage2DArray"] = "keyword2",
+ ["uimage2DArray"] = "keyword2",
+ ["image2DRect"] = "keyword2",
+ ["iimage2DRect"] = "keyword2",
+ ["uimage2DRect"] = "keyword2",
+ ["image2DMS"] = "keyword2",
+ ["iimage2DMS"] = "keyword2",
+ ["uimage2DMS"] = "keyword2",
+ ["image2DMSArray"] = "keyword2",
+ ["iimage2DMSArray"]= "keyword2",
+ ["uimage2DMSArray"]= "keyword2",
+ ["image3D"] = "keyword2",
+ ["iimage3D"] = "keyword2",
+ ["uimage3D"] = "keyword2",
+ ["imageCube"] = "keyword2",
+ ["iimageCube"] = "keyword2",
+ ["uimageCube"] = "keyword2",
+ ["imageCubeArray"] = "keyword2",
+ ["iimageCubeArray"]= "keyword2",
+ ["uimageCubeArray"]= "keyword2",
+ ["imageBuffer"] = "keyword2",
+ ["iimageBuffer"] = "keyword2",
+ ["uimageBuffer"] = "keyword2",
+
+ ["atomic_uint"] = "keyword2",
+
+ ["radians"] = "builtin",
+ ["degrees"] = "builtin",
+ ["sin"] = "builtin",
+ ["cos"] = "builtin",
+ ["tan"] = "builtin",
+ ["asin"] = "builtin",
+ ["acos"] = "builtin",
+ ["atan"] = "builtin",
+ ["sinh"] = "builtin",
+ ["cosh"] = "builtin",
+ ["tanh"] = "builtin",
+ ["asinh"] = "builtin",
+ ["acosh"] = "builtin",
+ ["pow"] = "builtin",
+ ["exp"] = "builtin",
+ ["exp2"] = "builtin",
+ ["log2"] = "builtin",
+ ["sqrt"] = "builtin",
+ ["inversesqrt"] = "forbiddenbuiltin",
+ ["abs"] = "builtin",
+ ["sign"] = "builtin",
+ ["floor"] = "builtin",
+ ["trunc"] = "builtin",
+ ["round"] = "builtin",
+ ["roundEven"] = "builtin",
+ ["ceil"] = "builtin",
+ ["fract"] = "builtin",
+ ["mod"] = "builtin",
+ ["modf"] = "builtin",
+ ["min"] = "builtin",
+ ["max"] = "builtin",
+ ["clamp"] = "builtin",
+ ["mix"] = "builtin",
+ ["step"] = "builtin",
+ ["smoothstep"] = "builtin",
+ ["isnan"] = "builtin",
+ ["isinf"] = "builtin",
+ ["floatBitsToInt"] = "builtin",
+ ["floatBitsToUint"] = "builtin",
+ ["intBitsToFloat"] = "builtin",
+ ["uintBitsToFloat"] = "builtin",
+ ["fma"] = "builtin",
+ ["frexp"] = "builtin",
+ ["ldexp"] = "builtin",
+ ["packUnorm2x16"] = "builtin",
+ ["packSnorm2x16"] = "builtin",
+ ["packUnorm4x8"] = "builtin",
+ ["packSnorm4x8"] = "builtin",
+ ["unpackUnorm2x16"] = "builtin",
+ ["unpackSnorm2x16"] = "builtin",
+ ["unpackUnorm4x8"] = "builtin",
+ ["unpackSnorm4x8"] = "builtin",
+ ["packHalf2x16"] = "builtin",
+ ["unpackHalf2x16"] = "builtin",
+ ["packDouble2x32"] = "builtin",
+ ["unpackDouble2x32"] = "builtin",
+ ["length"] = "builtin",
+ ["distance"] = "builtin",
+ ["dot"] = "builtin",
+ ["cross"] = "builtin",
+ ["normalize"] = "builtin",
+ ["ftransform"] = "builtin",
+ ["faceforward"] = "builtin",
+ ["reflect"] = "builtin",
+ ["refract"] = "builtin",
+ ["matrixCompMult"] = "builtin",
+ ["outerProduct"] = "builtin",
+ ["transpose"] = "builtin",
+ ["determinant"] = "builtin",
+ ["inverse"] = "builtin",
+ ["lessThan"] = "builtin",
+ ["lessThanEqual"] = "builtin",
+ ["greaterThan"] = "builtin",
+ ["greaterThanEqual"] = "builtin",
+ ["equal"] = "builtin",
+ ["notEqual"] = "builtin",
+ ["any"] = "builtin",
+ ["all"] = "builtin",
+ ["not"] = "builtin",
+ ["uaddCarry"] = "builtin",
+ ["usubBorrow"] = "builtin",
+ ["umulExtended"] = "builtin",
+ ["imulExtended"] = "builtin",
+ ["bitfieldExtract"] = "builtin",
+ ["bitfieldInsert"] = "builtin",
+ ["bitfieldReverse"] = "builtin",
+ ["bitCount"] = "builtin",
+ ["findLSB"] = "builtin",
+ ["findMSB"] = "builtin",
+ ["textureSize"] = "builtin",
+ ["textureQueryLod"] = "builtin",
+ ["textureQueryLevels"] = "builtin",
+ ["textureSamples"] = "builtin",
+ ["texture"] = "builtin",
+ ["textureProj"] = "builtin",
+ ["textureLod"] = "builtin",
+ ["textureOffset"] = "builtin",
+ ["texelFetch"] = "builtin",
+ ["texelFetchOffset"] = "builtin",
+ ["textureProjOffset"] = "builtin",
+ ["textureLodOffset"] = "builtin",
+ ["textureProjLod"] = "builtin",
+ ["textureProjLodOffset"] = "builtin",
+ ["textureGrad"] = "builtin",
+ ["textureGradOffset"] = "builtin",
+ ["textureProjGrad"] = "builtin",
+ ["textureProjGradOffset"]= "builtin",
+ ["textureGather"] = "builtin",
+ ["textureGatherOffset"] = "builtin",
+ ["textureGatherOffsets"] = "builtin",
+
+ --Atomic Counter Functions
+ ["atomicCounterIncrement"]= "builtin",
+ ["atomicCounterDecrement"]= "builtin",
+ ["atomicCounter"] = "builtin",
+ ["atomicCounterAdd"] = "builtin",
+ ["atomicCounterSubtract"] = "builtin",
+ ["atomicCounterMin"] = "builtin",
+ ["atomicCounterMax"] = "builtin",
+ ["atomicCounterAnd"] = "builtin",
+ ["atomicCounterOr"] = "builtin",
+ ["atomicCounterXor"] = "builtin",
+ ["atomicCounterExchange"] = "builtin",
+ ["atomicCounterCompSwap"] = "builtin",
+ --Atomic Memory Functions
+ ["atomicAdd"] = "builtin",
+ ["atomicMin"] = "builtin",
+ ["atomicMax"] = "builtin",
+ ["atomicAnd"] = "builtin",
+ ["atomicOr"] = "builtin",
+ ["atomicXor"] = "builtin",
+ ["atomicExchange"]= "builtin",
+ ["atomicCompSwap"]= "builtin",
+ --Image Functions
+ ["imageSize"] = "builtin",
+ ["imageSamples"] = "builtin",
+ ["imageLoad"] = "builtin",
+ ["imageStore"] = "builtin",
+ ["imageAtomicAdd"] = "builtin",
+ ["imageAtomicMin"] = "builtin",
+ ["imageAtomicMax"] = "builtin",
+ ["imageAtomicAnd"] = "builtin",
+ ["imageAtomicOr"] = "builtin",
+ ["imageAtomicXor"] = "builtin",
+ ["imageAtomicExchange"]= "builtin",
+ ["imageAtomicCompSwap"]= "builtin",
+ --Geometry Shader Functions
+ ["EmitStreamVertex"] = "builtin",
+ ["EndStreamPrimitive"] = "builtin",
+ ["EmitVertex"] = "builtin",
+ ["EndPrimitive"] = "builtin",
+ --Fragment Processing Functions
+ ["dFdx"] = "builtin",
+ ["dFdy"] = "builtin",
+ ["dFdxFine"] = "builtin",
+ ["dFdyFine"] = "builtin",
+ ["dFdxCoarse"] = "builtin",
+ ["dFdyCoarse"] = "builtin",
+ ["fwidth"] = "builtin",
+ ["fwidthFine"] = "builtin",
+ ["fwidthCoarse"] = "builtin",
+ ["interpolateAtCentroid"]= "builtin",
+ ["interpolateAtSample"] = "builtin",
+ ["interpolateAtOffset"] = "builtin",
+ --Shader Invocation Control Functions
+ ["barrier"] = "builtin",
+ --Shader Memory Control Functions
+ ["memoryBarrier"] = "builtin",
+ ["memoryBarrierAtomicCounter"]= "builtin",
+ ["memoryBarrierBuffer"] = "builtin",
+ ["memoryBarrierShared"] = "builtin",
+ ["memoryBarrierImage"] = "builtin",
+ ["groupMemoryBarrier"] = "builtin",
+ --Subpass-Input Functions
+ ["subpassLoad"] = "builtin",
+ --Shader Invocation Group Functions
+ ["anyInvocation"] = "builtin",
+ ["allInvocations"] = "builtin",
+ ["allInvocationsEqual"]= "builtin",
+
+ --"In addition, when targeting Vulkan, the following keywords also exist:"
+ ["texture1D"] = "builtin",
+ ["texture1DArray"] = "builtin",
+ ["itexture1D"] = "builtin",
+ ["itexture1DArray"] = "builtin",
+ ["utexture1D"] = "builtin",
+ ["utexture1DArray"] = "builtin",
+ ["texture2D"] = "builtin",
+ ["texture2DArray"] = "builtin",
+ ["itexture2D"] = "builtin",
+ ["itexture2DArray"] = "builtin",
+ ["utexture2D"] = "builtin",
+ ["utexture2DArray"] = "builtin",
+ ["texture2DRect"] = "builtin",
+ ["itexture2DRect"] = "builtin",
+ ["utexture2DRect"] = "builtin",
+ ["texture2DMS"] = "builtin",
+ ["itexture2DMS"] = "builtin",
+ ["utexture2DMS"] = "builtin",
+ ["texture2DMSArray"] = "builtin",
+ ["itexture2DMSArray"]= "builtin",
+ ["utexture2DMSArray"]= "builtin",
+ ["texture3D"] = "builtin",
+ ["itexture3D"] = "builtin",
+ ["utexture3D"] = "builtin",
+ ["textureCube"] = "builtin",
+ ["itextureCube"] = "builtin",
+ ["utextureCube"] = "builtin",
+ ["textureCubeArray"] = "builtin",
+ ["itextureCubeArray"]= "builtin",
+ ["utextureCubeArray"]= "builtin",
+ ["textureBuffer"] = "builtin",
+ ["itextureBuffer"] = "builtin",
+ ["utextureBuffer"] = "builtin",
+ ["sampler"] = "keyword2",
+ ["samplerShadow"] = "keyword2",
+ ["subpassInput"] = "keyword2",
+ ["isubpassInput"] = "keyword2",
+ ["usubpassInput"] = "keyword2",
+ ["subpassInputMS"] = "keyword2",
+ ["isubpassInputMS"] = "keyword2",
+ ["usubpassInputMS"] = "keyword2",
+
+ --"The following are the keywords reserved for future use. Using them will result in a compile-time error:"
+ ["common"] = "forbiddenbuiltin",
+ ["partition"] = "forbiddenbuiltin",
+ ["active"] = "forbiddenbuiltin",
+ ["asm"] = "forbiddenbuiltin",
+ ["class"] = "forbiddenbuiltin",
+ ["union"] = "forbiddenbuiltin",
+ ["enum"] = "forbiddenbuiltin",
+ ["typedef"] = "forbiddenbuiltin",
+ ["template"] = "forbiddenbuiltin",
+ ["this"] = "forbiddenbuiltin",
+ ["resource"] = "forbiddenbuiltin",
+ ["goto"] = "forbiddenbuiltin",
+ ["inline"] = "forbiddenbuiltin",
+ ["noinline"] = "forbiddenbuiltin",
+ ["public"] = "forbiddenbuiltin",
+ ["static"] = "forbiddenbuiltin",
+ ["extern"] = "forbiddenbuiltin",
+ ["external"] = "forbiddenbuiltin",
+ ["interface"] = "forbiddenbuiltin",
+ ["long"] = "forbiddenbuiltin",
+ ["short"] = "forbiddenbuiltin",
+ ["half"] = "forbiddenbuiltin",
+ ["fixed"] = "forbiddenbuiltin",
+ ["unsigned"] = "forbiddenbuiltin",
+ ["superp"] = "forbiddenbuiltin",
+ ["input"] = "forbiddenbuiltin",
+ ["output"] = "forbiddenbuiltin",
+ ["hvec2"] = "forbiddenbuiltin",
+ ["hvec3"] = "forbiddenbuiltin",
+ ["hvec4"] = "forbiddenbuiltin",
+ ["fvec2"] = "forbiddenbuiltin",
+ ["fvec3"] = "forbiddenbuiltin",
+ ["fvec4"] = "forbiddenbuiltin",
+ ["filter"] = "forbiddenbuiltin",
+ ["sizeof"] = "forbiddenbuiltin",
+ ["cast"] = "forbiddenbuiltin",
+ ["namespace"] = "forbiddenbuiltin",
+ ["using"] = "forbiddenbuiltin",
+ ["sampler3DRect"]= "forbiddenbuiltin",
+
+ --common symbols in HLSL that don't exist in GLSL
+ ["frac"] = "forbiddenbuiltin",
+ ["lerp"] = "forbiddenbuiltin",
+ ["mul"] = "forbiddenbuiltin",
+ ["min16float"] = "forbiddenbuiltin",
+ ["min10float"] = "forbiddenbuiltin",
+ ["min16int"] = "forbiddenbuiltin",
+ ["min12int"] = "forbiddenbuiltin",
+ ["min16uint"] = "forbiddenbuiltin",
+ ["rsqrt"] = "forbiddenbuiltin",
+ ["ddx"] = "forbiddenbuiltin",
+ ["ddx_coarse"] = "forbiddenbuiltin",
+ ["ddx_fine"] = "forbiddenbuiltin",
+ ["ddy"] = "forbiddenbuiltin",
+ ["ddy_coarse"] = "forbiddenbuiltin",
+ ["ddy_fine"] = "forbiddenbuiltin",
+
+ },
+}
+
diff --git a/plugins/language_hlsl.lua b/plugins/language_hlsl.lua
new file mode 100644
index 0000000..a7a4375
--- /dev/null
+++ b/plugins/language_hlsl.lua
@@ -0,0 +1,297 @@
+
+local style = require "core.style"
+local common = require "core.common"
+
+style.syntax["forbiddenbuiltin"] = { common.color "#ee0000" }
+style.syntax["builtin"] = { common.color "#77eecc" }
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.hlsl$", },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { "#", "[^\\]\n" }, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "-?0x%x+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*f?", type = "number" },
+ { pattern = "-?%.?%d+f?", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+
+ { pattern = "int[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "int1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "int[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "int1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "int[1-4]", type = "keyword2" },
+
+ { pattern = "uint[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "uint1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "uint[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "uint1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "uint[1-4]", type = "keyword2" },
+
+ { pattern = "dword[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "dword1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "dword[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "dword1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "dword[1-4]", type = "keyword2" },
+
+ { pattern = "half[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "half1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "half[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "half1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "half[1-4]", type = "keyword2" },
+
+ { pattern = "float[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "float1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "float[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "float1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "float[1-4]", type = "keyword2" },
+
+ { pattern = "double[1-9]x[1-9]", type = "keyword2" },
+ { pattern = "double1[0-6]x[1-9]", type = "keyword2" },
+ { pattern = "double[1-9]x1[0-6]", type = "keyword2" },
+ { pattern = "double1[0-6]x1[0-6]", type = "keyword2" },
+ { pattern = "double[1-4]", type = "keyword2" },
+
+ { pattern = "ivec[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "bvec[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "uvec[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "vec[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "dmat[2-4]x[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "dmat[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "mat[2-4]x[2-4]", type = "forbiddenbuiltin" },
+ { pattern = "mat[2-4]", type = "forbiddenbuiltin" },
+
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ --https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-keywords
+ --The symbols are added in the order they appear on this webpage, which is alphabetically
+ ["AppendStructuredBuffer"]= "keyword",
+ ["asm"] = "keyword",
+ ["asm_fragment"] = "keyword",
+ ["BlendState"] = "keyword2",
+ ["bool"] = "keyword2",
+ ["break"] = "keyword",
+ ["Buffer"] = "keyword2",
+ ["ByteAddressBuffer"]= "keyword2",
+ ["case"] = "keyword",
+ ["cbuffer"] = "keyword2",
+ ["centroid"] = "keyword2",
+ ["class"] = "keyword",
+ ["column_major"] = "keyword",
+ ["compile"] = "keyword",
+ ["compile_fragment"] = "keyword",
+ ["CompileShader"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["ComputeShader"] = "keyword",
+ ["ConsumeStructuredBuffer"]= "keyword",
+ ["default"] = "keyword",
+ ["DepthStencilState"]= "keyword",
+ ["DepthStencilView"] = "keyword",
+ ["discard"] = "keyword",
+ ["do"] = "keyword",
+ ["double"] = "keyword2",
+ ["DomainShader"] = "keyword2",
+ ["dword"] = "keyword2",
+ ["else"] = "keyword",
+ ["export"] = "keyword",
+ ["extern"] = "keyword",
+ ["false"] = "literal",
+ ["float"] = "keyword2",
+ ["for"] = "keyword",
+ ["fxgroup"] = "keyword2",
+ ["GeometryShader"] = "keyword2",
+ ["groupshared"] = "keyword",
+ ["half"] = "keyword2",
+ ["HullShader"] = "keyword2",
+ ["if"] = "keyword",
+ ["in"] = "keyword",
+ ["inline"] = "keyword",
+ ["inout"] = "keyword",
+ ["InputPatch"] = "keyword2",
+ ["int"] = "keyword2",
+ ["interface"] = "keyword",
+ ["line"] = "keyword2",
+ ["lineadj"] = "keyword2",
+ ["linear"] = "keyword",
+ ["LineStream"] = "keyword2",
+ ["matrix"] = "keyword2",
+ ["min16float"] = "keyword2",
+ ["min10float"] = "keyword2",
+ ["min16int"] = "keyword2",
+ ["min12int"] = "keyword2",
+ ["min16uint"] = "keyword2",
+ ["namespace"] = "keyword",
+ ["nointerpolation"] = "keyword",
+ ["noperspective"] = "keyword",
+ ["NULL"] = "literal",
+ ["out"] = "keyword",
+ ["OutputPatch"] = "keyword2",
+ ["packoffset"] = "keyword",
+ ["pass"] = "keyword",
+ ["pixelfragment"] = "keyword",
+ ["PixelShader"] = "keyword2",
+ ["point"] = "keyword2",
+ ["PointStream"] = "keyword2",
+ ["precise"] = "keyword",
+ ["RasterizerState"] = "keyword2",
+ ["RenderTargetView"] = "keyword2",
+ ["return"] = "keyword",
+ ["register"] = "keyword",
+ ["row_major"] = "keyword",
+ ["RWBuffer"] = "keyword2",
+ ["RWByteAddressBuffer"]= "keyword2",
+ ["RWStructuredBuffer"]= "keyword2",
+ ["RWTexture1D"] = "keyword2",
+ ["RWTexture1DArray"] = "keyword2",
+ ["RWTexture2D"] = "keyword2",
+ ["RWTexture2DArray"] = "keyword2",
+ ["RWTexture3D"] = "keyword2",
+ ["sample"] = "builtin",
+ ["sampler"] = "keyword2",
+ ["SamplerState"] = "keyword2",
+ ["SamplerComparisonState"]= "keyword2",
+ ["shared"] = "keyword",
+ ["snorm"] = "keyword",
+ ["stateblock"] = "keyword",
+ ["stateblock_state"] = "keyword",
+ ["static"] = "keyword",
+ ["string"] = "keyword2",
+ ["struct"] = "keyword",
+ ["switch"] = "keyword",
+ ["StructuredBuffer"] = "keyword2",
+ ["tbuffer"] = "keyword2",
+ ["technique"] = "keyword2",
+ ["technique10"] = "keyword2",
+ ["technique11"] = "keyword2",
+ ["texture"] = "keyword2",
+ ["Texture1D"] = "keyword2",
+ ["Texture1DArray"] = "keyword2",
+ ["Texture2D"] = "keyword2",
+ ["Texture2DArray"] = "keyword2",
+ ["Texture2DMS"] = "keyword2",
+ ["Texture2DMSArray"] = "keyword2",
+ ["Texture3D"] = "keyword2",
+ ["TextureCube"] = "keyword2",
+ ["TextureCubeArray"] = "keyword2",
+ ["true"] = "literal",
+ ["typedef"] = "keyword",
+ ["triangle"] = "keyword2",
+ ["triangleadj"] = "keyword2",
+ ["TriangleStream"] = "keyword2",
+ ["uint"] = "keyword2",
+ ["uniform"] = "keyword",
+ ["unorm"] = "keyword",
+ ["unsigned"] = "keyword",
+ ["vector"] = "keyword2",
+ ["vertexfragment"] = "keyword2",
+ ["VertexShader"] = "keyword2",
+ ["void"] = "keyword",
+ ["volatile"] = "keyword",
+ ["while"] = "keyword",
+
+ --https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-intrinsic-functions
+ --The symbols are added in the order they appear on this webpage, which is alphabetically
+ ["abort"] = "builtin",
+ ["abs"] = "builtin",
+ ["acos"] = "builtin",
+ ["all"] = "builtin",
+ ["any"] = "builtin",
+ ["asdouble"] = "builtin",
+ ["asfloat"] = "builtin",
+ ["asin"] = "builtin",
+ ["asint"] = "builtin",
+ ["asuint"] = "builtin",
+ ["atan"] = "builtin",
+ ["atan2"] = "builtin",
+ ["ceil"] = "builtin",
+ ["clamp"] = "builtin",
+ ["clip"] = "builtin",
+ ["cos"] = "builtin",
+ ["cosh"] = "builtin",
+ ["countbits"] = "builtin",
+ ["cross"] = "builtin",
+ ["ddx"] = "builtin",
+ ["ddx_coarse"] = "builtin",
+ ["ddx_fine"] = "builtin",
+ ["ddy"] = "builtin",
+ ["ddy_coarse"] = "builtin",
+ ["ddy_fine"] = "builtin",
+ ["degrees"] = "builtin",
+ ["determinant"] = "builtin",
+ ["distance"] = "builtin",
+ ["dot"] = "builtin",
+ ["dst"] = "builtin",
+ ["errorf"] = "builtin",
+ ["exp"] = "builtin",
+ ["exp2"] = "builtin",
+ ["f16tof32"] = "builtin",
+ ["f32tof16"] = "builtin",
+ ["faceforward"] = "builtin",
+ ["firstbithigh"]= "builtin",
+ ["firstbitlow"] = "builtin",
+ ["floor"] = "builtin",
+ ["fma"] = "builtin",
+ ["fmod"] = "builtin",
+ ["frac"] = "builtin",
+ ["frexp"] = "builtin",
+ ["fwidth"] = "builtin",
+ ["isfinite"] = "builtin",
+ ["isinf"] = "builtin",
+ ["isnan"] = "builtin",
+ ["ldexp"] = "builtin",
+ ["length"] = "builtin",
+ ["lerp"] = "builtin",
+ ["lit"] = "builtin",
+ ["log"] = "builtin",
+ ["log10"] = "builtin",
+ ["log2"] = "builtin",
+ ["mad"] = "builtin",
+ ["max"] = "builtin",
+ ["min"] = "builtin",
+ ["modf"] = "builtin",
+ ["msad4"] = "builtin",
+ ["mul"] = "builtin",
+ ["noise"] = "builtin",
+ ["normalize"] = "builtin",
+ ["pow"] = "builtin",
+ ["printf"] = "builtin",
+ ["radians"] = "builtin",
+ ["rcp"] = "builtin",
+ ["reflect"] = "builtin",
+ ["refract"] = "builtin",
+ ["reversebits"] = "builtin",
+ ["round"] = "builtin",
+ ["rsqrt"] = "builtin",
+ ["saturate"] = "builtin",
+ ["sign"] = "builtin",
+ ["sin"] = "builtin",
+ ["sincos"] = "builtin",
+ ["sinh"] = "builtin",
+ ["smoothstep"] = "builtin",
+ ["sqrt"] = "builtin",
+ ["step"] = "builtin",
+ ["tan"] = "builtin",
+ ["tanh"] = "builtin",
+ ["transpose"] = "builtin",
+ ["trunc"] = "builtin",
+
+ --common symbols in GLSL that don't exist in HLSL
+ ["mix"] = "forbiddenbuiltin",
+ ["fract"] = "forbiddenbuiltin",
+ ["inversesqrt"]= "forbiddenbuiltin",
+ ["dFdx"] = "forbiddenbuiltin",
+ ["dFdy"] = "forbiddenbuiltin",
+ ["dFdxFine"] = "forbiddenbuiltin",
+ ["dFdyFine"] = "forbiddenbuiltin",
+ ["dFdxCoarse"] = "forbiddenbuiltin",
+ ["dFdyCoarse"] = "forbiddenbuiltin",
+ },
+}
+