amarakon / nvim-cmp-buffer-lines

nvim-cmp completion source for buffer lines
GNU Affero General Public License v3.0
67 stars 2 forks source link

Only trigger line-completion with CTRL-X CTRL-L #12

Closed tummetott closed 11 months ago

tummetott commented 11 months ago

Hey there,

I'm wondering if it's possible to turn off automatic completion for this cmp source and instead activate it only when using a special key combination, like the native CTRL-X CTRL-L. When I trigger it manually, I'd like to see only completions from this source, and I don't want any other cmp sources to appear in the popup menu.

Thanks!

amarakon commented 11 months ago

I don’t know if this needs to be implemented in this plugin or if you can already do that with your nvim-cmp configuration. I think you should open an issue on https://github.com/hrsh7th/nvim-cmp/issues and ask about this.

tummetott commented 11 months ago

It is actually already working with the right cmp configuration. Thank you!

amarakon commented 11 months ago

Can you share your nvim-cmp configuration so that I can update the README with instructions on how to do this?

tummetott commented 11 months ago

This it how it works: Don't list the buffer-lines source in cmp-config.sources. Only create a keymap under cmp-config.mapping as follows

require('cmp').setup {
    mapping = {
        ['<C-x><C-l>'] = cmp.mapping.complete {
            config = {
                sources = {
                    {
                        name = 'buffer-lines',
                        option = { ... },
                    }
                },
            }
        }
    }
}
ricardo-jsd-santos commented 7 months ago

This was useful to me. Suggest adding it to the README.md.