nvim: Improve which-key group rendering
Moved most group definition functions into plugin 'init' functions so they run at the beginning and are displayed more reliably.
This commit is contained in:
parent
4e7b64aad0
commit
fad8f65214
3 changed files with 23 additions and 8 deletions
|
|
@ -31,6 +31,11 @@ local lsp = {
|
|||
},
|
||||
event = { "BufReadPost", "BufNewFile", "BufWritePre" },
|
||||
opts = { servers = get_all_servers() },
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>l", group = "language" })
|
||||
end
|
||||
end,
|
||||
config = function(_, lspconfig_opts)
|
||||
-- Display diagnostics as virtual text only if not in insert mode
|
||||
-- /r/neovim/comments/12inp4c/disable_diagnostics_virtual_text_when_in_insert/jqqifwk/
|
||||
|
|
@ -225,9 +230,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
o({ desc = "Next error" })
|
||||
)
|
||||
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>l", group = "language" })
|
||||
end
|
||||
map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", o({ desc = "Show line diagnostics" }))
|
||||
map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", o({ desc = "Codeactions" }))
|
||||
map("n", "<localleader>ln", "<cmd>lua vim.lsp.buf.rename()<cr>", o({ desc = "Rename element" }))
|
||||
|
|
|
|||
|
|
@ -97,6 +97,11 @@ local prose_plugs = {
|
|||
},
|
||||
ft = md_like,
|
||||
cmd = "RenderMarkdown",
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ { "<localleader>p", group = "presentation" } })
|
||||
end
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<localleader>pm",
|
||||
|
|
@ -160,6 +165,11 @@ local prose_plugs = {
|
|||
},
|
||||
},
|
||||
cmd = { "PasteImage" },
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ { "<localleader>p", group = "presentation" } })
|
||||
end
|
||||
end,
|
||||
keys = {
|
||||
{ "<localleader>pp", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
|
||||
},
|
||||
|
|
@ -169,7 +179,7 @@ local prose_plugs = {
|
|||
-- bring zettelkasten commands
|
||||
{
|
||||
"zk-org/zk-nvim",
|
||||
config = function()
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({
|
||||
{ "<leader>n", group = "notes" },
|
||||
|
|
@ -177,7 +187,8 @@ local prose_plugs = {
|
|||
{ "<localleader>n", group = "note", mode = "v" },
|
||||
})
|
||||
end
|
||||
|
||||
end,
|
||||
config = function()
|
||||
require("zk.commands").add("ZkOrphans", function(opts)
|
||||
opts = vim.tbl_extend("force", { orphan = true }, opts or {})
|
||||
require("zk").edit(opts, { title = "Zk Orphans" })
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ return {
|
|||
|
||||
"nvim-neotest/neotest-python",
|
||||
},
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>t", group = "test" })
|
||||
end
|
||||
end,
|
||||
config = function()
|
||||
require("neotest").setup({
|
||||
adapters = {
|
||||
|
|
@ -41,9 +46,6 @@ return {
|
|||
}),
|
||||
},
|
||||
})
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>t", group = "test" })
|
||||
end
|
||||
end,
|
||||
ft = { "python" },
|
||||
keys = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue