Skip to content

Commit 44b158f

Browse files
committed
Add grammar file and clean up
Clean up files. Update licence file. Add grammar file !
1 parent 77a656b commit 44b158f

File tree

5 files changed

+131
-34
lines changed

5 files changed

+131
-34
lines changed

LICENSE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Copyright (c) 2015 <Your name here>
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Teddy Bradford (for original ./Grammars/shaderlab.cson file)
4+
Copyright (c) 2015 Nadège Michel
25

36
Permission is hereby granted, free of charge, to any person obtaining
47
a copy of this software and associated documentation files (the

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,5 @@
22

33
Adds syntax highlighting to Unity 3D ShaderLab .shader files in Atom.
44

5-
Currently only supports Cg shaders.
6-
7-
Contributions are greatly appreciated. Please fork this repository and open a
8-
pull request to add snippets, make grammar tweaks, etc.
9-
10-
Originally forked from
5+
Grammar file is originally from
116
(dead)[language-unity-shaderlab](https://github.com/teddybradford/language-unity-shaderlab) and [language-unity-shaderlab](https://github.com/khakionion/language-unity-shaderlab).

grammars/shaderlab.cson

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
'scopeName': 'source.shaderlab'
2+
'name': 'ShaderLab'
3+
'fileTypes': [
4+
'shader'
5+
]
6+
'patterns': [
7+
{ # Numbers
8+
'match': '\\b([0-9]+\\.?[0-9]*)\\b'
9+
'name': 'constant.numeric.shaderlab'
10+
}
11+
{ # ShaderLab classes
12+
'match': '\\b(Shader|Properties|Category|SubShader|Tags|Pass)\\b'
13+
'name': 'support.class.shaderlab'
14+
}
15+
{ # Cg shader section
16+
'match': '\\b(CGPROGRAM|ENDCG)\\b'
17+
'name': 'support.class.shaderlab'
18+
}
19+
{ # Dependency and fallback
20+
'match': '\\b(Dependency|Fallback)\\b'
21+
'name': 'support.variable.shaderlab'
22+
}
23+
{ # Property keywords
24+
'match': '^\\s*\\[(HideInInspector)\\]'
25+
'name': 'keyword.shaderlab'
26+
}
27+
{ # Property variables
28+
'match': '\\b(_\\w+)\\b'
29+
'name': 'support.variable.input.shaderlab'
30+
}
31+
{ # Surface shader input structure
32+
'match': '\\b(uv(2)*_\\w+|viewDir|COLOR|screenPos|worldPos|worldRefl|worldNormal|worldRefl|worldNormal)\\b'
33+
'name': 'support.variable.input.shaderlab'
34+
}
35+
{ # Surface shader output structure
36+
'match': '\\b(Albedo|Normal|Emission|Specular|Gloss|Alpha)\\b'
37+
'name': 'support.variable.output.shaderlab'
38+
}
39+
{ # Data structures in UnityCG.cginc
40+
'match': '\\b(appdata_(base|tan|full|img)|SurfaceOutput)\\b'
41+
'name': 'support.variable.structure.shaderlab'
42+
}
43+
{ # Transformation variables
44+
'match': '\\b(UNITY_MATRIX_(MVP|MV|V|P|VP|T_MV|IT_MV|TEXTURE0|TEXTURE1|TEXTURE2|TEXTURE3)|_Object2World|_World2Object|_WorldSpaceCameraPos|unity_Scale)\\b'
45+
'name': 'support.variable.transformation.shaderlab'
46+
}
47+
{ # Lighting variables
48+
'match': '\\b(_ModelLightColor[0-9]|_SpecularLightColor[0-9]|_ObjectSpaceLightPos|_Light2World|_World2Light|_Object2Light)\\b'
49+
'name': 'support.variable.lighting.shaderlab'
50+
}
51+
{ # Various variables
52+
'match': '\\b(_Time|_SinTime|_CosTime|unity_DeltaTime|_ProjectionParams|_ScreenParams)\\b'
53+
'name': 'support.variable.other.shaderlab'
54+
}
55+
{
56+
'include': '#comments'
57+
}
58+
{
59+
'include': '#strings'
60+
}
61+
{
62+
'include': '#functions'
63+
}
64+
{
65+
'include': '#cg'
66+
}
67+
]
68+
'repository':
69+
'comments':
70+
'patterns': [
71+
{ # Comment line
72+
'begin': '//'
73+
'end': '$'
74+
'name': 'comment.line.double-slash.shaderlab'
75+
}
76+
{ # Comment block
77+
'begin': '/\\*'
78+
'end': '\\*/'
79+
'name': 'comment.line.block.shaderlab'
80+
}
81+
]
82+
'strings':
83+
'patterns': [
84+
{ # Double quoted string
85+
'begin': '"'
86+
'end': '"'
87+
'name': 'string.quoted.double.shaderlab'
88+
}
89+
]
90+
'functions':
91+
'patterns': [
92+
{ # Any function (copied from the languages-c package)
93+
'match': '(?x) (?: (?= \\s ) (?:(?<=else|new|return) | (?<!\\w)) (\\s+))?\n\t\t\t(\\b \n\t\t\t\t(?!(while|for|do|if|else|switch|catch|enumerate|return|sizeof|[cr]?iterate)\\s*\\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\\b | :: )++ # actual name\n\t\t\t)\n\t\t\t \\s*(\\()'
94+
'captures':
95+
'1':
96+
'name': 'punctuation.whitespace.function-call.leading.shaderlab'
97+
'2':
98+
'name': 'support.function.any-method.shaderlab'
99+
'3':
100+
'name': 'punctuation.definition.parameters.shaderlab'
101+
'name': 'meta.function-call.shaderlab'
102+
}
103+
]
104+
'cg':
105+
'patterns': [
106+
{ # Preprocessors
107+
'match': '^\\s*#\\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\\b'
108+
'name': 'keyword.control.shaderlab'
109+
}
110+
{ # Swizzle operator
111+
'match': '\\.([rgba]{1,4}|[xyzw]{1,4})\\b'
112+
'name': 'keyword.operator.shaderlab'
113+
}
114+
{ # Declarations and declaration specifiers
115+
'match': '\\b(const|extern|in|inline|inout|static|out|uniform|varying|profile name)\\b'
116+
'name': 'storage.modifier.shaderlab'
117+
}
118+
{ # Data types
119+
'match': '\\b(void|struct|typedef|signed|unsigned|double([1-4])*(x[1-4])*|float([1-4])*(x[1-4])*|half([1-4])*(x[1-4])*|fixed([1-4])*(x[1-4])*|long([1-4])*(x[1-4])*|int([1-4])*(x[1-4])*|short([1-4])*(x[1-4])*|char([1-4])*(x[1-4])*|bool([1-4])*(x[1-4])*|sampler([1-3]D|RECT|CUBE)*)\\b'
120+
'name': 'storage.type.shaderlab'
121+
}
122+
]

lib/unity-shader-files-view.coffee

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/unity-shader-files.coffee

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
UnityShaderFilesView = require './unity-shader-files-view'
21
{CompositeDisposable} = require 'atom'
32

43
module.exports = UnityShaderFiles =
5-
unityShaderFilesView: null
6-
modalPanel: null
7-
subscriptions: null
4+
unityShaderFilesView: null
5+
modalPanel: null
6+
subscriptions: null
87

9-
activate: (state) ->
8+
activate: (state) ->

0 commit comments

Comments
 (0)