diff --git a/data/fixtures/recorded/surroundingPair/parseTree/clojure/changePair.yml b/data/fixtures/recorded/surroundingPair/parseTree/clojure/changePair.yml new file mode 100644 index 0000000000..30c5b54a27 --- /dev/null +++ b/data/fixtures/recorded/surroundingPair/parseTree/clojure/changePair.yml @@ -0,0 +1,25 @@ +languageId: clojure +command: + version: 7 + spokenForm: change pair + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: any} + usePrePhraseSnapshot: false +initialState: + documentContents: |- + "Hello + world" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/scopes/clojure/anonymousFunction.scope b/data/fixtures/scopes/clojure/anonymousFunction.scope new file mode 100644 index 0000000000..27a9f95a0b --- /dev/null +++ b/data/fixtures/scopes/clojure/anonymousFunction.scope @@ -0,0 +1,10 @@ +(fn [] 0) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| (fn [] 0) + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/clojure/anonymousFunction2.scope b/data/fixtures/scopes/clojure/anonymousFunction2.scope new file mode 100644 index 0000000000..7202d72250 --- /dev/null +++ b/data/fixtures/scopes/clojure/anonymousFunction2.scope @@ -0,0 +1,10 @@ +#(* % 2) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| #(* % 2) + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/clojure/argument.actual.iteration.scope b/data/fixtures/scopes/clojure/argument.actual.iteration.scope new file mode 100644 index 0000000000..f92f5d03c9 --- /dev/null +++ b/data/fixtures/scopes/clojure/argument.actual.iteration.scope @@ -0,0 +1,10 @@ +(foo aaa bbb) +--- + +[Content] = 0:1-0:12 + >-----------< +0| (foo aaa bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| (foo aaa bbb) diff --git a/data/fixtures/scopes/clojure/argument.actual.multiLine.scope b/data/fixtures/scopes/clojure/argument.actual.multiLine.scope new file mode 100644 index 0000000000..806e7957fb --- /dev/null +++ b/data/fixtures/scopes/clojure/argument.actual.multiLine.scope @@ -0,0 +1,37 @@ +(foo + aaa + bbb) +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:7 + >---< +1| aaa + +[#1 Removal] = 1:0-2:0 + >------- +1| aaa +2| bbb) + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| aaa + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:7 + >---< +2| bbb) + +[#2 Removal] = 2:0-2:7 + >-------< +2| bbb) + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| bbb) + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/clojure/argument.actual.singleLine.scope b/data/fixtures/scopes/clojure/argument.actual.singleLine.scope new file mode 100644 index 0000000000..1828f4ba35 --- /dev/null +++ b/data/fixtures/scopes/clojure/argument.actual.singleLine.scope @@ -0,0 +1,37 @@ +(foo aaa bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:5-0:8 + >---< +0| (foo aaa bbb) + +[#1 Removal] = 0:5-0:9 + >----< +0| (foo aaa bbb) + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| (foo aaa bbb) + +[#1 Trailing delimiter] = 0:8-0:9 + >-< +0| (foo aaa bbb) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:9-0:12 + >---< +0| (foo aaa bbb) + +[#2 Removal] = 0:8-0:12 + >----< +0| (foo aaa bbb) + +[#2 Leading delimiter] = 0:8-0:9 + >-< +0| (foo aaa bbb) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/argumentList.actual.empty.scope b/data/fixtures/scopes/clojure/argumentList.actual.empty.scope new file mode 100644 index 0000000000..79c03b287e --- /dev/null +++ b/data/fixtures/scopes/clojure/argumentList.actual.empty.scope @@ -0,0 +1,13 @@ +() +--- + +[Content] = +[Removal] = 0:1-0:1 + >< +0| () + +[Domain] = 0:0-0:2 + >--< +0| () + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/clojure/argumentList.actual.multiLine.scope b/data/fixtures/scopes/clojure/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..9ff346343f --- /dev/null +++ b/data/fixtures/scopes/clojure/argumentList.actual.multiLine.scope @@ -0,0 +1,21 @@ +(foo + aaa + bbb) +--- + +[Content] = +[Removal] = 0:1-2:7 + >--- +0| (foo +1| aaa +2| bbb) + -------< + +[Domain] = 0:0-2:8 + >---- +0| (foo +1| aaa +2| bbb) + --------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/clojure/argumentList.actual.singleLine.scope b/data/fixtures/scopes/clojure/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..61b444a507 --- /dev/null +++ b/data/fixtures/scopes/clojure/argumentList.actual.singleLine.scope @@ -0,0 +1,13 @@ +(foo aaa bbb) +--- + +[Content] = +[Removal] = 0:1-0:12 + >-----------< +0| (foo aaa bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| (foo aaa bbb) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/condition.if.scope b/data/fixtures/scopes/clojure/condition.if.scope new file mode 100644 index 0000000000..a7e84484d6 --- /dev/null +++ b/data/fixtures/scopes/clojure/condition.if.scope @@ -0,0 +1,25 @@ +(if true + aaa + bbb) +--- + +[Content] = 0:4-0:8 + >----< +0| (if true + +[Removal] = 0:3-0:8 + >-----< +0| (if true + +[Leading delimiter] = 0:3-0:4 + >-< +0| (if true + +[Domain] = 0:0-2:8 + >-------- +0| (if true +1| aaa +2| bbb) + --------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/disqualifyDelimiter.scope b/data/fixtures/scopes/clojure/disqualifyDelimiter.scope new file mode 100644 index 0000000000..3915696a3e --- /dev/null +++ b/data/fixtures/scopes/clojure/disqualifyDelimiter.scope @@ -0,0 +1,20 @@ +(< 1 2) +(> 1 2) +(<= 1 2) +(>= 1 2) +--- +[#1 Content] = 0:1-0:2 + >-< +0| (< 1 2) + +[#2 Content] = 1:1-1:2 + >-< +1| (> 1 2) + +[#3 Content] = 2:1-2:3 + >--< +2| (<= 1 2) + +[#4 Content] = 3:1-3:3 + >--< +3| (>= 1 2) diff --git a/data/fixtures/scopes/clojure/functionCall.scope b/data/fixtures/scopes/clojure/functionCall.scope new file mode 100644 index 0000000000..8dfbcd72cb --- /dev/null +++ b/data/fixtures/scopes/clojure/functionCall.scope @@ -0,0 +1,10 @@ +(foo) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| (foo) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/functionCallee.scope b/data/fixtures/scopes/clojure/functionCallee.scope new file mode 100644 index 0000000000..2dbdd3015d --- /dev/null +++ b/data/fixtures/scopes/clojure/functionCallee.scope @@ -0,0 +1,13 @@ +(foo) +--- + +[Content] = +[Removal] = 0:1-0:4 + >---< +0| (foo) + +[Domain] = 0:0-0:5 + >-----< +0| (foo) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/ifStatement.scope b/data/fixtures/scopes/clojure/ifStatement.scope new file mode 100644 index 0000000000..3417a28c37 --- /dev/null +++ b/data/fixtures/scopes/clojure/ifStatement.scope @@ -0,0 +1,15 @@ +(if true + aaa + bbb) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:8 + >-------- +0| (if true +1| aaa +2| bbb) + --------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/clojure/list.scope b/data/fixtures/scopes/clojure/list.scope new file mode 100644 index 0000000000..40139bf939 --- /dev/null +++ b/data/fixtures/scopes/clojure/list.scope @@ -0,0 +1,10 @@ +[aaa bbb] +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| [aaa bbb] + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/list2.scope b/data/fixtures/scopes/clojure/list2.scope new file mode 100644 index 0000000000..7261ba0780 --- /dev/null +++ b/data/fixtures/scopes/clojure/list2.scope @@ -0,0 +1,10 @@ +'[aaa bbb] +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| '[aaa bbb] + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/list3.scope b/data/fixtures/scopes/clojure/list3.scope new file mode 100644 index 0000000000..84f9348900 --- /dev/null +++ b/data/fixtures/scopes/clojure/list3.scope @@ -0,0 +1,10 @@ +'(aaa bbb) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| '(aaa bbb) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/map.scope b/data/fixtures/scopes/clojure/map.scope new file mode 100644 index 0000000000..79f40a9fbd --- /dev/null +++ b/data/fixtures/scopes/clojure/map.scope @@ -0,0 +1,10 @@ +{:aaa 0 :bbb 1} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| {:aaa 0 :bbb 1} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/map2.scope b/data/fixtures/scopes/clojure/map2.scope new file mode 100644 index 0000000000..d09bf85efd --- /dev/null +++ b/data/fixtures/scopes/clojure/map2.scope @@ -0,0 +1,10 @@ +'{:aaa 0 :bbb 1} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:16 + >----------------< +0| '{:aaa 0 :bbb 1} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/name.function.scope b/data/fixtures/scopes/clojure/name.function.scope new file mode 100644 index 0000000000..8522014053 --- /dev/null +++ b/data/fixtures/scopes/clojure/name.function.scope @@ -0,0 +1,24 @@ +(defn foo [] 0) +--- + +[Content] = 0:6-0:9 + >---< +0| (defn foo [] 0) + +[Removal] = 0:6-0:10 + >----< +0| (defn foo [] 0) + +[Leading delimiter] = 0:5-0:6 + >-< +0| (defn foo [] 0) + +[Trailing delimiter] = 0:9-0:10 + >-< +0| (defn foo [] 0) + +[Domain] = 0:0-0:15 + >---------------< +0| (defn foo [] 0) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/namedFunction.iteration.document.scope b/data/fixtures/scopes/clojure/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..4b13b944b9 --- /dev/null +++ b/data/fixtures/scopes/clojure/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +(defn foo [] 0) + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| (defn foo [] 0) +2| + < diff --git a/data/fixtures/scopes/clojure/namedFunction.scope b/data/fixtures/scopes/clojure/namedFunction.scope new file mode 100644 index 0000000000..39e64cc91c --- /dev/null +++ b/data/fixtures/scopes/clojure/namedFunction.scope @@ -0,0 +1,10 @@ +(defn foo [] 0) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| (defn foo [] 0) + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/clojure/string.multiLine.scope b/data/fixtures/scopes/clojure/string.multiLine.scope new file mode 100644 index 0000000000..e8f7baaa0a --- /dev/null +++ b/data/fixtures/scopes/clojure/string.multiLine.scope @@ -0,0 +1,13 @@ +"Hello +world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:6 + >------ +0| "Hello +1| world" + ------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/string.singleLine.scope b/data/fixtures/scopes/clojure/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/clojure/string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/textFragment.comment.line.scope b/data/fixtures/scopes/clojure/textFragment.comment.line.scope new file mode 100644 index 0000000000..6ba8e375cc --- /dev/null +++ b/data/fixtures/scopes/clojure/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +;; Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| ;; Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/textFragment.string.multiLine.scope b/data/fixtures/scopes/clojure/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..2780f7ce95 --- /dev/null +++ b/data/fixtures/scopes/clojure/textFragment.string.multiLine.scope @@ -0,0 +1,13 @@ +"Hello +world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-1:5 + >----- +0| "Hello +1| world" + -----< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/clojure/textFragment.string.singleLine.scope b/data/fixtures/scopes/clojure/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..85dcf5fa7f --- /dev/null +++ b/data/fixtures/scopes/clojure/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/clojure.ts b/packages/common/src/scopeSupportFacets/clojure.ts index 3853f1358e..c557d6ed59 100644 --- a/packages/common/src/scopeSupportFacets/clojure.ts +++ b/packages/common/src/scopeSupportFacets/clojure.ts @@ -1,9 +1,371 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; +const { supported, notApplicable } = ScopeSupportFacetLevel; export const clojureScopeSupport: LanguageScopeSupportFacetMap = { + disqualifyDelimiter: supported, + list: supported, + map: supported, + ifStatement: supported, + "condition.if": supported, "comment.line": supported, + "name.function": supported, + anonymousFunction: supported, + + namedFunction: supported, + "namedFunction.iteration.document": supported, + + functionCall: supported, + functionCallee: supported, + + "argument.actual.singleLine": supported, + "argument.actual.multiLine": supported, + "argument.actual.iteration": supported, + + "argumentList.actual.empty": supported, + "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + + "string.singleLine": supported, + "string.multiLine": supported, + + "textFragment.comment.line": supported, + "textFragment.string.singleLine": supported, + "textFragment.string.multiLine": supported, + + /* NOT APPLICABLE */ + + // In Clojure every function definition is also a function call. + // Defining formal arguments therefore became problematic. + "argument.formal.singleLine": notApplicable, + "argument.formal.multiLine": notApplicable, + "argument.formal.iteration": notApplicable, + "argument.formal.lambda.singleLine": notApplicable, + "argument.formal.lambda.multiLine": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.iteration": notApplicable, + "name.argument.formal.lambda": notApplicable, + "name.argument.formal.lambda.iteration": notApplicable, + "value.argument.formal.lambda": notApplicable, + "value.argument.formal.lambda.iteration": notApplicable, + "argumentList.formal.empty": notApplicable, + "argumentList.formal.singleLine": notApplicable, + "argumentList.formal.multiLine": notApplicable, + "argumentList.formal.lambda.empty": notApplicable, + "argumentList.formal.lambda.singleLine": notApplicable, + "argumentList.formal.lambda.multiLine": notApplicable, + + // Assignment + "statement.assignment": notApplicable, + "statement.assignment.compound": notApplicable, + "statement.assignment.destructuring": notApplicable, + "name.assignment": notApplicable, + "name.assignment.compound": notApplicable, + "name.assignment.destructuring": notApplicable, + "value.assignment": notApplicable, + "value.assignment.compound": notApplicable, + "value.assignment.destructuring": notApplicable, + "statement.update": notApplicable, + + // Variable + "statement.variable.uninitialized": notApplicable, + "statement.variable.initialized": notApplicable, + "statement.variable.destructuring": notApplicable, + "name.variable.uninitialized": notApplicable, + "name.variable.initialized": notApplicable, + "name.variable.destructuring": notApplicable, + "type.variable.uninitialized": notApplicable, + "type.variable.initialized": notApplicable, + "value.variable": notApplicable, + "value.variable.destructuring": notApplicable, + + // Constant + "statement.constant": notApplicable, + "name.constant": notApplicable, + "value.constant": notApplicable, + "type.constant": notApplicable, + + // Class + class: notApplicable, + "class.iteration.class": notApplicable, + "class.iteration.document": notApplicable, + "name.class": notApplicable, + "name.field.class": notApplicable, + "name.iteration.class": notApplicable, + "statement.class": notApplicable, + "statement.field.class": notApplicable, + "statement.iteration.class": notApplicable, + "type.class": notApplicable, + "type.field.class": notApplicable, + "type.iteration.class": notApplicable, + "value.field.class": notApplicable, + "value.iteration.class": notApplicable, + "interior.class": notApplicable, + + // Constructor + "statement.constructor": notApplicable, + "namedFunction.constructor": notApplicable, + "argument.actual.constructor.singleLine": notApplicable, + "argument.actual.constructor.multiLine": notApplicable, + "argument.actual.constructor.iteration": notApplicable, + "argument.formal.constructor.singleLine": notApplicable, + "argument.formal.constructor.multiLine": notApplicable, + "argument.formal.constructor.iteration": notApplicable, + "argumentList.actual.constructor.empty": notApplicable, + "argumentList.actual.constructor.singleLine": notApplicable, + "argumentList.actual.constructor.multiLine": notApplicable, + "argumentList.formal.constructor.empty": notApplicable, + "argumentList.formal.constructor.singleLine": notApplicable, + "argumentList.formal.constructor.multiLine": notApplicable, + "interior.constructor": notApplicable, + "name.argument.formal.constructor": notApplicable, + "name.argument.formal.constructor.iteration": notApplicable, + "name.constructor": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + "functionCall.constructor": notApplicable, + "functionCallee.constructor": notApplicable, + + // Method + "statement.method": notApplicable, + "namedFunction.method": notApplicable, + "argument.actual.method.singleLine": notApplicable, + "argument.actual.method.multiLine": notApplicable, + "argument.actual.method.iteration": notApplicable, + "argument.formal.method.singleLine": notApplicable, + "argument.formal.method.multiLine": notApplicable, + "argument.formal.method.iteration": notApplicable, + "argumentList.actual.method.empty": notApplicable, + "argumentList.actual.method.singleLine": notApplicable, + "argumentList.actual.method.multiLine": notApplicable, + "argumentList.formal.method.empty": notApplicable, + "argumentList.formal.method.singleLine": notApplicable, + "argumentList.formal.method.multiLine": notApplicable, + "interior.method": notApplicable, + "name.argument.formal.method": notApplicable, + "name.argument.formal.method.iteration": notApplicable, + "name.method": notApplicable, + "type.argument.formal.method": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "type.return.method": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, + "functionCall.method": notApplicable, + "functionCallee.method": notApplicable, + + // Function + "statement.function": notApplicable, + "namedFunction.iteration.class": notApplicable, + + // Function call + "statement.functionCall": notApplicable, + "functionCall.generic": notApplicable, + "functionCallee.generic": notApplicable, + "functionCall.chain": notApplicable, + "functionCallee.chain": notApplicable, + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + + // Return statement + "statement.return": notApplicable, + "type.return": notApplicable, + "value.return": notApplicable, + + // Yield statement + "statement.yield": notApplicable, + "value.yield": notApplicable, + + // Throw statement + "statement.throw": notApplicable, + "value.throw": notApplicable, + + // Interface + "statement.interface": notApplicable, + "statement.field.interface": notApplicable, + "statement.iteration.interface": notApplicable, + "interior.interface": notApplicable, + "name.interface": notApplicable, + "name.field.interface": notApplicable, + "name.iteration.interface": notApplicable, + "type.interface": notApplicable, + "type.field.interface": notApplicable, + "value.field.interface": notApplicable, + "type.iteration.interface": notApplicable, + + // Enum + "statement.enum": notApplicable, + "functionCallee.enum": notApplicable, + "functionCall.enum": notApplicable, + "name.enum": notApplicable, + "name.field.enum": notApplicable, + "name.iteration.enum": notApplicable, + "value.field.enum": notApplicable, + "value.iteration.enum": notApplicable, + "type.enum": notApplicable, + "interior.enum": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Try catch + "statement.try": notApplicable, + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + + // If statement + "statement.if": notApplicable, + "branch.if.elif.else": notApplicable, + "branch.if": notApplicable, + "branch.if.else": notApplicable, + "branch.if.iteration": notApplicable, + + // Switch statement + "statement.switch": notApplicable, + "branch.switchCase": notApplicable, + "branch.switchCase.iteration": notApplicable, + "condition.switchCase": notApplicable, + "condition.switchCase.iteration": notApplicable, + "interior.switch": notApplicable, + "interior.switchCase": notApplicable, + "value.switch": notApplicable, + + // Loop + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + + // For loop + "statement.for": notApplicable, + "condition.for": notApplicable, + "interior.for": notApplicable, + + // For-each loop + "statement.foreach": notApplicable, + "interior.foreach": notApplicable, + "name.foreach": notApplicable, + "type.foreach": notApplicable, + "value.foreach": notApplicable, + + // While loop + "statement.while": notApplicable, + "condition.while": notApplicable, + "interior.while": notApplicable, + + // Do-while loop + "statement.doWhile": notApplicable, + "condition.doWhile": notApplicable, + "interior.doWhile": notApplicable, + + // Resource statement + "statement.resource": notApplicable, + "interior.resource": notApplicable, + "name.resource": notApplicable, + "type.resource": notApplicable, + "value.resource": notApplicable, + + // Static + "statement.static": notApplicable, + "interior.static": notApplicable, + + // Namespace + "statement.namespace": notApplicable, + "interior.namespace": notApplicable, + "name.namespace": notApplicable, + + // Ternary + "branch.ternary": notApplicable, + "branch.ternary.iteration": notApplicable, + "condition.ternary": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Element + element: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + + // Attribute + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Type alias + "type.alias": notApplicable, + "statement.typeAlias": notApplicable, + "name.typeAlias": notApplicable, + "value.typeAlias": notApplicable, + + // Collection item + "collectionItem.unenclosed.singleLine": notApplicable, + "collectionItem.unenclosed.multiLine": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + + // Interior + "interior.function": notApplicable, + "interior.lambda": notApplicable, + "interior.if": notApplicable, + + // Block comments + "comment.block": notApplicable, + "textFragment.comment.block": notApplicable, + + // Miscellaneous statements + "statement.misc": notApplicable, + "statement.break": notApplicable, + "statement.continue": notApplicable, + "statement.package": notApplicable, + "statement.import": notApplicable, + "statement.iteration.document": notApplicable, + "statement.iteration.block": notApplicable, + + // Miscellaneous + environment: notApplicable, + fieldAccess: notApplicable, + "key.mapPair": notApplicable, + "key.mapPair.iteration": notApplicable, + "name.iteration.block": notApplicable, + "name.iteration.document": notApplicable, + pairDelimiter: notApplicable, + regularExpression: notApplicable, + "type.argument.formal": notApplicable, + "type.argument.formal.iteration": notApplicable, + "type.argument.formal.lambda": notApplicable, + "type.argument.formal.lambda.iteration": notApplicable, + "type.cast": notApplicable, + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.iteration.block": notApplicable, + "type.iteration.document": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.iteration": notApplicable, + "value.iteration.block": notApplicable, + "value.iteration.document": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + "value.return.lambda": notApplicable, + selector: notApplicable, + unit: notApplicable, }; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts index 411d41f816..f6fb40546b 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts @@ -75,6 +75,10 @@ const delimiterToTextOverrides: Record> = { tripleDoubleQuotes: ["%Q(", ")"], }, + clojure: { + doubleQuotes: ['"', '"', { isSingleLine: false }], + }, + csharp: { doubleQuotes: [ ['@"', '"'], diff --git a/queries/clojure.scm b/queries/clojure.scm index 4a6dbdb357..c844805c6b 100644 --- a/queries/clojure.scm +++ b/queries/clojure.scm @@ -1,14 +1,47 @@ ;; https://github.com/sogaiu/tree-sitter-clojure/blob/master/src/grammar.json +(source) @namedFunction.iteration + +;;!! ;; Hello world +;;! ^^^^^^^^^^^^^^ (comment) @comment @textFragment -(str_lit) @string @textFragment +;;!! "Hello world" +;;! ^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ +( + (str_lit) @string @textFragment + (#character-range! @textFragment 1 -1) +) + +;;!! {:aaa 0 :bbb 1} +;;! ^^^^^^^^^^^^^^^ +( + (map_lit) @map + (#not-parent-type? @map quoting_lit) +) -(map_lit) @map +;;!! '{:aaa 0 :bbb 1} +;;! ^^^^^^^^^^^^^^^^ +(quoting_lit + (map_lit) +) @map -;; A list is either a vector literal or a quoted list literal -(vec_lit) @list +;;!! [aaa bbb] +;;! ^^^^^^^^^ +( + (vec_lit) @list + (#not-parent-type? @list quoting_lit) +) +;;!! '[aaa bbb] +;;! ^^^^^^^^^^ +(quoting_lit + (vec_lit) +) @list + +;;!! '(aaa bbb) +;;! ^^^^^^^^^^ (quoting_lit (list_lit) ) @list @@ -71,8 +104,8 @@ _ @_dummy . value: (_) @collectionItem - (#not-type? @_dummy "kwd_lit") - (#not-type? @collectionItem "kwd_lit") + (#not-type? @_dummy kwd_lit) + (#not-type? @collectionItem kwd_lit) ) (map_lit @@ -80,19 +113,32 @@ close: "}" @collectionItem.iteration.end.startOf ) @collectionItem.iteration.domain -;;!! (foo) -;;! ^^^^^ +;;!! (foo aaa bbb) +;;! ^^^^^^^^^^^^^ +;;! ^^^ ( (list_lit . value: (_) @functionCallee - ) @functionCall @functionCallee.domain @argumentOrParameter.iteration + ) @functionCall @functionCallee.domain ;; A function call is a list literal which is not quoted (#not-parent-type? @functionCall quoting_lit) ) -;;!! (foo :bar) -;;! ^^^^ +;;!! (foo) +;;! ^^^ +( + (list_lit + "(" @argumentOrParameter.iteration.start.endOf + ")" @argumentOrParameter.iteration.end.startOf + ) @argumentList @argumentList.domain @argumentOrParameter.iteration.domain + (#not-parent-type? @argumentList quoting_lit) + (#empty-single-multi-delimiter! @argumentList @argumentList "" " " "\n") + (#child-range! @argumentList 1 -2) +) + +;;!! (foo aaa bbb) +;;! ^^^ ^^^ ( (list_lit . @@ -100,6 +146,7 @@ value: (_) @argumentOrParameter ) @_dummy (#not-parent-type? @_dummy quoting_lit) + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy " " "\n") ) ;;!! (defn foo [] 5) @@ -161,3 +208,8 @@ "{" @collectionKey.iteration.start.endOf @value.iteration.start.endOf "}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf ) + +( + (sym_name) @disqualifyDelimiter + (#text? @disqualifyDelimiter "<" ">" "<=" ">=") +)