diff --git a/autoload/nerdcommenter.vim b/autoload/nerdcommenter.vim index 6c81827..721923d 100644 --- a/autoload/nerdcommenter.vim +++ b/autoload/nerdcommenter.vim @@ -1298,7 +1298,7 @@ function! nerdcommenter#Comment(mode, type) range abort endfunction -" Function: NERDCommentIsCharCommented(line, col) abort +" Function: nerdcommenter#IsCharCommented(line, col) abort " Check if the character at [line, col] is inside a comment " Note the Comment delimeter it self is considered as part of the comment " @@ -1306,7 +1306,7 @@ endfunction " -line the line number of the character " -col the column number of the character " Return: Number, 1 if the character is inside a comment, 0 if is not -function! NERDCommentIsCharCommented(line, col) abort +function! nerdcommenter#IsCharCommented(line, col) abort " Function: s:searchfor(str, line, col, direction, [maxline]) " search str in the buffer, including the character at [line, col] " Args: diff --git a/plugin/nerdcommenter.vim b/plugin/nerdcommenter.vim index 33eba31..276a0ae 100644 --- a/plugin/nerdcommenter.vim +++ b/plugin/nerdcommenter.vim @@ -42,6 +42,7 @@ call s:InitVariable('g:NERDDefaultAlign', 'none') call s:InitVariable('g:NERDTrimTrailingWhitespace', 0) call s:InitVariable('g:NERDToggleCheckAllLines', 0) call s:InitVariable('g:NERDDisableTabsInBlockComm', 0) +call s:InitVariable('g:NERDSuppressWarnings', 0) " Section: Comment mapping and menu item setup " =========================================================================== @@ -78,6 +79,7 @@ function! s:CreateMaps(modes, target, desc, combo) endif endfor endfunction + call s:CreateMaps('nx', 'Comment', 'Comment', 'cc') call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c') call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm') @@ -97,6 +99,32 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '') call s:CreateMaps('', ':', '-Sep3-', '') call s:CreateMaps('', ':help NERDCommenterContents', 'Help', '') +" Shim functions so old code gets passed through to the autoload functions +function! NERDComment(mode, type) range + if !g:NERDSuppressWarnings + echom 'Function NERDComment() has been deprecated, please use nerdcommenter#Comment() instead' + endif + if a:firstline != a:lastline + echoerr "Sorry! We can't pass a range through this deprecation shim, please update your code." + return v:false + endif + return nerdcommenter#Comment(a:mode, a:type) +endfunction + +function! NERDCommentIsLineCommented(lineNo) + if !g:NERDSuppressWarnings + echom 'Function NERDCommentIsLineCommented() has been deprecated, please use nerdcommenter#IsLineCommented() instead' + endif + return nerdcommenter#IsLineCommented(a:lineNo) +endfunction + +function! NERDCommentIsCharCommented(line, col) + if !g:NERDSuppressWarnings + echom 'Function NERDCommentIsCharCommented() has been deprecated, please use nerdcommenter#IsCharCommented() instead' + endif + return nerdcommenter#IsCharCommented(a:line, a:col) +endfunction + inoremap NERDCommenterInsert :call nerdcommenter#Comment('i', "insert") " switch to/from alternative delimiters (does not use wrapper function)