feat(keymaps): dynamic which-key icons/descriptions for toggles

This commit is contained in:
Folke Lemaitre 2024-07-15 13:25:32 +02:00
parent 6911327a5e
commit 82a3ccc4d6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 192 additions and 115 deletions

View file

@ -97,10 +97,19 @@ end
---@param buf? boolean
function M.toggle(buf)
M.enable(not M.enabled(), buf)
end
---@param enable? boolean
---@param buf? boolean
function M.enable(enable, buf)
if enable == nil then
enable = true
end
if buf then
vim.b.autoformat = not M.enabled()
vim.b.autoformat = enable
else
vim.g.autoformat = not M.enabled()
vim.g.autoformat = enable
vim.b.autoformat = nil
end
M.info()