fix: #96 improve startup time

For those who do not use the git branching feature, this may improve their Neovim startup time significantly
main
olimorris 2023-11-16 09:50:09 +00:00
parent 5b5ec1c797
commit d90f9adb04
1 changed files with 18 additions and 16 deletions

View File

@ -41,10 +41,11 @@ end
---Get the current Git branch
---@return string
function M.get_branch()
if config.options.use_git_branch then
vim.fn.system([[git rev-parse 2> /dev/null]])
local git_enabled = (vim.v.shell_error == 0)
if config.options.use_git_branch and git_enabled then
if git_enabled then
local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]])
if vim.v.shell_error == 0 then
branch = config.options.branch_separator .. branch[1]:gsub("/", "%%")
@ -62,6 +63,7 @@ function M.get_branch()
end
end
end
end
return config.options.branch_separator .. default_branch
end