From 7d348f51e442563f4ab2b6c3e136dac658649f93 Mon Sep 17 00:00:00 2001 From: Kasper Kondzielski Date: Thu, 16 Mar 2023 06:28:35 +0100 Subject: [PATCH] fix: Incorrect string interpolation highlighting group (#196) * fix: Incorrect string interpolation highlighting group Co-authored-by: ghostbuster91 --- .github/workflows/ci.yml | 12 ++++++------ bindings/rust/lib.rs | 2 +- package.json | 3 ++- queries/scala/highlights.scm | 5 ++++- queries/scala/locals.scm | 29 +++++++++++++++++++++++++++++ test/highlight/basics.scala | 10 ++++++++-- test/highlight/scala3.scala | 4 ++-- 7 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 queries/scala/locals.scm diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ab6c56..7e19276 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,22 +98,22 @@ jobs: DOTTY_DIR: dotty run: script/smoke_test.sh - - name: copy nvim-treesitter highlight queries + - name: copy nvim-treesitter queries if: ${{ runner.os == 'Linux' }} shell: bash - run: cp ./nvim_treesitter/queries/scala/highlights.scm ./queries/scala/highlights.scm + run: cp ./nvim_treesitter/queries/scala/*.scm ./queries/ - - name: Check if highlight queries are out of sync with nvim-treesitter + - name: Check if queries are out of sync with nvim-treesitter if: ${{ runner.os == 'Linux' }} uses: tj-actions/verify-changed-files@v13 id: verify-changed-files with: files: | - queries/scala/highlights.scm + queries/scala/*.scm - name: Test quries if out of sync with nvim-treesitter if: steps.verify-changed-files.outputs.files_changed == 'true' run: | - echo "::warning file=queries/scala/highlights.scm::Queries in this repo are out of sync with nvim-treesitter" - git diff queries/scala/highlights.scm + echo "::warning Queries in ${{ steps.verify-changed-files.outputs.changed_files }} in this repo are out of sync with nvim-treesitter" + git diff queries/scala/ npm run test diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index a55f824..b75454a 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -37,7 +37,7 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/scala/highlights.scm"); // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); -// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); +pub const LOCALS_QUERY: &'static str = include_str!("../../queries/scala/locals.scm"); // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); #[cfg(test)] diff --git a/package.json b/package.json index cd0fdc0..ea3ae51 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "file-types": [ "scala" ], - "highlights": "queries/scala/highlights.scm" + "highlights": "queries/scala/highlights.scm", + "locals": "queries/scala/locals.scm" } ] } diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index f600dc1..0703ea7 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -23,7 +23,10 @@ (class_parameter name: (identifier) @parameter) -(interpolation) @none +(self_type (identifier) @parameter) + +(interpolation (identifier) @none) +(interpolation (block) @none) ;; types diff --git a/queries/scala/locals.scm b/queries/scala/locals.scm new file mode 100644 index 0000000..8eaa75e --- /dev/null +++ b/queries/scala/locals.scm @@ -0,0 +1,29 @@ +(template_body) @local.scope +(lambda_expression) @local.scope + + +(function_declaration + name: (identifier) @local.definition) @local.scope + +(function_definition + name: (identifier) @local.definition) + +(parameter + name: (identifier) @local.definition) + +(binding + name: (identifier) @local.definition) + +(val_definition + pattern: (identifier) @local.definition) + +(var_definition + pattern: (identifier) @local.definition) + +(val_declaration + name: (identifier) @local.definition) + +(var_declaration + name: (identifier) @local.definition) + +(identifier) @local.reference diff --git a/test/highlight/basics.scala b/test/highlight/basics.scala index be73937..c879c01 100644 --- a/test/highlight/basics.scala +++ b/test/highlight/basics.scala @@ -57,7 +57,7 @@ object Hello { // ^ keyword // ^ type self: X => -// ^type +// ^parameter // ^type } @@ -70,8 +70,14 @@ object Hello { // ^keyword // ^type.definition - val hello = c"some $stuff" + val hello = c"some $mutation ${1}" // ^function.call // ^punctuation.special +// ^variable +// ^number + def meth = ??? +// ^method + val hello2 = c"some $meth" +// ^method } diff --git a/test/highlight/scala3.scala b/test/highlight/scala3.scala index 651a2d7..2ad88ae 100644 --- a/test/highlight/scala3.scala +++ b/test/highlight/scala3.scala @@ -141,9 +141,9 @@ class Copier: export scanUnit.scan // ^ include - // ^namespace + // ^variable export printUnit.{status as _, *} // ^ include - // ^namespace + // ^variable def status: List[String] = printUnit.status ++ scanUnit.status