atom / language-clojure

Clojure package for Atom
Other
49 stars 48 forks source link

Syntax improvements for defs and symbols #75

Open tonsky opened 6 years ago

tonsky commented 6 years ago

Description of the Change

In top-level definitions like

(defn f [] (+ 1 2))

we shouldn’t mark the whole expression as "meta.definition.global.clojure". Instead, we should mark only f (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:

Alternate 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 Reviewable

tonsky commented 6 years ago

Agree. Looks like in other languages meta.definition tends to capture the whole expression, while entity.name is usually just class/function name. I made the appropriate changes. I also think entity.name.definition.clojure is a better name than entity.name.global.clojure because meta is called meta.defintion.global.clojure, with definition being the main semantic part and global just a modifier

50Wliu commented 6 years ago

I don't think that patterns: include $self block should actually be there. Since before it was at the wrong indentation and not doing anything and similar grammars don't have it.

tonsky commented 6 years ago

Actually, I think I messed up the indentation when I copied it back. 'patterns' was on the same level as 'captures' and I accidentally made it deeper. Would it make more sense if I return it the way it was before?

50Wliu commented 6 years ago

@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.