chore: move code around
- deprecate config.lua file - move icon config code into renderer/icons - move file opening config in open-file.lua
This commit is contained in:
61
lua/nvim-tree/renderer/icons.lua
Normal file
61
lua/nvim-tree/renderer/icons.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
local M = {}
|
||||
|
||||
function M.get_config()
|
||||
local show_icons = vim.g.nvim_tree_show_icons or { git = 1, folders = 1, files = 1, folder_arrows = 1 }
|
||||
local icons = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
git_icons = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌"
|
||||
},
|
||||
folder_icons = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
}
|
||||
|
||||
local user_icons = vim.g.nvim_tree_icons
|
||||
if user_icons then
|
||||
if user_icons.default then
|
||||
icons.default = user_icons.default
|
||||
icons.symlink = user_icons.default
|
||||
end
|
||||
if user_icons.symlink then
|
||||
icons.symlink = user_icons.symlink
|
||||
end
|
||||
for key, val in pairs(user_icons.git or {}) do
|
||||
if icons.git_icons[key] then
|
||||
icons.git_icons[key] = val
|
||||
end
|
||||
end
|
||||
for key, val in pairs(user_icons.folder or {}) do
|
||||
if icons.folder_icons[key] then
|
||||
icons.folder_icons[key] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local has_devicons = pcall(require, 'nvim-web-devicons')
|
||||
return {
|
||||
show_file_icon = show_icons.files == 1,
|
||||
show_folder_icon = show_icons.folders == 1,
|
||||
show_git_icon = show_icons.git == 1,
|
||||
show_folder_arrows = show_icons.folder_arrows == 1,
|
||||
has_devicons = has_devicons,
|
||||
icons = icons
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -3,6 +3,7 @@ local utils = require'nvim-tree.utils'
|
||||
local view = require'nvim-tree.view'
|
||||
local _padding = require'nvim-tree.renderer.padding'
|
||||
local _help = require'nvim-tree.renderer.help'
|
||||
local _icons = require'nvim-tree.renderer.icons'
|
||||
|
||||
local api = vim.api
|
||||
|
||||
@@ -11,7 +12,7 @@ local hl = {}
|
||||
local index = 0
|
||||
local namespace_id = api.nvim_create_namespace('NvimTreeHighlights')
|
||||
|
||||
local icon_state = config.get_icon_state()
|
||||
local icon_state = _icons.get_config()
|
||||
|
||||
local should_hl_opened_files = (vim.g.nvim_tree_highlight_opened_files or 0) ~= 0
|
||||
|
||||
@@ -382,12 +383,12 @@ function M.draw()
|
||||
lines = {}
|
||||
hl = {}
|
||||
|
||||
icon_state = _icons.get_config()
|
||||
local show_arrows =
|
||||
vim.g.nvim_tree_indent_markers ~= 1
|
||||
and icon_state.show_folder_icon
|
||||
and icon_state.show_folder_arrows
|
||||
_padding.reload_padding_function()
|
||||
icon_state = config.get_icon_state()
|
||||
update_draw_data(TreeExplorer, show_arrows and 2 or 0, {})
|
||||
|
||||
if view.is_help_ui() then
|
||||
|
||||
@@ -33,7 +33,7 @@ local function get_padding_indent_markers(depth, idx, tree, _, markers)
|
||||
end
|
||||
|
||||
function M.reload_padding_function()
|
||||
local icon_state = require'nvim-tree.config'.get_icon_state()
|
||||
local icon_state = require'nvim-tree.renderer.icons'.get_config()
|
||||
|
||||
if icon_state.show_folder_icon and icon_state.show_folder_arrows then
|
||||
M.get_padding = get_padding_arrows(icon_state)
|
||||
|
||||
Reference in New Issue
Block a user