Skip to content

Commit

Permalink
feat(#2415): create DecoratorGit
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Oct 23, 2023
1 parent 3376e77 commit cc65530
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 3 additions & 11 deletions lua/nvim-tree/renderer/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ function Builder:configure_icon_padding(padding)
return self
end

function Builder:configure_git_icons_placement(where)
if where ~= "after" and where ~= "before" and where ~= "signcolumn" then
where = "before" -- default before
end
self.git_placement = where
return self
end

function Builder:configure_symlink_destination(show)
self.symlink_destination = show
return self
Expand Down Expand Up @@ -194,7 +186,7 @@ end
---@return HighlightedString[]|nil icon
function Builder:_get_git_icons(node)
local git_icons = self.decorators.git:get_icons(node)
if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then
if git_icons and #git_icons > 0 and self.decorators.git.icon_placement == ICON_PLACEMENT.signcolumn then
table.insert(self.signs, {
sign = git_icons[1].hl[1],
lnum = self.index + 1,
Expand Down Expand Up @@ -331,7 +323,7 @@ function Builder:_format_line(indent_markers, arrows, icon, name, git_icons, dia

local line = { indent_markers, arrows }
add_to_end(line, { icon })
if git_icons and self.git_placement == "before" then
if git_icons and self.decorators.git.icon_placement == ICON_PLACEMENT.before then
add_to_end(line, git_icons)
end
if modified_icon and self.decorators.modified.icon_placement == ICON_PLACEMENT.before then
Expand All @@ -346,7 +338,7 @@ function Builder:_format_line(indent_markers, arrows, icon, name, git_icons, dia

add_to_end(line, { name })

if git_icons and self.git_placement == "after" then
if git_icons and self.decorators.git.icon_placement == ICON_PLACEMENT.after then
add_to_end(line, git_icons)
end
if modified_icon and self.decorators.modified.icon_placement == ICON_PLACEMENT.after then
Expand Down
1 change: 0 additions & 1 deletion lua/nvim-tree/renderer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function M.draw(unloaded_bufnr)
:configure_picture_map(picture_map)
:configure_opened_file_highlighting(M.config.highlight_opened_files)
:configure_icon_padding(M.config.icons.padding)
:configure_git_icons_placement(M.config.icons.git_placement)
:configure_symlink_destination(M.config.symlink_destination)
:configure_filter(live_filter.filter, live_filter.prefix)
:build_header(view.is_root_folder_visible(core.get_cwd()))
Expand Down

0 comments on commit cc65530

Please sign in to comment.