-
Notifications
You must be signed in to change notification settings - Fork 1k
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: Add option to disable all LazyVim keymaps #238
Comments
Made this configurable. See https://www.lazyvim.org/configuration#default-settings |
@folke Will this new setting also disable default keymaps for telescope and lsp? If not, I think it would be great to have, or at least add separate options for those. I'm currently trying to remap some lsp bindings following this documention, but it doesn't seem to work, for example, remapping code action: {
"neovim/nvim-lspconfig",
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
keys[#keys + 1] = { "<leader>ca", false }
keys[#keys + 1] =
{ "C-s", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }
} In this example, |
You forgot {
"neovim/nvim-lspconfig",
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
keys[#keys + 1] =
{ "<C-s>", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }
end,
} |
@Nohac you can already disable default key bindings for plugins. It's in the docs. |
@folke, @Nohac's suggestion reminds me that there are still keymaps from plugins that get mapped too on init. Intuitively, when I tell LazyVim to not load any default keymaps, I'd expect a clean slate of keymaps, but here the plugins still get initialized with binds attached. This isn't as much of an issue for me, but it still only half solves the initial problem of conflicting remaps. You could still disable keymaps per plugin that you find conflicting. However, the intention of not loading defaults is that the user has a clean slate to add mappings on top of. Currently, the user can work top-down, deleting any keymaps and/or disabling/overwriting plugins you don't need. However, some users who have really minimal setups may want to work bottom-up, starting from the bare basics while still taking advantage of all the lazyloading and other features LazyVim provides. You can certainly disable all the plugins you don't need, but say I only wanted telescope and cmp, I'd have to manually disable EVERY other plugin that ships with LazyVim, which certainly adds up and could get outdated if we decide to include more plugins in the future. I can suggest a way to handle this in the context of keymaps at least. For all keymaps that are assigned in the framework, just use a wrapper In the context of plugins, I can suggest extending plugins = {
coding = true,
editor = true,
ui = true,
...
} This will let users still load subsets of plugins, and have a smaller amount of plugins to remove if they so choose. I'm not too familiar with the code for LazyVim, so I don't truly know the complexity of the implementation, but it's a suggestion. Overall, this will allow this recommendation would allow users to build bottom-up. The question is whether this is something that aligns with LazyVim's philosophy of convenience (since it's so manual, is it really "lazy" anymore). Users will still be inclined to use LazyVim though due to its lazyloading and compact UI and preconfigured plugins, they will just have more freedom in choosing exactly which set of plugins to enable from the core. Would love to hear your thoughts! |
If you don't want any of the keymaps for the plugins loaded as well, then you probably shouldn't be using LazyVim. I'm not going to add any additional ways to disable plugin keymaps. You can already do that right now. |
Sorry, probably stupid question: I don't get how to use this in my custom config. Should I create a lua file and add this configurations (as I do for plugins) or I should create a specific file inside my |
@egolep you can edit the LazyVim spec like you would change a color scheme, by editing In a spec file under return {
{
"LazyVim/LazyVim",
opts = {
defaults = {
autocmds = true, -- lazyvim.config.autocmds
keymaps = true, -- lazyvim.config.keymaps
options = true, -- lazyvim.config.options
},
}
}
} |
Thanks man! |
Did you check the docs?
Is your feature request related to a problem? Please describe.
It's really frustrating when reassigning keymaps, and you want to map say
<leader>f
, but somewhere there's a map for<leader>fr
. Of course, you don't initially know anfr
key bind exists, so whenever you do<leader>f
, nvim is pending for another keystroke before confirming the call...I think. So you have to hunt for any<leader>f{char}
keymaps and unbind them, or even worse, have to reassign them.I love how LazyVim ships with a great set of default bind. However, as someone who's built strong preferences for their keymaps, it can make the process of reassigning binds frustrating and tedious.
Describe the solution you'd like
I would love it if there was a way to just not load any of the default keymaps at all. Give the user the option to fully reconfigure their key binds from scratch, or let them start off with a much smaller subset of key binds, and provide the rest as opt-ins. This would be similar to how we approach
lazyvim.plugins.extras.lang.typescript
but instead of language extensions, we have keymap extensions.As someone migrating with a preconfigured list of keymaps, this would simplify the process for me a lot more. We can enable it through the main
lazy.lua
file:Keymap extensions aren't necessary, but it would be great if LazyVim had a way to disable importing its default keymaps. Then I can use the same principle of adding keymaps to my plugins inside spec files
keymaps.lua
and they'd just get merged like normal.Describe alternatives you've considered
Going into each separate plugin and disabling keys that are conflicting or making neovim wait.
Additional context
Sorry if the issue is too wordy, I'm not too used to writing issues yet. Also, I've tried adding
keys = function () return {} end
to the lazyVim spec, but keymaps were still getting loaded. If this is already implemented, am I doing it the wrong way?The text was updated successfully, but these errors were encountered: