Skip to content

How to select file/dir in Ex mode completion when input is not a prefix? #78

Description

@TamaMcGlinn

In command-mode, e.g. when you do :e ~/somedir/file but before pressing enter, file completion pops up. I can press tab if I happened to enter the prefix of a valid entry, and it will complete it. For example, if there is a file called file_something.txt then this works. If there are multiple entries, tab again to select the next. But if the file is instead named something_file.txt I can see the completion result, but pressing tab does nothing. How do I select the completion?

Repro steps

  1. touch ~/file_something.txt
  2. nvim -u repro.vim (listed below)
  3. :e ~/som

image

You can see the completion right there, but does nothing, and will edit ~/som.

repro.vim

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  augroup plug_install
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  augroup END
endif

" Install vim-plug if not found
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif

call plug#begin('~/.vim/plugged')
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-path'
call plug#end()

lua <<EOF
local cmp = require('cmp')
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
  sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}})
})
EOF

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions