fine-cmdline.nvim icon indicating copy to clipboard operation
fine-cmdline.nvim copied to clipboard

Integration with nvim-cmp

Open VonHeikemen opened this issue 2 years ago • 3 comments

I'm afraid that's not possible right now. The problem is cmp-cmdline only works in commandline-mode.

The solution to this is to make cmp-cmdline work in a normal buffer. So... you (not me) would need to create a new nvim-cmp source that has the same features as cmp-cmdline.

Let's imagine you already created this new source, here is what you'll do to make it work (in theory).

local cmp = require('cmp')

require('fine-cmdline').setup({
  cmdline = {
    enable_keymaps = false
  },
  hooks = {
    after_mount = function(input)
      cmp.setup.buffer({
        sources = {
          {name = 'new-imaginary-source'}
        }
      })
    end,
    set_keymaps = function(imap, feedkeys)
      local fn = require('fine-cmdline').fn
 
      -- Restore default keybindings...
      imap('<Esc>', fn.close)
      imap('<C-c>', fn.close)

      imap('<Up>', fn.up_search_history)
      imap('<Down>', fn.down_search_history)
    end
  }
})

VonHeikemen avatar Nov 20 '21 13:11 VonHeikemen