diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 1dd78219..c7041cdc 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -473,6 +473,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. show_on_open_dirs = true, disable_for_dirs = {}, timeout = 400, + cygwin_support = false, }, diagnostics = { enable = false, @@ -1118,6 +1119,10 @@ Kills the git process after some time if it takes too long. Git integration will be disabled after 10 git jobs exceed this timeout. Type: `number`, Default: `400` (ms) +*nvim-tree.git.cygwin_support* +Use `cygpath` if available to resolve paths for git. + Type: `boolean`, Default: `false` + ============================================================================== 5.8 OPTS: DIAGNOSTICS *nvim-tree-opts-diagnostics* diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index d2552b84..c6384c86 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -496,6 +496,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS show_on_open_dirs = true, disable_for_dirs = {}, timeout = 400, + cygwin_support = false, }, diagnostics = { enable = false, @@ -794,6 +795,7 @@ function M.setup(conf) require("nvim-tree.diagnostics").setup(opts) require("nvim-tree.explorer").setup(opts) require("nvim-tree.git").setup(opts) + require("nvim-tree.git.utils").setup(opts) require("nvim-tree.view").setup(opts) require("nvim-tree.lib").setup(opts) require("nvim-tree.renderer").setup(opts) diff --git a/lua/nvim-tree/git/utils.lua b/lua/nvim-tree/git/utils.lua index 9d5c58b9..b9ba371c 100644 --- a/lua/nvim-tree/git/utils.lua +++ b/lua/nvim-tree/git/utils.lua @@ -1,8 +1,9 @@ -local M = {} local log = require "nvim-tree.log" local utils = require "nvim-tree.utils" -local has_cygpath = vim.fn.executable "cygpath" == 1 +local M = { + use_cygpath = false, +} --- Retrieve the git toplevel directory --- @param cwd string path @@ -35,7 +36,7 @@ function M.get_toplevel(cwd) -- git always returns path with forward slashes if vim.fn.has "win32" == 1 then -- msys2 git support - if has_cygpath then + if M.use_cygpath then toplevel = vim.fn.system("cygpath -w " .. vim.fn.shellescape(toplevel)) if vim.v.shell_error ~= 0 then return nil, nil @@ -112,4 +113,10 @@ function M.file_status_to_dir_status(status, cwd) return r end +function M.setup(opts) + if opts.git.cygwin_support then + M.use_cygpath = vim.fn.executable "cygpath" == 1 + end +end + return M