zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.43k stars 65 forks source link

Ignore dismiss mapping when suggestion isn't visible #189

Closed MariaSolOs closed 1 year ago

MariaSolOs commented 1 year ago

I've mapped suggestion.keymap.dismiss to '/', but now that prevents me from typing '/' in insert mode. How can I properly enable the command only if a suggestion is visible?

MariaSolOs commented 1 year ago

nvm, I fixed it with the following:

vim.keymap.set('i', '/', function()
  if copilot.is_visible() then
    copilot.dismiss()
    return '<Ignore>'
  else
    return '/'
  end
end, { expr = true })

That being said, I believe that such logic should be integrated into the plugin :)

MariaSolOs commented 1 year ago

@MunifTanjim Would you be against me preparing a PR for this? :)

MunifTanjim commented 1 year ago

Nope. I'm open to merging a PR for this.