summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz S. Szczygieł2021-11-08 15:48:00 +0000
committerGitHub2021-11-08 15:48:00 +0000
commit3f0345ff5814cea1d733ec2c5d846db66de29af6 (patch)
tree6b09002e24f288ff027e172af25597ed1e6d598f
parent549cdee56159bed4266990ae66591dd6299293d4 (diff)
glsl support (#993)
* add glsl language support * glsl: use indents.toml file
-rw-r--r--.gitmodules4
m---------helix-syntax/languages/tree-sitter-glsl0
-rw-r--r--languages.toml8
-rw-r--r--runtime/queries/glsl/folds.scm1
-rw-r--r--runtime/queries/glsl/highlights.scm37
-rw-r--r--runtime/queries/glsl/indents.toml19
-rw-r--r--runtime/queries/glsl/injections.scm3
-rw-r--r--runtime/queries/glsl/locals.scm1
8 files changed, 73 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index 5c6f22cd..bf596bdc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -134,6 +134,10 @@
path = helix-syntax/languages/tree-sitter-cmake
url = https://github.com/uyha/tree-sitter-cmake
shallow = true
+[submodule "helix-syntax/languages/tree-sitter-glsl"]
+ path = helix-syntax/languages/tree-sitter-glsl
+ url = https://github.com/theHamsta/tree-sitter-glsl.git
+ shallow = true
[submodule "helix-syntax/languages/tree-sitter-perl"]
path = helix-syntax/languages/tree-sitter-perl
url = https://github.com/ganezdragon/tree-sitter-perl
diff --git a/helix-syntax/languages/tree-sitter-glsl b/helix-syntax/languages/tree-sitter-glsl
new file mode 160000
+Subproject 88408ffc5e27abcffced7010fc77396ae3636d7
diff --git a/languages.toml b/languages.toml
index 067138e4..45fc2ab2 100644
--- a/languages.toml
+++ b/languages.toml
@@ -402,6 +402,14 @@ indent = { tab-width = 2, unit = " " }
language-server = { command = "cmake-language-server" }
[[language]]
+name = "glsl"
+scope = "source.glsl"
+file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ]
+roots = []
+comment-token = "//"
+indent = { tab-width = 4, unit = " " }
+
+[[language]]
name = "perl"
scope = "source.perl"
file-types = ["pl", "pm"]
diff --git a/runtime/queries/glsl/folds.scm b/runtime/queries/glsl/folds.scm
new file mode 100644
index 00000000..a5a5208c
--- /dev/null
+++ b/runtime/queries/glsl/folds.scm
@@ -0,0 +1 @@
+; inherits: c
diff --git a/runtime/queries/glsl/highlights.scm b/runtime/queries/glsl/highlights.scm
new file mode 100644
index 00000000..af2a049f
--- /dev/null
+++ b/runtime/queries/glsl/highlights.scm
@@ -0,0 +1,37 @@
+; inherits: c
+
+[
+ "in"
+ "out"
+ "inout"
+ "uniform"
+ "shared"
+ "layout"
+ "attribute"
+ "varying"
+ "buffer"
+ "coherent"
+ "readonly"
+ "writeonly"
+ "precision"
+ "highp"
+ "mediump"
+ "lowp"
+ "centroid"
+ "sample"
+ "patch"
+ "smooth"
+ "flat"
+ "noperspective"
+ "invariant"
+ "precise"
+] @keyword
+
+"subroutine" @keyword.function
+
+(extension_storage_class) @attribute
+
+(
+ (identifier) @variable.builtin
+ (#match? @variable.builtin "^gl_")
+)
diff --git a/runtime/queries/glsl/indents.toml b/runtime/queries/glsl/indents.toml
new file mode 100644
index 00000000..a7fd499a
--- /dev/null
+++ b/runtime/queries/glsl/indents.toml
@@ -0,0 +1,19 @@
+indent = [
+ "init_declarator",
+ "compound_statement",
+ "preproc_arg",
+ "field_declaration_list",
+ "case_statement",
+ "conditional_expression",
+ "enumerator_list",
+ "struct_specifier",
+ "compound_literal_expression"
+]
+
+outdent = [
+ "#define",
+ "#ifdef",
+ "#endif",
+ "{",
+ "}"
+]
diff --git a/runtime/queries/glsl/injections.scm b/runtime/queries/glsl/injections.scm
new file mode 100644
index 00000000..7d3323b1
--- /dev/null
+++ b/runtime/queries/glsl/injections.scm
@@ -0,0 +1,3 @@
+(preproc_arg) @glsl
+
+(comment) @comment
diff --git a/runtime/queries/glsl/locals.scm b/runtime/queries/glsl/locals.scm
new file mode 100644
index 00000000..a5a5208c
--- /dev/null
+++ b/runtime/queries/glsl/locals.scm
@@ -0,0 +1 @@
+; inherits: c