From 0bb5f7e8894974d228cd5105a870d3503a8fa64b Mon Sep 17 00:00:00 2001 From: Benji Fisher Date: Tue, 6 Dec 2011 11:29:25 -0500 Subject: [PATCH] Removed s:CreateMaps(), adding its functionality to s:CreateMenuItems(). --- plugin/NERD_commenter.vim | 107 ++++++++++++++------------------------ 1 file changed, 40 insertions(+), 67 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 084781b..c8b5349 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -3,7 +3,7 @@ " Description: vim global plugin that provides easy code commenting " Maintainer: Martin Grenfell " Version: 2.3.0 -" Last Change: Tue Dec 06 10:00 AM 2011 Eastern Standard Time +" Last Change: Tue Dec 06 11:00 AM 2011 Eastern Standard Time " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -2746,74 +2746,47 @@ nmap NERDCommenterAppend :call NERDComment(0, "append") " insert comments inoremap NERDCommenterInInsert :call NERDComment(0, "insert") - -function! s:CreateMaps(target, combo) - if !hasmapto(a:target, 'n') - exec 'nmap ' . a:combo . ' ' . a:target - endif - - if !hasmapto(a:target, 'v') - exec 'vmap ' . a:combo . ' ' . a:target - endif -endfunction - -if g:NERDCreateDefaultMappings - call s:CreateMaps('NERDCommenterComment', 'cc') - call s:CreateMaps('NERDCommenterToggle', 'c') - call s:CreateMaps('NERDCommenterMinimal', 'cm') - call s:CreateMaps('NERDCommenterNest', 'cn') - call s:CreateMaps('NERDCommenterToEOL', 'c$') - call s:CreateMaps('NERDCommenterInvert', 'ci') - call s:CreateMaps('NERDCommenterSexy', 'cs') - call s:CreateMaps('NERDCommenterYank', 'cy') - call s:CreateMaps('NERDCommenterAppend', 'cA') - call s:CreateMaps('NERDCommenterAlignLeft', 'cl') - call s:CreateMaps('NERDCommenterAlignBoth', 'cb') - call s:CreateMaps('NERDCommenterUncomment', 'cu') - - if !hasmapto('NERDCommenterAltDelims', 'n') - nmap ca NERDCommenterAltDelims - endif -endif - - - " Section: Menu item setup {{{1 " =========================================================================== -"check if the user wants the menu to be displayed -if g:NERDMenuMode != 0 - function! s:CreateMenuItems(modes, target, desc, combo) - let menuRoot = get(['', 'comment', '&comment', '&Plugin.&comment'], - \ g:NERDMenuMode, '') - let command = 'menu ' . menuRoot . '.' . escape(a:desc, ' ') - let leader = escape(exists('mapleader') ? mapleader : '\', '\') - if strlen(a:combo) - let command .= '' . leader . a:combo - endif - let command .= ' ' . a:target - let modes = (a:modes == '') ? [''] : split(a:modes, '\zs') - for mode in modes +" Create menu items for the specified modes. If a:combo is not empty, then +" also define mappings and show a:combo in the menu items. +function! s:CreateMenuItems(modes, target, desc, combo) + let menuRoot = get(['', 'comment', '&comment', '&Plugin.&comment'], + \ g:NERDMenuMode, '') + let leader = escape(exists('mapleader') ? mapleader : '\', '\') + let command = 'menu ' . menuRoot . '.' . escape(a:desc, ' ') + if strlen(a:combo) + let command .= '' . leader . a:combo + endif + let command .= ' ' . a:target + for mode in (a:modes == '') ? [''] : split(a:modes, '\zs') + if g:NERDCreateDefaultMappings + \ && strlen(a:combo) && !hasmapto(a:target, mode) + exec mode . 'map ' . a:combo . ' ' . a:target + endif + "check if the user wants the menu to be displayed + if g:NERDMenuMode != 0 exec mode . command - endfor - endfunction - call s:CreateMenuItems('nv', 'NERDCommenterComment', 'Comment', 'cc') - call s:CreateMenuItems('nv', 'NERDCommenterToggle', 'Toggle', 'c') - call s:CreateMenuItems('nv', 'NERDCommenterMinimal', 'Minimal', 'cm') - call s:CreateMenuItems('nv', 'NERDCommenterNest', 'Nested', 'cn') - call s:CreateMenuItems('n', 'NERDCommenterToEOL', 'To EOL', 'c$') - call s:CreateMenuItems('nv', 'NERDCommenterInvert', 'Invert', 'ci') - call s:CreateMenuItems('nv', 'NERDCommenterSexy', 'Sexy', 'cs') - call s:CreateMenuItems('nv', 'NERDCommenterYank', 'Yank then comment', 'cy') - call s:CreateMenuItems('n', 'NERDCommenterAppend', 'Append', 'cA') - call s:CreateMenuItems('', ':', '-Sep-', '') - call s:CreateMenuItems('nv', 'NERDCommenterAlignLeft', 'Left aligned', 'cl') - call s:CreateMenuItems('nv', 'NERDCommenterAlignBoth', 'Left and right aligned', 'cb') - call s:CreateMenuItems('', ':', '-Sep2-', '') - call s:CreateMenuItems('nv', 'NERDCommenterUncomment', 'Uncomment', 'cu') - call s:CreateMenuItems('n', 'NERDCommenterAltDelims', 'Switch Delimiters', 'ca') - call s:CreateMenuItems('i', 'NERDCommenterInInsert', 'Insert Comment Here', '') - call s:CreateMenuItems('', ':', '-Sep3-', '') - call s:CreateMenuItems('', ':help NERDCommenterContents', 'Help', '') -endif + endif + endfor +endfunction +call s:CreateMenuItems('nv', 'NERDCommenterComment', 'Comment', 'cc') +call s:CreateMenuItems('nv', 'NERDCommenterToggle', 'Toggle', 'c') +call s:CreateMenuItems('nv', 'NERDCommenterMinimal', 'Minimal', 'cm') +call s:CreateMenuItems('nv', 'NERDCommenterNest', 'Nested', 'cn') +call s:CreateMenuItems('n', 'NERDCommenterToEOL', 'To EOL', 'c$') +call s:CreateMenuItems('nv', 'NERDCommenterInvert', 'Invert', 'ci') +call s:CreateMenuItems('nv', 'NERDCommenterSexy', 'Sexy', 'cs') +call s:CreateMenuItems('nv', 'NERDCommenterYank', 'Yank then comment', 'cy') +call s:CreateMenuItems('n', 'NERDCommenterAppend', 'Append', 'cA') +call s:CreateMenuItems('', ':', '-Sep-', '') +call s:CreateMenuItems('nv', 'NERDCommenterAlignLeft', 'Left aligned', 'cl') +call s:CreateMenuItems('nv', 'NERDCommenterAlignBoth', 'Left and right aligned', 'cb') +call s:CreateMenuItems('', ':', '-Sep2-', '') +call s:CreateMenuItems('nv', 'NERDCommenterUncomment', 'Uncomment', 'cu') +call s:CreateMenuItems('n', 'NERDCommenterAltDelims', 'Switch Delimiters', 'ca') +call s:CreateMenuItems('i', 'NERDCommenterInInsert', 'Insert Comment Here', '') +call s:CreateMenuItems('', ':', '-Sep3-', '') +call s:CreateMenuItems('', ':help NERDCommenterContents', 'Help', '') " vim: set foldmethod=marker :