英文:
In Neovim + Lazy.nvim, keymapping for a plugin does not work except for the first mapping
问题
我正在使用 Neovim 版本 0.9,并使用 Lazy.nvim 包管理器。使用以下配置,安装了 nvim-telescope。我设置了两个映射:<leader>ff
和 <leader>fg
。只有第一个有效;在这种情况下是 live_grep
。根据 Lazy.nvim 的规范(https://github.com/folke/lazy.nvim#-plugin-spec),keys
接受一个数组。
return {
{ 'nvim-telescope/telescope.nvim',
tag = '0.1.1',
dependencies = { 'nvim-lua/plenary.nvim' },
keys = {
{
{'<leader>fg', "<cmd>Telescope live_grep<cr>", desc = "Live grep"},
{'<leader>ff', "<cmd>Telescope find_files<cr>", desc = "Find file"},
},
},
}
}
这个配置有什么错误?我希望保留键绑定与插件配置一起,以便将与插件相关的完整配置保存在单个文件中。
英文:
I am using Neovim version 0.9 with Lazy.nvim package manager. Using the below configuration, nvim-telescope gets installed. I have set two mappings; <leader>ff
&& <leader>fg
. Only the first one works; live_grep
in this case. By Lazy.nvim specification in https://github.com/folke/lazy.nvim#-plugin-spec, keys
accepts an array.
return {
{ 'nvim-telescope/telescope.nvim',
tag = '0.1.1',
dependencies = { 'nvim-lua/plenary.nvim' },
keys = {
{
{'<leader>fg', "<cmd>Telescope live_grep<cr>", desc = "Live grep"},
{'<leader>ff', "<cmd>Telescope find_files<cr>" desc = "Find file"},
},
},
}
}
What is the mistake with this configuration? I would prefer to retain the keybinding along side the plugin configuration to keep the complete configuration related to a plugin in a single file.
答案1
得分: 1
Syntax error, you are not passing an array. You are passing a nested array.
You need to pass:
return
{
{
'nvim-telescope/telescope.nvim',
tag = '0.1.1',
dependencies = { 'nvim-lua/plenary.nvim' },
keys =
{
{'<leader>fg', "<cmd>Telescope live_grep<cr>", desc = "Live grep"},
{'<leader>ff', "<cmd>Telescope find_files<cr>", desc = "Find file"},
},
},
}
英文:
Syntax error, you are not passing an array. Your are passing a nested array.
you need to pass:
return
{
{
'nvim-telescope/telescope.nvim',
tag = '0.1.1',
dependencies = { 'nvim-lua/plenary.nvim' },
keys =
{
{'<leader>fg', "<cmd>Telescope live_grep<cr>", desc = "Live grep"},
{'<leader>ff', "<cmd>Telescope find_files<cr>" desc = "Find file"},
},
},
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论