What is the proper place to custom map/keybindings? #219
Replies: 5 comments
-
I use |
Beta Was this translation helpful? Give feedback.
-
This is a good question, and the use |
Beta Was this translation helpful? Give feedback.
-
In this case I don't think the plug mappings apply, because you're specifically The proper way to do what you want in Neovim is to use buffer local mappings, meaning they only apply in R buffers and they aren't mapped in others. Since you're using LazyVim, follow the LazyVim example |
Beta Was this translation helpful? Give feedback.
-
Thanks, @BlueDrink9! As in LazyVim, I moved the examples in the README of how to set keymaps to the |
Beta Was this translation helpful? Give feedback.
-
Personally, I have just opted for using local commands = {
"devtools::load_all()",
}
---@module "lazy"
---@type LazySpec
return {
"R-nvim/R.nvim",
ft = "r",
keys = {
{
"<Leader>re",
function()
vim.ui.select(commands, { prompt = "Execute in R" }, function(cmd)
if cmd ~= nil then
vim.cmd.RSend(cmd)
end
end)
end,
ft = "r",
desc = "Execute one of a predefined commands in R (via R.nvim)",
},
},
opts = {},
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for this package!
I created my custom map/keybindings to some functions when developing my R packages. I'm using Lazyvim and placed it in
keymaps.lua
. It works, but I don't know if it is the proper way to do it, since it works even when no .R, .Rmd file is open. Is this the proper way to use custom keybindings, placing it inkeymaps.lua
?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions