This file is indexed.

/usr/share/gocode/src/github.com/alecthomas/chroma/lexers/n/nix.go is in golang-github-alecthomas-chroma-dev 0.4.0+git20180402.51d250f-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package n

import (
	"strings"

	. "github.com/alecthomas/chroma" // nolint
	"github.com/alecthomas/chroma/lexers/internal"
)

// nixb matches right boundary of a nix word. Use it instead of \b.
const nixb = `(?![a-zA-Z0-9_'-])`

// Nix lexer.
var Nix = internal.Register(MustNewLexer(
	&Config{
		Name:      "Nix",
		Aliases:   []string{"nixos", "nix"},
		Filenames: []string{"*.nix"},
		MimeTypes: []string{"text/x-nix"},
	},
	Rules{
		"root": {
			Include("keywords"),
			Include("builtins"),
			// "./path" and ".float" literals have to be above "." operator
			Include("literals"),
			Include("operators"),
			{`#.*$`, CommentSingle, nil},
			{`/\*`, CommentMultiline, Push("comment")},
			{`\(`, Punctuation, Push("paren")},
			{`\[`, Punctuation, Push("list")},
			{`"`, StringDouble, Push("qstring")},
			{`''`, StringSingle, Push("istring")},
			{`{`, Punctuation, Push("scope")},
			{`let` + nixb, Keyword, Push("scope")},
			Include("id"),
			Include("space"),
		},
		"keywords": {
			{`import` + nixb, KeywordNamespace, nil},
			{Words(``, nixb, strings.Fields("rec inherit with if then else assert")...), Keyword, nil},
		},
		"builtins": {
			{`throw` + nixb, NameException, nil},
			{Words(``, nixb, strings.Fields("abort baseNameOf builtins currentTime dependencyClosure derivation dirOf fetchTarball filterSource getAttr getEnv hasAttr isNull map removeAttrs toString toXML")...), NameBuiltin, nil},
		},
		"literals": {
			{Words(``, nixb, strings.Fields("true false null")...), NameConstant, nil},
			Include("uri"),
			Include("path"),
			Include("int"),
			Include("float"),
		},
		"operators": {
			{` [/-] `, Operator, nil},
			{`(\.)(\${)`, ByGroups(Operator, StringInterpol), Push("interpol")},
			{`(\?)(\s*)(\${)`, ByGroups(Operator, Text, StringInterpol), Push("interpol")},
			{Words(``, ``, strings.Fields("@ . ? ++ + != ! // == && || -> <= < >= > *")...), Operator, nil},
			{`[;:]`, Punctuation, nil},
		},
		"comment": {
			{`\*/`, CommentMultiline, Pop(1)},
			{`.|\n`, CommentMultiline, nil},
		},
		"paren": {
			{`\)`, Punctuation, Pop(1)},
			Include("root"),
		},
		"list": {
			{`\]`, Punctuation, Pop(1)},
			Include("root"),
		},
		"qstring": {
			{`"`, StringDouble, Pop(1)},
			{`\${`, StringInterpol, Push("interpol")},
			{`\\.`, StringEscape, nil},
			{`.|\n`, StringDouble, nil},
		},
		"istring": {
			{`''\$`, StringEscape, nil},  // "$"
			{`'''`, StringEscape, nil},   // "''"
			{`''\\.`, StringEscape, nil}, // "\."
			{`''`, StringSingle, Pop(1)},
			{`\${`, StringInterpol, Push("interpol")},
			// The next rule is important: "$" escapes any symbol except "{"!
			{`\$.`, StringSingle, nil}, // "$."
			{`.|\n`, StringSingle, nil},
		},
		"scope": {
			{`}:`, Punctuation, Pop(1)},
			{`}`, Punctuation, Pop(1)},
			{`in` + nixb, Keyword, Pop(1)},
			{`\${`, StringInterpol, Push("interpol")},
			Include("root"), // "==" has to be above "="
			{Words(``, ``, strings.Fields("= ? ,")...), Operator, nil},
		},
		"interpol": {
			{`}`, StringInterpol, Pop(1)},
			Include("root"),
		},
		"id": {
			{`[a-zA-Z_][a-zA-Z0-9_'-]*`, Name, nil},
		},
		"uri": {
			{`[a-zA-Z][a-zA-Z0-9+.-]*:[a-zA-Z0-9%/?:@&=+$,_.!~*'-]+`, StringDoc, nil},
		},
		"path": {
			{`[a-zA-Z0-9._+-]*(/[a-zA-Z0-9._+-]+)+`, StringRegex, nil},
			{`~(/[a-zA-Z0-9._+-]+)+/?`, StringRegex, nil},
			{`<[a-zA-Z0-9._+-]+(/[a-zA-Z0-9._+-]+)*>`, StringRegex, nil},
		},
		"int": {
			{`-?[0-9]+` + nixb, NumberInteger, nil},
		},
		"float": {
			{`-?(([1-9][0-9]*\.[0-9]*)|(0?\.[0-9]+))([Ee][+-]?[0-9]+)?` + nixb, NumberFloat, nil},
		},
		"space": {
			{`[ \t\r\n]+`, Text, nil},
		},
	},
))