hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.45k stars 370 forks source link

Expanding `%` on cmdline keeps percent sign at the beginning of path #1893

Open tom-kuca opened 2 months ago

tom-kuca commented 2 months ago

FAQ

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-cmdline'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup({})

-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  }),
  matching = { disallow_symbol_nonprefix_matching = false }
})

EOF

Description

Expanding % on cmdline keeps the percent sign after expansion. The behavior is different when nvim-cmp is not installed.

Steps to reproduce

  1. Add hrsh7th/cmp-cmdline and cmdline configuration from README.
  2. Edit file /tmp/hello.txt
  3. Type :e %<Tab>

Expected behavior

cmdline expands to :e /tmp/hello.txt

Actual behavior

cmdline expands to :e %/tmp/hello.txt

Additional context

Without any plugin ( nvim --noplugin --clean), percent expands to /tmp/hello.txt.