Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in completion with Insert behaviour #20

Open
msva opened this issue Dec 2, 2021 · 6 comments
Open

Bugs in completion with Insert behaviour #20

msva opened this issue Dec 2, 2021 · 6 comments

Comments

@msva
Copy link

msva commented Dec 2, 2021

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 🤷‍♂️

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/ 🤷‍♂️

@msva msva changed the title Bugs in completion with Insert-on-Tab+Replace-on-CR behaviour Bugs in completion with Insert behaviour Dec 2, 2021
@msva
Copy link
Author

msva commented Dec 3, 2021

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>) 😢

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:

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

@msva
Copy link
Author

msva commented Dec 3, 2021

What happens in 11. on completing after second /:

image

@msva
Copy link
Author

msva commented Dec 3, 2021

Well, maybe I shouldn't use path source for c mode in the first place 🤷‍♂️

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

@hrsh7th
Copy link
Owner

hrsh7th commented Dec 3, 2021

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
Copy link
Author

msva commented Dec 3, 2021

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 / 🤷‍♂️

@msva
Copy link
Author

msva commented Apr 29, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants