I have the following map helper function
local function map(mode, lhs, rhs, opts)
local options = { noremap = true, silent = true }
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.keymap.set(mode, lhs, rhs, options)
end
And I stumbled upon this config with an interesting idea, a way of pretending a string to the each mapping description, where I can use to easily debug my mappings, because there are mappings that come from plugins, from my ftplugins etc. The idea seems like this:
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
As you can see in the above case the description indicates that those mappings come from the LSP.
How can I addapt my function so I can have the same in my map helper?