Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

[WIP] Docs on scopes #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[WIP] Docs on scopes #114

wants to merge 1 commit into from

Conversation

MaximSokolov
Copy link

Just scopes with examples.
No description yet.
Based on the Textmate docs

Refs atom/atom#8430

New scopes

  • constant
    • character
      • escape
        • ❓ unicode
          • 16-bit-hex (\u0394|...)
          • 32-bit-hex (\U00000394|...)
    • language
      • ❓ boolean
        • (false|true)
      • ❓ nothing (e.g. None in Python or null, nil etc. Should it be one standart scope?)
    • other
      • ❓ rgb-value (#cfcddd, ...)
  • keyword
    • control
      • ❓ exception (try|catch|finally|throw|...)
      • ❓ statement (break|continue|pass|return|yield|...)
    • operator
      • ❓ comparison ( = | == | < | > | != | ... )
      • ❓ arithmetic (+, -, /, *, ...)
      • ❓ assignment ( = | := | ... )
        • augmented compound ( += | -= | *= | %= | ... )
      • ❓ logical ( ! | && | and | not | or |...)
      • ❓ reference (& in &x)
      • ❓ dereference (* in int *pointer)
      • ❓ bitwise (<<, >>, |, &, ...)
      • increment-decrement (e.g. in Java and PHP)
      • ❓ increment (++ in ++x and x++)
      • ❓ decrement (-- in --x and x--)
  • storage
    • type
      • ❓ primitive
  • markup
    • ❓ changed
    • ❓ inserted
    • ❓ deleted
    • ❓ strike
    • raw
      • ❓ inline
      • ❓ block
  • meta
    • ❓ function (function test(param1, param2) in function test(param1, param2){})
      • ❓ inline
    • ❓ function-call (functionCall(arg1, arg2))
      • ❓ without-arguments
    • ❓ method-call (methodCall(arg1, arg2) in obj.methodCall(arg1, arg2))
      • ❓ without-arguments
    • ❓ parameters ((param1, param2) in function test(param1, param2){})
    • ❓ arguments ((arg1, arg2) in functionCall(arg1, arg2) , obj.methodCall(arg1, arg2))
  • string
    • ❓ heredoc
  • 🆕 punctuation
    • definition
      • (string|parameters|arguments|comment)
    • separator
      • (key-value|parameters|arguments|...)
        • (period|comma|...)
    • ❓ delimiter
      • (object|method|...)
        • (period|comma|...)
    • ❓ statement
      • (terminator|...)
  • variable
    • other
      • ❓ argument
      • ❓ assignment (x in x = 10)
      • ❓ interpolation (x in "#{x}")
      • ❓ readwrite (not a constant I guess. See @variable in Coffeescript)

@simurai
Copy link
Contributor

simurai commented Aug 27, 2015

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

@MaximSokolov
Copy link
Author

How much does this version differ from the TextMate convention?

The main difference is the punctuation scope. Most of suggested scopes already is used.

@MaximSokolov
Copy link
Author

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"

@mnquintana
Copy link
Contributor

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.

@MaximSokolov
Copy link
Author

Agree. However we can get punctuation via string -> punctuation.definition

@chbk
Copy link

chbk commented Sep 7, 2015

Where would brackets, braces and parentheses go? How about a "section" category in "punctuation", I like the way language-ruby handles those characters.

@MaximSokolov
Copy link
Author

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

@lee-dohm
Copy link
Contributor

Is this up-to-date with all the changes that the @atom/languages team have been doing?

@alexchandel
Copy link

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

@infininight
Copy link

@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

@ghost
Copy link

ghost commented Apr 17, 2018

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

@tabathap

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants