Unable to make `<Plug>` calls

Hi all, I seem to be having an issue with my init.lua where the coc-rename method is not working. I have my mapping as <leader>rn and it should call <Plug>(coc-rename) which is does, but nothing happens. I have tried different variations of using :call and :CocAction but they all say there is no action associated with that. Has anyone successfully made <Plug> calls and can give some direction here?

to answer your question Shadman, I use a utility function that wraps the underlying call, but the left and right hand sides are as follows: utils.map('n', '<leader>rn', '<Plug>(coc-rename)'). Behind the scenes this is making the call that you mentioned and it is setting noremap by default.

Utils Method:

function utils.map(mode, lhs, rhs, opts)
  local options = { noremap = true }
  if opts then
    options = vim.tbl_extend('force', options, opts)
  api.nvim_set_keymap(mode, lhs, rhs, options)

Well then that’s your issue . You can’t have noremap on <Plug> mappings . noremap means don’t recursively evaluate mapings . Here that is needed as <Plug> it self is a keymap and you’re basicaly trying to create a alias to that keymap.

1 Like

Ah, I was not aware that <Plug> was a keymap. I will have to give that a try here and see if that fixes it.

Edit: This totally fixed the issue! Thanks @shadman