I am doing a vim plugin for personal use, and it triggers from toolbar.
when I click Plugin in GVIM toolbar, it create a sub menu called ‘common’.
When I click common, it start check my vim settings and create sub menu, for instance, show/hide line number. But the following code has some problem, and cannot work. What’s wrong with it?
amenu &Plugin.&Common :call <SID>createSubMenu()<CR>
fun! s:createSubMenu()
let isNum = &number
if isNum == '1'
amenu &Plugin.&Common.Hide\ Line\ &Number :set nonu
else
amenu &Plugin.&Common.Show\ Line\ &Number :set nu
endif
endfunction
——————— Resolved ———————–
The code above cannot be used. It’s completed wrong.
Please refer to Luc Hermitte’s answer.
You need to
:unmenuthe old entry to remove it.BTW, I already have a fully functional toggling/cycling engine for values, than also updates menus. It’s done with a function from lh-vim-lib, see the test file to have examples of use, and the documentation for more explanations.