1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-25 21:39:02 +02:00

Update golangci-lint so we can force use of LazyLexer.

This commit is contained in:
Alec Thomas 2021-04-29 12:07:50 +10:00
parent f3874594e7
commit 7e282be495
15 changed files with 193 additions and 167 deletions

View File

@ -22,7 +22,7 @@ jobs:
- run:
name: Prepare
command: |
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.26.0
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.37.0
mkdir ~/report
when: always
- run:

View File

@ -25,6 +25,17 @@ linters:
- testpackage
- godot
- nestif
- paralleltest
- nlreturn
- cyclop
- exhaustivestruct
- gci
- gofumpt
- errorlint
- exhaustive
- ifshort
- wrapcheck
- stylecheck
linters-settings:
govet:
@ -36,6 +47,11 @@ linters-settings:
goconst:
min-len: 8
min-occurrences: 3
forbidigo:
forbid:
- (Must)?NewLexer
exclude_godoc_examples: false
issues:
max-per-linter: 0

View File

@ -7,7 +7,7 @@ import (
)
func TestCoalesce(t *testing.T) {
lexer := Coalesce(MustNewLexer(nil, Rules{
lexer := Coalesce(MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": []Rule{
{`[!@#$%^&*()]`, Punctuation, nil},
},

View File

@ -7,7 +7,7 @@ import (
)
func makeDelegationTestLexers() (lang Lexer, root Lexer) {
return MustNewLexer(nil, Rules{
return MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {
{`\<\?`, CommentPreproc, Push("inside")},
{`.`, Other, nil},
@ -18,7 +18,7 @@ func makeDelegationTestLexers() (lang Lexer, root Lexer) {
{`\s+`, Whitespace, nil},
},
}),
MustNewLexer(nil, Rules{
MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {
{`\bhello\b`, Keyword, nil},
{`\b(world|there)\b`, Name, nil},

View File

@ -120,7 +120,7 @@ func maxLineWidth(lines [][]chroma.Token) int {
for _, tokens := range lines {
length := 0
for _, token := range tokens {
length += len(strings.Replace(token.String(), ` `, " ", -1))
length += len(strings.ReplaceAll(token.String(), ` `, " "))
}
if length > maxWidth {
maxWidth = length
@ -136,7 +136,7 @@ func (f *Formatter) writeTokenBackgrounds(w io.Writer, lines [][]chroma.Token, s
for index, tokens := range lines {
lineLength := 0
for _, token := range tokens {
length := len(strings.Replace(token.String(), ` `, " ", -1))
length := len(strings.ReplaceAll(token.String(), ` `, " "))
tokenBackground := style.Get(token.Type).Background
if tokenBackground.IsSet() && tokenBackground != style.Get(chroma.Background).Background {
fmt.Fprintf(w, "<rect id=\"%s\" x=\"%dch\" y=\"%fem\" width=\"%dch\" height=\"1.2em\" fill=\"%s\" />\n", escapeString(token.String()), lineLength, 1.2*float64(index)+0.25, length, style.Get(token.Type).Background.String())

View File

@ -13,7 +13,7 @@ func TestTokenTypeClassifiers(t *testing.T) {
}
func TestSimpleLexer(t *testing.T) {
lexer, err := NewLexer(
lexer, err := NewLexer( // nolint: forbidigo
&Config{
Name: "INI",
Aliases: []string{"ini", "cfg"},

View File

@ -6,7 +6,7 @@ import (
)
// Dylan lexer.
var Dylan = internal.Register(MustNewLexer(
var Dylan = internal.Register(MustNewLazyLexer(
&Config{
Name: "Dylan",
Aliases: []string{"dylan"},
@ -14,61 +14,63 @@ var Dylan = internal.Register(MustNewLexer(
MimeTypes: []string{"text/x-dylan"},
CaseInsensitive: true,
},
Rules{
"root": {
{`\s+`, Whitespace, nil},
{`//.*?\n`, CommentSingle, nil},
{`([a-z0-9-]+:)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Whitespace, LiteralString), nil},
Default(Push("code")),
},
"code": {
{`\s+`, Whitespace, nil},
{`//.*?\n`, CommentSingle, nil},
{`/\*`, CommentMultiline, Push("comment")},
{`"`, LiteralString, Push("string")},
{`'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
{`#b[01]+`, LiteralNumberBin, nil},
{`#o[0-7]+`, LiteralNumberOct, nil},
{`[-+]?(\d*\.\d+([ed][-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)`, LiteralNumberFloat, nil},
{`[-+]?\d+`, LiteralNumberInteger, nil},
{`#x[0-9a-f]+`, LiteralNumberHex, nil},
func() Rules {
return Rules{
"root": {
{`\s+`, Whitespace, nil},
{`//.*?\n`, CommentSingle, nil},
{`([a-z0-9-]+:)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Whitespace, LiteralString), nil},
Default(Push("code")),
},
"code": {
{`\s+`, Whitespace, nil},
{`//.*?\n`, CommentSingle, nil},
{`/\*`, CommentMultiline, Push("comment")},
{`"`, LiteralString, Push("string")},
{`'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
{`#b[01]+`, LiteralNumberBin, nil},
{`#o[0-7]+`, LiteralNumberOct, nil},
{`[-+]?(\d*\.\d+([ed][-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)`, LiteralNumberFloat, nil},
{`[-+]?\d+`, LiteralNumberInteger, nil},
{`#x[0-9a-f]+`, LiteralNumberHex, nil},
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)(:)(token|name|variable|expression|body|case-body|\*)`,
ByGroups(Operator, NameVariable, Operator, NameBuiltin), nil},
{`(\?)(:)(token|name|variable|expression|body|case-body|\*)`,
ByGroups(Operator, Operator, NameVariable), nil},
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, NameVariable), nil},
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)(:)(token|name|variable|expression|body|case-body|\*)`,
ByGroups(Operator, NameVariable, Operator, NameBuiltin), nil},
{`(\?)(:)(token|name|variable|expression|body|case-body|\*)`,
ByGroups(Operator, Operator, NameVariable), nil},
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, NameVariable), nil},
{`(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])`, Punctuation, nil},
{`:=`, Operator, nil},
{`#[tf]`, Literal, nil},
{`#"`, LiteralStringSymbol, Push("symbol")},
{`#[a-z0-9-]+`, Keyword, nil},
{`#(all-keys|include|key|next|rest)`, Keyword, nil},
{`[\w!&*<>|^$%@+~?/=-]+:`, KeywordConstant, nil},
{`<[\w!&*<>|^$%@+~?/=-]+>`, NameClass, nil},
{`\*[\w!&*<>|^$%@+~?/=-]+\*`, NameVariableGlobal, nil},
{`\$[\w!&*<>|^$%@+~?/=-]+`, NameConstant, nil},
{`(let|method|function)([ \t]+)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(NameBuiltin, Whitespace, NameVariable), nil},
{`(error|signal|return|break)`, NameException, nil},
{`(\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, Name), nil},
},
"comment": {
{`[^*/]`, CommentMultiline, nil},
{`/\*`, CommentMultiline, Push()},
{`\*/`, CommentMultiline, Pop(1)},
{`[*/]`, CommentMultiline, nil},
},
"symbol": {
{`"`, LiteralStringSymbol, Pop(1)},
{`[^\\"]+`, LiteralStringSymbol, nil},
},
"string": {
{`"`, LiteralString, Pop(1)},
{`\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
{`[^\\"\n]+`, LiteralString, nil},
{`\\\n`, LiteralString, nil},
{`\\`, LiteralString, nil},
},
{`(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])`, Punctuation, nil},
{`:=`, Operator, nil},
{`#[tf]`, Literal, nil},
{`#"`, LiteralStringSymbol, Push("symbol")},
{`#[a-z0-9-]+`, Keyword, nil},
{`#(all-keys|include|key|next|rest)`, Keyword, nil},
{`[\w!&*<>|^$%@+~?/=-]+:`, KeywordConstant, nil},
{`<[\w!&*<>|^$%@+~?/=-]+>`, NameClass, nil},
{`\*[\w!&*<>|^$%@+~?/=-]+\*`, NameVariableGlobal, nil},
{`\$[\w!&*<>|^$%@+~?/=-]+`, NameConstant, nil},
{`(let|method|function)([ \t]+)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(NameBuiltin, Whitespace, NameVariable), nil},
{`(error|signal|return|break)`, NameException, nil},
{`(\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, Name), nil},
},
"comment": {
{`[^*/]`, CommentMultiline, nil},
{`/\*`, CommentMultiline, Push()},
{`\*/`, CommentMultiline, Pop(1)},
{`[*/]`, CommentMultiline, nil},
},
"symbol": {
{`"`, LiteralStringSymbol, Pop(1)},
{`[^\\"]+`, LiteralStringSymbol, nil},
},
"string": {
{`"`, LiteralString, Pop(1)},
{`\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
{`[^\\"\n]+`, LiteralString, nil},
{`\\\n`, LiteralString, nil},
{`\\`, LiteralString, nil},
},
}
},
))

View File

@ -61,7 +61,7 @@ var JavascriptRules = Rules{
}
// Javascript lexer.
var Javascript = internal.Register(MustNewLexer(
var Javascript = internal.Register(MustNewLexer( // nolint: forbidigo
&Config{
Name: "JavaScript",
Aliases: []string{"js", "javascript"},

View File

@ -3,7 +3,7 @@
// Sub-packages contain lexer implementations.
package lexers
// nolint: golint
// nolint
import (
"github.com/alecthomas/chroma"
_ "github.com/alecthomas/chroma/lexers/a"

View File

@ -6,7 +6,7 @@ import (
)
// mcfunction lexer.
var MCFunction = internal.Register(MustNewLexer(
var MCFunction = internal.Register(MustNewLazyLexer(
&Config{
Name: "mcfunction",
Aliases: []string{"mcfunction"},
@ -15,93 +15,95 @@ var MCFunction = internal.Register(MustNewLexer(
NotMultiline: true,
DotAll: true,
},
Rules{
"simplevalue": {
{`(true|false)`, KeywordConstant, nil},
{`[01]b`, LiteralNumber, nil},
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
{`'[^']+'`, LiteralStringSingle, nil},
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
},
"nbtobjectattribute": {
Include("nbtvalue"),
{`:`, Punctuation, nil},
{`,`, Punctuation, Pop(1)},
{`\}`, Punctuation, Pop(2)},
},
"nbtobjectvalue": {
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
{`\}`, Punctuation, Pop(1)},
},
"nbtarrayvalue": {
Include("nbtvalue"),
{`,`, Punctuation, nil},
{`\]`, Punctuation, Pop(1)},
},
"nbtvalue": {
Include("simplevalue"),
{`\{`, Punctuation, Push("nbtobjectvalue")},
{`\[`, Punctuation, Push("nbtarrayvalue")},
},
"argumentvalue": {
Include("simplevalue"),
{`,`, Punctuation, Pop(1)},
{`[}\]]`, Punctuation, Pop(2)},
},
"argumentlist": {
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
Include("simplevalue"),
{`,`, Punctuation, nil},
{`[}\]]`, Punctuation, Pop(1)},
},
"root": {
{`#.*?\n`, CommentSingle, nil},
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
`ban`, `ban-ip`, `banlist`, `bossbar`,
`camerashake`, `classroommode`, `clear`,
`clearspawnpoint`, `clone`, `code`, `collect`,
`createagent`, `data`, `datapack`, `debug`,
`defaultgamemode`, `deop`, `destroy`, `detect`,
`detectredstone`, `difficulty`, `dropall`,
`effect`, `enchant`, `event`, `execute`,
`experience`, `fill`, `flog`, `forceload`,
`function`, `gamemode`, `gamerule`,
`geteduclientinfo`, `give`, `help`, `item`,
`immutableworld`, `kick`, `kill`, `list`,
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
`mobevent`, `move`, `msg`, `music`, `op`,
`pardon`, `particle`, `playanimation`,
`playsound`, `position`, `publish`,
`raytracefog`, `recipe`, `reload`, `remove`,
`replaceitem`, `ride`, `save`, `save-all`,
`save-off`, `save-on`, `say`, `schedule`,
`scoreboard`, `seed`, `setblock`,
`setidletimeout`, `setmaxplayers`,
`setworldspawn`, `spawnpoint`, `spectate`,
`spreadplayers`, `stop`, `stopsound`,
`structure`, `summon`, `tag`, `team`, `teammsg`,
`teleport`, `tell`, `tellraw`, `testfor`,
`testforblock`, `testforblocks`, `tickingarea`,
`time`, `title`, `toggledownfall`, `tp`,
`tpagent`, `transfer`, `transferserver`,
`trigger`, `turn`, `w`, `weather`, `whitelist`,
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
), KeywordReserved, nil},
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
KeywordConstant, nil},
{`\[`, Punctuation, Push("argumentlist")},
{`{`, Punctuation, Push("nbtobjectvalue")},
{`~`, NameBuiltin, nil},
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
{`([<>=]|<=|>=)`, Punctuation, nil},
Include("simplevalue"),
{`\s+`, TextWhitespace, nil},
},
func() Rules {
return Rules{
"simplevalue": {
{`(true|false)`, KeywordConstant, nil},
{`[01]b`, LiteralNumber, nil},
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
{`'[^']+'`, LiteralStringSingle, nil},
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
},
"nbtobjectattribute": {
Include("nbtvalue"),
{`:`, Punctuation, nil},
{`,`, Punctuation, Pop(1)},
{`\}`, Punctuation, Pop(2)},
},
"nbtobjectvalue": {
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
{`\}`, Punctuation, Pop(1)},
},
"nbtarrayvalue": {
Include("nbtvalue"),
{`,`, Punctuation, nil},
{`\]`, Punctuation, Pop(1)},
},
"nbtvalue": {
Include("simplevalue"),
{`\{`, Punctuation, Push("nbtobjectvalue")},
{`\[`, Punctuation, Push("nbtarrayvalue")},
},
"argumentvalue": {
Include("simplevalue"),
{`,`, Punctuation, Pop(1)},
{`[}\]]`, Punctuation, Pop(2)},
},
"argumentlist": {
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
Include("simplevalue"),
{`,`, Punctuation, nil},
{`[}\]]`, Punctuation, Pop(1)},
},
"root": {
{`#.*?\n`, CommentSingle, nil},
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
`ban`, `ban-ip`, `banlist`, `bossbar`,
`camerashake`, `classroommode`, `clear`,
`clearspawnpoint`, `clone`, `code`, `collect`,
`createagent`, `data`, `datapack`, `debug`,
`defaultgamemode`, `deop`, `destroy`, `detect`,
`detectredstone`, `difficulty`, `dropall`,
`effect`, `enchant`, `event`, `execute`,
`experience`, `fill`, `flog`, `forceload`,
`function`, `gamemode`, `gamerule`,
`geteduclientinfo`, `give`, `help`, `item`,
`immutableworld`, `kick`, `kill`, `list`,
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
`mobevent`, `move`, `msg`, `music`, `op`,
`pardon`, `particle`, `playanimation`,
`playsound`, `position`, `publish`,
`raytracefog`, `recipe`, `reload`, `remove`,
`replaceitem`, `ride`, `save`, `save-all`,
`save-off`, `save-on`, `say`, `schedule`,
`scoreboard`, `seed`, `setblock`,
`setidletimeout`, `setmaxplayers`,
`setworldspawn`, `spawnpoint`, `spectate`,
`spreadplayers`, `stop`, `stopsound`,
`structure`, `summon`, `tag`, `team`, `teammsg`,
`teleport`, `tell`, `tellraw`, `testfor`,
`testforblock`, `testforblocks`, `tickingarea`,
`time`, `title`, `toggledownfall`, `tp`,
`tpagent`, `transfer`, `transferserver`,
`trigger`, `turn`, `w`, `weather`, `whitelist`,
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
), KeywordReserved, nil},
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
KeywordConstant, nil},
{`\[`, Punctuation, Push("argumentlist")},
{`{`, Punctuation, Push("nbtobjectvalue")},
{`~`, NameBuiltin, nil},
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
{`([<>=]|<=|>=)`, Punctuation, nil},
Include("simplevalue"),
{`\s+`, TextWhitespace, nil},
},
}
},
))

View File

@ -44,7 +44,7 @@ func TestInclude(t *testing.T) {
}
func TestCombine(t *testing.T) {
l := MustNewLexer(nil, Rules{
l := MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {{`hello`, String, Combined("world", "bye", "space")}},
"world": {{`world`, Name, nil}},
"bye": {{`bye`, Name, nil}},

View File

@ -162,10 +162,10 @@ func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, erro
type Rules map[string][]Rule
// Rename clones rules then a rule.
func (r Rules) Rename(old, new string) Rules {
func (r Rules) Rename(oldRule, newRule string) Rules {
r = r.Clone()
r[new] = r[old]
delete(r, old)
r[newRule] = r[oldRule]
delete(r, oldRule)
return r
}
@ -209,8 +209,10 @@ func NewLazyLexer(config *Config, rulesFunc func() Rules) (*RegexLexer, error) {
}
// MustNewLexer creates a new Lexer or panics.
func MustNewLexer(config *Config, rules Rules) *RegexLexer {
lexer, err := NewLexer(config, rules)
//
// Deprecated: Use MustNewLazyLexer instead.
func MustNewLexer(config *Config, rules Rules) *RegexLexer { // nolint: forbidigo
lexer, err := NewLexer(config, rules) // nolint: forbidigo
if err != nil {
panic(err)
}
@ -221,7 +223,9 @@ func MustNewLexer(config *Config, rules Rules) *RegexLexer {
//
// "rules" is a state machine transitition map. Each key is a state. Values are sets of rules
// that match input, optionally modify lexer state, and output tokens.
func NewLexer(config *Config, rules Rules) (*RegexLexer, error) {
//
// Deprecated: Use NewLazyLexer instead.
func NewLexer(config *Config, rules Rules) (*RegexLexer, error) { // nolint: forbidigo
return NewLazyLexer(config, func() Rules { return rules })
}

View File

@ -7,7 +7,7 @@ import (
)
func TestNewlineAtEndOfFile(t *testing.T) {
l := Coalesce(MustNewLexer(&Config{EnsureNL: true}, Rules{
l := Coalesce(MustNewLexer(&Config{EnsureNL: true}, Rules{ // nolint: forbidigo
"root": {
{`(\w+)(\n)`, ByGroups(Keyword, Whitespace), nil},
},
@ -16,7 +16,7 @@ func TestNewlineAtEndOfFile(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, []Token{{Keyword, "hello"}, {Whitespace, "\n"}}, it.Tokens())
l = Coalesce(MustNewLexer(nil, Rules{
l = Coalesce(MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {
{`(\w+)(\n)`, ByGroups(Keyword, Whitespace), nil},
},
@ -27,7 +27,7 @@ func TestNewlineAtEndOfFile(t *testing.T) {
}
func TestMatchingAtStart(t *testing.T) {
l := Coalesce(MustNewLexer(&Config{}, Rules{
l := Coalesce(MustNewLexer(&Config{}, Rules{ // nolint: forbidigo
"root": {
{`\s+`, Whitespace, nil},
{`^-`, Punctuation, Push("directive")},
@ -45,7 +45,7 @@ func TestMatchingAtStart(t *testing.T) {
}
func TestEnsureLFOption(t *testing.T) {
l := Coalesce(MustNewLexer(&Config{}, Rules{
l := Coalesce(MustNewLexer(&Config{}, Rules{ // nolint: forbidigo
"root": {
{`(\w+)(\r?\n|\r)`, ByGroups(Keyword, Whitespace), nil},
},
@ -62,7 +62,7 @@ func TestEnsureLFOption(t *testing.T) {
{Whitespace, "\n"},
}, it.Tokens())
l = Coalesce(MustNewLexer(nil, Rules{
l = Coalesce(MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {
{`(\w+)(\r?\n|\r)`, ByGroups(Keyword, Whitespace), nil},
},

View File

@ -7,7 +7,7 @@ import (
)
func TestRemappingLexer(t *testing.T) {
var lexer Lexer = MustNewLexer(nil, Rules{
var lexer Lexer = MustNewLexer(nil, Rules{ // nolint: forbidigo
"root": {
{`\s+`, Whitespace, nil},
{`\w+`, Name, nil},

View File

@ -287,8 +287,10 @@ func (s *Style) synthesise(ttype TokenType) StyleEntry {
// If we don't have line numbers, use the text colour but 20% brighter/darker
case LineNumbers, LineNumbersTable:
return text
default:
return StyleEntry{}
}
return StyleEntry{}
}
func (s *Style) synthesisable(ttype TokenType) bool {