From 2efd538d37ff368f55c0f2ca4b4083db927ec8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Fri, 30 Sep 2022 20:23:05 +0200 Subject: [PATCH] Explain where to get syntax kinds for custom rules from (#4246) --- README.md | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 33a2e2558..22fc0da2a 100644 --- a/README.md +++ b/README.md @@ -524,25 +524,34 @@ You can filter the matches by providing one or more `match_kinds`, which will reject matches that include syntax kinds that are not present in this list. Here are all the possible syntax kinds: -* argument -* attribute.builtin -* attribute.id -* buildconfig.id -* buildconfig.keyword -* comment -* comment.mark -* comment.url -* doccomment -* doccomment.field -* identifier -* keyword -* number -* objectliteral -* parameter -* placeholder -* string -* string_interpolation_anchor -* typeidentifier +* `argument` +* `attribute.builtin` +* `attribute.id` +* `buildconfig.id` +* `buildconfig.keyword` +* `comment` +* `comment.mark` +* `comment.url` +* `doccomment` +* `doccomment.field` +* `identifier` +* `keyword` +* `number` +* `objectliteral` +* `parameter` +* `placeholder` +* `string` +* `string_interpolation_anchor` +* `typeidentifier` + +All syntax kinds used in a snippet of Swift code can be extracted asking +[SourceKitten](https://github.com/jpsim/SourceKitten). For example, +`sourcekitten syntax --text "struct S {}"` delivers + +* `source.lang.swift.syntaxtype.keyword` for the `struct` keyword and +* `source.lang.swift.syntaxtype.identifier` for its name `S` + +which match to `keyword` and `identifier` in the above list. If using custom rules in combination with `only_rules`, make sure to add `custom_rules` as an item under `only_rules`.