【问题标题】:Issue on attach_mappings with Telescope find_files picker望远镜 find_files 选择器的 attach_mappings 问题
【发布时间】:2022-11-14 03:13:55
【问题描述】:

我尝试使用 Neovim Telescope 插件和 find_files 内置选择器创建一个函数来列出我的配置文件(在 ~/.config/nvim/lua 目录中)。但是我在通过 Telescope 选择条目后使用特定映射(此处使用 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() 时,望远镜find_files 选择器已正确打开,我可以在列表中选择一个文件,但我的CTRL-e 映射不起作用=> 打印未调用的选定文件名的功能。

有什么线索可以帮助我吗?

【问题讨论】:

    标签: neovim telescope.nvim


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-28
      相关资源
      最近更新 更多