-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: filetype-specific Lazy-key-mappings #1076
Comments
Good idea. Just added this. |
I really like this feature. I have a sidenote question. How can you make {
"toppair/peek.nvim",
build = "deno task --quiet build:fast",
keys = {
{
"<leader>pp",
function()
local peek = require("peek")
if peek.is_open() then
peek.close()
else
peek.open()
end
end,
desc = "Peek (Markdown Preview)",
ft = "markdown",
},
},
opts = { theme = "dark" },
},
{
"folke/which-key.nvim",
opts = {
defaults = {
["<leader>p"] = { name = "+peek" },
},
},
}, which without the |
@dpetka2001 that's a bug in which-key. I think there's a PR open to fix that (by reverting another PR). Need to look at it :) |
For the moment, as a work around, I added init = function()
require("lazyvim.util").on_load("which-key.nvim", function()
require("which-key").register({
["<leader>p"] = { name = "+peek" },
})
end)
end, which seems to do the trick for the time being, while maintaining the Edit: of course that snippet is Lazyvim specific, in case anyone tries to incorporate it in his own custom config with only |
@folke Was the |
As far as I'm aware, it hasn't been addressed yet. But there's a workaround for it in this issue comment until it gets resolved. |
Lets put the reference here in case anyone else comes across this: folke/which-key.nvim#514 |
Did you check the docs?
Is your feature request related to a problem? Please describe.
The
keys
from lazy's plugin spec allows for a very concise definition of keymappings with lazy-loading. However, when it comes to filetype-specific keymaps, there is quite a bit of boilerplate:Describe the solution you'd like
Adding a
ft
key to the Lazy Key Mappings would remove the boilerplate and result in a much cleaner config. It should fit well with lazy's style of configuring things:Describe alternatives you've considered
As a workaround, I basically created my own small utility function. reduces boilerplate a bit, but still not a great solution, I guess.
Additional context
No response
The text was updated successfully, but these errors were encountered: