Closed mnabila closed 3 years ago
@mnabila did you find any workaround for the issue. I am having the same problem.
@dash2507 sadly no :(
Also happens when you don't have branches but tags.
How to reproduce:
git clone --branch v0.38.0 git@github.com:nvm-sh/nvm.git
And opening any file in the repo raises:
/home/horseinthesky/.config/nvim/lua/statusline.lua:225: attempt to concatenate a nil value
E15: Invalid expression: luaeval('require("galaxyline").component_decorator')("GitBranch")
@dash2507 @horseinthesky
i have solutions for this issue, add function for check result from vcs.get_git_branch()
to condition in GitBranch module.
why we get this error ? because vcs.get_git_branch()
will return nil if galaxyline can't found .git directory
{
GitBranch = {
provider = function() return string.format('%s ', vcs.get_git_branch()) end,
condition = function()
local function is_empty()
return vcs.get_git_branch() ~= nil
end
return condition.check_git_workspace() and condition.hide_in_width() and is_empty()
end,
highlight = {colors.black, colors.bblack}
}
},
@mnabila I did a similar thing straight away:
gls.left[6] = {
GitBranch = {
provider = function()
if in_vcs() and wide_enough(85) then
local branch = vcs.get_git_branch()
if branch ~= nil then
return branch .. " "
end
return ""
end
return ""
end,
highlight = {colors.fg2, colors.bg1}
}
}
But it is a workaround. A good solution would be to return the tag name if the branch in nil
.
A good solution would be to return the tag name if the branch in nil.
@horseinthesky but how about repository without tag and only have branch like master or main ?
A good solution would be to return the tag name if the branch in nil.
@horseinthesky but how about repository without tag and only have branch like master or main ?
This is the default behavior - return branch name - master on main. If no branch then tag.
A good solution would be to return the tag name if the branch in nil.
@horseinthesky but how about repository without tag and only have branch like master or main ?
This is the default behavior - return branch name - master on main. If no branch then tag.
+1 for this idea
Everytime i open help from plugins with.git folder, i got this error from galaxyline
idk how to fix this, but i think from helper galaxyline.provider_vcs.get_git_branch got empty result. I was try change provider from default provider (provider='GitBranch') in my configuration but its still not working, in some file i got empty result. but if i use example galaxyline theme(evilline) this problem is gone.
this part of my configuration for git sections
and this full configuration for galaxyline galaxyline.lua