From f05393381d3bf3ac4f3fe3df940df088d87f3c39 Mon Sep 17 00:00:00 2001
From: Danila Mihailov <danilamihailov@icloud.com>
Date: Sat, 11 May 2024 01:02:35 +0500
Subject: [PATCH 1/2] feat(treesitter): add injections of glsl

---
 after/queries/lua/injections.scm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 after/queries/lua/injections.scm

diff --git a/after/queries/lua/injections.scm b/after/queries/lua/injections.scm
new file mode 100644
index 0000000..30e9fcf
--- /dev/null
+++ b/after/queries/lua/injections.scm
@@ -0,0 +1,19 @@
+;; extends
+
+;; inject glsl for any string that starts `#pragma language glsl`
+(string 
+  content: _ @injection.content
+  (#lua-match? @injection.content "^%s*#pragma language glsl")
+  (#set! injection.language "glsl"))
+
+
+; inject glsl for calls to newShader
+; love.graphics.newShader([[...]])
+; and even just newShader([[...]])
+((function_call
+  name: (_) @_function
+  arguments: (arguments
+    (string
+      content: _ @injection.content)))
+  (#contains? @_function "newShader")
+  (#set! injection.language "glsl"))

From bfafe887c4fe02f94ffe4aac5c5fe3222459deeb Mon Sep 17 00:00:00 2001
From: Danila Mihailov <danilamihailov@icloud.com>
Date: Sat, 11 May 2024 22:14:42 +0500
Subject: [PATCH 2/2] docs(treesitter): add docs for treesitter and glsl

---
 doc/love2d.txt | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/doc/love2d.txt b/doc/love2d.txt
index 960d892..f064d1b 100644
--- a/doc/love2d.txt
+++ b/doc/love2d.txt
@@ -8,6 +8,7 @@ Table of contents:
 1. SETUP: Install and setup the plugin.                         |love2d-setup|
 2. COMMANDS: Commands provided by the plugin.                |love2d-commands|
 3. LSP: Explaining LSP support for LÖVE.                          |love2d-lsp|
+4. GLSL: Notes about GLSL and tree-sitter support.               |love2d-glsl|
 
 
 ================================================================================
@@ -113,5 +114,44 @@ add the `love` namespace to the LSP.
 For example, when placing the cursor over the `love` variable and pressing
 `K`, you should see the documentation for the `love` namespace.
 
+
+================================================================================
+GLSL                                                             *love2d-glsl*
+
+OpenGL Shading Language (GLSL) is a high-level shading language for writing
+shaders. Shaders are small programs which are run on the graphics card when
+drawing. See https://www.love2d.org/wiki/love.graphics.newShader section
+"Shader Language" for love2d specific aliases.
+
+This plugin adds additional queries for |treesitter| to support inline GLSL in
+specific places. For example when calling `love.graphics.newShader()`.
+
+For these queries to take effect you need to have `lua` and `glsl` parsers
+installed. Easiest way to do so is by using plugin `nvim-treesitter` from
+github https://github.com/nvim-treesitter/nvim-treesitter . After installing
+the plugin, you can run `:TSInstall lua glsl` to install parsers.
+
+Doing so will enable neovim to "understand" that string inside
+`love.graphics.newShader()` is not just a string, but a `glsl` code. And you
+will get:
+
+1. Syntax highlighting for inline shaders.
+2. If you have `Comment.nvim`, it will now properly comment inside shaders.
+3. Plugin `nvim-treesitter-textobjects`, now will work inside shaders.
+4. And any other plugin/feature that depends on treesitter.
+
+If parsers are installed and plugin is loaded you should see the code below
+properly highlighted! (you may have to execute |:edit| to refresh current file)
+
+>lua
+  love.graphics.newShader([[
+    vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords)
+    {
+        vec4 texturecolor = VideoTexel(texture_coords);
+        return texturecolor * color;
+    }
+  ]])
+<
+
 ==============================================================================
  vim:tw=78:ts=8:et:ft=help:norl: