'Send register name to mapped command

I made this command to send my current buffer's file path into the + register:

:nmap <Leader>yp :let @+=expand("%:p")<cr>

I'd like to extend it so that the user choose the register to send to when calling <Leader>yp, but I'm not sure how.

If there's a way to "capture the selected register", can I use it into my command to then allow something like "a<Leader>yp? Thanks!



Solution 1:[1]

Thanks to romainl comment, I came to this solution:

:nmap <Leader>yp :call setreg(v:register, expand("%:p"))<cr>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1