mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-09 02:13:45 -05:00
Compare commits
17 Commits
doc-overha
...
2.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eddd535bdf | ||
|
|
13d00954a6 | ||
|
|
ab67976bea | ||
|
|
fa9b74ff69 | ||
|
|
a65465d321 | ||
|
|
9d5c12e126 | ||
|
|
2c87cae76e | ||
|
|
f7333809b6 | ||
|
|
576bd64482 | ||
|
|
ed591cb2a2 | ||
|
|
d398a0278c | ||
|
|
85364c56c4 | ||
|
|
b1bb758f14 | ||
|
|
eeabded555 | ||
|
|
918592cdc6 | ||
|
|
8e935a6367 | ||
|
|
f21b0f8fab |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
### 2.6.0
|
||||||
|
|
||||||
|
* Refactor code to run as autoload plugin
|
||||||
|
* Add lots of community contributed file types
|
||||||
|
* Fix several languages with idiosyncrasies
|
||||||
|
* Improve interoperability with other vim settings
|
||||||
|
* Improve handling of ranges
|
||||||
|
* Improve help documentation
|
||||||
|
* Cleanup and fix vimscript issues
|
||||||
|
|
||||||
### 2.5.2
|
### 2.5.2
|
||||||
|
|
||||||
* Minor update to include new file types contributed by the community over the last few months.
|
* Minor update to include new file types contributed by the community over the last few months.
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ let s:delimiterMap = {
|
|||||||
\ 'exports': { 'left': '#' },
|
\ 'exports': { 'left': '#' },
|
||||||
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
|
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
|
||||||
\ 'fancy': { 'left': '#' },
|
\ 'fancy': { 'left': '#' },
|
||||||
|
\ 'fasm': { 'left': ';' },
|
||||||
\ 'faust': { 'left': '//' },
|
\ 'faust': { 'left': '//' },
|
||||||
\ 'fgl': { 'left': '#' },
|
\ 'fgl': { 'left': '#' },
|
||||||
\ 'fluent': { 'left': '#', 'leftAlt': '##' },
|
\ 'fluent': { 'left': '#', 'leftAlt': '##' },
|
||||||
@@ -187,6 +188,7 @@ let s:delimiterMap = {
|
|||||||
\ 'jgraph': { 'left': '(*', 'right': '*)' },
|
\ 'jgraph': { 'left': '(*', 'right': '*)' },
|
||||||
\ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' },
|
\ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' },
|
||||||
\ 'jproperties': { 'left': '#' },
|
\ 'jproperties': { 'left': '#' },
|
||||||
|
\ 'json5': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
|
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
|
||||||
@@ -506,8 +508,8 @@ function! s:CreateDelimMapFromCms() abort
|
|||||||
return delims
|
return delims
|
||||||
endif
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''),
|
\ 'left': matchstr(&commentstring, '^\S*\ze\s*%s'),
|
||||||
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
|
\ 'right': matchstr(&commentstring, '%s\s*\zs.*$'),
|
||||||
\ 'nested': 0,
|
\ 'nested': 0,
|
||||||
\ 'leftAlt': '',
|
\ 'leftAlt': '',
|
||||||
\ 'rightAlt': '',
|
\ 'rightAlt': '',
|
||||||
@@ -651,7 +653,7 @@ function! s:CommentBlock(top, bottom, lSide, rSide, forceNested) abort
|
|||||||
"alternative delimiters (if THEY are) as the comment will be better and more
|
"alternative delimiters (if THEY are) as the comment will be better and more
|
||||||
"accurate with multipart delimiters
|
"accurate with multipart delimiters
|
||||||
let switchedDelims = 0
|
let switchedDelims = 0
|
||||||
if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart()
|
if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart()
|
||||||
let switchedDelims = 1
|
let switchedDelims = 1
|
||||||
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
||||||
endif
|
endif
|
||||||
@@ -1068,7 +1070,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
|
|||||||
|
|
||||||
"switch delimiters (if we can) if the current set isn't multipart
|
"switch delimiters (if we can) if the current set isn't multipart
|
||||||
let switchedDelims = 0
|
let switchedDelims = 0
|
||||||
if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims
|
if !s:Multipart() && s:AltMultipart() && g:NERDAllowAnyVisualDelims
|
||||||
let switchedDelims = 1
|
let switchedDelims = 1
|
||||||
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
||||||
endif
|
endif
|
||||||
@@ -1091,7 +1093,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
|
|||||||
|
|
||||||
"comment the bottom line
|
"comment the bottom line
|
||||||
let bottom = getline(a:bottomLine)
|
let bottom = getline(a:bottomLine)
|
||||||
let numLeadingSpacesTabs = strlen(substitute(bottom, '^\([ \t]*\).*$', '\1', ''))
|
let numLeadingSpacesTabs = strlen(matchstr(bottom, '^\s*'))
|
||||||
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
@@ -1236,7 +1238,7 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
for i in range(firstLine, lastLine)
|
for i in range(firstLine, lastLine)
|
||||||
let theLine = getline(i)
|
let theLine = getline(i)
|
||||||
" if have one line no comment(not include blank/whitespace-only lines), then comment all lines
|
" if have one line no comment(not include blank/whitespace-only lines), then comment all lines
|
||||||
if theLine =~# '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
if theLine =~# '\S\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||||
let l:commentAllLines = 1
|
let l:commentAllLines = 1
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
@@ -1259,9 +1261,9 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
endtry
|
endtry
|
||||||
|
|
||||||
elseif a:type ==? 'ToEOL'
|
elseif a:type ==? 'ToEOL'
|
||||||
call s:SaveScreenState()
|
let view = winsaveview()
|
||||||
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
||||||
call s:RestoreScreenState()
|
call winrestview(view)
|
||||||
|
|
||||||
elseif a:type ==? 'Append'
|
elseif a:type ==? 'Append'
|
||||||
call s:AppendCommentToLine()
|
call s:AppendCommentToLine()
|
||||||
@@ -1298,7 +1300,7 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: NERDCommentIsCharCommented(line, col) abort
|
" Function: nerdcommenter#IsCharCommented(line, col) abort
|
||||||
" Check if the character at [line, col] is inside a comment
|
" Check if the character at [line, col] is inside a comment
|
||||||
" Note the Comment delimeter it self is considered as part of the comment
|
" Note the Comment delimeter it self is considered as part of the comment
|
||||||
"
|
"
|
||||||
@@ -1306,7 +1308,7 @@ endfunction
|
|||||||
" -line the line number of the character
|
" -line the line number of the character
|
||||||
" -col the column 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
|
" 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])
|
" Function: s:searchfor(str, line, col, direction, [maxline])
|
||||||
" search str in the buffer, including the character at [line, col]
|
" search str in the buffer, including the character at [line, col]
|
||||||
" Args:
|
" Args:
|
||||||
@@ -1671,7 +1673,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
let theLine = getline(a:topline)
|
let theLine = getline(a:topline)
|
||||||
|
|
||||||
" if the first line contains only the left delimiter then just delete it
|
" if the first line contains only the left delimiter then just delete it
|
||||||
if theLine =~# '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs
|
if theLine =~# '^\s*' . left . '\s*$' && !g:NERDCompactSexyComs
|
||||||
call cursor(a:topline, 1)
|
call cursor(a:topline, 1)
|
||||||
normal! dd
|
normal! dd
|
||||||
let bottomline = bottomline - 1
|
let bottomline = bottomline - 1
|
||||||
@@ -1695,7 +1697,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
let theLine = getline(bottomline)
|
let theLine = getline(bottomline)
|
||||||
|
|
||||||
" if the bottomline contains only the right delimiter then just delete it
|
" if the bottomline contains only the right delimiter then just delete it
|
||||||
if theLine =~# '^[ \t]*' . right . '[ \t]*$'
|
if theLine =~# '^\s*' . right . '\s*$'
|
||||||
call cursor(bottomline, 1)
|
call cursor(bottomline, 1)
|
||||||
normal! dd
|
normal! dd
|
||||||
|
|
||||||
@@ -1712,7 +1714,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
|
|
||||||
" if the last line also starts with a sexy comment marker then we
|
" if the last line also starts with a sexy comment marker then we
|
||||||
" remove this as well
|
" remove this as well
|
||||||
if theLine =~# '^[ \t]*' . sexyComMarker
|
if theLine =~# '^\s*' . sexyComMarker
|
||||||
|
|
||||||
" remove the sexyComMarker. If there is a space after it then
|
" remove the sexyComMarker. If there is a space after it then
|
||||||
" remove that too
|
" remove that too
|
||||||
@@ -1836,7 +1838,7 @@ endfunction
|
|||||||
" Function: s:AddLeftDelim(delim, theLine)
|
" Function: s:AddLeftDelim(delim, theLine)
|
||||||
" Args:
|
" Args:
|
||||||
function! s:AddLeftDelim(delim, theLine) abort
|
function! s:AddLeftDelim(delim, theLine) abort
|
||||||
return substitute(a:theLine, '^\([ \t]*\)', '\1' . a:delim, '')
|
return substitute(a:theLine, '^\(\s*\)', '\1' . a:delim, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:AddLeftDelimAligned(delim, theLine)
|
" Function: s:AddLeftDelimAligned(delim, theLine)
|
||||||
@@ -1906,7 +1908,7 @@ function! s:CanCommentLine(forceNested, lineNum) abort
|
|||||||
|
|
||||||
" make sure we don't comment lines that are just spaces or tabs or empty,
|
" make sure we don't comment lines that are just spaces or tabs or empty,
|
||||||
" unless configured otherwise
|
" unless configured otherwise
|
||||||
if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$"
|
if g:NERDCommentEmptyLines ==# 0 && theLine =~# '^\s*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1973,7 +1975,7 @@ function! s:CanToggleCommentLine(forceNested, lineNum) abort
|
|||||||
|
|
||||||
" make sure we don't comment lines that are just spaces or tabs or empty,
|
" make sure we don't comment lines that are just spaces or tabs or empty,
|
||||||
" unless configured otherwise
|
" unless configured otherwise
|
||||||
if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$"
|
if g:NERDCommentEmptyLines ==# 0 && theLine =~# '^\s*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2194,16 +2196,16 @@ function! s:FindBoundingLinesOfSexyCom(lineNum) abort
|
|||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
|
|
||||||
"check if the current line is the top of the sexy comment
|
"check if the current line is the top of the sexy comment
|
||||||
if currentLine <= a:lineNum && theLine =~# '^[ \t]*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf()
|
if currentLine <= a:lineNum && theLine =~# '^\s*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf()
|
||||||
let top = currentLine
|
let top = currentLine
|
||||||
let currentLine = a:lineNum
|
let currentLine = a:lineNum
|
||||||
|
|
||||||
"check if the current line is the bottom of the sexy comment
|
"check if the current line is the bottom of the sexy comment
|
||||||
elseif theLine =~# '^[ \t]*' . right && theLine !~# '.*' . left && currentLine > 1
|
elseif theLine =~# '^\s*' . right && theLine !~# '.*' . left && currentLine > 1
|
||||||
let bottom = currentLine
|
let bottom = currentLine
|
||||||
|
|
||||||
"the right delimiter is on the same line as the last sexyComMarker
|
"the right delimiter is on the same line as the last sexyComMarker
|
||||||
elseif theLine =~# '^[ \t]*' . sexyComMarker . '.*' . right
|
elseif theLine =~# '^\s*' . sexyComMarker . '.*' . right
|
||||||
let bottom = currentLine
|
let bottom = currentLine
|
||||||
|
|
||||||
"we have not found the top or bottom line so we assume currentLine is an
|
"we have not found the top or bottom line so we assume currentLine is an
|
||||||
@@ -2212,7 +2214,7 @@ function! s:FindBoundingLinesOfSexyCom(lineNum) abort
|
|||||||
|
|
||||||
"if the line doesn't start with a sexyComMarker then it is not a sexy
|
"if the line doesn't start with a sexyComMarker then it is not a sexy
|
||||||
"comment
|
"comment
|
||||||
if theLine !~# '^[ \t]*' . sexyComMarker
|
if theLine !~# '^\s*' . sexyComMarker
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2450,7 +2452,7 @@ endfunction
|
|||||||
" -left: the left delimiter to check for
|
" -left: the left delimiter to check for
|
||||||
function! s:IsCommentedFromStartOfLine(left, line) abort
|
function! s:IsCommentedFromStartOfLine(left, line) abort
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
||||||
let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', ''))
|
let numSpaces = strlen(matchstr(theLine, '^ *'))
|
||||||
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
||||||
return delimIndx ==# numSpaces
|
return delimIndx ==# numSpaces
|
||||||
endfunction
|
endfunction
|
||||||
@@ -2552,7 +2554,7 @@ function! s:IsDelimValid(delimiter, delIndx, line) abort
|
|||||||
|
|
||||||
"if the delimiter is on the very first char of the line or is the
|
"if the delimiter is on the very first char of the line or is the
|
||||||
"first non-tab/space char on the line then it is a valid comment delimiter
|
"first non-tab/space char on the line then it is a valid comment delimiter
|
||||||
if a:delIndx ==# 0 || a:line =~# "^[ \t]\\{" . a:delIndx . "\\}\".*$"
|
if a:delIndx ==# 0 || a:line =~# "^\s\\{" . a:delIndx . "\\}\".*$"
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2653,7 +2655,7 @@ function! s:IsSexyComment(topline, bottomline) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"if the top line doesn't begin with a left delimiter then the comment isn't sexy
|
"if the top line doesn't begin with a left delimiter then the comment isn't sexy
|
||||||
if getline(a:topline) !~# '^[ \t]*' . left
|
if getline(a:topline) !~# '^\s*' . left
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2681,7 +2683,7 @@ function! s:IsSexyComment(topline, bottomline) abort
|
|||||||
while currentLine < a:bottomline
|
while currentLine < a:bottomline
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
|
|
||||||
if theLine !~# '^[ \t]*' . sexyComMarker
|
if theLine !~# '^\s*' . sexyComMarker
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2780,12 +2782,12 @@ function! s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomli
|
|||||||
" get the next line and if it is allowed to be commented, or is not
|
" get the next line and if it is allowed to be commented, or is not
|
||||||
" commented, check it
|
" commented, check it
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
if a:countEmptyLines || theLine !~# '^[ \t]*$'
|
if a:countEmptyLines || theLine !~# '^\s*$'
|
||||||
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
||||||
" convert spaces to tabs and get the number of leading spaces for
|
" convert spaces to tabs and get the number of leading spaces for
|
||||||
" this line and update leftMostIndx if need be
|
" this line and update leftMostIndx if need be
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
||||||
let leadSpaceOfLine = strlen( substitute(theLine, '\(^[ \t]*\).*$','\1','') )
|
let leadSpaceOfLine = strlen(matchstr(theLine, '^\s*'))
|
||||||
if leadSpaceOfLine < leftMostIndx
|
if leadSpaceOfLine < leftMostIndx
|
||||||
let leftMostIndx = leadSpaceOfLine
|
let leftMostIndx = leadSpaceOfLine
|
||||||
endif
|
endif
|
||||||
@@ -2833,7 +2835,7 @@ endfunction
|
|||||||
" Function: s:NumberOfLeadingTabs(s)
|
" Function: s:NumberOfLeadingTabs(s)
|
||||||
" returns the number of leading tabs in the given string
|
" returns the number of leading tabs in the given string
|
||||||
function! s:NumberOfLeadingTabs(s) abort
|
function! s:NumberOfLeadingTabs(s) abort
|
||||||
return strlen(substitute(a:s, '^\(\t*\).*$', '\1', ''))
|
return strlen(matchstr(a:s, '^\t*'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:NumLinesInBuf()
|
" Function: s:NumLinesInBuf()
|
||||||
@@ -2907,21 +2909,6 @@ function! s:ReplaceRightMostDelim(toReplace, replacor, str) abort
|
|||||||
return line
|
return line
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:RestoreScreenState()
|
|
||||||
"
|
|
||||||
"Sets the screen state back to what it was when s:SaveScreenState was last
|
|
||||||
"called.
|
|
||||||
"
|
|
||||||
function! s:RestoreScreenState() abort
|
|
||||||
if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos')
|
|
||||||
throw 'NERDCommenter exception: cannot restore screen'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call cursor(t:NERDComOldTopLine, 0)
|
|
||||||
normal! zt
|
|
||||||
call setpos('.', t:NERDComOldPos)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:Right(...)
|
" Function: s:Right(...)
|
||||||
" returns right delimiter data
|
" returns right delimiter data
|
||||||
function! s:Right(...) abort
|
function! s:Right(...) abort
|
||||||
@@ -2963,7 +2950,7 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml
|
|||||||
" get the next line and see if it is commentable, otherwise it doesn't
|
" get the next line and see if it is commentable, otherwise it doesn't
|
||||||
" count
|
" count
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
if a:countEmptyLines || theLine !~# '^[ \t]*$'
|
if a:countEmptyLines || theLine !~# '^\s*$'
|
||||||
|
|
||||||
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
||||||
|
|
||||||
@@ -2983,14 +2970,6 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml
|
|||||||
return rightMostIndx
|
return rightMostIndx
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:SaveScreenState()
|
|
||||||
"Saves the current cursor position in the current buffer and the window
|
|
||||||
"scroll position
|
|
||||||
function! s:SaveScreenState() abort
|
|
||||||
let t:NERDComOldPos = getpos('.')
|
|
||||||
let t:NERDComOldTopLine = line('w0')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line)
|
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line)
|
||||||
" This function takes a line and swaps the outer most multi-part delimiters for
|
" This function takes a line and swaps the outer most multi-part delimiters for
|
||||||
" place holders
|
" place holders
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ call s:InitVariable('g:NERDDefaultAlign', 'none')
|
|||||||
call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
|
call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
|
||||||
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
|
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
|
||||||
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
|
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
|
||||||
|
call s:InitVariable('g:NERDSuppressWarnings', 0)
|
||||||
|
|
||||||
" Section: Comment mapping and menu item setup
|
" Section: Comment mapping and menu item setup
|
||||||
" ===========================================================================
|
" ===========================================================================
|
||||||
@@ -78,6 +79,7 @@ function! s:CreateMaps(modes, target, desc, combo)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
|
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', 'Minimal', 'Minimal', 'cm')
|
||||||
@@ -97,6 +99,32 @@ 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', '')
|
||||||
|
|
||||||
|
" 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 <silent> <Plug>NERDCommenterInsert <Space><BS><Esc>:call nerdcommenter#Comment('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)
|
||||||
|
|||||||
Reference in New Issue
Block a user