0
let user_dir = input('Enter a directory: ', '', 'dir')

This is simple not working for me. When I press <tab> instead of completion, I get ^I .

I use nvim-cmp. Could it be the reason? Can I use nvim-cmp capabilities to get my input completed?

Configuration(a bit TMI) :

cmp.setup({
  mapping = cmp.mapping.preset.insert({
    --['<C-b>'] = cmp.mapping.scroll_docs(-4),
    --['<C-f>'] = cmp.mapping.scroll_docs(4),
["<Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then
        feedkey("<Plug>(ultisnips_expand)", "")
      elseif has_words_before() then
        cmp.complete()
      else
        fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
      end
    end, { "i", "s" }),

    ["<S-Tab>"] = cmp.mapping(function(fallback)
     if cmp.visible() then
        cmp.select_prev_item()
      elseif has_words_before() then
        cmp.complete()
      else
        fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
     end
    end, { "i", "s" }),
    ['<esc>'] = cmp.mapping(function(fallback)
    if cmp.visible() then cmp.abort()
    else vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, true, true), "n", true)
    end 
    
end ),
    ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  }),
  sources = cmp.config.sources(
{
    { name = 'buffer', priority = 1 },
    { name = 'path' , proiority=5 },
    { name = 'nvim_lsp', priority =200 }
     

})

})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})
6
  • “Could it be the reason”—does this work if you disable that plugin?
    – D. Ben Knoble
    Jan 6 at 21:32
  • Test using nvim --clean and verify if it works in a clean version? Jan 7 at 15:07
  • Yes, it does work in clean version.
    – eyal karni
    Jan 8 at 0:14
  • It works without cmp.
    – eyal karni
    Jan 8 at 0:28
  • then you should create a ticket in cmp github page Jan 8 at 13:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.