1
1
local api = vim .api
2
- local get_colors = require ' lib/config' .get_colors
3
-
4
- local colors = get_colors ()
5
2
6
3
local M = {}
7
4
8
- local function create_hl ()
5
+ local function get_color_from_hl (hl_name , fallback )
6
+ local id = vim .api .nvim_get_hl_id_by_name (hl_name )
7
+ if not id then return fallback end
8
+
9
+ local hl = vim .api .nvim_get_hl_by_id (id , true )
10
+ if not hl or not hl .foreground then return fallback end
11
+
12
+ return hl .foreground
13
+ end
14
+
15
+ local function get_colors ()
16
+ return {
17
+ red = vim .g .terminal_color_1 or get_color_from_hl (' Keyword' , ' Red' ),
18
+ green = vim .g .terminal_color_2 or get_color_from_hl (' Character' , ' Green' ),
19
+ yellow = vim .g .terminal_color_3 or get_color_from_hl (' PreProc' , ' Yellow' ),
20
+ blue = vim .g .terminal_color_4 or get_color_from_hl (' Include' , ' Blue' ),
21
+ purple = vim .g .terminal_color_5 or get_color_from_hl (' Define' , ' Purple' ),
22
+ cyan = vim .g .terminal_color_6 or get_color_from_hl (' Conditional' , ' Cyan' ),
23
+ dark_red = vim .g .terminal_color_9 or get_color_from_hl (' Keyword' , ' DarkRed' ),
24
+ orange = vim .g .terminal_color_11 or get_color_from_hl (' Number' , ' Orange' ),
25
+ }
26
+ end
27
+
28
+ local function get_hl_groups ()
29
+ local colors = get_colors ()
30
+
9
31
return {
10
32
Symlink = { gui = ' bold' , fg = colors .cyan },
11
33
FolderName = { gui = ' bold' , fg = colors .blue },
@@ -22,6 +44,7 @@ local function create_hl()
22
44
JsonIcon = { fg = colors .yellow },
23
45
24
46
LuaIcon = { fg = ' #42a5f5' },
47
+ GoIcon = { fg = ' #7Fd5EA' },
25
48
PythonIcon = { fg = colors .green },
26
49
ShellIcon = { fg = colors .green },
27
50
JavascriptIcon = { fg = colors .yellow },
@@ -40,25 +63,195 @@ local function create_hl()
40
63
}
41
64
end
42
65
43
- local HIGHLIGHTS = create_hl ()
66
+ M .hl_groups = {
67
+ [' LICENSE' ] = ' LicenseIcon' ;
68
+ [' license' ] = ' LicenseIcon' ;
69
+ [' vim' ] = ' VimIcon' ;
70
+ [' .vimrc' ] = ' VimIcon' ;
71
+ [' c' ] = ' CIcon' ;
72
+ [' cpp' ] = ' CIcon' ;
73
+ [' python' ] = ' PythonIcon' ;
74
+ [' lua' ] = ' LuaIcon' ;
75
+ [' rs' ] = ' RustIcon' ;
76
+ [' sh' ] = ' ShellIcon' ;
77
+ [' csh' ] = ' ShellIcon' ;
78
+ [' zsh' ] = ' ShellIcon' ;
79
+ [' bash' ] = ' ShellIcon' ;
80
+ [' md' ] = ' MarkdownIcon' ;
81
+ [' json' ] = ' JsonIcon' ;
82
+ [' toml' ] = ' TomlIcon' ;
83
+ [' go' ] = ' GoIcon' ;
84
+ [' yaml' ] = ' YamlIcon' ;
85
+ [' yml' ] = ' YamlIcon' ;
86
+ [' conf' ] = ' GitignoreIcon' ;
87
+ [' javascript' ] = ' JavascriptIcon' ;
88
+ [' typescript' ] = ' TypescriptIcon' ;
89
+ [' jsx' ] = ' ReactIcon' ;
90
+ [' tsx' ] = ' ReactIcon' ;
91
+ [' htm' ] = ' HtmlIcon' ;
92
+ [' html' ] = ' HtmlIcon' ;
93
+ [' slim' ] = ' HtmlIcon' ;
94
+ [' haml' ] = ' HtmlIcon' ;
95
+ [' ejs' ] = ' HtmlIcon' ;
44
96
45
- local LINKS = {
46
- Normal = ' Normal' ,
47
- EndOfBuffer = ' EndOfBuffer' ,
48
- CursorLine = ' CursorLine' ,
49
- VertSplit = ' VertSplit' ,
50
- CursorColumn = ' CursorColumn'
97
+ [' Gemfile$' ] = ' RubyIcon' ;
98
+ [' Vagrantfile$' ] = ' VagrantIcon' ;
99
+ -- ['styl'] = '';
100
+ -- ['sass'] = '';
101
+ -- ['scss'] = '';
102
+ --
103
+ -- ['css'] = '';
104
+ -- ['less'] = '';
105
+ -- ['md'] = '';
106
+ -- ['mdx'] = '';
107
+ -- ['markdown'] = '';
108
+ -- ['rmd'] = '';
109
+ -- ['json'] = '';
110
+ -- ['webmanifest'] = '';
111
+ -- ['js'] = '';
112
+ -- ['mjs'] = '';
113
+ -- ['jsx'] = '';
114
+ -- ['rb'] = '';
115
+ -- ['gemspec'] = '';
116
+ -- ['rake'] = '';
117
+ -- ['php'] = '';
118
+ -- ['py'] = '';
119
+ -- ['pyc'] = '';
120
+ -- ['pyo'] = '';
121
+ -- ['pyd'] = '';
122
+ -- ['coffee'] = '';
123
+ -- ['mustache'] = '';
124
+ -- ['hbs'] = '';
125
+ -- ['conf'] = '';
126
+ -- ['ini'] = '';
127
+ -- ['yml'] = '';
128
+ -- ['yaml'] = '';
129
+ -- ['toml'] = '';
130
+ -- ['bat'] = '';
131
+ -- ['jpg'] = '';
132
+ -- ['jpeg'] = '';
133
+ -- ['bmp'] = '';
134
+ -- ['png'] = '';
135
+ -- ['webp'] = '';
136
+ -- ['gif'] = '';
137
+ -- ['ico'] = '';
138
+ -- ['twig'] = '';
139
+ -- ['cpp'] = '';
140
+ -- ['c++'] = '';
141
+ -- ['cxx'] = '';
142
+ -- ['cc'] = '';
143
+ -- ['cp'] = '';
144
+ -- ['c'] = '';
145
+ -- ['cs'] = '';
146
+ -- ['h'] = '';
147
+ -- ['hh'] = '';
148
+ -- ['hpp'] = '';
149
+ -- ['hxx'] = '';
150
+ -- ['hs'] = '';
151
+ -- ['lhs'] = '';
152
+ -- ['lua'] = '';
153
+ -- ['java'] = '';
154
+ -- ['sh'] = '';
155
+ -- ['fish'] = '';
156
+ -- ['bash'] = '';
157
+ -- ['zsh'] = '';
158
+ -- ['ksh'] = '';
159
+ -- ['csh'] = '';
160
+ -- ['awk'] = '';
161
+ -- ['ps1'] = '';
162
+ -- ['ml'] = 'λ';
163
+ -- ['mli'] = 'λ';
164
+ -- ['diff'] = '';
165
+ -- ['db'] = '';
166
+ -- ['sql'] = '';
167
+ -- ['dump'] = '';
168
+ -- ['clj'] = '';
169
+ -- ['cljc'] = '';
170
+ -- ['cljs'] = '';
171
+ -- ['edn'] = '';
172
+ -- ['scala'] = '';
173
+ -- ['go'] = '';
174
+ -- ['dart'] = '';
175
+ -- ['xul'] = '';
176
+ -- ['sln'] = '';
177
+ -- ['suo'] = '';
178
+ -- ['pl'] = '';
179
+ -- ['pm'] = '';
180
+ -- ['t'] = '';
181
+ -- ['rss'] = '';
182
+ -- ['f#'] = '';
183
+ -- ['fsscript'] = '';
184
+ -- ['fsx'] = '';
185
+ -- ['fs'] = '';
186
+ -- ['fsi'] = '';
187
+ -- ['rs'] = '';
188
+ -- ['rlib'] = '';
189
+ -- ['d'] = '';
190
+ -- ['erl'] = '';
191
+ -- ['hrl'] = '';
192
+ -- ['ex'] = '';
193
+ -- ['exs'] = '';
194
+ -- ['eex'] = '';
195
+ -- ['leex'] = '';
196
+ -- ['vim'] = '';
197
+ -- ['ai'] = '';
198
+ -- ['psd'] = '';
199
+ -- ['psb'] = '';
200
+ -- ['ts'] = '';
201
+ -- ['jl'] = '';
202
+ -- ['pp'] = '';
203
+ -- ['vue'] = '﵂';
204
+ -- ['elm'] = '';
205
+ -- ['swift'] = '';
206
+ -- ['xcplayground'] = '';
207
+ -- ['tex'] = 'ﭨ';
208
+ -- ['r'] = 'ﳒ';
209
+ -- ['rproj'] = '鉶';
210
+ -- ['mix.lock'] = '';
211
+ -- ['dropbox'] = '';
212
+ -- ['.ds_store'] = '';
213
+ -- ['.gitconfig'] = '';
214
+ -- ['.gitignore'] = '';
215
+ -- ['.gitlab-ci.yml'] = '';
216
+ -- ['.bashrc'] = '';
217
+ -- ['.zshrc'] = '';
218
+ -- ['.vimrc'] = '';
219
+ -- ['.gvimrc'] = '';
220
+ -- ['_vimrc'] = '';
221
+ -- ['_gvimrc'] = '';
222
+ -- ['.bashprofile'] = '';
223
+ -- ['favicon.ico'] = '';
224
+ -- ['license'] = '';
225
+ -- ['LICENSE'] = '';
226
+ -- ['node_modules'] = '';
227
+ -- ['procfile'] = '';
228
+ -- ['dockerfile'] = '';
229
+ -- ['docker-compose.yml'] = '';
230
+ -- ['rakefile'] = '';
231
+ -- ['config.ru'] = '';
232
+ -- ['makefile'] = '';
233
+ -- ['cmakelists.txt'] = '';
51
234
}
52
235
53
- function M .init_colors ()
54
- colors = get_colors ()
55
- HIGHLIGHTS = create_hl ()
56
- for k , d in pairs (HIGHLIGHTS ) do
236
+ local function get_links ()
237
+ return {
238
+ Normal = ' Normal' ,
239
+ EndOfBuffer = ' EndOfBuffer' ,
240
+ CursorLine = ' CursorLine' ,
241
+ VertSplit = ' VertSplit' ,
242
+ CursorColumn = ' CursorColumn'
243
+ }
244
+ end
245
+
246
+ function M .setup ()
247
+ local higlight_groups = get_hl_groups ()
248
+ for k , d in pairs (higlight_groups ) do
57
249
local gui = d .gui or ' NONE'
58
250
api .nvim_command (' hi def LuaTree' .. k .. ' gui=' .. gui .. ' guifg=' .. d .fg )
59
251
end
60
252
61
- for k , d in pairs (LINKS ) do
253
+ local links = get_links ()
254
+ for k , d in pairs (links ) do
62
255
api .nvim_command (' hi def link LuaTree' .. k .. ' ' .. d )
63
256
end
64
257
end
0 commit comments