Skip to content

Commit bfafe88

Browse files
docs(treesitter): add docs for treesitter and glsl
1 parent f053933 commit bfafe88

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

doc/love2d.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Table of contents:
88
1. SETUP: Install and setup the plugin. |love2d-setup|
99
2. COMMANDS: Commands provided by the plugin. |love2d-commands|
1010
3. LSP: Explaining LSP support for LÖVE. |love2d-lsp|
11+
4. GLSL: Notes about GLSL and tree-sitter support. |love2d-glsl|
1112

1213

1314
================================================================================
@@ -113,5 +114,44 @@ add the `love` namespace to the LSP.
113114
For example, when placing the cursor over the `love` variable and pressing
114115
`K`, you should see the documentation for the `love` namespace.
115116

117+
118+
================================================================================
119+
GLSL *love2d-glsl*
120+
121+
OpenGL Shading Language (GLSL) is a high-level shading language for writing
122+
shaders. Shaders are small programs which are run on the graphics card when
123+
drawing. See https://www.love2d.org/wiki/love.graphics.newShader section
124+
"Shader Language" for love2d specific aliases.
125+
126+
This plugin adds additional queries for |treesitter| to support inline GLSL in
127+
specific places. For example when calling `love.graphics.newShader()`.
128+
129+
For these queries to take effect you need to have `lua` and `glsl` parsers
130+
installed. Easiest way to do so is by using plugin `nvim-treesitter` from
131+
github https://github.com/nvim-treesitter/nvim-treesitter . After installing
132+
the plugin, you can run `:TSInstall lua glsl` to install parsers.
133+
134+
Doing so will enable neovim to "understand" that string inside
135+
`love.graphics.newShader()` is not just a string, but a `glsl` code. And you
136+
will get:
137+
138+
1. Syntax highlighting for inline shaders.
139+
2. If you have `Comment.nvim`, it will now properly comment inside shaders.
140+
3. Plugin `nvim-treesitter-textobjects`, now will work inside shaders.
141+
4. And any other plugin/feature that depends on treesitter.
142+
143+
If parsers are installed and plugin is loaded you should see the code below
144+
properly highlighted! (you may have to execute |:edit| to refresh current file)
145+
146+
>lua
147+
love.graphics.newShader([[
148+
vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords)
149+
{
150+
vec4 texturecolor = VideoTexel(texture_coords);
151+
return texturecolor * color;
152+
}
153+
]])
154+
<
155+
116156
==============================================================================
117157
vim:tw=78:ts=8:et:ft=help:norl:

0 commit comments

Comments
 (0)