-
I am using AstroNvim v3. It is shifted from packer.nvim to lazy.nvim. I am having hard time to figure out that how am I going to add this plugin and add prefix keymap |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I've never looked into AstroNvim or lazy.nvim before; I would recommend looking at either of their help pages for more information. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm also using AstroNvim v3, I found how to install the plugin by adding -- .config/nvim/user/plugins/surround.lua
return {
"kylechui/nvim-surround",
event = 'verylazy',
config = function()
require("nvim-surround").setup({})
end
} |
Beta Was this translation helpful? Give feedback.
-
If you're looking to lazily load nvim-surround on key presses, here is the way I am doing it. There's probably a better or more idiomatic way, but I haven't found it yet. local surround_keys = function()
local pfx = "surround: "
local m = {
{ "i", "insert", "<C-g>s", pfx .. "cursor" },
{ "i", "insert_line", "<C-g>S", pfx .. "cursor newline" },
{ "n", "normal", "gs", pfx .. "motion" },
{ "n", "normal_cur", "gss", pfx .. "current line" },
{ "n", "normal_line", "gsS", pfx .. "current line on newlines" },
{ "n", "normal_cur_line", "gsN", pfx .. "motion on newlines" },
{ "x", "visual", "S", pfx .. "visual selection" },
{ "x", "visual_line", "gS", pfx .. "visual selection on newlines" },
{ "n", "delete", "ds", pfx .. "delete motion" },
{ "n", "change", "cs", pfx .. "change pairs" },
{ "n", "change_line", "cS", pfx .. "change pairs on newlines" },
}
local keys = {}
local keymaps = {}
for _, v in ipairs(m)
do
table.insert(keys, { v[3], mode = v[1], desc = v[4] })
keymaps[v[2]] = v[3]
end
return { keys, keymaps }
end
return {
{
"kylechui/nvim-surround",
keys = surround_keys()[1],
config = true,
opts = {
keymaps = surround_keys()[2]
},
},
} |
Beta Was this translation helpful? Give feedback.
Hi, I'm also using AstroNvim v3, I found how to install the plugin by adding
event:verylazy
in the config file as below: