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

Enabling cmp-path hides snippets that start with a slash

Open rudism opened this issue 3 years ago • 0 comments

Using luasnip, snippets that start with a / or . character don't show up in the completion menu when the path source is enabled in the nvim-cmp config.

nvim-cmp config:

cmp.setup {
  snippet = {
    expand = function(args)
      require'luasnip'.lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<Tab>'] = cmp.mapping.select_next_item(),
    ['<S-Tab>'] = cmp.mapping.select_prev_item(),
    ['<CR>'] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Replace,
      select = false,
    })
  },
  preselect = cmp.PreselectMode.None,
  confirmation = { get_commit_characters = function(_) return {} end },
  sources = {
    { name = 'luasnip' },
    { name = 'nvim_lsp' },
    { name = 'buffer' },
    { name = 'path' },
  },
}

luasnip config:

require('luasnip.loaders.from_snipmate').lazy_load({
  paths = "~/.config/nvim/snippets"
})

Example snippet definition:

snippet ///
	/// <summary>
	/// ${0}
	/// </summary>

Expected Behavior

Typing /// should show the defined snippet in the completion menu, however instead it only shows path completions for files at the root file system:

image

If I disable the { name = 'path' } source from the nvim-cmp config then it works as expected:

image

Is there some way to configure it so that both of these things can work together that I'm missing?

rudism avatar Jan 12 '23 22:01 rudism