...

Source file src/github.com/alecthomas/chroma/lexers/s/systemd.go

Documentation: github.com/alecthomas/chroma/lexers/s

     1  package s
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  var SYSTEMD = internal.Register(MustNewLazyLexer(
     9  	&Config{
    10  		Name:    "SYSTEMD",
    11  		Aliases: []string{"systemd"},
    12  		// Suspects: man systemd.index | grep -E 'systemd\..*configuration'
    13  		Filenames: []string{"*.automount", "*.device", "*.dnssd", "*.link", "*.mount", "*.netdev", "*.network", "*.path", "*.scope", "*.service", "*.slice", "*.socket", "*.swap", "*.target", "*.timer"},
    14  		MimeTypes: []string{"text/plain"},
    15  	},
    16  	systemdRules,
    17  ))
    18  
    19  func systemdRules() Rules {
    20  	return Rules{
    21  		"root": {
    22  			{`\s+`, Text, nil},
    23  			{`[;#].*`, Comment, nil},
    24  			{`\[.*?\]$`, Keyword, nil},
    25  			{`(.*?)(=)(.*)(\\\n)`, ByGroups(NameAttribute, Operator, LiteralString, Text), Push("continuation")},
    26  			{`(.*?)(=)(.*)`, ByGroups(NameAttribute, Operator, LiteralString), nil},
    27  		},
    28  		"continuation": {
    29  			{`(.*?)(\\\n)`, ByGroups(LiteralString, Text), nil},
    30  			{`(.*)`, LiteralString, Pop(1)},
    31  		},
    32  	}
    33  }
    34  

View as plain text