aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-09-14 18:30:12 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-09-14 18:30:12 +0200
commit291cb06fc2d578ac19c01ebda9b71f94733af0e8 (patch)
tree42de2f30f49d1bf86239074abfa9578d560c7e1e
parent3a3ed761881ac220b517c30e1e4596ecead4f354 (diff)
Fix comment queries for Neovim
-rw-r--r--.gitignore26
-rw-r--r--Cargo.lock80
-rw-r--r--bindings/node/binding_test.js9
-rw-r--r--bindings/python/tests/test_binding.py11
-rw-r--r--bindings/swift/TreeSitterGspTests/TreeSitterGspTests.swift12
-rw-r--r--go.mod5
-rw-r--r--package-lock.json21
-rw-r--r--queries/gsp/highlights.scm2
8 files changed, 162 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index e60b124..a0c8c50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,22 @@
-/node_modules/
-/target/
-Cargo.lock
-package-lock.json
+target/
+build/
+prebuilds/
+node_modules/
+*.tgz
+.build/
+Package.resolved
+_obj/
+.venv/
+dist/
+*.egg-info
+*.whl
+*.a
+*.so
+*.so.*
+*.dylib
+*.dll
+*.pc
+/examples/*/
+*.wasm
+*.obj
+*.o
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..2d700d1
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,80 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "aho-corasick"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "cc"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.148"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
+
+[[package]]
+name = "memchr"
+version = "2.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
+
+[[package]]
+name = "regex"
+version = "1.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
+
+[[package]]
+name = "tree-sitter"
+version = "0.20.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
+dependencies = [
+ "cc",
+ "regex",
+]
+
+[[package]]
+name = "tree-sitter-gsp"
+version = "0.0.1"
+dependencies = [
+ "cc",
+ "tree-sitter",
+]
diff --git a/bindings/node/binding_test.js b/bindings/node/binding_test.js
new file mode 100644
index 0000000..afede30
--- /dev/null
+++ b/bindings/node/binding_test.js
@@ -0,0 +1,9 @@
+/// <reference types="node" />
+
+const assert = require("node:assert");
+const { test } = require("node:test");
+
+test("can load grammar", () => {
+ const parser = new (require("tree-sitter"))();
+ assert.doesNotThrow(() => parser.setLanguage(require(".")));
+});
diff --git a/bindings/python/tests/test_binding.py b/bindings/python/tests/test_binding.py
new file mode 100644
index 0000000..9da0402
--- /dev/null
+++ b/bindings/python/tests/test_binding.py
@@ -0,0 +1,11 @@
+from unittest import TestCase
+
+import tree_sitter, tree_sitter_gsp
+
+
+class TestLanguage(TestCase):
+ def test_can_load_grammar(self):
+ try:
+ tree_sitter.Language(tree_sitter_gsp.language())
+ except Exception:
+ self.fail("Error loading Gsp grammar")
diff --git a/bindings/swift/TreeSitterGspTests/TreeSitterGspTests.swift b/bindings/swift/TreeSitterGspTests/TreeSitterGspTests.swift
new file mode 100644
index 0000000..df7bc99
--- /dev/null
+++ b/bindings/swift/TreeSitterGspTests/TreeSitterGspTests.swift
@@ -0,0 +1,12 @@
+import XCTest
+import SwiftTreeSitter
+import TreeSitterGsp
+
+final class TreeSitterGspTests: XCTestCase {
+ func testCanLoadGrammar() throws {
+ let parser = Parser()
+ let language = Language(language: tree_sitter_gsp())
+ XCTAssertNoThrow(try parser.setLanguage(language),
+ "Error loading Gsp grammar")
+ }
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..f88138b
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/tree-sitter/tree-sitter-gsp
+
+go 1.23
+
+require github.com/tree-sitter/go-tree-sitter v0.23
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..5f1401e
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,21 @@
+{
+ "name": "tree-sitter-gsp",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "tree-sitter-gsp",
+ "version": "1.0.0",
+ "license": "0BSD",
+ "dependencies": {
+ "nan": "^2.18.0"
+ }
+ },
+ "node_modules/nan": {
+ "version": "2.18.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz",
+ "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w=="
+ }
+ }
+}
diff --git a/queries/gsp/highlights.scm b/queries/gsp/highlights.scm
index a15f087..92e61f6 100644
--- a/queries/gsp/highlights.scm
+++ b/queries/gsp/highlights.scm
@@ -8,3 +8,5 @@
] @tag.attribute
(attribute_value) @string
(comment) @comment
+([_] @comment
+ (#has-ancestor? @comment comment))