Skip to content

More control over Go lang (and other lang) tagging. #8

@rocky

Description

@rocky

I am writing a debugger for Go and came across this project via Dmitri Shuralyov and his use of this which uses go/scanner.

One improvement I'd like to see is more fined-grained control over what gets tagged. Rather than reinvent stuff when not necessary, I consulted Pygments to see what it has.

This is from pygments/formatters/terminal.py;

    Whitespace:         ('lightgray',   'darkgray'),
    Comment:            ('lightgray',   'darkgray'),
    Comment.Preproc:    ('teal',        'turquoise'),
    Keyword:            ('darkblue',    'blue'),
    Keyword.Type:       ('teal',        'turquoise'),
    Operator.Word:      ('purple',      'fuchsia'),
    Name.Builtin:       ('teal',        'turquoise'),
    Name.Function:      ('darkgreen',   'green'),
    Name.Namespace:     ('_teal_',      '_turquoise_'),
    Name.Class:         ('_darkgreen_', '_green_'),
    Name.Exception:     ('teal',        'turquoise'),
    Name.Decorator:     ('darkgray',    'lightgray'),
    Name.Variable:      ('darkred',     'red'),
    Name.Constant:      ('darkred',     'red'),
    Name.Attribute:     ('teal',        'turquoise'),
    Name.Tag:           ('blue',        'blue'),
    String:             ('brown',       'brown'),
    Number:             ('darkblue',    'blue'),

There are some things above that aren't relevant to Go (but you might want to add them for other languages), and there are some things that should be added above for go like Rune, possibly Case label and so on. So here is a list below:

  • Whitespace
  • Comment
  • Keyword
  • Type name
  • Built in
  • Function
  • Variable
  • Exported name
  • Number
  • Rune

Kind is a uint8 so there is plenty of space to add constants to this.

If you would like me to create a pull request for this, let me know.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions