Syntax improvements for defs and symbols#75
Conversation
…k just fn name with "meta.definition.global.clojure entity.name.global.clojure"
| '1': | ||
| 'name': 'keyword.control.clojure' | ||
| 'end': '(?=\\))' | ||
| 'name': 'meta.definition.global.clojure' |
There was a problem hiding this comment.
I think this meta should be kept and the actual function changed to just entity.name.global.clojure.
| 'match': '([\\w\\.\\-\\_\\:\\+\\=\\>\\<\\!\\?\\*][\\w\\.\\-\\_\\:\\+\\=\\>\\<\\!\\?\\*\\d]+)' | ||
| 'name': 'entity.global.clojure' | ||
| 'match': '([A-Z_a-z!$%&+\\-.:<=>?|*][0-9#\'A-Z_a-z!$%&+\\-.:<=>?|*]*)' | ||
| 'name': 'meta.definition.global.clojure entity.name.global.clojure' |
There was a problem hiding this comment.
Scopes != CSS classes and while this may look correct in the DOM it will appear as one scope internally.
| for symbol in symbols | ||
| {tokens} = grammar.tokenizeLine "(#{macro} #{symbol} 'bar)" | ||
| expect(tokens[1]).toEqual value: macro, scopes: ["source.clojure", "meta.expression.clojure", "keyword.control.clojure"] | ||
| expect(tokens[3]).toEqual value: symbol, scopes: ["source.clojure", "meta.expression.clojure", "meta.definition.global.clojure entity.name.global.clojure"] |
|
Agree. Looks like in other languages |
| 'include': '#sexp' | ||
| } | ||
| { | ||
| 'match': '(?<=\\()(.+?)(?=\\s|\\))' |
There was a problem hiding this comment.
This was placing the same entity.name.function to all function calls inside defn. Because the token is the same, there was no way to distinguish between function declaration and function call. I checked with other syntaxes and they seem to put entity.name.* on definitions only as well
There was a problem hiding this comment.
Hmm, I think this is worth keeping. I checked language-javascript, language-java, and language-php and all use entity.name.function for function declarations and function calls but have an additional meta scope to differentiate between whether it's a declaration or call (usually meta.function vs meta.{function|method}-call).
There was a problem hiding this comment.
maybe you’re right. I was looking at Ruby. Returned it back
|
I don't think that |
|
Actually, I think I messed up the indentation when I copied it back. |
|
@tonsky the previous indentation, with the patterns at the same level as captures, also doesn't make sense. That syntax is only for begin/end patterns and not regular matches. |
Description of the Change
In top-level definitions like
we shouldn’t mark the whole expression as
"meta.definition.global.clojure". Instead, we should mark onlyf(function name) as"entity.name.global.clojure meta.definition.global.clojure". This is similar to how other syntaxes do it, e.g. JavaScript and Python.In addition to that, this PR contains a couple of fixes to existing regexps:
[0-9#'][#$%&'|](def *var* ...), capture*var*as"entity.name.global"as wellAlternate Designs
Not applicable
Benefits
Possible Drawbacks
Existing themes that were designed specifically with Clojure syntax in mind might break (I doubt ones exist, though)
Applicable Issues
Not applicable
This change is