From 14563f91e243604f2dfe07f84f97bc8495c2b414 Mon Sep 17 00:00:00 2001 From: Keith Russell Date: Tue, 12 Oct 2021 21:08:56 -0400 Subject: [PATCH] Fix Go's variables The Go syntax causes some schemes to colour _all_ variables of any kind with the "variable" colour. This can also be seen with the built-in "Sixteen" colour scheme (and, indeed, with the original Base16 it came from). Without the change in this commit there is no instance of a variable with foreground which contrasts with, say, Python where most variables appear with the foreground colour. In the case of Solarized light it's a "sea of blue". An example in Python shows the expected behaviour. if not os.path.exists(repo_name): return False for fname in ["refs", "HEAD", "objects", "hooks"]: "os", "path", "repo_name" and "fname" are all set to the default foreground. This Go code, however does not. fileHeader := make([]byte, exifHeaderSize) if _, err := data.Read(fileHeader); err != nil { "fileHeader", "exifHeaderSize", "err" (both instances) and "data" all display as the variable colour (blue, in the case of Solarized light theme). I'm not expecting the syntax file to change any time soon (changing the way the syntax definition works could have drastic downstream effects). Working around it in the scheme seems like the right approach. I believe JavaScript has a similar variable workaround. --- Solarized (dark).sublime-color-scheme | 7 +++++++ Solarized (light).sublime-color-scheme | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Solarized (dark).sublime-color-scheme b/Solarized (dark).sublime-color-scheme index 6913ccc..50fbff6 100644 --- a/Solarized (dark).sublime-color-scheme +++ b/Solarized (dark).sublime-color-scheme @@ -540,6 +540,13 @@ "foreground": "var(base0)" }, + // Go + { + "name": "Go Variables", + "scope": "variable.other.go, variable.other.member.go, variable.other.member.declaration.go, variable.other.constant.declaration.go", + "foreground": "var(base0)" + }, + // Sublime Merge { "scope": "diff.deleted", diff --git a/Solarized (light).sublime-color-scheme b/Solarized (light).sublime-color-scheme index ddbcf8e..4786166 100644 --- a/Solarized (light).sublime-color-scheme +++ b/Solarized (light).sublime-color-scheme @@ -540,6 +540,13 @@ "foreground": "var(base00)" }, + // Go + { + "name": "Go Variables", + "scope": "variable.other.go, variable.other.member.go, variable.other.member.declaration.go, variable.other.constant.declaration.go", + "foreground": "var(base00)" + }, + // Sublime Merge { "scope": "diff.deleted",