flight-manual.atom.io
flight-manual.atom.io copied to clipboard
[WIP] Docs on scopes
Just scopes with examples. No description yet. Based on the Textmate docs
Refs atom/atom#8430
New scopes
- constant
- character
- escape
- :question: unicode
- 16-bit-hex (
\u0394
|...) - 32-bit-hex (
\U00000394
|...)
- 16-bit-hex (
- :question: unicode
- escape
- language
- :question: boolean
- (false|true)
- :question: nothing (e.g.
None
in Python ornull
,nil
etc. Should it be one standart scope?)
- :question: boolean
- other
- :question: rgb-value (
#cfcddd
, ...)
- :question: rgb-value (
- character
- keyword
- control
- :question: exception (try|catch|finally|throw|...)
- :question: statement (break|continue|pass|return|yield|...)
- operator
- :question: comparison ( = | == | < | > | != | ... )
- :question: arithmetic (+, -, /, *, ...)
- :question: assignment ( = | := | ... )
- ~~augmented~~ compound ( += | -= | *= | %= | ... )
- :question: logical ( ! | && | and | not | or |...)
- :question: reference (
&
in&x
) - :question: dereference (
*
inint *pointer
) - :question: bitwise (<<, >>, |, &, ...)
- :question: ~~increment-decrement~~ (e.g. in Java and PHP)
- :question: increment (
++
in++x
andx++
) - :question: decrement (
--
in--x
andx--
)
- control
- storage
- type
- :question: primitive
- type
- markup
- :question: changed
- :question: inserted
- :question: deleted
- :question: strike
- raw
- :question: inline
- :question: block
- meta
- :question: function (
function test(param1, param2)
infunction test(param1, param2){}
)- :question: inline
- :question: function-call (
functionCall(arg1, arg2)
)- :question: without-arguments
- :question: method-call (
methodCall(arg1, arg2)
inobj.methodCall(arg1, arg2)
)- :question: without-arguments
- :question: parameters (
(param1, param2)
infunction test(param1, param2){}
) - :question: arguments (
(arg1, arg2)
infunctionCall(arg1, arg2)
,obj.methodCall(arg1, arg2)
)
- :question: function (
- string
- :question: heredoc
- :new: punctuation
- definition
- (string|parameters|arguments|comment)
- separator
- (key-value|parameters|arguments|...)
- (period|comma|...)
- (key-value|parameters|arguments|...)
- :question: delimiter
- (object|method|...)
- (period|comma|...)
- (object|method|...)
- :question: statement
- (terminator|...)
- definition
- variable
- other
- :question: argument
- :question: assignment (
x
inx = 10
) - :question: interpolation (
x
in "#{x}") - :question: readwrite (not a constant I guess. See
@variable
in Coffeescript)
- other
:+1: Having an official grammar naming convention would be great. Then there is at least a place to refer to. And the convention could be refined over time.
How much does this version differ from the TextMate convention? I think until an Atom 2.0, it would need to stay somewhat close. Just because there are already lots of themes out there that are mostly based on TextMate's convention. Smaller changes are fine, just not big ones.
How much does this version differ from the TextMate convention?
The main difference is the punctuation
scope. Most of suggested scopes already is used.
I think these scopes are redundant:
comment
- line
- double-slash
- double-dash
- number-sign
- percentage
- character
string
- quoted
- single
- double
- triple
- other
- unquoted
These scopes don't append any information about language symbol.
I doubt someone would use different color for 'string'
and "string"
I doubt someone would use different color for 'string' and "string"
That may be true, but scopes are used for far more than just syntax highlighting - since they're what give raw text semantic structure in Atom, they're also used for things like autocomplete and static analysis. So while the distinction between single- and double-quoted strings might not really matter for syntax highlighting, it could make all the difference in other contexts.
Agree. However we can get punctuation via string
-> punctuation.definition
Where would brackets, braces and parentheses go? How about a "section" category in "punctuation", I like the way language-ruby handles those characters.
Where would brackets, braces and parentheses go? How about a "section" category in "punctuation", I like the way language-ruby handles those characters.
IMO punctuation.definition
scope is better for this purpose:
// `punctuation.definition.parameters` for `(`, `)`
test(param, param) {
// `punctuation.definition.function[.brace.curly]` for `{`, `}`
...
}
punctuation.definition.array
for [
, ]
punctuation.definition.parameters
punctuation.definition.arguments
etc.
Even punctuation.definition.section
Is this up-to-date with all the changes that the @atom/languages team have been doing?
@MaximSokolov In addition to documenting these scopes, could you document how these scopes can be debugged for a particular grammar (e.g. when looking at a file highlighted with that grammar, when trying to find out why a particular scope was applied to a string of text, etc...)? The Hacking Atom: Debugging has laughably little to say on this.
@MaximSokolov Didn't see this until now, we never added the punctuation scope to the documentation but we do have a spec I've posted here for reference. This is what we go by for the TextMate grammars.
This isn't the most complete list but there is also completion for scopes when editing grammars in TextMate, the list of scopes completed is in this command.
- Michael Sheets, TextMate Bundle Maintainer
I noticed that this does not reference the entity scope in the textmate doc, is this intentional? for python this would be useful for "import somepackage" where "somepackage" would be entity.name.package
👌