diff options
| author | Philip Zander <philip.zander@gmail.com> | 2022-01-02 18:12:58 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-01-05 20:59:26 +0100 |
| commit | b05803402965395cfab2c3e9c0258f494dac377d (patch) | |
| tree | 47ae3ca2e9c70a1d356e0e9278846784086960da | |
| parent | e81a60b6927521f7dc218ddb00e2c7fb6b1d797d (diff) | |
highlights(Pascal): Fix highlighting of types
A recent change broke highlighting for namespaces & generic types like
`foo.bar` and `foo<t>`.
| -rw-r--r-- | queries/pascal/highlights.scm | 19 | ||||
| -rw-r--r-- | tests/query/highlights/pascal/test.pas | 39 |
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 |
