mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-09 18:23:48 -05:00
essential changes ... renamed functions, added plug function; per default no mappings creation
This commit is contained in:
@@ -54,7 +54,7 @@ call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
|
|||||||
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
|
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
|
||||||
call s:InitVariable("g:NERDCommentEmptyLines", 0)
|
call s:InitVariable("g:NERDCommentEmptyLines", 0)
|
||||||
call s:InitVariable("g:NERDCompactSexyComs", 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:NERDDefaultNesting", 1)
|
||||||
call s:InitVariable("g:NERDMenuMode", 3)
|
call s:InitVariable("g:NERDMenuMode", 3)
|
||||||
call s:InitVariable("g:NERDLPlace", "[>")
|
call s:InitVariable("g:NERDLPlace", "[>")
|
||||||
@@ -1173,12 +1173,12 @@ function s:InvertComment(firstLine, lastLine)
|
|||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! NERDCommentIsLineCommented(lineNo)
|
function! nerdcommenter#IsLineCommented(lineNo)
|
||||||
let theLine = getline(a:lineNo)
|
let theLine = getline(a:lineNo)
|
||||||
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: NERDComment(mode, type) function {{{2
|
" Function: nerdcommenter#Comment(mode, type) function {{{2
|
||||||
" This function is a Wrapper for the main commenting functions
|
" This function is a Wrapper for the main commenting functions
|
||||||
"
|
"
|
||||||
" Args:
|
" Args:
|
||||||
@@ -1187,7 +1187,7 @@ endfunction
|
|||||||
" -type: the type of commenting requested. Can be 'Sexy', 'Invert',
|
" -type: the type of commenting requested. Can be 'Sexy', 'Invert',
|
||||||
" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment',
|
" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment',
|
||||||
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
|
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
|
||||||
function! NERDComment(mode, type) range
|
function! nerdcommenter#Comment(mode, type) range
|
||||||
if exists('*NERDCommenter_before')
|
if exists('*NERDCommenter_before')
|
||||||
exe "call NERDCommenter_before()"
|
exe "call NERDCommenter_before()"
|
||||||
endif
|
endif
|
||||||
@@ -1285,7 +1285,7 @@ function! NERDComment(mode, type) range
|
|||||||
else
|
else
|
||||||
normal! yy
|
normal! yy
|
||||||
endif
|
endif
|
||||||
execute firstLine .','. lastLine .'call NERDComment("'. a:mode .'", "Comment")'
|
execute firstLine .','. lastLine .'call nerdcommenter#Comment("'. a:mode .'", "Comment")'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:RecoverStateAfterLineComment(state)
|
call s:RecoverStateAfterLineComment(state)
|
||||||
@@ -2980,13 +2980,17 @@ endfunction
|
|||||||
" Section: Comment mapping and menu item setup {{{1
|
" Section: Comment mapping and menu item setup {{{1
|
||||||
" ===========================================================================
|
" ===========================================================================
|
||||||
|
|
||||||
|
function! nerdcommenter#Plug(target)
|
||||||
|
return "\<Plug>NERDCommenter". a:target
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Create menu items for the specified modes. If a:combo is not empty, then
|
" 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.
|
" also define mappings and show a:combo in the menu items.
|
||||||
function! s:CreateMaps(modes, target, desc, combo)
|
function! s:CreateMaps(modes, target, desc, combo)
|
||||||
" Build up a map command like
|
" Build up a map command like
|
||||||
" 'noremap <silent> <plug>NERDCommenterComment :call NERDComment("n", "Comment")'
|
" 'noremap <silent> <plug>NERDCommenterComment :call NERDComment("n", "Comment")'
|
||||||
let plug = '<plug>NERDCommenter' . a:target
|
let plug = '<plug>NERDCommenter' . a:target
|
||||||
let plug_start = 'noremap <silent> ' . plug . ' :call NERDComment("'
|
let plug_start = 'noremap <silent> ' . plug . ' :call nerdcommenter#Comment("'
|
||||||
let plug_end = '", "' . a:target . '")<cr>'
|
let plug_end = '", "' . a:target . '")<cr>'
|
||||||
" Build up a menu command like
|
" Build up a menu command like
|
||||||
" 'menu <silent> comment.Comment<Tab>\\cc <plug>NERDCommenterComment'
|
" 'menu <silent> comment.Comment<Tab>\\cc <plug>NERDCommenterComment'
|
||||||
@@ -3031,7 +3035,7 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '')
|
|||||||
call s:CreateMaps('', ':', '-Sep3-', '')
|
call s:CreateMaps('', ':', '-Sep3-', '')
|
||||||
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
|
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
|
||||||
|
|
||||||
inoremap <silent> <plug>NERDCommenterInsert <SPACE><BS><ESC>:call NERDComment('i', "insert")<CR>
|
inoremap <silent> <plug>NERDCommenterInsert <SPACE><BS><ESC>:call nerdcommenter#Comment('i', "insert")<CR>
|
||||||
|
|
||||||
" switch to/from alternative delimiters (does not use wrapper function)
|
" switch to/from alternative delimiters (does not use wrapper function)
|
||||||
nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>
|
nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>
|
||||||
|
|||||||
Reference in New Issue
Block a user