Skip to content

Commit

Permalink
Fix WinEnter autocmd is not reliable
Browse files Browse the repository at this point in the history
Because WinEnter autocmd is executed before some specific options can be
configured for that window it is not reliable for testing if label
should be shown in such a window. Fix this with nested emulation of
InsertEnter (once).
  • Loading branch information
monkoose committed Nov 5, 2024
1 parent db05edf commit 7d371fe
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lua/neocodeium/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,22 @@ local function enable_autocmds()
return vim.wo.number or vim.wo.relativenumber
end

create_autocmd("ModeChanged", {
pattern = "*:i*",
once = true,
callback = function()
completer.label.enabled = nu_or_rnu()
end,
})
local function insert_enter_once()
create_autocmd("ModeChanged", {
pattern = "*:i*",
once = true,
callback = function()
vim.print(nu_or_rnu())
completer.label.enabled = nu_or_rnu()
end,
})
end

insert_enter_once()

create_autocmd("WinEnter", {
callback = function()
completer.label.enabled = nu_or_rnu()
insert_enter_once()
end,
})

Expand Down

0 comments on commit 7d371fe

Please sign in to comment.