feat(#1389): add git.show_on_dirs (#1390)

This commit is contained in:
Alexander Courtis 2022-07-03 19:57:12 +10:00 committed by GitHub
parent 80d4f28383
commit 736cc843e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 4 deletions

View File

@ -276,6 +276,7 @@ Subsequent calls to setup will replace the previous configuration.
git = {
enable = true,
ignore = true,
show_on_dirs = true,
timeout = 400,
},
actions = {
@ -464,8 +465,7 @@ Show LSP and COC diagnostics in the signcolumn
Type: `boolean`, Default: `false`
*nvim-tree.diagnostics.show_on_dirs*
If the node with diagnostic is not visible, then show diagnostic in the
parent directory.
Show diagnostic icons on parent directories.
Type: `boolean`, Default: `false`
*nvim-tree.diagnostics.icons*
@ -491,6 +491,10 @@ Git integration with icons and colors.
Toggle via the `toggle_git_ignored` action, default mapping `I`.
Type: `boolean`, Default: `true`
*nvim-tree.git.show_on_dirs*
Show status icons of children when directory itself has no status icon.
Type: `boolean`, Default: `true`
*nvim-tree.git.timeout*
Kills the git process after some time if it takes too long.
Type: `number`, Default: `400` (ms)

View File

@ -529,6 +529,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
git = {
enable = true,
ignore = true,
show_on_dirs = true,
timeout = 400,
},
actions = {

View File

@ -6,9 +6,15 @@ local function get_dir_git_status(parent_ignored, status, absolute_path)
if parent_ignored then
return "!!"
end
local dir_status = status.dirs and status.dirs[absolute_path]
local file_status = status.files and status.files[absolute_path]
return dir_status or file_status
if file_status then
return file_status
end
if M.config.git.show_on_dirs then
return status.dirs and status.dirs[absolute_path]
end
end
local function get_git_status(parent_ignored, status, absolute_path)
@ -37,4 +43,10 @@ function M.update_git_status(node, parent_ignored, status)
end
end
function M.setup(opts)
M.config = {
git = opts.git,
}
end
return M

View File

@ -52,6 +52,7 @@ function Explorer:_clear_watchers()
end
function M.setup(opts)
require("nvim-tree.explorer.common").setup(opts)
require("nvim-tree.explorer.explore").setup(opts)
require("nvim-tree.explorer.filters").setup(opts)
require("nvim-tree.explorer.sorters").setup(opts)