Skip to content

fix: Incorrect string interpolation highlighting group #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also great.

// ^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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

export printUnit.{status as _, *}
// ^ include
// ^namespace
// ^variable

def status: List[String] = printUnit.status ++ scanUnit.status