hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
566 stars 45 forks source link

Don't show path completions #60

Open PowerUser64 opened 2 years ago

PowerUser64 commented 2 years ago

Currently, cmp-cmdline shows paths in the list of possible completions. As demonstrated in hrsh7th/cmp-path#40, however, it can cause a lot of unexpected behavior by adding lots of effectively duplicate completions to the completion list (see screenshots in mentioned issue).

A possible solution to this would be to do a similar thing to cmp-path, and show the trailing / in the completion list (to make it clear which things are directories) but don't make it complete when the user selects it. Then, when the user types a / to complete within the directory. Just like using cmp-path.

Another possible solution would be to try and remove directories from cmp-cmdline's completion output entirely. I do not know the details of cmp-cmdline's implementation, so I cannot say for sure, but I am guessing this would be the more difficuly option to find a proper implementation for. However, I believe it would solve the problem better than the first suggested solution does.

I like the first option from a functionality standpoint because it means you don't have to always press . or / to start a path completion from the cmdline (a very common task). However, I also like the second option from a code organization/project purpose standpoint because it would probably be a good idea to not implement cmp-path within cmp-cmdline.

PowerUser64 commented 5 months ago

@hrsh7th any progress for this issue? I noticed treat_trailing_slash was added and enabled by default, which does mostly solve the problem, so thanks for that! Now the only issue is there being a ton of duplicate completions in the menu when cmp-path is showing things. (https://github.com/hrsh7th/cmp-path/issues/40 also, but that's less problematic now.)

It seems like this would be possible to work around if we could hide cmp-cmdline items when cmp-path items are visible. Is this possible? I could see this being useful in other cases too.

I suppose the simple solution for now is to not use cmp-path in the cmdline, but I would like to use cmp-path if possible because it is nicer to use.