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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/coloration/writers/vim_theme_writer.rb', line 15
def build_result
add_line "\" Vim color file"
add_line "\" #{}"
add_line
add_line "set background=dark"
add_line "highlight clear"
add_line
add_line 'if exists("syntax_on")'
add_line " syntax reset"
add_line "endif"
add_line
add_line "let g:colors_name = \"#{@name}\""
add_line
default_style = Style.new(:fg => @ui["foreground"])
border_color = @ui["background"].mix_with(@ui["foreground"], 71)
bg_line_color = @ui["background"].mix_with(@ui["foreground"], 90)
ui_mapping = {
"Cursor" => Style.new(:fg => @ui['background'], :bg => @ui["caret"]),
"Visual" => Style.new(:bg => @ui["selection"]),
"CursorLine" => Style.new(:bg => bg_line_color),
"CursorColumn" => Style.new(:bg => bg_line_color),
"ColorColumn" => Style.new(:bg => bg_line_color),
"LineNr" => Style.new(:fg => @ui["foreground"].mix_with(@ui["background"], 50), :bg => bg_line_color),
"VertSplit" => Style.new(:fg => border_color, :bg => border_color),
"MatchParen" => Style.new(:fg => @items["keyword"].foreground, :underline => true),
"StatusLine" => Style.new(:fg => @ui["foreground"], :bg => border_color, :bold => true),
"StatusLineNC" => Style.new(:fg => @ui["foreground"], :bg => border_color),
"Pmenu" => "entity.name",
"PmenuSel" => Style.new(:bg => @ui["selection"]),
"IncSearch" => Style.new(:bg => @items['string'].foreground, :fg => @ui['background']),
"Search" => Style.new(:underline => true),
"Directory" => "constant.other.symbol",
"Folded" => Style.new(:fg => @items["comment"].try(:foreground), :bg => @ui["background"]),
}
ui_mapping.keys.each do |key|
add_line(format_item(key, ui_mapping[key] || default_style))
end
add_line
bg_brightness = @ui["background"].brightness
if bg_brightness >= 0.5
red = Color::RGB.from_html '#ef2929'
green = Color::RGB.from_html '#8ae234'
blue = Color::RGB.from_html '#729fcf'
else
red = Color::RGB.from_html '#a40000'
green = Color::RGB.from_html '#4e9a06'
blue = Color::RGB.from_html '#204a87'
end
items_mapping = {
"Normal" => Style.new(:fg => @ui["foreground"], :bg => @ui["background"]),
"Boolean" => "constant.language",
"Character" => "constant.character",
"Comment" => "comment",
"Conditional" => "keyword.control",
"Constant" => "constant",
"Define" => "keyword",
"DiffAdd" => Style.new(:bg => green.mix_with(@ui['background'], 80), :fg => @ui['foreground'], :bold => true),
"DiffDelete" => Style.new(:fg => red.mix_with(@ui['background'], 80)),
"DiffChange" => Style.new(:bg => blue.mix_with(@ui['background'], 50), :fg => @ui['foreground']),
"DiffText" => Style.new(:bg => blue.mix_with(@ui['background'], 100), :fg => @ui['foreground'], :bold => true),
"ErrorMsg" => "invalid",
"WarningMsg" => "invalid",
"Float" => "constant.numeric",
"Function" => "entity.name.function",
"Identifier" => "storage.type",
"Keyword" => "keyword",
"Label" => "string.other",
"NonText" => Style.new(:fg => @ui["invisibles"], :bg => @ui["background"].mix_with(@ui["foreground"], 95)),
"Number" => "constant.numeric",
"Operator" => "keyword.operator",
"PreProc" => "keyword.other",
"Special" => Style.new(:fg => @ui["foreground"]),
"SpecialKey" => Style.new(:fg => @ui["invisibles"], :bg => bg_line_color),
"Statement" => "keyword.control",
"StorageClass" => "storage.type",
"String" => "string,string.quoted",
"Tag" => "entity.name.tag",
"Title" => Style.new(:fg => @ui["foreground"], :bold => true),
"Todo" => (@items["comment"] || default_style).clone.tap { |c| c.inverse = true; c.bold = true },
"Type" => "entity.name.type",
"Underlined" => Style.new(:underline => true),
"rubyClass" => "keyword.controll.class.ruby",
"rubyFunction" => "entity.name.function.ruby",
"rubyInterpolationDelimiter" => "",
"rubySymbol" => "constant.other.symbol.ruby",
"rubyConstant" => "support.class",
"rubyStringDelimiter" => "string,string.quoted",
"rubyBlockParameter" => "variable.parameter",
"rubyInstanceVariable" => "variable.language",
"rubyInclude" => "keyword.other.special-method.ruby",
"rubyGlobalVariable" => "variable.other",
"rubyRegexp" => "string.regexp",
"rubyRegexpDelimiter" => "string.regexp",
"rubyEscape" => "constant.character.escape",
"rubyControl" => "keyword.control",
"rubyClassVariable" => "variable",
"rubyOperator" => "keyword.operator",
"rubyException" => "keyword.other.special-method.ruby",
"rubyPseudoVariable" => "variable.language.ruby",
"rubyRailsUserClass" => "support.class.ruby",
"rubyRailsARAssociationMethod" => "support.function.activerecord.rails",
"rubyRailsARMethod" => "support.function.activerecord.rails",
"rubyRailsRenderMethod" => "support.function",
"rubyRailsMethod" => "support.function",
"erubyDelimiter" => "punctuation.section.embedded.ruby",
"erubyComment" => "comment",
"erubyRailsMethod" => "support.function",
"htmlTag" => "meta.tag entity",
"htmlEndTag" => "meta.tag entity",
"htmlTagName" => "meta.tag entity",
"htmlArg" => "meta.tag entity",
"htmlSpecialChar" => "constant.character.entity.html",
"javaScriptFunction" => "storage.type.function.js",
"javaScriptRailsFunction" => "support.function",
"javaScriptBraces" => "meta.brace.curly.js",
"yamlKey" => "entity.name.tag.yaml",
"yamlAnchor" => "variable.other.yaml",
"yamlAlias" => "variable.other.yaml",
"yamlDocumentHeader" => "string.unquoted.yaml",
"cssURL" => "variable.parameter.misc.css",
"cssFunctionName" => "support.function.misc.css",
"cssColor" => "constant.other.color.rgb-value.css",
"cssPseudoClassId" => "entity.other.attribute-name.pseudo-class.css",
"cssClassName" => "entity.other.attribute-name.class.css",
"cssValueLength" => "constant.numeric.css",
"cssCommonAttr" => "support.constant.property-value.css",
"cssBraces" => "punctuation.section.property-list.css",
}
items_mapping.keys.each do |key|
add_line(format_item(key, items_mapping[key] || default_style))
end
self.result = @lines.join("\n")
end
|