Skip to content

Commit

Permalink
fix: Incorrect string interpolation highlighting group (#196)
Browse files Browse the repository at this point in the history
* fix: Incorrect string interpolation highlighting group

Co-authored-by: ghostbuster91 <[email protected]>
  • Loading branch information
Kasper Kondzielski and ghostbuster91 authored Mar 16, 2023
1 parent 6f9bc5a commit 7d348f5
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 13 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion bindings/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"file-types": [
"scala"
],
"highlights": "queries/scala/highlights.scm"
"highlights": "queries/scala/highlights.scm",
"locals": "queries/scala/locals.scm"
}
]
}
5 changes: 4 additions & 1 deletion queries/scala/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
(class_parameter
name: (identifier) @parameter)

(interpolation) @none
(self_type (identifier) @parameter)

(interpolation (identifier) @none)
(interpolation (block) @none)

;; types

Expand Down
29 changes: 29 additions & 0 deletions queries/scala/locals.scm
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions test/highlight/basics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object Hello {
// ^ keyword
// ^ type
self: X =>
// ^type
// ^parameter
// ^type
}

Expand All @@ -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
}

4 changes: 2 additions & 2 deletions test/highlight/scala3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7d348f5

Please sign in to comment.