aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_hlsl.lua
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 /plugins/language_hlsl.lua
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
Diffstat (limited to 'plugins/language_hlsl.lua')
-rw-r--r--plugins/language_hlsl.lua297
1 files changed, 297 insertions, 0 deletions
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",
+ },
+}
+