Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax/go: do not treat builtins as keywords #605

Merged
merged 1 commit into from
Nov 22, 2015
Merged

syntax/go: do not treat builtins as keywords #605

merged 1 commit into from
Nov 22, 2015

Conversation

mmlb
Copy link
Contributor

@mmlb mmlb commented Nov 17, 2015

builtins have a very different property from keywords, the identifiers are
settable. It is perfectly valid to override the builtins, though hopefully used
sparingly.

Instead of using syn keyword, we now use syn match and detect a function
call by searching for an open parentheses.

builtins have a very different property from keywords, the identifiers are
settable. It is perfectly valid to override the builtins, though hopefully used
sparingly.

Instead of using `syn keyword`, we now use `syn match` and detect a function
call by searching for an open parentheses.
@fatih
Copy link
Owner

fatih commented Nov 21, 2015

Hi @mmlb

Can you show me what this changes exactly?

@mmlb
Copy link
Contributor Author

mmlb commented Nov 21, 2015

I ran into this because I was defining a rename function and really wanted to use old, new string as the arg names but the syntax highlighting threw me off. Same deal with new, sometimes I really want to use it.

https://play.golang.org/p/SmNjYyJq1J

before:
image

after:
image

fatih added a commit that referenced this pull request Nov 22, 2015
syntax/go: do not treat builtins as keywords
@fatih fatih merged commit fe85bd6 into fatih:master Nov 22, 2015
@fatih
Copy link
Owner

fatih commented Nov 22, 2015

Thanks @mmlb this makes totally sense. 👍

bhcleek pushed a commit to bhcleek/vim-go that referenced this pull request Sep 2, 2018
This was changed from keywords to the regexp in fatih#605, but I think that
was a mistake.

If you do `new := "foo"` then this is perfectly valid Go, but I don't
think it's a bad thing to add a reminder that you're actually overriding
a global built-in by highlighting the `new`, just as it's not a bad idea
to highlight the `new()` in `func new()` to serve as a similar reminder.

This is a common-ish mistake that most of us have probably made at least
once or twice.

The only case where this fails is in method declaration and calls:

    func () x new() {
      other.new()
    }

But this is the case with the current highlight as well, so it doesn't
make that worse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants