src-mcp 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +721 -0
- package/assets/languages.json +219 -0
- package/assets/queries/_javascript/highlights.scm +36 -0
- package/assets/queries/_javascript/locals.scm +14 -0
- package/assets/queries/_javascript/tags.scm +88 -0
- package/assets/queries/_jsx/highlights.scm +43 -0
- package/assets/queries/_jsx/indents.scm +6 -0
- package/assets/queries/_jsx/textobjects.scm +7 -0
- package/assets/queries/_typescript/highlights.scm +148 -0
- package/assets/queries/_typescript/indents.scm +5 -0
- package/assets/queries/_typescript/locals.scm +34 -0
- package/assets/queries/_typescript/tags.scm +23 -0
- package/assets/queries/_typescript/textobjects.scm +12 -0
- package/assets/queries/c/highlights.scm +167 -0
- package/assets/queries/c/indents.scm +51 -0
- package/assets/queries/c/injections.scm +2 -0
- package/assets/queries/c/locals.scm +38 -0
- package/assets/queries/c/rainbows.scm +29 -0
- package/assets/queries/c/tags.scm +9 -0
- package/assets/queries/c/textobjects.scm +27 -0
- package/assets/queries/c_sharp/highlights.scm +208 -0
- package/assets/queries/c_sharp/injections.scm +2 -0
- package/assets/queries/c_sharp/tags.scm +21 -0
- package/assets/queries/c_sharp/textobjects.scm +20 -0
- package/assets/queries/cpp/highlights.scm +177 -0
- package/assets/queries/cpp/indents.scm +3 -0
- package/assets/queries/cpp/injections.scm +4 -0
- package/assets/queries/cpp/rainbows.scm +49 -0
- package/assets/queries/cpp/tags.scm +12 -0
- package/assets/queries/cpp/textobjects.scm +7 -0
- package/assets/queries/ecma/highlights.scm +288 -0
- package/assets/queries/ecma/indents.scm +28 -0
- package/assets/queries/ecma/injections.scm +100 -0
- package/assets/queries/ecma/locals.scm +26 -0
- package/assets/queries/ecma/rainbows.scm +28 -0
- package/assets/queries/ecma/textobjects.scm +45 -0
- package/assets/queries/go/highlights.scm +236 -0
- package/assets/queries/go/indents.scm +40 -0
- package/assets/queries/go/injections.scm +92 -0
- package/assets/queries/go/locals.scm +25 -0
- package/assets/queries/go/rainbows.scm +33 -0
- package/assets/queries/go/tags.scm +30 -0
- package/assets/queries/go/textobjects.scm +33 -0
- package/assets/queries/html/highlights.scm +47 -0
- package/assets/queries/html/injections.scm +10 -0
- package/assets/queries/html/rainbows.scm +13 -0
- package/assets/queries/html/textobjects.scm +9 -0
- package/assets/queries/java/highlights.scm +227 -0
- package/assets/queries/java/indents.scm +35 -0
- package/assets/queries/java/injections.scm +2 -0
- package/assets/queries/java/rainbows.scm +35 -0
- package/assets/queries/java/tags.scm +27 -0
- package/assets/queries/java/textobjects.scm +44 -0
- package/assets/queries/javascript/highlights.scm +3 -0
- package/assets/queries/javascript/indents.scm +3 -0
- package/assets/queries/javascript/injections.scm +3 -0
- package/assets/queries/javascript/locals.scm +3 -0
- package/assets/queries/javascript/rainbows.scm +1 -0
- package/assets/queries/javascript/tags.scm +3 -0
- package/assets/queries/javascript/textobjects.scm +3 -0
- package/assets/queries/jsx/highlights.scm +3 -0
- package/assets/queries/jsx/indents.scm +3 -0
- package/assets/queries/jsx/injections.scm +3 -0
- package/assets/queries/jsx/locals.scm +3 -0
- package/assets/queries/jsx/rainbows.scm +9 -0
- package/assets/queries/jsx/tags.scm +3 -0
- package/assets/queries/jsx/textobjects.scm +3 -0
- package/assets/queries/kotlin/folds.scm +17 -0
- package/assets/queries/kotlin/highlights.scm +330 -0
- package/assets/queries/kotlin/indents.scm +44 -0
- package/assets/queries/kotlin/injections.scm +42 -0
- package/assets/queries/kotlin/locals.scm +23 -0
- package/assets/queries/kotlin/tags.scm +12 -0
- package/assets/queries/kotlin/textobjects.scm +45 -0
- package/assets/queries/ocaml/highlights.scm +151 -0
- package/assets/queries/ocaml/indents.scm +12 -0
- package/assets/queries/ocaml/injections.scm +2 -0
- package/assets/queries/ocaml/locals.scm +24 -0
- package/assets/queries/php/highlights.scm +319 -0
- package/assets/queries/php/indents.scm +18 -0
- package/assets/queries/php/injections.scm +25 -0
- package/assets/queries/php/rainbows.scm +15 -0
- package/assets/queries/php/tags.scm +26 -0
- package/assets/queries/php/textobjects.scm +52 -0
- package/assets/queries/python/highlights.scm +308 -0
- package/assets/queries/python/indents.scm +84 -0
- package/assets/queries/python/injections.scm +14 -0
- package/assets/queries/python/locals.scm +50 -0
- package/assets/queries/python/rainbows.scm +30 -0
- package/assets/queries/python/tags.scm +14 -0
- package/assets/queries/python/textobjects.scm +35 -0
- package/assets/queries/ruby/highlights.scm +191 -0
- package/assets/queries/ruby/indents.scm +24 -0
- package/assets/queries/ruby/injections.scm +35 -0
- package/assets/queries/ruby/locals.scm +20 -0
- package/assets/queries/ruby/rainbows.scm +28 -0
- package/assets/queries/ruby/tags.scm +64 -0
- package/assets/queries/ruby/textobjects.scm +56 -0
- package/assets/queries/rust/highlights.scm +514 -0
- package/assets/queries/rust/indents.scm +148 -0
- package/assets/queries/rust/injections.scm +170 -0
- package/assets/queries/rust/locals.scm +28 -0
- package/assets/queries/rust/rainbows.scm +60 -0
- package/assets/queries/rust/tags.scm +26 -0
- package/assets/queries/rust/textobjects.scm +85 -0
- package/assets/queries/scala/highlights.scm +267 -0
- package/assets/queries/scala/indents.scm +22 -0
- package/assets/queries/scala/injections.scm +16 -0
- package/assets/queries/scala/locals.scm +14 -0
- package/assets/queries/scala/textobjects.scm +65 -0
- package/assets/queries/svelte/folds.scm +13 -0
- package/assets/queries/svelte/highlights.scm +38 -0
- package/assets/queries/svelte/indents.scm +24 -0
- package/assets/queries/svelte/injections.scm +46 -0
- package/assets/queries/svelte/locals.scm +1 -0
- package/assets/queries/swift/highlights.scm +200 -0
- package/assets/queries/swift/indents.scm +100 -0
- package/assets/queries/swift/injections.scm +10 -0
- package/assets/queries/swift/locals.scm +19 -0
- package/assets/queries/swift/rainbows.scm +60 -0
- package/assets/queries/swift/textobjects.scm +23 -0
- package/assets/queries/tsx/highlights.scm +3 -0
- package/assets/queries/tsx/indents.scm +3 -0
- package/assets/queries/tsx/injections.scm +3 -0
- package/assets/queries/tsx/locals.scm +3 -0
- package/assets/queries/tsx/rainbows.scm +2 -0
- package/assets/queries/tsx/tags.scm +3 -0
- package/assets/queries/tsx/textobjects.scm +3 -0
- package/assets/queries/typescript/highlights.scm +3 -0
- package/assets/queries/typescript/indents.scm +3 -0
- package/assets/queries/typescript/injections.scm +3 -0
- package/assets/queries/typescript/locals.scm +3 -0
- package/assets/queries/typescript/rainbows.scm +19 -0
- package/assets/queries/typescript/tags.scm +3 -0
- package/assets/queries/typescript/textobjects.scm +3 -0
- package/assets/wasm/tree-sitter-c.wasm +0 -0
- package/assets/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/assets/wasm/tree-sitter-cpp.wasm +0 -0
- package/assets/wasm/tree-sitter-go.wasm +0 -0
- package/assets/wasm/tree-sitter-html.wasm +0 -0
- package/assets/wasm/tree-sitter-java.wasm +0 -0
- package/assets/wasm/tree-sitter-javascript.wasm +0 -0
- package/assets/wasm/tree-sitter-kotlin.wasm +0 -0
- package/assets/wasm/tree-sitter-ocaml.wasm +0 -0
- package/assets/wasm/tree-sitter-php.wasm +0 -0
- package/assets/wasm/tree-sitter-python.wasm +0 -0
- package/assets/wasm/tree-sitter-ruby.wasm +0 -0
- package/assets/wasm/tree-sitter-rust.wasm +0 -0
- package/assets/wasm/tree-sitter-scala.wasm +0 -0
- package/assets/wasm/tree-sitter-svelte.wasm +0 -0
- package/assets/wasm/tree-sitter-swift.wasm +0 -0
- package/assets/wasm/tree-sitter-tsx.wasm +0 -0
- package/assets/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/adapter.d.ts +7 -0
- package/dist/cli/adapter.d.ts.map +1 -0
- package/dist/cli/adapter.js +39 -0
- package/dist/cli/adapter.js.map +1 -0
- package/dist/cli/commands/index.d.ts +24 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +13 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/serve.command.d.ts +21 -0
- package/dist/cli/commands/serve.command.d.ts.map +1 -0
- package/dist/cli/commands/serve.command.js +62 -0
- package/dist/cli/commands/serve.command.js.map +1 -0
- package/dist/cli/commands/version.command.d.ts +2 -0
- package/dist/cli/commands/version.command.d.ts.map +1 -0
- package/dist/cli/commands/version.command.js +12 -0
- package/dist/cli/commands/version.command.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/parser.d.ts +7 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +99 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/config/index.d.ts +24 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +38 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/ast/index.d.ts +82 -0
- package/dist/core/ast/index.d.ts.map +1 -0
- package/dist/core/ast/index.js +204 -0
- package/dist/core/ast/index.js.map +1 -0
- package/dist/core/ast/types.d.ts +152 -0
- package/dist/core/ast/types.d.ts.map +1 -0
- package/dist/core/ast/types.js +5 -0
- package/dist/core/ast/types.js.map +1 -0
- package/dist/core/constants.d.ts +17 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +49 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/embeddings/callgraph.d.ts +98 -0
- package/dist/core/embeddings/callgraph.d.ts.map +1 -0
- package/dist/core/embeddings/callgraph.js +415 -0
- package/dist/core/embeddings/callgraph.js.map +1 -0
- package/dist/core/embeddings/chunker.d.ts +37 -0
- package/dist/core/embeddings/chunker.d.ts.map +1 -0
- package/dist/core/embeddings/chunker.js +298 -0
- package/dist/core/embeddings/chunker.js.map +1 -0
- package/dist/core/embeddings/client.d.ts +30 -0
- package/dist/core/embeddings/client.d.ts.map +1 -0
- package/dist/core/embeddings/client.js +65 -0
- package/dist/core/embeddings/client.js.map +1 -0
- package/dist/core/embeddings/crossfile.d.ts +58 -0
- package/dist/core/embeddings/crossfile.d.ts.map +1 -0
- package/dist/core/embeddings/crossfile.js +202 -0
- package/dist/core/embeddings/crossfile.js.map +1 -0
- package/dist/core/embeddings/enricher.d.ts +53 -0
- package/dist/core/embeddings/enricher.d.ts.map +1 -0
- package/dist/core/embeddings/enricher.js +308 -0
- package/dist/core/embeddings/enricher.js.map +1 -0
- package/dist/core/embeddings/index.d.ts +13 -0
- package/dist/core/embeddings/index.d.ts.map +1 -0
- package/dist/core/embeddings/index.js +20 -0
- package/dist/core/embeddings/index.js.map +1 -0
- package/dist/core/embeddings/reranker.d.ts +41 -0
- package/dist/core/embeddings/reranker.d.ts.map +1 -0
- package/dist/core/embeddings/reranker.js +117 -0
- package/dist/core/embeddings/reranker.js.map +1 -0
- package/dist/core/embeddings/store.d.ts +93 -0
- package/dist/core/embeddings/store.d.ts.map +1 -0
- package/dist/core/embeddings/store.js +304 -0
- package/dist/core/embeddings/store.js.map +1 -0
- package/dist/core/embeddings/types.d.ts +77 -0
- package/dist/core/embeddings/types.d.ts.map +1 -0
- package/dist/core/embeddings/types.js +5 -0
- package/dist/core/embeddings/types.js.map +1 -0
- package/dist/core/embeddings/watcher.d.ts +130 -0
- package/dist/core/embeddings/watcher.d.ts.map +1 -0
- package/dist/core/embeddings/watcher.js +448 -0
- package/dist/core/embeddings/watcher.js.map +1 -0
- package/dist/core/fallback/index.d.ts +26 -0
- package/dist/core/fallback/index.d.ts.map +1 -0
- package/dist/core/fallback/index.js +76 -0
- package/dist/core/fallback/index.js.map +1 -0
- package/dist/core/parser/index.d.ts +64 -0
- package/dist/core/parser/index.d.ts.map +1 -0
- package/dist/core/parser/index.js +205 -0
- package/dist/core/parser/index.js.map +1 -0
- package/dist/core/parser/languages.d.ts +26 -0
- package/dist/core/parser/languages.d.ts.map +1 -0
- package/dist/core/parser/languages.js +101 -0
- package/dist/core/parser/languages.js.map +1 -0
- package/dist/core/queries/helpers.d.ts +72 -0
- package/dist/core/queries/helpers.d.ts.map +1 -0
- package/dist/core/queries/helpers.js +101 -0
- package/dist/core/queries/helpers.js.map +1 -0
- package/dist/core/queries/index.d.ts +144 -0
- package/dist/core/queries/index.d.ts.map +1 -0
- package/dist/core/queries/index.js +396 -0
- package/dist/core/queries/index.js.map +1 -0
- package/dist/core/queries/loader.d.ts +46 -0
- package/dist/core/queries/loader.d.ts.map +1 -0
- package/dist/core/queries/loader.js +216 -0
- package/dist/core/queries/loader.js.map +1 -0
- package/dist/core/queries/patterns.d.ts +10 -0
- package/dist/core/queries/patterns.d.ts.map +1 -0
- package/dist/core/queries/patterns.js +112 -0
- package/dist/core/queries/patterns.js.map +1 -0
- package/dist/core/symbols/index.d.ts +70 -0
- package/dist/core/symbols/index.d.ts.map +1 -0
- package/dist/core/symbols/index.js +359 -0
- package/dist/core/symbols/index.js.map +1 -0
- package/dist/core/unified/index.d.ts +118 -0
- package/dist/core/unified/index.d.ts.map +1 -0
- package/dist/core/unified/index.js +428 -0
- package/dist/core/unified/index.js.map +1 -0
- package/dist/core/utils/assets.d.ts +34 -0
- package/dist/core/utils/assets.d.ts.map +1 -0
- package/dist/core/utils/assets.js +85 -0
- package/dist/core/utils/assets.js.map +1 -0
- package/dist/core/utils/cache.d.ts +43 -0
- package/dist/core/utils/cache.d.ts.map +1 -0
- package/dist/core/utils/cache.js +60 -0
- package/dist/core/utils/cache.js.map +1 -0
- package/dist/core/utils/index.d.ts +7 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/index.js +10 -0
- package/dist/core/utils/index.js.map +1 -0
- package/dist/core/utils/tsconfig.d.ts +34 -0
- package/dist/core/utils/tsconfig.d.ts.map +1 -0
- package/dist/core/utils/tsconfig.js +173 -0
- package/dist/core/utils/tsconfig.js.map +1 -0
- package/dist/features/analyze-file/index.d.ts +15 -0
- package/dist/features/analyze-file/index.d.ts.map +1 -0
- package/dist/features/analyze-file/index.js +164 -0
- package/dist/features/analyze-file/index.js.map +1 -0
- package/dist/features/get-call-graph/index.d.ts +24 -0
- package/dist/features/get-call-graph/index.d.ts.map +1 -0
- package/dist/features/get-call-graph/index.js +246 -0
- package/dist/features/get-call-graph/index.js.map +1 -0
- package/dist/features/get-index-status/index.d.ts +20 -0
- package/dist/features/get-index-status/index.d.ts.map +1 -0
- package/dist/features/get-index-status/index.js +90 -0
- package/dist/features/get-index-status/index.js.map +1 -0
- package/dist/features/index-codebase/index.d.ts +24 -0
- package/dist/features/index-codebase/index.d.ts.map +1 -0
- package/dist/features/index-codebase/index.js +283 -0
- package/dist/features/index-codebase/index.js.map +1 -0
- package/dist/features/index.d.ts +15 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +28 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/info/index.d.ts +19 -0
- package/dist/features/info/index.d.ts.map +1 -0
- package/dist/features/info/index.js +41 -0
- package/dist/features/info/index.js.map +1 -0
- package/dist/features/list-symbols/index.d.ts +22 -0
- package/dist/features/list-symbols/index.d.ts.map +1 -0
- package/dist/features/list-symbols/index.js +74 -0
- package/dist/features/list-symbols/index.js.map +1 -0
- package/dist/features/parse-ast/index.d.ts +12 -0
- package/dist/features/parse-ast/index.d.ts.map +1 -0
- package/dist/features/parse-ast/index.js +71 -0
- package/dist/features/parse-ast/index.js.map +1 -0
- package/dist/features/query-code/index.d.ts +23 -0
- package/dist/features/query-code/index.d.ts.map +1 -0
- package/dist/features/query-code/index.js +96 -0
- package/dist/features/query-code/index.js.map +1 -0
- package/dist/features/search-code/index.d.ts +39 -0
- package/dist/features/search-code/index.d.ts.map +1 -0
- package/dist/features/search-code/index.js +258 -0
- package/dist/features/search-code/index.js.map +1 -0
- package/dist/features/types.d.ts +14 -0
- package/dist/features/types.d.ts.map +1 -0
- package/dist/features/types.js +2 -0
- package/dist/features/types.js.map +1 -0
- package/dist/features/update-index/index.d.ts +24 -0
- package/dist/features/update-index/index.d.ts.map +1 -0
- package/dist/features/update-index/index.js +358 -0
- package/dist/features/update-index/index.js.map +1 -0
- package/dist/features/utils/content.d.ts +30 -0
- package/dist/features/utils/content.d.ts.map +1 -0
- package/dist/features/utils/content.js +49 -0
- package/dist/features/utils/content.js.map +1 -0
- package/dist/features/utils/index.d.ts +6 -0
- package/dist/features/utils/index.d.ts.map +1 -0
- package/dist/features/utils/index.js +8 -0
- package/dist/features/utils/index.js.map +1 -0
- package/dist/features/utils/result.d.ts +37 -0
- package/dist/features/utils/result.d.ts.map +1 -0
- package/dist/features/utils/result.js +53 -0
- package/dist/features/utils/result.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +9 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +188 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +3 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +17 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +24 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/adapter.d.ts +4 -0
- package/dist/tools/adapter.d.ts.map +1 -0
- package/dist/tools/adapter.js +28 -0
- package/dist/tools/adapter.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/colors.d.ts +24 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +30 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +57 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/spinner.d.ts +11 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +36 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
; -------
|
|
2
|
+
; Basic identifiers
|
|
3
|
+
; -------
|
|
4
|
+
|
|
5
|
+
; We do not style ? as an operator on purpose as it allows styling ? differently, as many highlighters do. @operator.special might have been a better scope, but @special is already documented so the change would break themes (including the intent of the default theme)
|
|
6
|
+
"?" @special
|
|
7
|
+
|
|
8
|
+
(type_identifier) @type
|
|
9
|
+
(identifier) @variable
|
|
10
|
+
(field_identifier) @variable.other.member
|
|
11
|
+
|
|
12
|
+
; -------
|
|
13
|
+
; Operators
|
|
14
|
+
; -------
|
|
15
|
+
|
|
16
|
+
[
|
|
17
|
+
"*"
|
|
18
|
+
"'"
|
|
19
|
+
"->"
|
|
20
|
+
"=>"
|
|
21
|
+
"<="
|
|
22
|
+
"="
|
|
23
|
+
"=="
|
|
24
|
+
"!"
|
|
25
|
+
"!="
|
|
26
|
+
"%"
|
|
27
|
+
"%="
|
|
28
|
+
"&"
|
|
29
|
+
"&="
|
|
30
|
+
"&&"
|
|
31
|
+
"|"
|
|
32
|
+
"|="
|
|
33
|
+
"||"
|
|
34
|
+
"^"
|
|
35
|
+
"^="
|
|
36
|
+
"*"
|
|
37
|
+
"*="
|
|
38
|
+
"-"
|
|
39
|
+
"-="
|
|
40
|
+
"+"
|
|
41
|
+
"+="
|
|
42
|
+
"/"
|
|
43
|
+
"/="
|
|
44
|
+
">"
|
|
45
|
+
"<"
|
|
46
|
+
">="
|
|
47
|
+
">>"
|
|
48
|
+
"<<"
|
|
49
|
+
">>="
|
|
50
|
+
"<<="
|
|
51
|
+
"@"
|
|
52
|
+
".."
|
|
53
|
+
"..="
|
|
54
|
+
"'"
|
|
55
|
+
] @operator
|
|
56
|
+
|
|
57
|
+
; -------
|
|
58
|
+
; Paths
|
|
59
|
+
; -------
|
|
60
|
+
|
|
61
|
+
(use_declaration
|
|
62
|
+
argument: (identifier) @namespace)
|
|
63
|
+
(use_wildcard
|
|
64
|
+
(identifier) @namespace)
|
|
65
|
+
(extern_crate_declaration
|
|
66
|
+
name: (identifier) @namespace
|
|
67
|
+
alias: (identifier)? @namespace)
|
|
68
|
+
(mod_item
|
|
69
|
+
name: (identifier) @namespace)
|
|
70
|
+
(scoped_use_list
|
|
71
|
+
path: (identifier)? @namespace)
|
|
72
|
+
(use_list
|
|
73
|
+
(identifier) @namespace)
|
|
74
|
+
(use_as_clause
|
|
75
|
+
path: (identifier)? @namespace
|
|
76
|
+
alias: (identifier) @namespace)
|
|
77
|
+
|
|
78
|
+
; -------
|
|
79
|
+
; Types
|
|
80
|
+
; -------
|
|
81
|
+
|
|
82
|
+
(type_parameter
|
|
83
|
+
name: (type_identifier) @type.parameter)
|
|
84
|
+
((type_arguments (type_identifier) @constant)
|
|
85
|
+
(#match? @constant "^[A-Z_]+$"))
|
|
86
|
+
(type_arguments (type_identifier) @type)
|
|
87
|
+
; `_` in `(_, _)`
|
|
88
|
+
(tuple_struct_pattern "_" @comment.unused)
|
|
89
|
+
; `_` in `Vec<_>`
|
|
90
|
+
((type_arguments (type_identifier) @comment.unused)
|
|
91
|
+
(#eq? @comment.unused "_"))
|
|
92
|
+
; `_` in `Rc<[_]>`
|
|
93
|
+
((array_type (type_identifier) @comment.unused)
|
|
94
|
+
(#eq? @comment.unused "_"))
|
|
95
|
+
|
|
96
|
+
; ---
|
|
97
|
+
; Primitives
|
|
98
|
+
; ---
|
|
99
|
+
|
|
100
|
+
(escape_sequence) @constant.character.escape
|
|
101
|
+
(primitive_type) @type.builtin
|
|
102
|
+
(boolean_literal) @constant.builtin.boolean
|
|
103
|
+
(integer_literal) @constant.numeric.integer
|
|
104
|
+
(float_literal) @constant.numeric.float
|
|
105
|
+
(char_literal) @constant.character
|
|
106
|
+
[
|
|
107
|
+
(string_literal)
|
|
108
|
+
(raw_string_literal)
|
|
109
|
+
] @string
|
|
110
|
+
|
|
111
|
+
; -------
|
|
112
|
+
; Comments
|
|
113
|
+
; -------
|
|
114
|
+
|
|
115
|
+
(shebang) @comment
|
|
116
|
+
(line_comment) @comment.line
|
|
117
|
+
(block_comment) @comment.block
|
|
118
|
+
|
|
119
|
+
; Doc Comments
|
|
120
|
+
(line_comment
|
|
121
|
+
(outer_doc_comment_marker "/" @comment.line.documentation)
|
|
122
|
+
(doc_comment)) @comment.line.documentation
|
|
123
|
+
(line_comment
|
|
124
|
+
(inner_doc_comment_marker "!" @comment.line.documentation)
|
|
125
|
+
(doc_comment)) @comment.line.documentation
|
|
126
|
+
|
|
127
|
+
(block_comment
|
|
128
|
+
(outer_doc_comment_marker) @comment.block.documentation
|
|
129
|
+
(doc_comment) "*/" @comment.block.documentation) @comment.block.documentation
|
|
130
|
+
(block_comment
|
|
131
|
+
(inner_doc_comment_marker) @comment.block.documentation
|
|
132
|
+
(doc_comment) "*/" @comment.block.documentation) @comment.block.documentation
|
|
133
|
+
|
|
134
|
+
; ---
|
|
135
|
+
; Extraneous
|
|
136
|
+
; ---
|
|
137
|
+
|
|
138
|
+
(self) @variable.builtin
|
|
139
|
+
|
|
140
|
+
(field_initializer
|
|
141
|
+
(field_identifier) @variable.other.member)
|
|
142
|
+
(shorthand_field_initializer
|
|
143
|
+
(identifier) @variable.other.member)
|
|
144
|
+
(shorthand_field_identifier) @variable.other.member
|
|
145
|
+
|
|
146
|
+
(lifetime
|
|
147
|
+
"'" @label
|
|
148
|
+
(identifier) @label)
|
|
149
|
+
(label
|
|
150
|
+
"'" @label
|
|
151
|
+
(identifier) @label)
|
|
152
|
+
|
|
153
|
+
; ---
|
|
154
|
+
; Punctuation
|
|
155
|
+
; ---
|
|
156
|
+
|
|
157
|
+
[
|
|
158
|
+
"::"
|
|
159
|
+
"."
|
|
160
|
+
";"
|
|
161
|
+
","
|
|
162
|
+
":"
|
|
163
|
+
] @punctuation.delimiter
|
|
164
|
+
|
|
165
|
+
[
|
|
166
|
+
"("
|
|
167
|
+
")"
|
|
168
|
+
"["
|
|
169
|
+
"]"
|
|
170
|
+
"{"
|
|
171
|
+
"}"
|
|
172
|
+
"#"
|
|
173
|
+
] @punctuation.bracket
|
|
174
|
+
(type_arguments
|
|
175
|
+
[
|
|
176
|
+
"<"
|
|
177
|
+
">"
|
|
178
|
+
] @punctuation.bracket)
|
|
179
|
+
(type_parameters
|
|
180
|
+
[
|
|
181
|
+
"<"
|
|
182
|
+
">"
|
|
183
|
+
] @punctuation.bracket)
|
|
184
|
+
(for_lifetimes ["<" ">"] @punctuation.bracket)
|
|
185
|
+
(closure_parameters
|
|
186
|
+
"|" @punctuation.bracket)
|
|
187
|
+
(bracketed_type ["<" ">"] @punctuation.bracket)
|
|
188
|
+
|
|
189
|
+
; ---
|
|
190
|
+
; Variables
|
|
191
|
+
; ---
|
|
192
|
+
|
|
193
|
+
(let_declaration
|
|
194
|
+
pattern: [
|
|
195
|
+
((identifier) @variable)
|
|
196
|
+
((tuple_pattern
|
|
197
|
+
(identifier) @variable))
|
|
198
|
+
])
|
|
199
|
+
|
|
200
|
+
; It needs to be anonymous to not conflict with `call_expression` further below.
|
|
201
|
+
(_
|
|
202
|
+
value: (field_expression
|
|
203
|
+
value: (identifier)? @variable
|
|
204
|
+
field: (field_identifier) @variable.other.member))
|
|
205
|
+
|
|
206
|
+
(parameter
|
|
207
|
+
pattern: (identifier) @variable.parameter)
|
|
208
|
+
(closure_parameters
|
|
209
|
+
(identifier) @variable.parameter)
|
|
210
|
+
|
|
211
|
+
; -------
|
|
212
|
+
; Keywords
|
|
213
|
+
; -------
|
|
214
|
+
|
|
215
|
+
"in" @keyword.control
|
|
216
|
+
|
|
217
|
+
[
|
|
218
|
+
"match"
|
|
219
|
+
"if"
|
|
220
|
+
"else"
|
|
221
|
+
"try"
|
|
222
|
+
] @keyword.control.conditional
|
|
223
|
+
|
|
224
|
+
[
|
|
225
|
+
"while"
|
|
226
|
+
"loop"
|
|
227
|
+
] @keyword.control.repeat
|
|
228
|
+
|
|
229
|
+
[
|
|
230
|
+
"break"
|
|
231
|
+
"continue"
|
|
232
|
+
"return"
|
|
233
|
+
"await"
|
|
234
|
+
"yield"
|
|
235
|
+
] @keyword.control.return
|
|
236
|
+
|
|
237
|
+
"use" @keyword.control.import
|
|
238
|
+
(mod_item "mod" @keyword.control.import !body)
|
|
239
|
+
(use_as_clause "as" @keyword.control.import)
|
|
240
|
+
|
|
241
|
+
(type_cast_expression "as" @keyword.operator)
|
|
242
|
+
|
|
243
|
+
[
|
|
244
|
+
(crate)
|
|
245
|
+
(super)
|
|
246
|
+
"as"
|
|
247
|
+
"pub"
|
|
248
|
+
"mod"
|
|
249
|
+
"extern"
|
|
250
|
+
|
|
251
|
+
"impl"
|
|
252
|
+
"where"
|
|
253
|
+
"trait"
|
|
254
|
+
"for"
|
|
255
|
+
|
|
256
|
+
"default"
|
|
257
|
+
"async"
|
|
258
|
+
] @keyword
|
|
259
|
+
|
|
260
|
+
(for_expression
|
|
261
|
+
"for" @keyword.control.repeat)
|
|
262
|
+
(gen_block "gen" @keyword.control)
|
|
263
|
+
|
|
264
|
+
[
|
|
265
|
+
"struct"
|
|
266
|
+
"enum"
|
|
267
|
+
"union"
|
|
268
|
+
"type"
|
|
269
|
+
] @keyword.storage.type
|
|
270
|
+
|
|
271
|
+
"let" @keyword.storage
|
|
272
|
+
"fn" @keyword.function
|
|
273
|
+
"unsafe" @keyword.special
|
|
274
|
+
"macro_rules!" @function.macro
|
|
275
|
+
|
|
276
|
+
(mutable_specifier) @keyword.storage.modifier.mut
|
|
277
|
+
|
|
278
|
+
(reference_type "&" @keyword.storage.modifier.ref)
|
|
279
|
+
(self_parameter "&" @keyword.storage.modifier.ref)
|
|
280
|
+
|
|
281
|
+
[
|
|
282
|
+
"static"
|
|
283
|
+
"const"
|
|
284
|
+
"raw"
|
|
285
|
+
"ref"
|
|
286
|
+
"move"
|
|
287
|
+
"dyn"
|
|
288
|
+
] @keyword.storage.modifier
|
|
289
|
+
|
|
290
|
+
; TODO: variable.mut to highlight mutable identifiers via locals.scm
|
|
291
|
+
|
|
292
|
+
; ---
|
|
293
|
+
; Remaining Paths
|
|
294
|
+
; ---
|
|
295
|
+
|
|
296
|
+
(scoped_identifier
|
|
297
|
+
path: (identifier)? @namespace
|
|
298
|
+
name: (identifier) @namespace)
|
|
299
|
+
(scoped_type_identifier
|
|
300
|
+
path: (identifier) @namespace)
|
|
301
|
+
|
|
302
|
+
; -------
|
|
303
|
+
; Functions
|
|
304
|
+
; -------
|
|
305
|
+
|
|
306
|
+
; highlight `baz` in `any_function(foo::bar::baz)` as function
|
|
307
|
+
; This generically works for an unlimited number of path segments:
|
|
308
|
+
;
|
|
309
|
+
; - `f(foo::bar)`
|
|
310
|
+
; - `f(foo::bar::baz)`
|
|
311
|
+
; - `f(foo::bar::baz::quux)`
|
|
312
|
+
;
|
|
313
|
+
; We know that in the above examples, the last component of each path is a function
|
|
314
|
+
; as the only other valid thing (following Rust naming conventions) would be a module at
|
|
315
|
+
; that position, however you cannot pass modules as arguments
|
|
316
|
+
(call_expression
|
|
317
|
+
function: _
|
|
318
|
+
arguments: (arguments
|
|
319
|
+
(scoped_identifier
|
|
320
|
+
path: _
|
|
321
|
+
name: (identifier) @function)))
|
|
322
|
+
|
|
323
|
+
(call_expression
|
|
324
|
+
function: [
|
|
325
|
+
((identifier) @function)
|
|
326
|
+
(scoped_identifier
|
|
327
|
+
name: (identifier) @function)
|
|
328
|
+
(field_expression
|
|
329
|
+
field: (field_identifier) @function)
|
|
330
|
+
])
|
|
331
|
+
(generic_function
|
|
332
|
+
function: [
|
|
333
|
+
((identifier) @function)
|
|
334
|
+
(scoped_identifier
|
|
335
|
+
name: (identifier) @function)
|
|
336
|
+
(field_expression
|
|
337
|
+
field: (field_identifier) @function.method)
|
|
338
|
+
])
|
|
339
|
+
|
|
340
|
+
(function_item
|
|
341
|
+
name: (identifier) @function)
|
|
342
|
+
|
|
343
|
+
(function_signature_item
|
|
344
|
+
name: (identifier) @function)
|
|
345
|
+
|
|
346
|
+
; -------
|
|
347
|
+
; Guess Other Types
|
|
348
|
+
; -------
|
|
349
|
+
; Other PascalCase identifiers are assumed to be structs.
|
|
350
|
+
|
|
351
|
+
((identifier) @type
|
|
352
|
+
(#match? @type "^[A-Z]"))
|
|
353
|
+
|
|
354
|
+
(never_type "!" @type)
|
|
355
|
+
|
|
356
|
+
((identifier) @constant
|
|
357
|
+
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
|
|
358
|
+
|
|
359
|
+
; ---
|
|
360
|
+
; PascalCase identifiers in call_expressions (e.g. `Ok()`)
|
|
361
|
+
; are assumed to be enum constructors.
|
|
362
|
+
; ---
|
|
363
|
+
|
|
364
|
+
(call_expression
|
|
365
|
+
function: [
|
|
366
|
+
((identifier) @constructor
|
|
367
|
+
(#match? @constructor "^[A-Z]"))
|
|
368
|
+
(scoped_identifier
|
|
369
|
+
name: ((identifier) @constructor
|
|
370
|
+
(#match? @constructor "^[A-Z]")))
|
|
371
|
+
])
|
|
372
|
+
|
|
373
|
+
; ---
|
|
374
|
+
; PascalCase identifiers under a path which is also PascalCase
|
|
375
|
+
; are assumed to be constructors if they have methods or fields.
|
|
376
|
+
; ---
|
|
377
|
+
|
|
378
|
+
(field_expression
|
|
379
|
+
value: (scoped_identifier
|
|
380
|
+
path: [
|
|
381
|
+
(identifier) @type
|
|
382
|
+
(scoped_identifier
|
|
383
|
+
name: (identifier) @type)
|
|
384
|
+
]
|
|
385
|
+
name: (identifier) @constructor
|
|
386
|
+
(#match? @type "^[A-Z]")
|
|
387
|
+
(#match? @constructor "^[A-Z]")))
|
|
388
|
+
|
|
389
|
+
(enum_variant (identifier) @type.enum.variant)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
; -------
|
|
393
|
+
; Constructors
|
|
394
|
+
; -------
|
|
395
|
+
; TODO: this is largely guesswork, remove it once we get actual info from locals.scm or r-a
|
|
396
|
+
|
|
397
|
+
(struct_expression
|
|
398
|
+
name: (type_identifier) @constructor)
|
|
399
|
+
|
|
400
|
+
(tuple_struct_pattern
|
|
401
|
+
type: [
|
|
402
|
+
(identifier) @constructor
|
|
403
|
+
(scoped_identifier
|
|
404
|
+
name: (identifier) @constructor)
|
|
405
|
+
])
|
|
406
|
+
(struct_pattern
|
|
407
|
+
type: [
|
|
408
|
+
((type_identifier) @constructor)
|
|
409
|
+
(scoped_type_identifier
|
|
410
|
+
name: (type_identifier) @constructor)
|
|
411
|
+
])
|
|
412
|
+
(match_pattern
|
|
413
|
+
((identifier) @constructor) (#match? @constructor "^[A-Z]"))
|
|
414
|
+
(or_pattern
|
|
415
|
+
((identifier) @constructor)
|
|
416
|
+
((identifier) @constructor)
|
|
417
|
+
(#match? @constructor "^[A-Z]"))
|
|
418
|
+
|
|
419
|
+
; ---
|
|
420
|
+
; Macros
|
|
421
|
+
; ---
|
|
422
|
+
|
|
423
|
+
(attribute
|
|
424
|
+
(identifier) @function.macro)
|
|
425
|
+
(inner_attribute_item "!" @punctuation)
|
|
426
|
+
(attribute
|
|
427
|
+
[
|
|
428
|
+
(identifier) @function.macro
|
|
429
|
+
(scoped_identifier
|
|
430
|
+
name: (identifier) @function.macro)
|
|
431
|
+
]
|
|
432
|
+
(token_tree (identifier) @function.macro)?)
|
|
433
|
+
|
|
434
|
+
(inner_attribute_item) @attribute
|
|
435
|
+
|
|
436
|
+
(macro_definition
|
|
437
|
+
name: (identifier) @function.macro)
|
|
438
|
+
(macro_invocation
|
|
439
|
+
macro: [
|
|
440
|
+
((identifier) @function.macro)
|
|
441
|
+
(scoped_identifier
|
|
442
|
+
name: (identifier) @function.macro)
|
|
443
|
+
]
|
|
444
|
+
"!" @function.macro)
|
|
445
|
+
|
|
446
|
+
(metavariable) @variable.parameter
|
|
447
|
+
(fragment_specifier) @type
|
|
448
|
+
|
|
449
|
+
(attribute
|
|
450
|
+
(identifier) @special
|
|
451
|
+
arguments: (token_tree (identifier) @type)
|
|
452
|
+
(#eq? @special "derive")
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
(token_repetition_pattern) @punctuation.delimiter
|
|
456
|
+
(token_repetition_pattern [")" "(" "$"] @punctuation.special)
|
|
457
|
+
(token_repetition_pattern "?" @operator)
|
|
458
|
+
|
|
459
|
+
; ---
|
|
460
|
+
; Prelude
|
|
461
|
+
; ---
|
|
462
|
+
|
|
463
|
+
((identifier) @type.enum.variant.builtin
|
|
464
|
+
(#any-of? @type.enum.variant.builtin "Some" "None" "Ok" "Err"))
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
(call_expression
|
|
468
|
+
(identifier) @function.builtin
|
|
469
|
+
(#any-of? @function.builtin
|
|
470
|
+
"drop"
|
|
471
|
+
"size_of"
|
|
472
|
+
"size_of_val"
|
|
473
|
+
"align_of"
|
|
474
|
+
"align_of_val"))
|
|
475
|
+
|
|
476
|
+
((type_identifier) @type.builtin
|
|
477
|
+
(#any-of?
|
|
478
|
+
@type.builtin
|
|
479
|
+
"Send"
|
|
480
|
+
"Sized"
|
|
481
|
+
"Sync"
|
|
482
|
+
"Unpin"
|
|
483
|
+
"Drop"
|
|
484
|
+
"Fn"
|
|
485
|
+
"FnMut"
|
|
486
|
+
"FnOnce"
|
|
487
|
+
"AsMut"
|
|
488
|
+
"AsRef"
|
|
489
|
+
"From"
|
|
490
|
+
"Into"
|
|
491
|
+
"DoubleEndedIterator"
|
|
492
|
+
"ExactSizeIterator"
|
|
493
|
+
"Extend"
|
|
494
|
+
"IntoIterator"
|
|
495
|
+
"Iterator"
|
|
496
|
+
"Option"
|
|
497
|
+
"Result"
|
|
498
|
+
"Clone"
|
|
499
|
+
"Copy"
|
|
500
|
+
"Debug"
|
|
501
|
+
"Default"
|
|
502
|
+
"Eq"
|
|
503
|
+
"Hash"
|
|
504
|
+
"Ord"
|
|
505
|
+
"PartialEq"
|
|
506
|
+
"PartialOrd"
|
|
507
|
+
"ToOwned"
|
|
508
|
+
"Box"
|
|
509
|
+
"String"
|
|
510
|
+
"ToString"
|
|
511
|
+
"Vec"
|
|
512
|
+
"FromIterator"
|
|
513
|
+
"TryFrom"
|
|
514
|
+
"TryInto"))
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
[
|
|
2
|
+
(use_list)
|
|
3
|
+
(block)
|
|
4
|
+
(match_block)
|
|
5
|
+
(arguments)
|
|
6
|
+
(parameters)
|
|
7
|
+
(declaration_list)
|
|
8
|
+
(field_declaration_list)
|
|
9
|
+
(field_initializer_list)
|
|
10
|
+
(struct_pattern)
|
|
11
|
+
(tuple_pattern)
|
|
12
|
+
(unit_expression)
|
|
13
|
+
(enum_variant_list)
|
|
14
|
+
(call_expression)
|
|
15
|
+
(binary_expression)
|
|
16
|
+
(field_expression)
|
|
17
|
+
(await_expression)
|
|
18
|
+
(tuple_expression)
|
|
19
|
+
(array_expression)
|
|
20
|
+
(where_clause)
|
|
21
|
+
(type_cast_expression)
|
|
22
|
+
|
|
23
|
+
(token_tree)
|
|
24
|
+
(macro_definition)
|
|
25
|
+
(token_tree_pattern)
|
|
26
|
+
(token_repetition)
|
|
27
|
+
] @indent
|
|
28
|
+
|
|
29
|
+
[
|
|
30
|
+
"}"
|
|
31
|
+
"]"
|
|
32
|
+
")"
|
|
33
|
+
] @outdent
|
|
34
|
+
|
|
35
|
+
; Indent the right side of assignments.
|
|
36
|
+
; The #not-same-line? predicate is required to prevent an extra indent for e.g.
|
|
37
|
+
; an else-clause where the previous if-clause starts on the same line as the assignment.
|
|
38
|
+
(assignment_expression
|
|
39
|
+
.
|
|
40
|
+
(_) @expr-start
|
|
41
|
+
right: (_) @indent
|
|
42
|
+
(#not-same-line? @indent @expr-start)
|
|
43
|
+
(#set! "scope" "all")
|
|
44
|
+
)
|
|
45
|
+
(compound_assignment_expr
|
|
46
|
+
.
|
|
47
|
+
(_) @expr-start
|
|
48
|
+
right: (_) @indent
|
|
49
|
+
(#not-same-line? @indent @expr-start)
|
|
50
|
+
(#set! "scope" "all")
|
|
51
|
+
)
|
|
52
|
+
(let_declaration
|
|
53
|
+
"let" @expr-start
|
|
54
|
+
value: (_) @indent
|
|
55
|
+
alternative: (_)? @indent
|
|
56
|
+
(#not-same-line? @indent @expr-start)
|
|
57
|
+
(#set! "scope" "all")
|
|
58
|
+
)
|
|
59
|
+
(let_condition
|
|
60
|
+
.
|
|
61
|
+
(_) @expr-start
|
|
62
|
+
value: (_) @indent
|
|
63
|
+
(#not-same-line? @indent @expr-start)
|
|
64
|
+
(#set! "scope" "all")
|
|
65
|
+
)
|
|
66
|
+
(if_expression
|
|
67
|
+
.
|
|
68
|
+
(_) @expr-start
|
|
69
|
+
condition: (_) @indent
|
|
70
|
+
(#not-same-line? @indent @expr-start)
|
|
71
|
+
(#set! "scope" "all")
|
|
72
|
+
)
|
|
73
|
+
(static_item
|
|
74
|
+
.
|
|
75
|
+
(_) @expr-start
|
|
76
|
+
value: (_) @indent
|
|
77
|
+
(#not-same-line? @indent @expr-start)
|
|
78
|
+
(#set! "scope" "all")
|
|
79
|
+
)
|
|
80
|
+
(field_pattern
|
|
81
|
+
.
|
|
82
|
+
(_) @expr-start
|
|
83
|
+
pattern: (_) @indent
|
|
84
|
+
(#not-same-line? @indent @expr-start)
|
|
85
|
+
(#set! "scope" "all")
|
|
86
|
+
)
|
|
87
|
+
; Indent type aliases that span multiple lines, similar to
|
|
88
|
+
; regular assignment expressions
|
|
89
|
+
(type_item
|
|
90
|
+
.
|
|
91
|
+
(_) @expr-start
|
|
92
|
+
type: (_) @indent
|
|
93
|
+
(#not-same-line? @indent @expr-start)
|
|
94
|
+
(#set! "scope" "all")
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
; Some field expressions where the left part is a multiline expression are not
|
|
98
|
+
; indented by cargo fmt.
|
|
99
|
+
; Because this multiline expression might be nested in an arbitrary number of
|
|
100
|
+
; field expressions, this can only be matched using a Regex.
|
|
101
|
+
(field_expression
|
|
102
|
+
value: (_) @val
|
|
103
|
+
"." @outdent
|
|
104
|
+
; Check whether the first line ends with `(`, `{` or `[` (up to whitespace).
|
|
105
|
+
(#match? @val "(\\A[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r))")
|
|
106
|
+
)
|
|
107
|
+
; Same as above, but with an additional `call_expression`. This is required since otherwise
|
|
108
|
+
; the arguments of the function call won't be outdented.
|
|
109
|
+
(call_expression
|
|
110
|
+
function: (field_expression
|
|
111
|
+
value: (_) @val
|
|
112
|
+
"." @outdent
|
|
113
|
+
(#match? @val "(\\A[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r))")
|
|
114
|
+
)
|
|
115
|
+
arguments: (_) @outdent
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
; Indent if guards in patterns.
|
|
120
|
+
; Since the tree-sitter grammar doesn't create a node for the if expression,
|
|
121
|
+
; it's not possible to do this correctly in all cases. Indenting the tail of the
|
|
122
|
+
; whole pattern whenever it contains an `if` only fails if the `if` appears after
|
|
123
|
+
; the second line of the pattern (which should only rarely be the case)
|
|
124
|
+
(match_pattern
|
|
125
|
+
.
|
|
126
|
+
(_) @expr-start
|
|
127
|
+
"if" @pattern-guard
|
|
128
|
+
(#not-same-line? @expr-start @pattern-guard)
|
|
129
|
+
) @indent
|
|
130
|
+
|
|
131
|
+
; Align closure parameters if they span more than one line
|
|
132
|
+
(closure_parameters
|
|
133
|
+
"|"
|
|
134
|
+
.
|
|
135
|
+
(_) @anchor
|
|
136
|
+
(_) @expr-end
|
|
137
|
+
.
|
|
138
|
+
(#not-same-line? @anchor @expr-end)
|
|
139
|
+
) @align
|
|
140
|
+
|
|
141
|
+
(for_expression
|
|
142
|
+
"in" @in
|
|
143
|
+
.
|
|
144
|
+
(_) @indent
|
|
145
|
+
(#not-same-line? @in @indent)
|
|
146
|
+
(#set! "scope" "all")
|
|
147
|
+
)
|
|
148
|
+
|