mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45: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"
|
local f = require "lvim.utils.functions"
|
||||||
|
|
||||||
if not f.isempty(filename) then
|
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
|
if f.isempty(file_icon) then
|
||||||
file_icon = lvim.icons.kind.File
|
file_icon = lvim.icons.kind.File
|
||||||
|
end
|
||||||
|
else
|
||||||
|
file_icon = ""
|
||||||
|
hl_group = "Normal"
|
||||||
end
|
end
|
||||||
|
|
||||||
local buf_ft = vim.bo.filetype
|
local buf_ft = vim.bo.filetype
|
||||||
|
|
|
@ -83,6 +83,10 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.icon_setup()
|
function M.icon_setup()
|
||||||
|
if not lvim.builtin.lir.devicons.enable then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local function get_hl_by_name(name)
|
local function get_hl_by_name(name)
|
||||||
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
|
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
|
||||||
return string.format("#%06x", ret[name.property])
|
return string.format("#%06x", ret[name.property])
|
||||||
|
@ -93,13 +97,16 @@ function M.icon_setup()
|
||||||
icon_hl = "#42A5F5"
|
icon_hl = "#42A5F5"
|
||||||
end
|
end
|
||||||
|
|
||||||
require("nvim-web-devicons").set_icon {
|
local devicons_ok, devicons = pcall(require, "nvim-web-devicons")
|
||||||
lir_folder_icon = {
|
if devicons_ok then
|
||||||
icon = lvim.builtin.lir.icon,
|
devicons.set_icon {
|
||||||
color = icon_hl,
|
lir_folder_icon = {
|
||||||
name = "LirFolderNode",
|
icon = lvim.builtin.lir.icon,
|
||||||
},
|
color = icon_hl,
|
||||||
}
|
name = "LirFolderNode",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
|
@ -107,6 +114,11 @@ function M.setup()
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not lvim.use_icons then
|
||||||
|
lvim.builtin.lir.devicons.enable = false
|
||||||
|
end
|
||||||
|
|
||||||
lir.setup(lvim.builtin.lir)
|
lir.setup(lvim.builtin.lir)
|
||||||
|
|
||||||
if lvim.builtin.lir.on_config_done then
|
if lvim.builtin.lir.on_config_done then
|
||||||
|
|
Loading…
Reference in a new issue