hrsh7th / cmp-path

nvim-cmp source for path
MIT License
626 stars 61 forks source link

Bugs in completion with `Insert` behaviour #20

Open msva opened 2 years ago

msva commented 2 years ago

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 commented 2 years ago

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.

2) I open neovim to edit one of "ebuilds". Then I want to also open some patch, placed in files subdirectory of current working dir. 3) So, I type: :e fil<Tab> 4) completion menu appears 5) there is only "files/" suggeston available (ok). 6) I press <Tab> 7) it inserts the result to commandline. Now there is :e files/ 8) Now I want to navigate over files inside files directory 9) I press <Tab> (noticing that cursor is placed after /) 10) I expect to see completion menu with files from files directory, but instead, there is still menu with only files/. 11) only ways to get completion menu with files - is to:

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

msva commented 2 years ago

What happens in 11. on completing after second /:

image

msva commented 2 years ago

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

hrsh7th commented 2 years ago

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.

msva commented 2 years ago

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 commented 1 year ago

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?