Skip to content

Commit

Permalink
feat: better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 29, 2021
1 parent 060a574 commit c39df95
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lua/which-key/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ function M.parse_keys(keystr)
return ret
end

function M.log(msg, hl) vim.api.nvim_echo({ { "WhichKey: " .. msg, hl } }, true, {}) end
function M.log(msg, hl) vim.api.nvim_echo({ { "WhichKey: ", hl }, { msg } }, true, {}) end

function M.warn(msg) M.log(msg, "WarningMsg") end

function M.error(msg)
vim.api.nvim_echo({
{ "WhichKey: ", "Error" },
{ msg },
{ " (please report this issue if it persists)", "Comment" },
}, true, {})
end

function M.check_mode(mode, buf)
if not ("nvsoiRct"):find(mode) then
M.error(string.format("Invalid mode %q for buf %d", mode, buf or 0))
end
end

return M

0 comments on commit c39df95

Please sign in to comment.