hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
533 stars 40 forks source link

:map completion doesn't find mappings with <leader> #6

Closed aMOPel closed 2 years ago

aMOPel commented 2 years ago

I'm using <space> as the <leader>.

Reproduce when typing :map leader or :map space or :map <leader> i get 0 completions, even though i have a lot of mappings starting with leader and e.g. :map <leader>g<cr> gives me output about these mappings.

Misc This source is great! I could completely get rid of https://github.com/gelguy/wilder.nvim.

Minor things are annoying though:

  1. when typing e.g. :e to get path completions, i get some paths mixed with some other commands provided by this source. However I have setup the cmp-path source to work with this source.
    cmp.setup.cmdline(':', {
    sources = cmp.config.sources({
    { name = 'path', max_item_count = 20 }
    }, {
    { name = 'cmdline', max_item_count = 30, }
    }),
    })

    Only when typing / or ./ etc. I get completions from (only) the path source. This is normally not necessary with :e because it assumes a relative path. The path completions provided by this source are hard to use.

Example: I have a folder ./rc in my cwd. when typing :e r i get the completion rc/ ending in a /. Now i have no possibility to get completions for the contents of the folder easily. When typing <cr> it executes the cmdline immediately. (I have set ['<CR>'] = cmp.mapping.confirm() out of personal preference). When typing / again i get completions from the path source for root. And when typing <tab> I continue cycling the completions.

To actually descend into the folder I need to do something weird like <space><backspace> to retrigger completion.

  1. Since every completion item provided by this source seems to be of the same type Variable, displaying the type is just useless. So I tried to modify the formatting option of the cmp.setup.cmdline(':', {formatting=..} but it didn't work for me.

My current formatting table

cmp.setup({
  formatting = {
    format = require('lspkind').cmp_format({
      with_text = true,
      maxwidth = 50,
      menu = {
        cmp_tabnine = '[T9]',
        vsnip = '[VSNIP]',
        path = '[PATH]',
        nvim_lsp = '[LSP]',
        nvim_lua = '[LUA]',
        buffer = '[BUF]',
        cmdline = '[CMD]',
      },
    })
  },
}

It would be nice to be able to adjust the formatting for the cmdline completion seperately.

hrsh7th commented 2 years ago

@aMOPel I think this is fixed now by latest nvim-cmp. Please re-test .

hrsh7th commented 2 years ago

The native wildmenu completion is the same behavior.