diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..28eb83b --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This repository is licensed under: + +CC0 1.0 Universal +https://creativecommons.org/publicdomain/zero/1.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed9b9f0 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +## ebitengine-kage-support Ebitengine Kage support for Vim + +Basic syntax and snippet support for the Ebitengine Kage shading language. + +
+ +Ebitengine adopts an original shading language 'Kage'. This has a compatible syntax with Go, but the details are different. Kage has high portability. Ebitengine uses graphics libraries like OpenGL or Metal and this depends on environments, but Kage is compiled on the fly so that this works equally everywhere. + +### Installation + +[![](https://img.shields.io/badge/get%20it%20from-555555?style=for-the-badge&logo=vim&logoColor=60b371)![](https://img.shields.io/badge/vim.org-60b371?style=for-the-badge)](https://www.vim.org/scripts/script.php?script_id=6021) + +
Manual installation
+ + Make sure you are using `vim > 8.0.2` with `python3` support. Building the latest version of vim: + + ``` + git clone https://github.com/vim/vim.git + cd vim/src/ + ./configure --enable-python3interp + make + sudo make install + ``` + + Install `vim-plug` plugin manager: + + ``` + curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + ``` + + Install `vim-easycomplete` and `ultisnips` to support hints and snippets: + + ```vim + Plug 'jayli/vim-easycomplete' + Plug 'SirVer/ultisnips' + ``` + + Install `sedyh/ebitengine-kage-support` to enable syntax highlighting and snippet support for Kage: + + ```vim + Plug 'sedyh/ebitengine-kage-support', {'rtp': 'vim'} + ``` + +
+ +### Other editors + +[![](https://img.shields.io/badge/source-555555?style=for-the-badge&logo=sublimetext&logoColor=ba9759)](https://github.com/sedyh/ebitengine-kage-sublime)[![](https://img.shields.io/badge/download-ba9759?style=for-the-badge)](https://packagecontrol.io)
+[![](https://img.shields.io/badge/source-555555?style=for-the-badge&logo=visualstudiocode&logoColor=72a9d4)](https://github.com/sedyh/ebitengine-kage-vscode)[![](https://img.shields.io/badge/download-72a9d4?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=sedyh.ebitengine-kage) + + +### Features + +- [Basic syntax highlighting](#basic-syntax-highlighting) +- [Quick start](#quick-start) +- [Short documentation](#short-documentation) +- [List of all built-in functions](#list-of-all-built-in-functions) + +### Basic syntax highlighting + +back This plugin provides basic Kage language support for Ebitengine. It includes keywords, types, literals and snippets. + +![feature-syntax](https://user-images.githubusercontent.com/19890545/179100567-bcd809b1-d9b1-48e3-830a-55259feb463a.png) + +### Quick start + +back To quickly start writing a shader, you can type "fragment" or "package". + +![feature-quickstart](https://user-images.githubusercontent.com/19890545/179321074-51b8bdf4-07d6-4ab9-b14d-8c201564becc.png) + +### Short documentation + +back The plugin provides a short help for each feature in Kage. + +![feature-description](https://user-images.githubusercontent.com/19890545/179321166-23841d30-8e30-4784-9f53-d5067cf57463.png) + +### List of all built-in functions + +back You can see a list of all built-in functions by typing "kage". + +![feature-help](https://user-images.githubusercontent.com/19890545/179321661-059ae3ca-f69e-4640-a213-ec3287b801b4.png) + +## Known Issues + +The plugin will highlight complex numbers despite the fact that, at the moment, Kage does not support them. + +There are some problems with displaying scientific notation for floating point numbers (two numbers with the -+ operator without spaces will be highlighted as one). diff --git a/UltiSnips/kage.snippets b/UltiSnips/kage.snippets new file mode 100644 index 0000000..2336908 --- /dev/null +++ b/UltiSnips/kage.snippets @@ -0,0 +1,350 @@ +priority -50 + +snippet fragment "The basis for the shader" +package main + +func Fragment(pos vec4, tex vec2, col vec4) vec4 { + ${0:${VISUAL}} + return vec4(0.5, 0.0, 0.0, 1.0) +} +endsnippet + +snippet vec2 "Usage vec2(x, y) or vec2(x)" +vec2(0, 0) +endsnippet + +snippet vec3 "Usage vec3(x, y, z) or vec3(x)" +vec3(0, 0, 0) +endsnippet + +snippet vec4 "Usage vec4(x, y, z, w) or vec4(x)" +vec4(0, 0, 0, 0) +endsnippet + +snippet mat2 "Usage mat2(a, b, c, d)" +mat2( + 0, 0, + 0, 0, +) +endsnippet + +snippet mat3 "Usage mat3(a, b, c, d, e, f, g, h, i)" +mat3( + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, +) +endsnippet + +snippet mat4 "Usage mat4(a, b, c, d, e, f, g, h, i, j, k, l" +mat4( + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, +) +endsnippet + +snippet sin "Usage sin(x T), T is float or vec" +sin(${0:${VISUAL}}) +endsnippet + +snippet cos "Usage cos(x T), T is float or vec" +cos(${0:${VISUAL}}) +endsnippet + +snippet tan "Usage tan(x T), T is float or vec" +tan(${0:${VISUAL}}) +endsnippet + +snippet asin "Usage asin(x T), T is float or vec" +asin(${0:${VISUAL}}) +endsnippet + +snippet acos "Usage acos(x T), T is float or vec" +acos(${0:${VISUAL}}) +endsnippet + +snippet atan "Usage atan(y_over_x T), T is float or vec" +atan(${0:${VISUAL}}) +endsnippet + +snippet atan2 "Usage atan2(x, y T), T is float or vec" +atan2(${0:${VISUAL}}) +endsnippet + +snippet pow "Usage pow(x, y T), T is float or vec" +pow(${0:${VISUAL}}) +endsnippet + +snippet exp "Usage exp(x T), T is float or vec" +exp(${0:${VISUAL}}) +endsnippet + +snippet log "Usage log(x T), T is float or vec" +log(${0:${VISUAL}}) +endsnippet + +snippet exp2 "Usage exp2(x T), T is float or vec" +exp2(${0:${VISUAL}}) +endsnippet + +snippet log2 "Usage log2(x T), T is float or vec" +log2(${0:${VISUAL}}) +endsnippet + +snippet sqrt "Usage sqrt(x T), T is float or vec" +sqrt(${0:${VISUAL}}) +endsnippet + +snippet inversesqrt "Usage inversesqrt(x T), T is float or vec" +inversesqrt(${0:${VISUAL}}) +endsnippet + +snippet abs "Usage abs(x T), T is float or vec" +abs(${0:${VISUAL}}) +endsnippet + +snippet sign "Usage sign(x T), T is float or vec" +sign(${0:${VISUAL}}) +endsnippet + +snippet floor "Usage floor(x T), T is float or vec" +floor(${0:${VISUAL}}) +endsnippet + +snippet ceil "Usage ceil(x T), T is float or vec" +ceil(${0:${VISUAL}}) +endsnippet + +snippet fract "Usage fract(x T), T is float or vec" +fract(${0:${VISUAL}}) +endsnippet + +snippet mod "Usage mod(x, y T), T is float or vec" +mod(${0:${VISUAL}}) +endsnippet + +snippet min "Usage min(x, y T), T is float or vec" +min(${0:${VISUAL}}) +endsnippet + +snippet max "Usage max(x, y T), T is float or vec" +max(${0:${VISUAL}}) +endsnippet + +snippet clamp "Usage clap(x, min, max T), T is float or vec" +clamp(${0:${VISUAL}}) +endsnippet + +snippet mix "Usage mix(x, y, a T), T is float or vec" +mix(${0:${VISUAL}}) +endsnippet + +snippet step "Usage step(edge, x T), T is float or vec" +step(${0:${VISUAL}}) +endsnippet + +snippet smoothstep "Usage smoothstep(edge0, edge1, x T), T is float or vec" +smoothstep(${0:${VISUAL}}) +endsnippet + +snippet length "Usage length(x T), T is float or vec" +length(${0:${VISUAL}}) +endsnippet + +snippet distance "Usage distance(p0, p1 T), T is float or vec" +distance(${0:${VISUAL}}) +endsnippet + +snippet dot "Usage dot(x, y T), T is float or vec" +dot(${0:${VISUAL}}) +endsnippet + +snippet cross "Usage cross(x, y vec3)" +cross(${0:${VISUAL}}) +endsnippet + +snippet normalize "Usage normalize(x T), T is float or vec" +normalize(${0:${VISUAL}}) +endsnippet + +snippet faceforward "Usage faceforward(n, i, nref T), T is float or vec" +faceforward(${0:${VISUAL}}) +endsnippet + +snippet reflect "Usage reflect(i, n T), T is float or vec" +reflect(${0:${VISUAL}}) +endsnippet + +snippet refract "Usage refract(i, n T, eta float), T is float or vec" +refract(${0:${VISUAL}}) +endsnippet + +snippet transpose "Usage transpose(x T), T is mat" +transpose(${0:${VISUAL}}) +endsnippet + +snippet dfdx "Usage dfdx(x T), T is float or vec" +dfdx(${0:${VISUAL}}) +endsnippet + +snippet dfdy "Usage dfdy(x T), T is float or vec" +dfdy(${0:${VISUAL}}) +endsnippet + +snippet fwidth "Usage fwidth(x T), T is float or vec" +fwidth(${0:${VISUAL}}) +endsnippet + +snippet kage:sin "Usage sin(x T), T is float or vec" +sin(${0:${VISUAL}}) +endsnippet + +snippet kage:cos "Usage cos(x T), T is float or vec" +cos(${0:${VISUAL}}) +endsnippet + +snippet kage:tan "Usage tan(x T), T is float or vec" +tan(${0:${VISUAL}}) +endsnippet + +snippet kage:asin "Usage asin(x T), T is float or vec" +asin(${0:${VISUAL}}) +endsnippet + +snippet kage:acos "Usage acos(x T), T is float or vec" +acos(${0:${VISUAL}}) +endsnippet + +snippet kage:atan "Usage atan(y_over_x T), T is float or vec" +atan(${0:${VISUAL}}) +endsnippet + +snippet kage:atan2 "Usage atan2(x, y T), T is float or vec" +atan2(${0:${VISUAL}}) +endsnippet + +snippet kage:pow "Usage pow(x, y T), T is float or vec" +pow(${0:${VISUAL}}) +endsnippet + +snippet kage:exp "Usage exp(x T), T is float or vec" +exp(${0:${VISUAL}}) +endsnippet + +snippet kage:log "Usage log(x T), T is float or vec" +log(${0:${VISUAL}}) +endsnippet + +snippet kage:exp2 "Usage exp2(x T), T is float or vec" +exp2(${0:${VISUAL}}) +endsnippet + +snippet kage:log2 "Usage log2(x T), T is float or vec" +log2(${0:${VISUAL}}) +endsnippet + +snippet kage:sqrt "Usage sqrt(x T), T is float or vec" +sqrt(${0:${VISUAL}}) +endsnippet + +snippet kage:inversesqrt "Usage inversesqrt(x T), T is float or vec" +inversesqrt(${0:${VISUAL}}) +endsnippet + +snippet kage:abs "Usage abs(x T), T is float or vec" +abs(${0:${VISUAL}}) +endsnippet + +snippet kage:sign "Usage sign(x T), T is float or vec" +sign(${0:${VISUAL}}) +endsnippet + +snippet kage:floor "Usage floor(x T), T is float or vec" +floor(${0:${VISUAL}}) +endsnippet + +snippet kage:ceil "Usage ceil(x T), T is float or vec" +ceil(${0:${VISUAL}}) +endsnippet + +snippet kage:fract "Usage fract(x T), T is float or vec" +fract(${0:${VISUAL}}) +endsnippet + +snippet kage:mod "Usage mod(x, y T), T is float or vec" +mod(${0:${VISUAL}}) +endsnippet + +snippet kage:min "Usage min(x, y T), T is float or vec" +min(${0:${VISUAL}}) +endsnippet + +snippet kage:max "Usage max(x, y T), T is float or vec" +max(${0:${VISUAL}}) +endsnippet + +snippet kage:clamp "Usage clap(x, min, max T), T is float or vec" +clamp(${0:${VISUAL}}) +endsnippet + +snippet kage:mix "Usage mix(x, y, a T), T is float or vec" +mix(${0:${VISUAL}}) +endsnippet + +snippet kage:step "Usage step(edge, x T), T is float or vec" +step(${0:${VISUAL}}) +endsnippet + +snippet kage:smoothstep "Usage smoothstep(edge0, edge1, x T), T is float or vec" +smoothstep(${0:${VISUAL}}) +endsnippet + +snippet kage:length "Usage length(x T), T is float or vec" +length(${0:${VISUAL}}) +endsnippet + +snippet kage:distance "Usage distance(p0, p1 T), T is float or vec" +distance(${0:${VISUAL}}) +endsnippet + +snippet kage:dot "Usage dot(x, y T), T is float or vec" +dot(${0:${VISUAL}}) +endsnippet + +snippet kage:cross "Usage cross(x, y vec3)" +cross(${0:${VISUAL}}) +endsnippet + +snippet kage:normalize "Usage normalize(x T), T is float or vec" +normalize(${0:${VISUAL}}) +endsnippet + +snippet kage:faceforward "Usage faceforward(n, i, nref T), T is float or vec" +faceforward(${0:${VISUAL}}) +endsnippet + +snippet kage:reflect "Usage reflect(i, n T), T is float or vec" +reflect(${0:${VISUAL}}) +endsnippet + +snippet kage:refract "Usage refract(i, n T, eta float), T is float or vec" +refract(${0:${VISUAL}}) +endsnippet + +snippet kage:transpose "Usage transpose(x T), T is mat" +transpose(${0:${VISUAL}}) +endsnippet + +snippet kage:dfdx "Usage dfdx(x T), T is float or vec" +dfdx(${0:${VISUAL}}) +endsnippet + +snippet kage:dfdy "Usage dfdy(x T), T is float or vec" +dfdy(${0:${VISUAL}}) +endsnippet + +snippet kage:fwidth "Usage fwidth(x T), T is float or vec" +fwidth(${0:${VISUAL}}) +endsnippet diff --git a/ftdetect/kage.vim b/ftdetect/kage.vim new file mode 100644 index 0000000..52f6c51 --- /dev/null +++ b/ftdetect/kage.vim @@ -0,0 +1,2 @@ +au BufRead,BufNewFile *.kage set filetype=kage + diff --git a/syntax/kage.vim b/syntax/kage.vim new file mode 100644 index 0000000..5194a97 --- /dev/null +++ b/syntax/kage.vim @@ -0,0 +1,27 @@ +" Keywords +syn keyword kageKeyword package var func if else for return true false nil +syn keyword kageType bool int float vec2 vec3 vec4 mat2 mat3 mat4 +syn keyword kageBuiltin sin cos tan asin acos atan atan2 pow exp log exp2 log2 sqrt inversesqrt abs sign floor ceil fract mod min max clamp mix step smoothstep length distance dot bcross normalize faceforward reflect refract transpose dfdx dfdy fwidth + +" Matches +syn match kageNumber "\(\w\)\@