refactoring to use config options from lua module
This commit is contained in:
@@ -1,17 +1,7 @@
|
||||
local config = require 'lib/config'
|
||||
|
||||
local api = vim.api
|
||||
|
||||
local HAS_DEV_ICONS = api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1
|
||||
|
||||
local function get(var, fallback)
|
||||
if api.nvim_call_function('exists', { 'g:'..var }) == 1 then
|
||||
return api.nvim_get_var(var)
|
||||
else
|
||||
return fallback
|
||||
end
|
||||
end
|
||||
|
||||
local SHOW_FOLDER_ICON = get('lua_tree_show_folders', 1) == 1
|
||||
|
||||
local function get_padding(depth)
|
||||
local str = ""
|
||||
|
||||
@@ -24,7 +14,7 @@ local function get_padding(depth)
|
||||
end
|
||||
|
||||
local function default_icons(_, isdir, open)
|
||||
if isdir == true and SHOW_FOLDER_ICON then
|
||||
if isdir == true and config.SHOW_FOLDER_ICON then
|
||||
if open == true then return " " end
|
||||
return " "
|
||||
end
|
||||
@@ -69,7 +59,7 @@ local function dev_icons(pathname, isdir, open)
|
||||
end
|
||||
|
||||
local function get_icon_func_gen()
|
||||
if HAS_DEV_ICONS then
|
||||
if config.HAS_DEV_ICONS then
|
||||
return dev_icons
|
||||
else
|
||||
return default_icons
|
||||
@@ -132,7 +122,7 @@ local function highlight_line(buffer)
|
||||
highlight('LuaTreeFolderName', line, 0, -1)
|
||||
|
||||
elseif node.dir == true then
|
||||
if SHOW_FOLDER_ICON then
|
||||
if config.SHOW_FOLDER_ICON then
|
||||
text_start = text_start + 4
|
||||
highlight('LuaTreeFolderIcon', line, 0, text_start)
|
||||
end
|
||||
@@ -150,7 +140,7 @@ local function highlight_line(buffer)
|
||||
elseif is_pic(node.path .. node.name) then
|
||||
highlight('LuaTreeImageFile', line, text_start + gitlen, -1)
|
||||
|
||||
elseif HAS_DEV_ICONS then
|
||||
elseif config.HAS_DEV_ICONS then
|
||||
for k, v in pairs(HIGHLIGHT_GROUPS) do
|
||||
if string.match(node.name, k) ~= nil then
|
||||
text_start = text_start + 4
|
||||
|
||||
Reference in New Issue
Block a user