Skip to content

Commit 6979124

Browse files
committed
reformat, refactor code, run fs command with luv.spawn
1 parent 81ee46e commit 6979124

File tree

9 files changed

+690
-715
lines changed

9 files changed

+690
-715
lines changed

lua/lib/colors.lua

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
1+
local api = vim.api
12
local colors = require 'lib/config'.colors
23

3-
local cmd = vim.api.nvim_command
4+
local M = {}
45

56
local HIGHLIGHTS = {
6-
Symlink = { gui = 'bold', fg = colors.cyan },
7-
FolderName = { gui = 'bold', fg = colors.blue },
8-
FolderIcon = { fg = '#90a4ae' },
9-
10-
ExecFile = { gui = 'bold', fg = colors.green },
11-
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
12-
ImageFile = { gui = 'bold', fg = colors.purple },
13-
MarkdownFile = { fg = colors.purple },
14-
LicenseIcon = { fg = colors.yellow },
15-
YamlIcon = { fg = colors.yellow },
16-
TomlIcon = { fg = colors.yellow },
17-
GitignoreIcon = { fg = colors.yellow },
18-
JsonIcon = { fg = colors.yellow },
19-
20-
LuaIcon = { fg = '#42a5f5' },
21-
PythonIcon = { fg = colors.green },
22-
ShellIcon = { fg = colors.green },
23-
JavascriptIcon = { fg = colors.yellow },
24-
CIcon = { fg = colors.blue },
25-
ReactIcon = { fg = colors.cyan },
26-
HtmlIcon = { fg = colors.orange },
27-
RustIcon = { fg = colors.orange },
28-
VimIcon = { fg = colors.green },
29-
TypescriptIcon = { fg = colors.blue },
30-
31-
GitDirty = { fg = colors.dark_red },
32-
GitStaged = { fg = colors.green },
33-
GitMerge = { fg = colors.orange },
34-
GitRenamed = { fg = colors.purple },
35-
GitNew = { fg = colors.yellow }
7+
Symlink = { gui = 'bold', fg = colors.cyan },
8+
FolderName = { gui = 'bold', fg = colors.blue },
9+
FolderIcon = { fg = '#90a4ae' },
10+
11+
ExecFile = { gui = 'bold', fg = colors.green },
12+
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
13+
ImageFile = { gui = 'bold', fg = colors.purple },
14+
MarkdownFile = { fg = colors.purple },
15+
LicenseIcon = { fg = colors.yellow },
16+
YamlIcon = { fg = colors.yellow },
17+
TomlIcon = { fg = colors.yellow },
18+
GitignoreIcon = { fg = colors.yellow },
19+
JsonIcon = { fg = colors.yellow },
20+
21+
LuaIcon = { fg = '#42a5f5' },
22+
PythonIcon = { fg = colors.green },
23+
ShellIcon = { fg = colors.green },
24+
JavascriptIcon = { fg = colors.yellow },
25+
CIcon = { fg = colors.blue },
26+
ReactIcon = { fg = colors.cyan },
27+
HtmlIcon = { fg = colors.orange },
28+
RustIcon = { fg = colors.orange },
29+
VimIcon = { fg = colors.green },
30+
TypescriptIcon = { fg = colors.blue },
31+
32+
GitDirty = { fg = colors.dark_red },
33+
GitStaged = { fg = colors.green },
34+
GitMerge = { fg = colors.orange },
35+
GitRenamed = { fg = colors.purple },
36+
GitNew = { fg = colors.yellow }
3637
}
3738

3839
local LINKS = {
39-
Normal = 'Normal',
40-
EndOfBuffer = 'EndOfBuffer',
41-
CursorLine = 'CursorLine',
42-
VertSplit = 'VertSplit',
43-
CursorColumn = 'CursorColumn'
40+
Normal = 'Normal',
41+
EndOfBuffer = 'EndOfBuffer',
42+
CursorLine = 'CursorLine',
43+
VertSplit = 'VertSplit',
44+
CursorColumn = 'CursorColumn'
4445
}
4546

46-
local function init_colors()
47-
for k, d in pairs(HIGHLIGHTS) do
48-
local gui = d.gui or 'NONE'
49-
vim.api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg)
50-
end
47+
function M.init_colors()
48+
for k, d in pairs(HIGHLIGHTS) do
49+
local gui = d.gui or 'NONE'
50+
api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg)
51+
end
5152

52-
for k, d in pairs(LINKS) do
53-
vim.api.nvim_command('hi def link LuaTree'..k..' '..d)
54-
end
53+
for k, d in pairs(LINKS) do
54+
api.nvim_command('hi def link LuaTree'..k..' '..d)
55+
end
5556
end
5657

57-
return {
58-
init_colors = init_colors
59-
}
58+
return M

lua/lib/config.lua

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,45 @@
11
local api = vim.api
22

3+
local M = {}
4+
35
local function get(var, fallback)
4-
if vim.api.nvim_call_function('exists', { var }) == 1 then
5-
return vim.api.nvim_get_var(var)
6-
else
7-
return fallback
8-
end
6+
if api.nvim_call_function('exists', { var }) == 1 then
7+
return api.nvim_get_var(var)
8+
else
9+
return fallback
10+
end
911
end
1012

1113
local HAS_DEV_ICONS = api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1
1214

1315
local show_icons = get('lua_tree_show_icons', { git = 1, folders = 1, files = 1 })
1416

15-
local SHOW_FILE_ICON = HAS_DEV_ICONS and show_icons.files == 1
16-
local SHOW_FOLDER_ICON = show_icons.folders == 1
17-
local SHOW_GIT_ICON = show_icons.git == 1
18-
19-
local colors = {
20-
red = get('terminal_color_1', 'Red'),
21-
green = get('terminal_color_2', 'Green'),
22-
yellow = get('terminal_color_3', 'Yellow'),
23-
blue = get('terminal_color_4', 'Blue'),
24-
purple = get('terminal_color_5', 'Purple'),
25-
cyan = get('terminal_color_6', 'Cyan'),
26-
orange = get('terminal_color_11', 'Orange'),
27-
dark_red = get('terminal_color_9', 'DarkRed'),
17+
M.SHOW_FILE_ICON = HAS_DEV_ICONS and show_icons.files == 1
18+
M.SHOW_FOLDER_ICON = show_icons.folders == 1
19+
M.SHOW_GIT_ICON = show_icons.git == 1
20+
21+
M.colors = {
22+
red = get('terminal_color_1', 'Red'),
23+
green = get('terminal_color_2', 'Green'),
24+
yellow = get('terminal_color_3', 'Yellow'),
25+
blue = get('terminal_color_4', 'Blue'),
26+
purple = get('terminal_color_5', 'Purple'),
27+
cyan = get('terminal_color_6', 'Cyan'),
28+
orange = get('terminal_color_11', 'Orange'),
29+
dark_red = get('terminal_color_9', 'DarkRed'),
2830
}
2931

3032
local keybindings = get('lua_tree_bindings', {});
3133

32-
local bindings = {
33-
edit = keybindings.edit or '<CR>',
34-
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
35-
edit_split = keybindings.edit_split or '<C-x>',
36-
edit_tab = keybindings.edit_tab or '<C-t>',
37-
cd = keybindings.cd or '.',
38-
create = keybindings.create or 'a',
39-
remove = keybindings.remove or 'd',
40-
rename = keybindings.rename or 'r',
41-
}
42-
43-
return {
44-
SHOW_FOLDER_ICON = SHOW_FOLDER_ICON,
45-
SHOW_FILE_ICON = SHOW_FILE_ICON,
46-
SHOW_GIT_ICON = SHOW_GIT_ICON,
47-
colors = colors,
48-
bindings = bindings
34+
M.bindings = {
35+
edit = keybindings.edit or '<CR>',
36+
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
37+
edit_split = keybindings.edit_split or '<C-x>',
38+
edit_tab = keybindings.edit_tab or '<C-t>',
39+
cd = keybindings.cd or '.',
40+
create = keybindings.create or 'a',
41+
remove = keybindings.remove or 'd',
42+
rename = keybindings.rename or 'r',
4943
}
5044

45+
return M

0 commit comments

Comments
 (0)