Skip to content

Commit

Permalink
Match builtins as keywords and highlight with the Identifier group.
Browse files Browse the repository at this point in the history
This was changed from keywords to the regexp in #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.
  • Loading branch information
arp242 authored and bhcleek committed Sep 2, 2018
1 parent ebfd80b commit 25d4783
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ hi def link goFloats Type
hi def link goComplexes Type

" Predefined functions and values
syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/
syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/
syn keyword goBuiltins append cap close complex copy delete imag len
syn keyword goBuiltins make new panic print println real recover
syn keyword goBoolean true false
syn keyword goPredefinedIdentifiers nil iota

hi def link goBuiltins Keyword
hi def link goBuiltins Identifier
hi def link goBoolean Boolean
hi def link goPredefinedIdentifiers goBoolean

Expand Down

0 comments on commit 25d4783

Please sign in to comment.