mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-21 15:23:19 +01:00
Add support for WGSL
This commit is contained in:
parent
6e5fd36882
commit
d376a4b631
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -257,3 +257,6 @@
|
||||
[submodule "assets/syntaxes/02_Extra/NSIS"]
|
||||
path = assets/syntaxes/02_Extra/NSIS
|
||||
url = https://github.com/SublimeText/NSIS
|
||||
[submodule "assets/syntaxes/02_Extra/vscode-wgsl"]
|
||||
path = assets/syntaxes/02_Extra/vscode-wgsl
|
||||
url = https://github.com/PolyMeilex/vscode-wgsl.git
|
||||
|
@ -22,6 +22,7 @@
|
||||
- Replaced quotes with double quotes so fzf integration example script works on windows and linux. see #2095 (@johnmatthiggins)
|
||||
- Associate `ksh` files with `bash` syntax, see #2633 (@johnmatthiggins)
|
||||
- Associate `ron` files with `rust` syntax, see #2427 (@YeungOnion)
|
||||
- Add support for [WebGPU Shader Language](https://www.w3.org/TR/WGSL/), see #2692 (@rhysd)
|
||||
|
||||
## Themes
|
||||
|
||||
|
BIN
assets/acknowledgements.bin
vendored
BIN
assets/acknowledgements.bin
vendored
Binary file not shown.
BIN
assets/syntaxes.bin
vendored
BIN
assets/syntaxes.bin
vendored
Binary file not shown.
1
assets/syntaxes/02_Extra/vscode-wgsl
vendored
Submodule
1
assets/syntaxes/02_Extra/vscode-wgsl
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit acf26718d7a327377641e31d8f9a9dab376efa84
|
198
assets/syntaxes/02_Extra/wgsl.sublime-syntax
vendored
Normal file
198
assets/syntaxes/02_Extra/wgsl.sublime-syntax
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/syntax.html
|
||||
name: WGSL
|
||||
file_extensions:
|
||||
- wgsl
|
||||
scope: source.wgsl
|
||||
contexts:
|
||||
main:
|
||||
- include: line_comments
|
||||
- include: block_comments
|
||||
- include: keywords
|
||||
- include: attributes
|
||||
- include: functions
|
||||
- include: function_calls
|
||||
- include: constants
|
||||
- include: types
|
||||
- include: variables
|
||||
- include: punctuation
|
||||
attributes:
|
||||
- match: '(@)([A-Za-z_]+)'
|
||||
comment: attribute declaration
|
||||
scope: meta.attribute.wgsl
|
||||
captures:
|
||||
1: keyword.operator.attribute.at
|
||||
2: entity.name.attribute.wgsl
|
||||
block_comments:
|
||||
- match: /\*\*/
|
||||
comment: empty block comments
|
||||
scope: comment.block.wgsl
|
||||
- match: /\*\*
|
||||
comment: block documentation comments
|
||||
push:
|
||||
- meta_scope: comment.block.documentation.wgsl
|
||||
- match: \*/
|
||||
pop: true
|
||||
- include: block_comments
|
||||
- match: /\*(?!\*)
|
||||
comment: block comments
|
||||
push:
|
||||
- meta_scope: comment.block.wgsl
|
||||
- match: \*/
|
||||
pop: true
|
||||
- include: block_comments
|
||||
constants:
|
||||
- match: '(-?\b[0-9][0-9]*\.[0-9][0-9]*)([eE][+-]?[0-9]+)?\b'
|
||||
comment: decimal float literal
|
||||
scope: constant.numeric.float.wgsl
|
||||
- match: '-?\b0x[0-9a-fA-F]+\b|\b0\b|-?\b[1-9][0-9]*\b'
|
||||
comment: int literal
|
||||
scope: constant.numeric.decimal.wgsl
|
||||
- match: '\b0x[0-9a-fA-F]+u\b|\b0u\b|\b[1-9][0-9]*u\b'
|
||||
comment: uint literal
|
||||
scope: constant.numeric.decimal.wgsl
|
||||
- match: \b(true|false)\b
|
||||
comment: boolean constant
|
||||
scope: constant.language.boolean.wgsl
|
||||
function_calls:
|
||||
- match: '([A-Za-z0-9_]+)(\()'
|
||||
comment: function/method calls
|
||||
captures:
|
||||
1: entity.name.function.wgsl
|
||||
2: punctuation.brackets.round.wgsl
|
||||
push:
|
||||
- meta_scope: meta.function.call.wgsl
|
||||
- match: \)
|
||||
captures:
|
||||
0: punctuation.brackets.round.wgsl
|
||||
pop: true
|
||||
- include: line_comments
|
||||
- include: block_comments
|
||||
- include: keywords
|
||||
- include: attributes
|
||||
- include: function_calls
|
||||
- include: constants
|
||||
- include: types
|
||||
- include: variables
|
||||
- include: punctuation
|
||||
functions:
|
||||
- match: '\b(fn)\s+([A-Za-z0-9_]+)((\()|(<))'
|
||||
comment: function definition
|
||||
captures:
|
||||
1: keyword.other.fn.wgsl
|
||||
2: entity.name.function.wgsl
|
||||
4: punctuation.brackets.round.wgsl
|
||||
push:
|
||||
- meta_scope: meta.function.definition.wgsl
|
||||
- match: '\{'
|
||||
captures:
|
||||
0: punctuation.brackets.curly.wgsl
|
||||
pop: true
|
||||
- include: line_comments
|
||||
- include: block_comments
|
||||
- include: keywords
|
||||
- include: attributes
|
||||
- include: function_calls
|
||||
- include: constants
|
||||
- include: types
|
||||
- include: variables
|
||||
- include: punctuation
|
||||
keywords:
|
||||
- match: \b(bitcast|block|break|case|continue|continuing|default|discard|else|elseif|enable|fallthrough|for|function|if|loop|private|read|read_write|return|storage|switch|uniform|while|workgroup|write)\b
|
||||
comment: other keywords
|
||||
scope: keyword.control.wgsl
|
||||
- match: \b(asm|const|do|enum|handle|mat|premerge|regardless|typedef|unless|using|vec|void)\b
|
||||
comment: reserved keywords
|
||||
scope: keyword.control.wgsl
|
||||
- match: \b(let|var)\b
|
||||
comment: storage keywords
|
||||
scope: keyword.other.wgsl storage.type.wgsl
|
||||
- match: \b(type)\b
|
||||
comment: type keyword
|
||||
scope: keyword.declaration.type.wgsl storage.type.wgsl
|
||||
- match: \b(enum)\b
|
||||
comment: enum keyword
|
||||
scope: keyword.declaration.enum.wgsl storage.type.wgsl
|
||||
- match: \b(struct)\b
|
||||
comment: struct keyword
|
||||
scope: keyword.declaration.struct.wgsl storage.type.wgsl
|
||||
- match: \bfn\b
|
||||
comment: fn
|
||||
scope: keyword.other.fn.wgsl
|
||||
- match: (\^|\||\|\||&&|<<|>>|!)(?!=)
|
||||
comment: logical operators
|
||||
scope: keyword.operator.logical.wgsl
|
||||
- match: '&(?![&=])'
|
||||
comment: logical AND, borrow references
|
||||
scope: keyword.operator.borrow.and.wgsl
|
||||
- match: (\+=|-=|\*=|/=|%=|\^=|&=|\|=|<<=|>>=)
|
||||
comment: assignment operators
|
||||
scope: keyword.operator.assignment.wgsl
|
||||
- match: '(?<![<>])=(?!=|>)'
|
||||
comment: single equal
|
||||
scope: keyword.operator.assignment.equal.wgsl
|
||||
- match: (=(=)?(?!>)|!=|<=|(?<!=)>=)
|
||||
comment: comparison operators
|
||||
scope: keyword.operator.comparison.wgsl
|
||||
- match: '(([+%]|(\*(?!\w)))(?!=))|(-(?!>))|(/(?!/))'
|
||||
comment: math operators
|
||||
scope: keyword.operator.math.wgsl
|
||||
- match: \.(?!\.)
|
||||
comment: dot access
|
||||
scope: keyword.operator.access.dot.wgsl
|
||||
- match: '->'
|
||||
comment: dashrocket, skinny arrow
|
||||
scope: keyword.operator.arrow.skinny.wgsl
|
||||
line_comments:
|
||||
- match: \s*//.*
|
||||
comment: single line comment
|
||||
scope: comment.line.double-slash.wgsl
|
||||
punctuation:
|
||||
- match: ','
|
||||
comment: comma
|
||||
scope: punctuation.comma.wgsl
|
||||
- match: '[{}]'
|
||||
comment: curly braces
|
||||
scope: punctuation.brackets.curly.wgsl
|
||||
- match: '[()]'
|
||||
comment: parentheses, round brackets
|
||||
scope: punctuation.brackets.round.wgsl
|
||||
- match: ;
|
||||
comment: semicolon
|
||||
scope: punctuation.semi.wgsl
|
||||
- match: '[\[\]]'
|
||||
comment: square brackets
|
||||
scope: punctuation.brackets.square.wgsl
|
||||
- match: '(?<![=-])[<>]'
|
||||
comment: angle brackets
|
||||
scope: punctuation.brackets.angle.wgsl
|
||||
types:
|
||||
- match: \b(bool|i32|u32|f32)\b
|
||||
comment: scalar Types
|
||||
scope: storage.type.wgsl
|
||||
- match: \b(i64|u64|f64)\b
|
||||
comment: reserved scalar Types
|
||||
scope: storage.type.wgsl
|
||||
- match: \b(vec2i|vec3i|vec4i|vec2u|vec3u|vec4u|vec2f|vec3f|vec4f|vec2h|vec3h|vec4h)\b
|
||||
comment: vector type aliasses
|
||||
scope: storage.type.wgsl
|
||||
- match: \b(mat2x2f|mat2x3f|mat2x4f|mat3x2f|mat3x3f|mat3x4f|mat4x2f|mat4x3f|mat4x4f|mat2x2h|mat2x3h|mat2x4h|mat3x2h|mat3x3h|mat3x4h|mat4x2h|mat4x3h|mat4x4h)\b
|
||||
comment: matrix type aliasses
|
||||
scope: storage.type.wgsl
|
||||
- match: '\b(vec[2-4]|mat[2-4]x[2-4])\b'
|
||||
comment: vector/matrix types
|
||||
scope: storage.type.wgsl
|
||||
- match: \b(atomic)\b
|
||||
comment: atomic types
|
||||
scope: storage.type.wgsl
|
||||
- match: \b(array)\b
|
||||
comment: array types
|
||||
scope: storage.type.wgsl
|
||||
- match: '\b([A-Z][A-Za-z0-9]*)\b'
|
||||
comment: Custom type
|
||||
scope: entity.name.type.wgsl
|
||||
variables:
|
||||
- match: '\b(?<!(?<!\.)\.)(?:r#(?!(crate|[Ss]elf|super)))?[a-z0-9_]+\b'
|
||||
comment: variables
|
||||
scope: variable.other.wgsl
|
@ -84,6 +84,7 @@ The following files have been manually modified after converting from a `.tmLang
|
||||
* `Org mode.sublime-syntax` => removed `task` file type.
|
||||
* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension.
|
||||
* `SML.sublime_syntax` => removed `ml` file type.
|
||||
* `wgsl.sublime-syntax` => added `wgsl` file extension.
|
||||
|
||||
### Non-submodule additions
|
||||
|
||||
|
20
tests/syntax-tests/highlighted/WGSL/test.wgsl
vendored
Normal file
20
tests/syntax-tests/highlighted/WGSL/test.wgsl
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m [0m[38;2;166;226;46mVertexOut[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m@[0m[38;2;166;226;46mbuiltin[0m[38;2;248;248;242m([0m[38;2;255;255;255mposition[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;255;255;255mposition[0m[38;2;248;248;242m : [0m[3;38;2;102;217;239mvec4f[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m@[0m[38;2;166;226;46mlocation[0m[38;2;248;248;242m([0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m : [0m[3;38;2;102;217;239mvec4f[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114m@[0m[38;2;166;226;46mvertex[0m
|
||||
[38;2;249;38;114mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mvertex_main[0m[38;2;248;248;242m([0m[38;2;249;38;114m@[0m[38;2;166;226;46mlocation[0m[38;2;248;248;242m([0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;255;255;255mposition[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mvec4f[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m@[0m[38;2;166;226;46mlocation[0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mvec4f[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[38;2;166;226;46mVertexOut[0m
|
||||
[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255moutput[0m[38;2;248;248;242m : [0m[38;2;166;226;46mVertexOut[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255moutput[0m[38;2;249;38;114m.[0m[38;2;248;248;242mposition [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mposition[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255moutput[0m[38;2;249;38;114m.[0m[38;2;248;248;242mcolor [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;255;255;255moutput[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114m@[0m[38;2;166;226;46mfragment[0m
|
||||
[38;2;249;38;114mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mfragment_main[0m[38;2;248;248;242m([0m[38;2;248;248;242mfragData: [0m[38;2;166;226;46mVertexOut[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[38;2;249;38;114m@[0m[38;2;166;226;46mlocation[0m[38;2;248;248;242m([0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvec4f[0m
|
||||
[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m fragData[0m[38;2;249;38;114m.[0m[38;2;248;248;242mcolor[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m}[0m
|
5
tests/syntax-tests/source/WGSL/LICENSE.md
vendored
Normal file
5
tests/syntax-tests/source/WGSL/LICENSE.md
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
The `test.wgsl` file has been added from https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API under the following license:
|
||||
|
||||
```
|
||||
Any copyright is dedicated to the Public Domain: https://creativecommons.org/publicdomain/zero/1.0/
|
||||
```
|
20
tests/syntax-tests/source/WGSL/test.wgsl
vendored
Normal file
20
tests/syntax-tests/source/WGSL/test.wgsl
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
struct VertexOut {
|
||||
@builtin(position) position : vec4f,
|
||||
@location(0) color : vec4f
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn vertex_main(@location(0) position: vec4f,
|
||||
@location(1) color: vec4f) -> VertexOut
|
||||
{
|
||||
var output : VertexOut;
|
||||
output.position = position;
|
||||
output.color = color;
|
||||
return output;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fragment_main(fragData: VertexOut) -> @location(0) vec4f
|
||||
{
|
||||
return fragData.color;
|
||||
}
|
Loading…
Reference in New Issue
Block a user