use nvim devicon colors and fix empty space before file

This commit is contained in:
kiyan42 2020-08-04 21:07:29 +02:00 committed by Kiyan Yazdani
parent 2c453c9b9f
commit 505d63a3e7
2 changed files with 9 additions and 57 deletions

View File

@ -1,4 +1,5 @@
local api = vim.api local api = vim.api
local config = require'lib.config'
local M = {} local M = {}
@ -42,62 +43,10 @@ local function get_hl_groups()
GitStaged = { fg = colors.green }, GitStaged = { fg = colors.green },
GitMerge = { fg = colors.orange }, GitMerge = { fg = colors.orange },
GitRenamed = { fg = colors.purple }, GitRenamed = { fg = colors.purple },
GitNew = { fg = colors.yellow }, GitNew = { fg = colors.yellow }
-- TODO: remove those when we add this to nvim-web-devicons
MarkdownIcon = { fg = colors.purple },
LicenseIcon = { fg = colors.yellow },
YamlIcon = { fg = colors.yellow },
TomlIcon = { fg = colors.yellow },
GitignoreIcon = { fg = colors.yellow },
JsonIcon = { fg = colors.yellow },
LuaIcon = { fg = '#42a5f5' },
GoIcon = { fg = '#7Fd5EA' },
PythonIcon = { fg = colors.green },
ShellIcon = { fg = colors.green },
JavascriptIcon = { fg = colors.yellow },
CIcon = { fg = colors.blue },
ReactIcon = { fg = colors.cyan },
HtmlIcon = { fg = colors.orange },
RustIcon = { fg = colors.orange },
VimIcon = { fg = colors.green },
TypescriptIcon = { fg = colors.blue },
} }
end end
-- TODO: remove those when we add this to nvim-web-devicons
M.hl_groups = {
['LICENSE'] = 'LicenseIcon';
['license'] = 'LicenseIcon';
['vim'] = 'VimIcon';
['.vimrc'] = 'VimIcon';
['c'] = 'CIcon';
['cpp'] = 'CIcon';
['python'] = 'PythonIcon';
['lua'] = 'LuaIcon';
['rs'] = 'RustIcon';
['sh'] = 'ShellIcon';
['csh'] = 'ShellIcon';
['zsh'] = 'ShellIcon';
['bash'] = 'ShellIcon';
['md'] = 'MarkdownIcon';
['json'] = 'JsonIcon';
['toml'] = 'TomlIcon';
['go'] = 'GoIcon';
['yaml'] = 'YamlIcon';
['yml'] = 'YamlIcon';
['conf'] = 'GitignoreIcon';
['javascript'] = 'JavascriptIcon';
['typescript'] = 'TypescriptIcon';
['jsx'] = 'ReactIcon';
['tsx'] = 'ReactIcon';
['htm'] = 'HtmlIcon';
['html'] = 'HtmlIcon';
['slim'] = 'HtmlIcon';
['haml'] = 'HtmlIcon';
['ejs'] = 'HtmlIcon';
}
local function get_links() local function get_links()
return { return {
FolderName = 'Directory', FolderName = 'Directory',
@ -115,6 +64,9 @@ local function get_links()
end end
function M.setup() function M.setup()
if config.get_icon_state().show_file_icon then
require'nvim-web-devicons'.setup()
end
local higlight_groups = get_hl_groups() local higlight_groups = get_hl_groups()
for k, d in pairs(higlight_groups) do for k, d in pairs(higlight_groups) do
local gui = d.gui or 'NONE' local gui = d.gui or 'NONE'

View File

@ -35,14 +35,14 @@ if icon_state.show_file_icon then
get_file_icon = function(fname, extension, line, depth) get_file_icon = function(fname, extension, line, depth)
local icon, hl_group = web_devicons.get_icon(fname, extension) local icon, hl_group = web_devicons.get_icon(fname, extension)
local hl_override = colors.hl_groups[fname] or colors.hl_groups[extension]
hl_group = hl_override or hl_group
if icon then if icon then
table.insert(hl, { 'LuaTree'..hl_group, line, depth, depth + #icon }) if hl_group then
table.insert(hl, { hl_group, line, depth, depth + #icon })
end
return icon.." " return icon.." "
else else
return icon_state.icons.default and icon_state.icons.default.." " or "" return #icon_state.icons.default > 0 and icon_state.icons.default.." " or ""
end end
end end