Skip to content

Commit

Permalink
perf: as long as we didnt finish loading, queue registers
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 29, 2021
1 parent 928288b commit 1bac978
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lua/which-key/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ function M.show_command(keys, mode)
end
end

local function ready() return vim.api.nvim_get_vvar("vim_did_enter") == 1 end

local queue = {}
local loaded = false -- once we loaded everything

-- Defer registering keymaps until VimEnter
function M.register(mappings, opts)
if ready() then
if loaded then
Keys.register(mappings, opts)
Keys.update()
else
Expand All @@ -67,6 +66,7 @@ function M.load()
end
Keys.update()
queue = {}
loaded = true
end

function M.reset()
Expand Down

0 comments on commit 1bac978

Please sign in to comment.