19 Commits

Author SHA1 Message Date
Andy Wokula
f0d58015ca restored scrooloose's original readme 2019-05-01 14:41:38 +02:00
Andy Wokula
c888c82828 fix startup init omitted for empty filetype (my bad) 2019-05-01 11:30:13 +02:00
Andy Wokula
20f9e88395 Merge remote-tracking branch 'upstream/master'
Ignored changes in other README!
2019-04-30 19:55:23 +02:00
Andy Wokula
8718240a51 merge remote-tracking branch 'upstream/master' 2018-02-18 21:50:16 +01:00
Andy Wokula
f18bb5b223 Merge remote-tracking branch 'upstream/master' 2017-11-10 21:03:42 +01:00
Andy Wokula
9d1b1d5827 one more menu mode 2017-11-01 20:51:50 +01:00
Andy Wokula
14004e00e0 more cautious init check 2017-11-01 20:50:25 +01:00
Andy Wokula
c5bf6053f3 use string() 2017-11-01 20:45:36 +01:00
Andy Wokula
5fce03e259 Merge remote-tracking branch 'upstream/master' 2017-11-01 20:33:56 +01:00
Andy Wokula
e935614365 Merge remote-tracking branch 'upstream/master' 2017-04-08 19:25:33 +02:00
Andy Wokula
9b5b930b72 Merge remote-tracking branch 'upstream/master' 2017-03-31 21:13:38 +02:00
Andy Wokula
398a3e22a4 indent 2016-12-18 17:57:29 +01:00
Andy Wokula
b4827d552e readme 2016-12-18 17:54:51 +01:00
Andy Wokula
0b2a2b0641 style: changed case in keycodes 2016-12-18 17:39:03 +01:00
Andy Wokula
cb8527ed3f fix comments 2016-12-18 17:37:07 +01:00
Andy Wokula
032143ad23 no default mappings at all 2016-12-18 17:34:36 +01:00
Andy Wokula
f5571fd82f autoload scripts don't need loading guards, and Vim7 is implied 2016-12-18 17:32:45 +01:00
Andy Wokula
3ebd9b56ff essential changes ... renamed functions, added plug function; per default no mappings creation 2016-12-18 17:31:06 +01:00
Andy Wokula
80eb7ff3fd moved plugin file to autoload 2016-12-18 17:22:11 +01:00

View File

@@ -1,5 +1,5 @@
" ============================================================================
" File: NERD_commenter.vim
" File: nerdcommenter.vim
" Description: vim global plugin that provides easy code commenting
" Author: Martin Grenfell <martin.grenfell at gmail dot com>
" Maintainer: Caleb Maclennan <caleb@alerque.com>
@@ -14,14 +14,7 @@
" ============================================================================
" Section: script init stuff {{{1
if exists("loaded_nerd_comments")
finish
endif
if v:version < 700
echoerr "NERDCommenter: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
finish
endif
let loaded_nerd_comments = 1
let nerdcommenter#loaded = 1
" Function: s:InitVariable() function {{{2
" This function is used to initialise a given variable to a given value. The
@@ -35,7 +28,7 @@ let loaded_nerd_comments = 1
" 1 if the var is set, 0 otherwise
function s:InitVariable(var, value)
if !exists(a:var)
execute 'let ' . a:var . ' = ' . "'" . a:value . "'"
execute 'let ' . a:var . ' = ' . string(a:value)
return 1
endif
return 0
@@ -54,7 +47,6 @@ 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:NERDDefaultNesting", 1)
call s:InitVariable("g:NERDMenuMode", 3)
call s:InitVariable("g:NERDLPlace", "[>")
@@ -1196,12 +1188,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:
@@ -1210,7 +1202,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
@@ -1325,7 +1317,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)
@@ -3020,17 +3012,21 @@ endfunction
" 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
" 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 <silent> <plug>NERDCommenterComment :call NERDComment("n", "Comment")'
let plug = '<plug>NERDCommenter' . a:target
let plug_start = 'noremap <silent> ' . plug . ' :call NERDComment("'
let plug_end = '", "' . a:target . '")<cr>'
" 'noremap <silent> <Plug>NERDCommenterComment :call nerdcommenter#Comment("n", "Comment")'
let plug = '<Plug>NERDCommenter' . a:target
let plug_start = 'noremap <silent> ' . plug . ' :call nerdcommenter#Comment("'
let plug_end = '", "' . a:target . '")<CR>'
" Build up a menu command like
" 'menu <silent> comment.Comment<Tab>\\cc <plug>NERDCommenterComment'
let menuRoot = get(['', 'comment', '&comment', '&Plugin.&comment'],
" 'menu <silent> comment.Comment<Tab>\\cc <Plug>NERDCommenterComment'
let menuRoot = get(['', 'comment', '&comment', '&Plugin.&comment', '&Plugin.Nerd\ &Commenter'],
\ g:NERDMenuMode, '')
let menu_command = 'menu <silent> ' . menuRoot . '.' . escape(a:desc, ' ')
if strlen(a:combo)
@@ -3042,9 +3038,6 @@ function! s:CreateMaps(modes, target, desc, combo)
for mode in (a:modes == '') ? [''] : split(a:modes, '\zs')
if strlen(a:combo)
execute mode . plug_start . mode . plug_end
if g:NERDCreateDefaultMappings && !hasmapto(plug, mode)
execute mode . 'map <leader>' . a:combo . ' ' . plug
endif
endif
" Check if the user wants the menu to be displayed.
if g:NERDMenuMode != 0
@@ -3053,7 +3046,7 @@ function! s:CreateMaps(modes, target, desc, combo)
endfor
endfunction
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<space>')
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<Space>')
call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm')
call s:CreateMaps('nx', 'Nested', 'Nested', 'cn')
call s:CreateMaps('n', 'ToEOL', 'To EOL', 'c$')
@@ -3071,13 +3064,15 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '')
call s:CreateMaps('', ':', '-Sep3-', '')
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)
nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>
nnoremap <Plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<CR>
" This is a workaround to enable lazy-loading from supported plugin managers:
" See https://github.com/scrooloose/nerdcommenter/issues/176
if !has('vim_starting')
call s:SetUpForNewFiletype(&filetype, 1)
endif
" vim: set foldmethod=marker :