nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

cmdline input method (@) completion failed int filetype c files

Open qrsforever opened this issue 1 year ago • 2 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

  1. mini.lua
vim.opt.runtimepath:remove(vim.fn.stdpath("config"))
vim.opt.packpath:remove(vim.fn.stdpath("data") .. "/site")
vim.opt.termguicolors = true
vim.opt.laststatus = 0

local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
	vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
	vim.cmd("packadd packer.nvim")
	install_plugins = true
end

local packer = require("packer")

packer.init({
	package_root = test_dir .. "/pack",
	compile_path = test_dir .. "/plugin/packer_compiled.lua",
})


packer.startup(function(use)
	use("wbthomason/packer.nvim")

    use('hrsh7th/cmp-path')
    use('hrsh7th/cmp-cmdline')
    use('hrsh7th/nvim-cmp')

	if install_plugins then
		packer.sync()
	end
end)


local cmp = require'cmp'
cmp.setup({
    sources = cmp.config.sources({
        { name = 'path' },
        { name = 'cmdline' },
    })
})


cmp.setup.cmdline({':', '@'}, {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
        { name = 'path' }
    }, {
        { name = 'cmdline' }
    })
})
  1. nvim --clean -u mini.lua test.c
  2. steps video

https://github.com/hrsh7th/nvim-cmp/assets/1296332/86c61c48-bc5b-4621-9390-f3e916a9785c

Description

using vim.fn.input method on command mode, some filetypes cannot path complete correctly, eg: c files.

Steps to reproduce

  1. open a suffix c file

  2. command mode input: call input('from dir@:', '/usr/local/share/nvim', 'dir')

  3. backsapce some characters of the path (see video above)

  4. you will see somewrong.

  5. if set filetype=txt, reproduce the steps above , that's ok.

Expected behavior

hope the c file @ completion correctly on the cmdline.

Actual behavior

no path completion.

Additional context

No response

qrsforever avatar Jun 09 '23 11:06 qrsforever

The video seems broken.

Shougo avatar Jun 09 '23 17:06 Shougo

same problem

Wangch29 avatar Aug 08 '23 12:08 Wangch29