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

Commit

Permalink
Implement naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
chbk committed Mar 16, 2020
1 parent 16c8071 commit ea47cc6
Showing 1 changed file with 233 additions and 82 deletions.
315 changes: 233 additions & 82 deletions grammars/tree-sitter-go.cson
Original file line number Diff line number Diff line change
Expand Up @@ -43,88 +43,239 @@ folds: [
scopes:
'source_file': 'source.go'

'comment': 'comment.block'
# Keyword
'"if"': 'keyword.control.condition'
'"else"': 'keyword.control.condition'
'"switch"': 'keyword.control.condition'
'"select"': 'keyword.control.condition'
'"case"': 'keyword.control.condition'
'"fallthrough"': 'keyword.control.condition'
'"default"': 'keyword.control.condition'
'"for"': 'keyword.control.loop'
'"range"': 'keyword.control.loop'
'"break"': 'keyword.control.jump'
'"return"': 'keyword.control.jump'
'"continue"': 'keyword.control.jump'
'"goto"': 'keyword.control.jump'
'"defer"': 'keyword.control.jump'
'"go"': 'keyword.control.jump'
'"package"': 'keyword.control.directive'
'"import"': 'keyword.control.package'

'"+"': 'keyword.operator.symbol'
'"-"': 'keyword.operator.symbol'
'"*"': 'keyword.operator.symbol'
'"/"': 'keyword.operator.symbol'
'"%"': 'keyword.operator.symbol'
'"++"': 'keyword.operator.symbol'
'"--"': 'keyword.operator.symbol'
'"=="': 'keyword.operator.symbol'
'"!="': 'keyword.operator.symbol'
'">"': 'keyword.operator.symbol'
'"<"': 'keyword.operator.symbol'
'">="': 'keyword.operator.symbol'
'"<="': 'keyword.operator.symbol'
'"!"': 'keyword.operator.symbol'
'"|"': 'keyword.operator.symbol'
'"^"': 'keyword.operator.symbol'
'"<<"': 'keyword.operator.symbol'
'">>"': 'keyword.operator.symbol'
'"="': 'keyword.operator.symbol'
'"+="': 'keyword.operator.symbol'
'"-="': 'keyword.operator.symbol'
'"*="': 'keyword.operator.symbol'
'"/="': 'keyword.operator.symbol'
'"%="': 'keyword.operator.symbol'
'"<<="': 'keyword.operator.symbol'
'">>="': 'keyword.operator.symbol'
'"&="': 'keyword.operator.symbol'
'"^="': 'keyword.operator.symbol'
'"|="': 'keyword.operator.symbol'
'":="': 'keyword.operator.symbol'
'"&"': 'keyword.operator.symbol'
'"&&"': 'keyword.operator.symbol'
'"||"': 'keyword.operator.symbol'
'"..."': 'keyword.operator.symbol'
'"<-"': 'keyword.operator.symbol'

# Storage
'"var"': 'storage.declaration.variable'
'"const"': 'storage.declaration.variable.immutable'
'"func"': 'storage.declaration.function'
'"type"': 'storage.declaration.datatype'

'function_type > "func"': 'storage.type.language.function'
'"interface"': 'storage.type.language.interface'
'"struct"': 'storage.type.language.structure'
'"map"': 'storage.type.language.map'
'"chan"': 'storage.type.language.channel'

'type_identifier': [
{
match: '^(bool|byte|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$',
scopes: 'storage.type.language.primitive'
},
'storage.type.entity'
]

# Entity
'package_identifier': 'entity.package'

'identifier': [
{
exact: 'iota',
scopes: 'entity.variable.support.iota'
},
'entity.variable'
]

'parameter_declaration > identifier': [
{
exact: 'iota',
scopes: 'entity.variable.support.parameter.iota'
},
'entity.variable.parameter'
]

'field_identifier': 'entity.variable.member'

'call_expression > identifier': [
{
match: '^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$',
scopes: 'entity.function.support.call'
},
'entity.function.call'
]

'call_expression > selector_expression > field_identifier': 'entity.function.call'

'function_declaration > identifier': 'entity.function.definition'
'method_declaration > field_identifier': 'entity.function.method.definition'
'type_declaration > type_spec > type_identifier': 'entity.type.definition'

# String
'interpreted_string_literal': 'string.quoted'
'raw_string_literal': 'string.quoted'

# Constant
'escape_sequence': [
{
match: '[tf]',
scopes: 'constant.character.escape.whitespace'
},
{
match: '[nr]',
scopes: 'constant.character.escape.whitespace.newline'
},
'constant.character.escape'
]

'rune_literal': 'constant.character.rune'

'"var"': 'keyword.import'
'"type"': 'keyword.type'
'"func"': 'keyword.function'
'"const"': 'keyword.const'
'"struct"': 'keyword.struct'
'"interface"': 'keyword.interface'
'"import"': 'keyword.import'
'"package"': 'keyword.package'
'"map"': 'keyword.map'
'"chan"': 'keyword.chan'

'type_identifier': 'support.storage.type'
'field_identifier': 'variable.other.object.property'
'package_identifier': 'entity.name.package'

'"if"': 'keyword.control'
'"for"': 'keyword.control'
'"else"': 'keyword.control'
'"case"': 'keyword.control'
'"break"': 'keyword.control'
'"switch"': 'keyword.control'
'"select"': 'keyword.control'
'"return"': 'keyword.control'
'"default"': 'keyword.control'
'"continue"': 'keyword.control'
'"goto"': 'keyword.control'
'"fallthrough"': 'keyword.control'
'"defer"': 'keyword.control'
'"range"': 'keyword.control'
'"go"': 'keyword.control'

'interpreted_string_literal': 'string.quoted.double'
'raw_string_literal': 'string.quoted.double'
'escape_sequence': 'constant.character.escape'
'rune_literal': 'constant.other.rune'
'int_literal': 'constant.numeric.integer'
'float_literal': 'constant.numeric.float'
'imaginary_literal': 'constant.numeric.integer'
'nil': 'constant.language.nil'
'false': 'constant.language.false'
'true': 'constant.language.true'

'call_expression > identifier': 'entity.name.function'
'function_declaration > identifier': 'entity.name.function'
'method_declaration > field_identifier': 'entity.name.function'
'call_expression > selector_expression > field_identifier': 'entity.name.function'

'"+"': 'keyword.operator'
'"-"': 'keyword.operator'
'"*"': 'keyword.operator'
'"/"': 'keyword.operator'
'"%"': 'keyword.operator'
'"++"': 'keyword.operator'
'"--"': 'keyword.operator'
'"=="': 'keyword.operator'
'"!="': 'keyword.operator'
'">"': 'keyword.operator'
'"<"': 'keyword.operator'
'">="': 'keyword.operator'
'"<="': 'keyword.operator'
'"!"': 'keyword.operator'
'"|"': 'keyword.operator'
'"^"': 'keyword.operator'
'"<<"': 'keyword.operator'
'">>"': 'keyword.operator'
'"="': 'keyword.operator'
'"+="': 'keyword.operator'
'"-="': 'keyword.operator'
'"*="': 'keyword.operator'
'"/="': 'keyword.operator'
'"%="': 'keyword.operator'
'"<<="': 'keyword.operator'
'">>="': 'keyword.operator'
'"&="': 'keyword.operator'
'"^="': 'keyword.operator'
'"|="': 'keyword.operator'
'":="': 'keyword.operator'
'"&"': 'keyword.operator'
'"*"': 'keyword.operator'
'"&&"': 'keyword.operator'
'"||"': 'keyword.operator'
'"..."': 'keyword.operator'
'"<-"': 'keyword.operator'
'imaginary_literal': 'constant.numeric.complex'

'nil': 'constant.language.null'
'true': 'constant.language.boolean.true'
'false': 'constant.language.boolean.false'

# Comment
'comment': 'comment.block'

# Punctuation
'"."': 'punctuation.accessor'
'","': 'punctuation.separator'
'";"': 'punctuation.terminator'
'":"': 'punctuation.definition'
# '"("': 'punctuation.definition'
# '")"': 'punctuation.definition'
# '"{"': 'punctuation.definition'
# '"}"': 'punctuation.definition'
# '"["': 'punctuation.definition'
# '"]"': 'punctuation.definition'
'"\\""': 'punctuation.definition.string'

'slice_expression > ":"': 'punctuation.separator.slice'
'keyed_element > ":"': 'punctuation.separator.pair'

'parenthesized_expression > "("': 'punctuation.definition.expression'
'parenthesized_expression > ")"': 'punctuation.definition.expression'

'parameter_list > "("': 'punctuation.definition.parameters'
'parameter_list > ")"': 'punctuation.definition.parameters'

'argument_list > "("': 'punctuation.definition.arguments'
'argument_list > ")"': 'punctuation.definition.arguments'
'special_argument_list > "("': 'punctuation.definition.arguments'
'special_argument_list > ")"': 'punctuation.definition.arguments'
'type_switch_statement > "("': 'punctuation.definition.arguments'
'type_switch_statement > ")"': 'punctuation.definition.arguments'
'type_assertion_expression > "("': 'punctuation.definition.arguments'
'type_assertion_expression > ")"': 'punctuation.definition.arguments'
'type_conversion_expression > "("': 'punctuation.definition.arguments'
'type_conversion_expression > ")"': 'punctuation.definition.arguments'

'import_spec_list > "("': 'punctuation.definition.package'
'import_spec_list > ")"': 'punctuation.definition.package'

'const_declaration > "("': 'punctuation.definition.variable'
'const_declaration > ")"': 'punctuation.definition.variable'
'var_declaration > "("': 'punctuation.definition.variable'
'var_declaration > ")"': 'punctuation.definition.variable'

'type_declaration > "("': 'punctuation.definition.type'
'type_declaration > ")"': 'punctuation.definition.type'
'parenthesized_type > "("': 'punctuation.definition.type'
'parenthesized_type > ")"': 'punctuation.definition.type'

'literal_value > "{"': 'punctuation.definition.literal'
'literal_value > "}"': 'punctuation.definition.literal'

'field_declaration_list > "{"': 'punctuation.definition.type.structure'
'field_declaration_list > "}"': 'punctuation.definition.type.structure'

'method_spec_list > "{"': 'punctuation.definition.type.class.abstract'
'method_spec_list > "}"': 'punctuation.definition.type.class.abstract'

'block > "{"': 'punctuation.definition.statement'
'block > "}"': 'punctuation.definition.statement'
'select_statement > "{"': 'punctuation.definition.statement'
'select_statement > "}"': 'punctuation.definition.statement'
'type_switch_statement > "{"': 'punctuation.definition.statement'
'type_switch_statement > "}"': 'punctuation.definition.statement'
'expression_switch_statement > "{"': 'punctuation.definition.statement'
'expression_switch_statement > "}"': 'punctuation.definition.statement'

'func_literal > block > "{"': 'punctuation.definition.function'
'func_literal > block > "}"': 'punctuation.definition.function'
'function_declaration > block > "{"': 'punctuation.definition.function'
'function_declaration > block > "}"': 'punctuation.definition.function'
'method_declaration > block > "{"': 'punctuation.definition.function.method'
'method_declaration > block > "}"': 'punctuation.definition.function.method'

'map_type > "["': 'punctuation.definition.map'
'map_type > "]"': 'punctuation.definition.map'
'slice_type > "["': 'punctuation.definition.slice'
'slice_type > "]"': 'punctuation.definition.slice'
'array_type > "["': 'punctuation.definition.array'
'array_type > "]"': 'punctuation.definition.array'
'implicit_length_array_type > "["': 'punctuation.definition.array'
'implicit_length_array_type > "]"': 'punctuation.definition.array'

'index_expression > "["': 'punctuation.accessor.index'
'index_expression > "]"': 'punctuation.accessor.index'
'slice_expression > "["': 'punctuation.accessor.slice'
'slice_expression > "]"': 'punctuation.accessor.slice'

'ERROR > "."': 'punctuation.accessor.invalid.illegal'
'ERROR > ","': 'punctuation.separator.invalid.illegal'
'ERROR > ";"': 'punctuation.terminator.invalid.illegal'
'ERROR > ":"': 'punctuation.definition.invalid.illegal'
'ERROR > "{"': 'punctuation.definition.invalid.illegal'
'ERROR > "}"': 'punctuation.definition.invalid.illegal'
'ERROR > "("': 'punctuation.definition.invalid.illegal'
'ERROR > ")"': 'punctuation.definition.invalid.illegal'
'ERROR > "["': 'punctuation.definition.invalid.illegal'
'ERROR > "]"': 'punctuation.definition.invalid.illegal'
'ERROR > "\\""': 'punctuation.definition.string.invalid.illegal'

0 comments on commit ea47cc6

Please sign in to comment.