Skip to content

Commit

Permalink
fix: ensure 'statuscolumn' requires the plugin
Browse files Browse the repository at this point in the history
Avoids issues with session restores that set 'statuscolumn'. Fix #136, Close #137.
  • Loading branch information
luukvbaal committed Aug 20, 2024
1 parent 93d8bcd commit 1022f92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/statuscol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ end

local formatstr, formatargret, segments, segmentcount
--- Return 'statuscolumn' option value (%! item).
local function get_statuscol_string()
M.get_statuscol_string = function()
local win = g.statusline_winid
local args = callargs[win]
local tick = C.display_tick
Expand Down Expand Up @@ -417,8 +417,7 @@ function M.setup(user)
local id = a.nvim_create_augroup("StatusCol", {})

if cfg.setopt then
_G.StatusCol = get_statuscol_string
o.statuscolumn = "%!v:lua.StatusCol()"
o.statuscolumn = "%!v:lua.require('statuscol').get_statuscol_string()"
a.nvim_create_autocmd("WinClosed", {
group = id,
callback = function(args)
Expand Down Expand Up @@ -463,4 +462,7 @@ function M.setup(user)
end
end

-- Restored session may set 'statuscolumn', requiring the plugin without calling setup.
if not callargs then M.setup() end

return M

0 comments on commit 1022f92

Please sign in to comment.