From 3ebd9b56ff7d4e7d3be2ba75c8b15a5828bcd207 Mon Sep 17 00:00:00 2001 From: Andy Wokula Date: Sun, 18 Dec 2016 17:31:06 +0100 Subject: [PATCH] essential changes ... renamed functions, added plug function; per default no mappings creation --- autoload/nerdcommenter.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autoload/nerdcommenter.vim b/autoload/nerdcommenter.vim index e8e1af9..9bd9c19 100644 --- a/autoload/nerdcommenter.vim +++ b/autoload/nerdcommenter.vim @@ -54,7 +54,7 @@ call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0) call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0) call s:InitVariable("g:NERDCommentEmptyLines", 0) call s:InitVariable("g:NERDCompactSexyComs", 0) -call s:InitVariable("g:NERDCreateDefaultMappings", 1) +call s:InitVariable("g:NERDCreateDefaultMappings", 0) call s:InitVariable("g:NERDDefaultNesting", 1) call s:InitVariable("g:NERDMenuMode", 3) call s:InitVariable("g:NERDLPlace", "[>") @@ -1173,12 +1173,12 @@ function s:InvertComment(firstLine, lastLine) endwhile endfunction -function! NERDCommentIsLineCommented(lineNo) +function! nerdcommenter#IsLineCommented(lineNo) let theLine = getline(a:lineNo) return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) endfunction -" Function: NERDComment(mode, type) function {{{2 +" Function: nerdcommenter#Comment(mode, type) function {{{2 " This function is a Wrapper for the main commenting functions " " Args: @@ -1187,7 +1187,7 @@ endfunction " -type: the type of commenting requested. Can be 'Sexy', 'Invert', " 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment', " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' -function! NERDComment(mode, type) range +function! nerdcommenter#Comment(mode, type) range if exists('*NERDCommenter_before') exe "call NERDCommenter_before()" endif @@ -1285,7 +1285,7 @@ function! NERDComment(mode, type) range else normal! yy endif - execute firstLine .','. lastLine .'call NERDComment("'. a:mode .'", "Comment")' + execute firstLine .','. lastLine .'call nerdcommenter#Comment("'. a:mode .'", "Comment")' endif call s:RecoverStateAfterLineComment(state) @@ -2980,13 +2980,17 @@ endfunction " Section: Comment mapping and menu item setup {{{1 " =========================================================================== +function! nerdcommenter#Plug(target) + return "\NERDCommenter". a:target +endfunction + " 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:CreateMaps(modes, target, desc, combo) " Build up a map command like " 'noremap NERDCommenterComment :call NERDComment("n", "Comment")' let plug = 'NERDCommenter' . a:target - let plug_start = 'noremap ' . plug . ' :call NERDComment("' + let plug_start = 'noremap ' . plug . ' :call nerdcommenter#Comment("' let plug_end = '", "' . a:target . '")' " Build up a menu command like " 'menu comment.Comment\\cc NERDCommenterComment' @@ -3031,7 +3035,7 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '') call s:CreateMaps('', ':', '-Sep3-', '') call s:CreateMaps('', ':help NERDCommenterContents', 'Help', '') -inoremap NERDCommenterInsert :call NERDComment('i', "insert") +inoremap NERDCommenterInsert :call nerdcommenter#Comment('i', "insert") " switch to/from alternative delimiters (does not use wrapper function) nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1)