cmp-path icon indicating copy to clipboard operation
cmp-path copied to clipboard

Bugs in completion with `Insert` behaviour

Open msva opened this issue 2 years ago • 6 comments

Hi there!

I've faced issue, possibly related to my (probably wrong) workflow, but I don't know how to fix it properly:

I've "path" source enabled in "global" sources (I mean, not for just cmdline). Also I have mappings that uses behavior = cmp.SelectBehavior.Insert for <Tab>, behavior = cmp.SelectBehavior.Select for <Up>/<Down>, and behavior = cmp.ConfirmBehavior.Replace, select = false for <CR>.

Meaning "if I'm okay with first suggested variant, I'll just press Tab, and won't bother to navigate anything and pressing Enter, and if it is not - I'll navigate to the appropriate variant and will press Enter on it to replace completion with proper one".

So, when I type :e fil<Tab>, and select the appropriate result, I'm getting cmdlne completed to :e files/. Next I want to navigate files inside it, and since cmp doesnt do that by typing <Tab> once more, I type / (as I did with deoplete time ago), and then <backspace> it, to somehow make cmp know that previous completion stage is over, and I want to complete further. Unfortunately, it still shows only files/ as only available completion suggestion, and doesn't look inside...

And it will only work as expected after selecting proper suggeston (files/) with <CR>

So, it looks for me like cmp-path is intended to work with Insert behaviour on <CR>, and not-inserting over navigation :man_shrugging:

P.S. also I hit another variant of #19 while tested things for that issue:

if I type . after files/, and will try to navigate over results, there would be: files/., files/.., and files/. Selecting first two inserts exactly what said, but choosing last one (files/) inserts files/.files/ :man_shrugging:

msva avatar Dec 02 '21 22:12 msva

Label: can't understand

As of thing in P.S.: https://asciinema.org/a/gjJE20ad1di6opgk5YNxgVTmY

And as of the issue itself - unfortunately, I can't just show it (because it is no any visible mark that I pressing <Tab>) :cry:

I'll try to rephrase:

a) I have following mappings:

      ["<Tab>"] = cmp.mapping({
        c = function()    
          if cmp.visible() then     
            cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })                                                                                                                                                                                                    
          else     
            cmp.complete()     
          end     
        end,
        i = function(fallback)
          if cmp.visible() then      
            cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })     
          elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then     
            vim.api.nvim_feedkeys(t("<Plug>(ultisnips_jump_forward)"), 'm', true)     
          else     
            fallback()     
          end     
        end,
      }),
      ['<CR>'] = cmp.mapping({
        i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }),
        c = function(fallback)
          if cmp.visible() then
            cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
          else
            fallback()
          end
        end
      }),

1.a) Also, my current working directory consists of subdirectory files (with some patches inside) and few files in curent working directory itself. Say, vtk-8.blabla.ebuild, vtk-9.0.3-r3.ebuild, and so on.

  1. I open neovim to edit one of "ebuilds". Then I want to also open some patch, placed in files subdirectory of current working dir.
  2. So, I type: :e fil<Tab>
  3. completion menu appears
  4. there is only "files/" suggeston available (ok).
  5. I press <Tab>
  6. it inserts the result to commandline. Now there is :e files/
  7. Now I want to navigate over files inside files directory
  8. I press <Tab> (noticing that cursor is placed after /)
  9. I expect to see completion menu with files from files directory, but instead, there is still menu with only files/.
  10. only ways to get completion menu with files - is to:
  • add one more / and press <Tab> again, but this will show content of root directory (I mean disk's top level directory, not the /root) instead of expected content of files/ directory.
  • add * and press <Tab>, but this leads to #19

So I just want to ask, what is a right things to do in such workflow? :smile_cat:

msva avatar Dec 03 '21 03:12 msva

What happens in 11. on completing after second /:

image

msva avatar Dec 03 '21 03:12 msva

Well, maybe I shouldn't use path source for c mode in the first place :man_shrugging:

But then it will only elliminate one part of 11.. and make this issue be still actual, but in context of cmp-cmdline

msva avatar Dec 03 '21 03:12 msva

The files/ isn't a cmp-path source's result. It's cmp-cmdline issue.

Finally, I understand your problem. I will fix it in cmp-cmdline.

hrsh7th avatar Dec 03 '21 03:12 hrsh7th

Yeah, files/ itself - is cmdline's result (and yes, I also missed that until posting a similar comment in #19). But as you can see on screenshot, somewhy cmp-path ignores presence of "files/" and completes files// like it was a / :man_shrugging:

msva avatar Dec 03 '21 09:12 msva

Btw, looks like the issue that cmp-path takes multiple trailing slashes as reference to a root dir is still here: image

Or is it a feature, and not a bug?

msva avatar Apr 29 '23 21:04 msva