Skip to content

Commit 12fb937

Browse files
committed
perf(#3257): remove git utils setup
1 parent 4146915 commit 12fb937

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

lua/nvim-tree.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ function M.setup(config_user)
288288
require("nvim-tree.appearance").setup()
289289
require("nvim-tree.explorer"):setup(config.g)
290290
require("nvim-tree.explorer.watch").setup(config.g)
291-
require("nvim-tree.git.utils").setup(config.g)
292291
require("nvim-tree.view").setup(config.g)
293292
require("nvim-tree.renderer.components").setup(config.g)
294293

lua/nvim-tree/git/utils.lua

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
local log = require("nvim-tree.log")
22
local utils = require("nvim-tree.utils")
3+
local config = require("nvim-tree.config")
34

4-
local M = {
5-
use_cygpath = false,
6-
}
5+
local M = {}
6+
7+
---@type boolean?
8+
local use_cygpath_cached = nil
9+
10+
---true when cygwin enabled and present
11+
---@return boolean
12+
local function use_cygpath()
13+
if use_cygpath_cached == nil then
14+
if config.g.git.cygwin_support then
15+
use_cygpath_cached = vim.fn.executable("cygpath") == 1
16+
else
17+
use_cygpath_cached = false
18+
end
19+
end
20+
return use_cygpath_cached
21+
end
722

823
--- Execute system command
924
---@param cmd string[]
1025
---@return string stdout
1126
---@return integer exit code
1227
local function system(cmd)
1328
if vim.fn.has("nvim-0.10") == 1 then
14-
local obj = vim.system(cmd):wait(M.opts.git.timeout)
29+
local obj = vim.system(cmd):wait(config.g.git.timeout)
1530
return obj.stdout or "", obj.code
1631
else
1732
return vim.fn.system(cmd), vim.v.shell_error
@@ -50,7 +65,7 @@ function M.get_toplevel(cwd)
5065
if vim.fn.has("win32") == 1 then
5166
-- msys2 git support
5267
-- cygpath calls must in array format to avoid shell compatibility issues
53-
if M.use_cygpath then
68+
if use_cygpath() then
5469
toplevel = vim.fn.system({ "cygpath", "-w", toplevel })
5570
if vim.v.shell_error ~= 0 then
5671
return nil, nil
@@ -195,11 +210,4 @@ function M.git_status_dir(parent_ignored, project, path, path_fallback)
195210
return ns
196211
end
197212

198-
function M.setup(opts)
199-
if opts.git.cygwin_support then
200-
M.use_cygpath = vim.fn.executable("cygpath") == 1
201-
end
202-
M.opts = opts
203-
end
204-
205213
return M

0 commit comments

Comments
 (0)