summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--queries/pascal/highlights.scm19
-rw-r--r--tests/query/highlights/pascal/test.pas39
2 files changed, 53 insertions, 5 deletions
diff --git a/queries/pascal/highlights.scm b/queries/pascal/highlights.scm
index 1c9dc2ca..77c509cc 100644
--- a/queries/pascal/highlights.scm
+++ b/queries/pascal/highlights.scm
@@ -228,12 +228,20 @@
(literalNumber) @number
(literalString) @string
-; -- Identifiers
-
-; Unless a more specific rule applies, treat identifiers as variables
-(identifier) @variable
+; -- Variables
+
+(exprBinary (identifier) @variable)
+(exprUnary (identifier) @variable)
+(assignment (identifier) @variable)
+(exprBrackets (identifier) @variable)
+(exprParens (identifier) @variable)
+(exprDot (identifier) @variable)
+(exprTpl (identifier) @variable)
+(exprArgs (identifier) @variable)
+(defaultValue (identifier) @variable)
; -- Comments
+
(comment) @comment
(pp) @function.macro
@@ -278,11 +286,12 @@
(genericTpl entity: (genericDot (identifier) @type))
; -- Exception parameters
+
(exceptionHandler variable: (identifier) @parameter)
; -- Type usage
-(typeref (_) @type)
+(typeref) @type
; -- Constant usage
diff --git a/tests/query/highlights/pascal/test.pas b/tests/query/highlights/pascal/test.pas
new file mode 100644
index 00000000..f60e8b40
--- /dev/null
+++ b/tests/query/highlights/pascal/test.pas
@@ -0,0 +1,39 @@
+program foobar;
+// ^ keyword
+
+var
+// <- keyword
+ foo: bar;
+// ^ variable
+// ^ type
+ foo: foo.bar<t>;
+// ^ variable
+// ^ type
+// ^ type
+// ^ type
+begin
+// ^ keyword
+ foo := bar;
+// ^ variable
+// ^ variable
+ foo;
+// ^ function
+ foo();
+// ^ function
+ foo(bar(xyz));
+// ^ function
+// ^ function
+// ^ variable
+ xx + yy;
+// ^ variable
+// ^ variable
+ xx := y + z + func(a, b, c);
+// ^ variable
+// ^ variable
+// ^ variable
+// ^ function
+// ^ variable
+// ^ variable
+// ^ variable
+end.
+// <- keyword