feat(renderer): add ability to set git icons in signcolumn (#1242)

This commit is contained in:
Kiyan
2022-05-14 09:54:27 +02:00
committed by GitHub
parent 46014449b6
commit f8312cd06f
5 changed files with 42 additions and 11 deletions

View File

@@ -17,11 +17,14 @@ local M = {
local namespace_id = api.nvim_create_namespace "NvimTreeHighlights"
local function _draw(bufnr, lines, hl)
local function _draw(bufnr, lines, hl, signs)
api.nvim_buf_set_option(bufnr, "modifiable", true)
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
M.render_hl(bufnr, hl)
api.nvim_buf_set_option(bufnr, "modifiable", false)
for _, sign in pairs(signs) do
vim.fn.sign_place(0, git.SIGN_GROUP, sign.sign, bufnr, { lnum = sign.lnum, priority = 1 })
end
end
function M.render_hl(bufnr, hl)
@@ -71,10 +74,11 @@ function M.draw()
git.reload()
local lines, hl
local signs = {}
if view.is_help_ui() then
lines, hl = help.compute_lines()
else
lines, hl = Builder.new(core.get_cwd())
lines, hl, signs = Builder.new(core.get_cwd())
:configure_initial_depth(should_show_arrows())
:configure_root_modifier(vim.g.nvim_tree_root_folder_modifier)
:configure_trailing_slash(vim.g.nvim_tree_add_trailing == 1)
@@ -88,7 +92,8 @@ function M.draw()
:unwrap()
end
_draw(bufnr, lines, hl)
_draw(bufnr, lines, hl, signs)
M.last_highlights = hl
if cursor and #lines >= cursor[1] then
@@ -111,6 +116,7 @@ function M.setup(opts)
}
_padding.setup(opts)
git.setup_signs()
end
return M