1

I try to create a function with the Neovim Telescope plugin and find_files builtin picker to list my configuration files (in ~/.config/nvim/lua directory). But I have an issue to use a specific mapping (here defined with CTRL-e) after selecting an entry via Telescope.

My lua/reload.lua file :

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

When I call reload method require('reload').reload(), the Telescope find_files picker is open correctly, I can select a file in the list but my CTRL-e mapping does not work => function to print selected filename not called.

Have some clue to help me ?

lcheylus
  • 1,217
  • 8
  • 21

1 Answers1

-1

You will need to press ctr+e before selecting the item in the list.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 20 '22 at 22:15