I'm using nvim-cmp.
Here is the issue I'm facing;
In the command line completion for :
if I start with /
or .
, path
source completion gets triggered. If I tab through the entries to a directory, a trailing /
is not appended, and when I type in the trailing /
, then I can autocomplete the files and directories contained in the directory I just appended /
to.
But if I don't start with .
or /
then cmdline
source completion is used, and when I select a directory, a trailing /
is appended and I have to delete it and retype it to autocomplete files and directories on the next level. Adding a second /
starts autocomplete using the path
source from the root directory, /
.
One think I've tried doing is disabling the cmdline
source for certain commands, which is not ideal;
So my question is; does anyone know how to stop the cmdline
source for nvim-cmp to not append trailing slashes to directory names? Or some more elegant way to make it autocomplete into the next directory level?
here is a minimal config to test what I'm talking about
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup(
{
{
"hrsh7th/nvim-cmp",
dependencies = {
{ "hrsh7th/cmp-path", },
{ "hrsh7th/cmp-cmdline",},
{
"L3MON4D3/LuaSnip", -- tag = "v<CurrentMajor>.*",
dependencies = { "rafamadriz/friendly-snippets" },
config = function()
require("plugin_configs.LuaSnip")
end,
event = "VeryLazy"
},
{ "saadparwaiz1/cmp_luasnip" }
},
config = function()
local cmp = require 'cmp'
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(
{
}),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end,
},
}
)
vim.cmd([[colorscheme elflord]])
Thanks in advace for any insight!