mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-12 19:53:47 -05:00
Merge remote-tracking branch 'upstream/master'
Ignored changes in other README!
This commit is contained in:
@@ -57,6 +57,8 @@ call s:InitVariable("g:NERDRPlace", "<]")
|
||||
call s:InitVariable("g:NERDSpaceDelims", 0)
|
||||
call s:InitVariable("g:NERDDefaultAlign", "none")
|
||||
call s:InitVariable("g:NERDTrimTrailingWhitespace", 0)
|
||||
call s:InitVariable("g:NERDToggleCheckAllLines", 0)
|
||||
call s:InitVariable("g:NERDDisableTabsInBlockComm", 0)
|
||||
|
||||
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
|
||||
|
||||
@@ -135,7 +137,7 @@ let s:delimiterMap = {
|
||||
\ 'desktop': { 'left': '#' },
|
||||
\ 'dhcpd': { 'left': '#' },
|
||||
\ 'diff': { 'left': '#' },
|
||||
\ 'django': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
|
||||
\ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' },
|
||||
\ 'dns': { 'left': ';' },
|
||||
\ 'docbk': { 'left': '<!--', 'right': '-->' },
|
||||
\ 'dockerfile': { 'left': '#' },
|
||||
@@ -163,6 +165,7 @@ let s:delimiterMap = {
|
||||
\ 'exports': { 'left': '#' },
|
||||
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
|
||||
\ 'fancy': { 'left': '#' },
|
||||
\ 'faust': { 'left': '//' },
|
||||
\ 'fgl': { 'left': '#' },
|
||||
\ 'focexec': { 'left': '-*' },
|
||||
\ 'form': { 'left': '*' },
|
||||
@@ -197,7 +200,7 @@ let s:delimiterMap = {
|
||||
\ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'haml': { 'left': '-#', 'leftAlt': '/' },
|
||||
\ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' },
|
||||
\ 'haskell': { 'left': '{-', 'right': '-}', 'nested': 1, 'leftAlt': '--', 'nestedAlt': 1 },
|
||||
\ 'haskell': { 'left': '--', 'nested': 0, 'leftAlt': '{-', 'rightAlt': '-}', 'nestedAlt': 1 },
|
||||
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'hb': { 'left': '#' },
|
||||
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
|
||||
@@ -206,7 +209,7 @@ let s:delimiterMap = {
|
||||
\ 'hog': { 'left': '#' },
|
||||
\ 'hostsaccess': { 'left': '#' },
|
||||
\ 'htmlcheetah': { 'left': '##' },
|
||||
\ 'htmldjango': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
|
||||
\ 'htmldjango': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' },
|
||||
\ 'htmlos': { 'left': '#', 'right': '/#' },
|
||||
\ 'hxml': { 'left': '#' },
|
||||
\ 'hyphy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
@@ -232,6 +235,7 @@ let s:delimiterMap = {
|
||||
\ 'jproperties': { 'left': '#' },
|
||||
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
|
||||
\ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
|
||||
\ 'kivy': { 'left': '#' },
|
||||
\ 'kix': { 'left': ';' },
|
||||
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'lace': { 'left': '--' },
|
||||
@@ -273,7 +277,6 @@ let s:delimiterMap = {
|
||||
\ 'mkd': { 'left': '<!---', 'right': '-->' },
|
||||
\ 'mma': { 'left': '(*', 'right': '*)' },
|
||||
\ 'model': { 'left': '$', 'right': '$' },
|
||||
\ 'moduala.': { 'left': '(*', 'right': '*)' },
|
||||
\ 'modula2': { 'left': '(*', 'right': '*)' },
|
||||
\ 'modula3': { 'left': '(*', 'right': '*)' },
|
||||
\ 'molpro': { 'left': '!' },
|
||||
@@ -355,7 +358,7 @@ let s:delimiterMap = {
|
||||
\ 'robot': { 'left': '#' },
|
||||
\ 'robots': { 'left': '#' },
|
||||
\ 'rspec': { 'left': '#' },
|
||||
\ 'ruby': { 'left': '#', 'leftAlt': '=begin', 'rightAlt': '=end' },
|
||||
\ 'ruby': { 'left': '#' },
|
||||
\ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'sa': { 'left': '--' },
|
||||
\ 'samba': { 'left': ';', 'leftAlt': '#' },
|
||||
@@ -367,6 +370,7 @@ let s:delimiterMap = {
|
||||
\ 'scons': { 'left': '#' },
|
||||
\ 'scsh': { 'left': ';' },
|
||||
\ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'sdc': { 'left': '#' },
|
||||
\ 'sed': { 'left': '#' },
|
||||
\ 'sgmldecl': { 'left': '--', 'right': '--' },
|
||||
\ 'sgmllnx': { 'left': '<!--', 'right': '-->' },
|
||||
@@ -421,7 +425,7 @@ let s:delimiterMap = {
|
||||
\ 'tex': { 'left': '%' },
|
||||
\ 'texinfo': { 'left': "@c " },
|
||||
\ 'texmf': { 'left': '%' },
|
||||
\ 'tf': { 'left': ';' },
|
||||
\ 'tf': { 'left': '#' },
|
||||
\ 'tidy': { 'left': '#' },
|
||||
\ 'tli': { 'left': '#' },
|
||||
\ 'tmux': { 'left': '#' },
|
||||
@@ -986,7 +990,11 @@ function s:CommentLinesSexy(topline, bottomline)
|
||||
" the lines down when we added the left delimiter
|
||||
call cursor(a:bottomline+1, 1)
|
||||
execute 'normal! o'
|
||||
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right
|
||||
if g:NERDDisableTabsInBlockComm
|
||||
let theLine = repeat(' ', leftAlignIndx) . right
|
||||
else
|
||||
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right
|
||||
endif
|
||||
|
||||
" Make sure tabs are respected
|
||||
if !&expandtab
|
||||
@@ -1012,7 +1020,11 @@ function s:CommentLinesSexy(topline, bottomline)
|
||||
endif
|
||||
|
||||
" add the sexyComMarker
|
||||
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
|
||||
if g:NERDDisableTabsInBlockComm
|
||||
let theLine = repeat(' ', leftAlignIndx) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
|
||||
else
|
||||
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
|
||||
endif
|
||||
|
||||
if lineHasTabs
|
||||
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
|
||||
@@ -1249,12 +1261,29 @@ function! nerdcommenter#Comment(mode, type) range
|
||||
endtry
|
||||
|
||||
elseif a:type ==? 'Toggle'
|
||||
let theLine = getline(firstLine)
|
||||
|
||||
if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||
call s:UncommentLines(firstLine, lastLine)
|
||||
if g:NERDToggleCheckAllLines ==# 0
|
||||
let theLine = getline(firstLine)
|
||||
if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||
call s:UncommentLines(firstLine, lastLine)
|
||||
else
|
||||
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
|
||||
endif
|
||||
else
|
||||
let l:commentAllLines = 0
|
||||
for i in range(firstLine, lastLine)
|
||||
let theLine = getline(i)
|
||||
" 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)
|
||||
let l:commentAllLines = 1
|
||||
break
|
||||
else
|
||||
endif
|
||||
endfor
|
||||
if l:commentAllLines ==# 1
|
||||
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
|
||||
else
|
||||
call s:UncommentLines(firstLine, lastLine)
|
||||
endif
|
||||
endif
|
||||
|
||||
elseif a:type ==? 'Minimal'
|
||||
|
||||
Reference in New Issue
Block a user