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 Aug 4, 2020
1 parent 16c8071 commit a4b39ee
Showing 1 changed file with 252 additions and 83 deletions.
335 changes: 252 additions & 83 deletions grammars/tree-sitter-go.cson
Original file line number Diff line number Diff line change
Expand Up @@ -43,88 +43,257 @@ 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.arithmetic.symbol'
'"-"': 'keyword.operator.arithmetic.symbol'
'binary_expression > "*"': 'keyword.operator.arithmetic.symbol'
'"/"': 'keyword.operator.arithmetic.symbol'
'"%"': 'keyword.operator.arithmetic.symbol'
'"++"': 'keyword.operator.arithmetic.symbol'
'"--"': 'keyword.operator.arithmetic.symbol'

'binary_expression > "&"': 'keyword.operator.bitwise.symbol'
'"|"': 'keyword.operator.bitwise.symbol'
'"^"': 'keyword.operator.bitwise.symbol'
'"&^"': 'keyword.operator.bitwise.symbol'
'"<<"': 'keyword.operator.bitwise.shift.symbol'
'">>"': 'keyword.operator.bitwise.shift.symbol'

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

'"=="': 'keyword.operator.comparison.symbol'
'"!="': 'keyword.operator.comparison.symbol'
'"<"': 'keyword.operator.comparison.symbol'
'">"': 'keyword.operator.comparison.symbol'
'"<="': 'keyword.operator.comparison.symbol'
'">="': 'keyword.operator.comparison.symbol'

'"!"': 'keyword.operator.logical.symbol'
'"&&"': 'keyword.operator.logical.symbol'
'"||"': 'keyword.operator.logical.symbol'

'"&"': 'keyword.operator.pointer.reference.symbol'
'"*"': 'keyword.operator.pointer.dereference.symbol'

'"<-"': 'keyword.operator.channel.symbol'

'variadic_parameter_declaration > "..."': 'keyword.operator.variadic.symbol'
'variadic_argument > "..."': 'keyword.operator.unpack.symbol'
'implicit_length_array_type > "..."': 'keyword.operator.implicit.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'

'label_name': 'entity.label'

'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'
},
{
match: '^(bool|byte|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$',
scopes: 'entity.type.cast.language.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'
'float_literal': 'constant.numeric.decimal'
'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.definition'
'"("': 'punctuation.definition'
'")"': 'punctuation.definition'
'"{"': 'punctuation.definition'
'"}"': 'punctuation.definition'
'"["': 'punctuation.definition'
'"]"': 'punctuation.definition'
'","': 'punctuation.separator'
'";"': 'punctuation.terminator'
'"."': 'punctuation.accessor.member'
'"\\""': '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.body.structure'
'field_declaration_list > "}"': 'punctuation.definition.body.structure'

'method_spec_list > "{"': 'punctuation.definition.body.class.abstract'
'method_spec_list > "}"': 'punctuation.definition.body.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.body.function'
'func_literal > block > "}"': 'punctuation.definition.body.function'
'function_declaration > block > "{"': 'punctuation.definition.body.function'
'function_declaration > block > "}"': 'punctuation.definition.body.function'
'method_declaration > block > "{"': 'punctuation.definition.body.function.method'
'method_declaration > block > "}"': 'punctuation.definition.body.function.method'

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

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

'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.separator.invalid.illegal'
'ERROR > ";"': 'punctuation.terminator.invalid.illegal'
'ERROR > "."': 'punctuation.accessor.member.invalid.illegal'
'ERROR > "\\""': 'punctuation.definition.string.invalid.illegal'

0 comments on commit a4b39ee

Please sign in to comment.