Telescope find_files选择器的attach_mappings问题



我尝试使用Neovim Telescope插件和find_files内置选择器创建一个函数,以列出我的配置文件(在~/.config/nvim/lua目录中(。但我有一个问题,在通过望远镜选择一个条目后,使用特定的映射(这里用CTRL-e定义(。

我的lua/reload.lua文件:

local M = {}
M.reload = function()
local opts = {
prompt_title = 'Configuration files',
cwd = '~/.config/nvim/lua',
attach_mappings = function(_, map)
local action_state = require('telescope.actions.state')
-- Adds a new map to ctrl+e.
map('i', '<C-e>', function(_)
local entry = action_state.get_selected_entry()
local name = get_module_name(entry.value)
print('Name = ' .. name)
return true
end,
}
-- call the builtin method to list files
require('telescope.builtin').find_files(opts)
end
return M

当我调用reload方法require('reload').reload()时,Telescopefind_files选择器正确打开,我可以在列表中选择一个文件,但我的CTRL-e映射不起作用=>函数打印未调用的选定文件名。

有什么线索可以帮我吗?

在选择列表中的项目之前,您需要按ctr+e。

最新更新