Skip to content

Commit

Permalink
fix: show error when setup was not run
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 6, 2021
1 parent 2d2954a commit 194f788
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/which-key/init.lua
Expand Up @@ -4,7 +4,9 @@ local Util = require("which-key.util")
---@class WhichKey
local M = {}

local did_setup = false
function M.setup(options)
did_setup = true
require("which-key.config").setup(options)
if vim.v.vim_did_enter == 0 then
vim.cmd([[au VimEnter * ++once lua require("which-key").load()]])
Expand Down Expand Up @@ -60,6 +62,9 @@ local loaded = false -- once we loaded everything

-- Defer registering keymaps until VimEnter
function M.register(mappings, opts)
if not did_setup then
Util.error("Did you forget to run WhichKey setup?")
end
if loaded then
Keys.register(mappings, opts)
Keys.update()
Expand Down

0 comments on commit 194f788

Please sign in to comment.