Skip to content

Commit

Permalink
Colorscheme group inheritance
Browse files Browse the repository at this point in the history
With this commit, the syntax files can define groups that are subsets of
other groups, for example constant.string. This is so that colorschemes
can be more accurate, possibly highlighting strings differently than
numbers for example.

See #176. This doesn't fully close that issue yet because the string
group still needs to be added to all strings in the syntax files.
  • Loading branch information
zyedidia committed Jun 22, 2016
1 parent 5c68a67 commit dbeb99b
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 103 deletions.
16 changes: 14 additions & 2 deletions cmd/micro/highlighter.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,20 @@ func LoadRulesFromFile(text, filename string) []SyntaxRule {
// in which case we should look that up in the colorscheme
// They can also just give us a straight up color
st := defStyle
if _, ok := colorscheme[color]; ok {
st = colorscheme[color]
groups := strings.Split(color, ".")
if len(groups) > 1 {
curGroup := ""
for i, g := range groups {
if i != 0 {
curGroup += "."
}
curGroup += g
if style, ok := colorscheme[curGroup]; ok {
st = style
}
}
} else if style, ok := colorscheme[color]; ok {
st = style
} else {
st = StringToStyle(color)
}
Expand Down
Loading

0 comments on commit dbeb99b

Please sign in to comment.