mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
fix(icons): make devicons optional (#3616)
* fix(icons): make devicons optional * code review suggestion * fix: devicons_enable > devicons.enable
This commit is contained in:
parent
28acebe7dd
commit
3115088e92
2 changed files with 29 additions and 10 deletions
|
@ -99,10 +99,17 @@ M.get_filename = function()
|
|||
local f = require "lvim.utils.functions"
|
||||
|
||||
if not f.isempty(filename) then
|
||||
local file_icon, hl_group = require("nvim-web-devicons").get_icon(filename, extension, { default = true })
|
||||
local file_icon, hl_group
|
||||
local devicons_ok, devicons = pcall(require, "nvim-web-devicons")
|
||||
if lvim.use_icons and devicons_ok then
|
||||
file_icon, hl_group = devicons.get_icon(filename, extension, { default = true })
|
||||
|
||||
if f.isempty(file_icon) then
|
||||
file_icon = lvim.icons.kind.File
|
||||
if f.isempty(file_icon) then
|
||||
file_icon = lvim.icons.kind.File
|
||||
end
|
||||
else
|
||||
file_icon = ""
|
||||
hl_group = "Normal"
|
||||
end
|
||||
|
||||
local buf_ft = vim.bo.filetype
|
||||
|
|
|
@ -83,6 +83,10 @@ M.config = function()
|
|||
end
|
||||
|
||||
function M.icon_setup()
|
||||
if not lvim.builtin.lir.devicons.enable then
|
||||
return
|
||||
end
|
||||
|
||||
local function get_hl_by_name(name)
|
||||
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
|
||||
return string.format("#%06x", ret[name.property])
|
||||
|
@ -93,13 +97,16 @@ function M.icon_setup()
|
|||
icon_hl = "#42A5F5"
|
||||
end
|
||||
|
||||
require("nvim-web-devicons").set_icon {
|
||||
lir_folder_icon = {
|
||||
icon = lvim.builtin.lir.icon,
|
||||
color = icon_hl,
|
||||
name = "LirFolderNode",
|
||||
},
|
||||
}
|
||||
local devicons_ok, devicons = pcall(require, "nvim-web-devicons")
|
||||
if devicons_ok then
|
||||
devicons.set_icon {
|
||||
lir_folder_icon = {
|
||||
icon = lvim.builtin.lir.icon,
|
||||
color = icon_hl,
|
||||
name = "LirFolderNode",
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
|
@ -107,6 +114,11 @@ function M.setup()
|
|||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
if not lvim.use_icons then
|
||||
lvim.builtin.lir.devicons.enable = false
|
||||
end
|
||||
|
||||
lir.setup(lvim.builtin.lir)
|
||||
|
||||
if lvim.builtin.lir.on_config_done then
|
||||
|
|
Loading…
Reference in a new issue