X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=vim%2Fbundle%2Fnerdcommenter%2Fplugin%2FNERD_commenter.vim;h=ef88dd42a4e1cea60b43cb608994d99805866b7e;hb=fb2acc98087de1a3cc442cbd66f84d5d325cef9e;hp=18a348f7d1cfeb0767092511d40c14cb04e96600;hpb=2cc93b7ada0b925d1ccecfa19a8b3f04cba13f2b;p=config%2Fdotfiles.git diff --git a/vim/bundle/nerdcommenter/plugin/NERD_commenter.vim b/vim/bundle/nerdcommenter/plugin/NERD_commenter.vim index 18a348f..ef88dd4 100644 --- a/vim/bundle/nerdcommenter/plugin/NERD_commenter.vim +++ b/vim/bundle/nerdcommenter/plugin/NERD_commenter.vim @@ -1,9 +1,9 @@ " ============================================================================ " File: NERD_commenter.vim " Description: vim global plugin that provides easy code commenting -" Maintainer: Martin Grenfell -" Version: 2.2.2 -" Last Change: 30th March, 2008 +" Maintainer: Martin Grenfell +" Version: 2.3.0 +" Last Change: 08th December, 2010 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -63,9 +63,318 @@ call s:InitVariable("g:NERDRPlace", "<]") call s:InitVariable("g:NERDSpaceDelims", 0) call s:InitVariable("g:NERDDelimiterRequests", 1) - - let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" +"vf ;;dA:hcs"'A {j^f(lyi(k$p0f{a A }0f{a 'left':jdd^ + +let s:delimiterMap = { + \ 'aap': { 'left': '#' }, + \ 'abc': { 'left': '%' }, + \ 'acedb': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'actionscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ada': { 'left': '--', 'leftAlt': '-- ' }, + \ 'ahdl': { 'left': '--' }, + \ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'amiga': { 'left': ';' }, + \ 'aml': { 'left': '/*' }, + \ 'ampl': { 'left': '#' }, + \ 'apache': { 'left': '#' }, + \ 'apachestyle': { 'left': '#' }, + \ 'asciidoc': { 'left': '//' }, + \ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' }, + \ 'asm68k': { 'left': ';' }, + \ 'asm': { 'left': ';', 'leftAlt': '#' }, + \ 'asn': { 'left': '--' }, + \ 'aspvbs': { 'left': '''' }, + \ 'asterisk': { 'left': ';' }, + \ 'asy': { 'left': '//' }, + \ 'atlas': { 'left': 'C', 'right': '$' }, + \ 'autohotkey': { 'left': ';' }, + \ 'autoit': { 'left': ';' }, + \ 'ave': { 'left': "'" }, + \ 'awk': { 'left': '#' }, + \ 'basic': { 'left': "'", 'leftAlt': 'REM ' }, + \ 'bbx': { 'left': '%' }, + \ 'bc': { 'left': '#' }, + \ 'bib': { 'left': '%' }, + \ 'bindzone': { 'left': ';' }, + \ 'bst': { 'left': '%' }, + \ 'btm': { 'left': '::' }, + \ 'caos': { 'left': '*' }, + \ 'calibre': { 'left': '//' }, + \ 'catalog': { 'left': '--', 'right': '--' }, + \ 'c': { 'left': '/*','right': '*/', 'leftAlt': '//' }, + \ 'cfg': { 'left': '#' }, + \ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ch': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'cl': { 'left': '#' }, + \ 'clean': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'clipper': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'clojure': { 'left': ';' }, + \ 'cmake': { 'left': '#' }, + \ 'conkyrc': { 'left': '#' }, + \ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'crontab': { 'left': '#' }, + \ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'csp': { 'left': '--' }, + \ 'cterm': { 'left': '*' }, + \ 'cucumber': { 'left': '#' }, + \ 'cvs': { 'left': 'CVS:' }, + \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'dcl': { 'left': '$!' }, + \ 'dakota': { 'left': '#' }, + \ 'debcontrol': { 'left': '#' }, + \ 'debsources': { 'left': '#' }, + \ 'def': { 'left': ';' }, + \ 'desktop': { 'left': '#' }, + \ 'dhcpd': { 'left': '#' }, + \ 'diff': { 'left': '#' }, + \ 'django': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'docbk': { 'left': '' }, + \ 'dns': { 'left': ';' }, + \ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' }, + \ 'dosini': { 'left': ';' }, + \ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'dracula': { 'left': ';' }, + \ 'dsl': { 'left': ';' }, + \ 'dtml': { 'left': '', 'right': '' }, + \ 'dylan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ebuild': { 'left': '#' }, + \ 'ecd': { 'left': '#' }, + \ 'eclass': { 'left': '#' }, + \ 'eiffel': { 'left': '--' }, + \ 'elf': { 'left': "'" }, + \ 'elmfilt': { 'left': '#' }, + \ 'erlang': { 'left': '%' }, + \ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '' }, + \ 'expect': { 'left': '#' }, + \ 'exports': { 'left': '#' }, + \ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, + \ 'fgl': { 'left': '#' }, + \ 'focexec': { 'left': '-*' }, + \ 'form': { 'left': '*' }, + \ 'foxpro': { 'left': '*' }, + \ 'fstab': { 'left': '#' }, + \ 'fvwm': { 'left': '#' }, + \ 'fx': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'gams': { 'left': '*' }, + \ 'gdb': { 'left': '#' }, + \ 'gdmo': { 'left': '--' }, + \ 'geek': { 'left': 'GEEK_COMMENT:' }, + \ 'genshi': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'gentoo-conf-d': { 'left': '#' }, + \ 'gentoo-env-d': { 'left': '#' }, + \ 'gentoo-init-d': { 'left': '#' }, + \ 'gentoo-make-conf': { 'left': '#' }, + \ 'gentoo-package-keywords': { 'left': '#' }, + \ 'gentoo-package-mask': { 'left': '#' }, + \ 'gentoo-package-use': { 'left': '#' }, + \ 'gitcommit': { 'left': '#' }, + \ 'gitconfig': { 'left': ';' }, + \ 'gitrebase': { 'left': '#' }, + \ 'gnuplot': { 'left': '#' }, + \ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'gsp': { 'left': '<%--', 'right': '--%>' }, + \ 'gtkrc': { 'left': '#' }, + \ 'haskell': { 'left': '{-','right': '-}', 'leftAlt': '--' }, + \ 'hb': { 'left': '#' }, + \ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'haml': { 'left': '-#', 'leftAlt': '/' }, + \ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'hog': { 'left': '#' }, + \ 'hostsaccess': { 'left': '#' }, + \ 'htmlcheetah': { 'left': '##' }, + \ 'htmldjango': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'htmlos': { 'left': '#', 'right': '/#' }, + \ 'ia64': { 'left': '#' }, + \ 'icon': { 'left': '#' }, + \ 'idlang': { 'left': ';' }, + \ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'inform': { 'left': '!' }, + \ 'inittab': { 'left': '#' }, + \ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'iss': { 'left': ';' }, + \ 'ist': { 'left': '%' }, + \ 'java': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javacc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javascript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'jess': { 'left': ';' }, + \ 'jgraph': { 'left': '(*', 'right': '*)' }, + \ 'jproperties': { 'left': '#' }, + \ 'jsp': { 'left': '<%--', 'right': '--%>' }, + \ 'kix': { 'left': ';' }, + \ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'lace': { 'left': '--' }, + \ 'ldif': { 'left': '#' }, + \ 'lilo': { 'left': '#' }, + \ 'lilypond': { 'left': '%' }, + \ 'liquid': { 'left': '{%', 'right': '%}' }, + \ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, + \ 'llvm': { 'left': ';' }, + \ 'lotos': { 'left': '(*', 'right': '*)' }, + \ 'lout': { 'left': '#' }, + \ 'lprolog': { 'left': '%' }, + \ 'lscript': { 'left': "'" }, + \ 'lss': { 'left': '#' }, + \ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' }, + \ 'lynx': { 'left': '#' }, + \ 'lytex': { 'left': '%' }, + \ 'mail': { 'left': '> ' }, + \ 'mako': { 'left': '##' }, + \ 'man': { 'left': '."' }, + \ 'map': { 'left': '%' }, + \ 'maple': { 'left': '#' }, + \ 'markdown': { 'left': '' }, + \ 'masm': { 'left': ';' }, + \ 'mason': { 'left': '<% #', 'right': '%>' }, + \ 'master': { 'left': '$' }, + \ 'matlab': { 'left': '%' }, + \ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'mib': { 'left': '--' }, + \ 'mkd': { 'left': '>' }, + \ 'mma': { 'left': '(*', 'right': '*)' }, + \ 'model': { 'left': '$', 'right': '$' }, + \ 'moduala.': { 'left': '(*', 'right': '*)' }, + \ 'modula2': { 'left': '(*', 'right': '*)' }, + \ 'modula3': { 'left': '(*', 'right': '*)' }, + \ 'monk': { 'left': ';' }, + \ 'mush': { 'left': '#' }, + \ 'named': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'nasm': { 'left': ';' }, + \ 'nastran': { 'left': '$' }, + \ 'natural': { 'left': '/*' }, + \ 'ncf': { 'left': ';' }, + \ 'newlisp': { 'left': ';' }, + \ 'nroff': { 'left': '\"' }, + \ 'nsis': { 'left': '#' }, + \ 'ntp': { 'left': '#' }, + \ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ocaml': { 'left': '(*', 'right': '*)' }, + \ 'occam': { 'left': '--' }, + \ 'omlet': { 'left': '(*', 'right': '*)' }, + \ 'omnimark': { 'left': ';' }, + \ 'openroad': { 'left': '//' }, + \ 'opl': { 'left': "REM" }, + \ 'ora': { 'left': '#' }, + \ 'ox': { 'left': '//' }, + \ 'pascal': { 'left': '{','right': '}', 'leftAlt': '(*', 'rightAlt': '*)' }, + \ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pcap': { 'left': '#' }, + \ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pdf': { 'left': '%' }, + \ 'pfmain': { 'left': '//' }, + \ 'php': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pic': { 'left': ';' }, + \ 'pike': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pilrc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pine': { 'left': '#' }, + \ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'plsql': { 'left': '--', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'po': { 'left': '#' }, + \ 'postscr': { 'left': '%' }, + \ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'povini': { 'left': ';' }, + \ 'ppd': { 'left': '%' }, + \ 'ppwiz': { 'left': ';;' }, + \ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ps1': { 'left': '#' }, + \ 'psf': { 'left': '#' }, + \ 'ptcap': { 'left': '#' }, + \ 'python': { 'left': '#' }, + \ 'radiance': { 'left': '#' }, + \ 'ratpoison': { 'left': '#' }, + \ 'r': { 'left': '#' }, + \ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'rebol': { 'left': ';' }, + \ 'registry': { 'left': ';' }, + \ 'remind': { 'left': '#' }, + \ 'resolv': { 'left': '#' }, + \ 'rgb': { 'left': '!' }, + \ 'rib': { 'left': '#' }, + \ 'robots': { 'left': '#' }, + \ 'sa': { 'left': '--' }, + \ 'samba': { 'left': ';', 'leftAlt': '#' }, + \ 'sass': { 'left': '//', 'leftAlt': '/*' }, + \ 'sather': { 'left': '--' }, + \ 'scala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'scilab': { 'left': '//' }, + \ 'scsh': { 'left': ';' }, + \ 'sed': { 'left': '#' }, + \ 'sgmldecl': { 'left': '--', 'right': '--' }, + \ 'sgmllnx': { 'left': '' }, + \ 'sicad': { 'left': '*' }, + \ 'simula': { 'left': '%', 'leftAlt': '--' }, + \ 'sinda': { 'left': '$' }, + \ 'skill': { 'left': ';' }, + \ 'slang': { 'left': '%' }, + \ 'slice': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'slrnrc': { 'left': '%' }, + \ 'sm': { 'left': '#' }, + \ 'smarty': { 'left': '{*', 'right': '*}' }, + \ 'smil': { 'left': '' }, + \ 'smith': { 'left': ';' }, + \ 'sml': { 'left': '(*', 'right': '*)' }, + \ 'snnsnet': { 'left': '#' }, + \ 'snnspat': { 'left': '#' }, + \ 'snnsres': { 'left': '#' }, + \ 'snobol4': { 'left': '*' }, + \ 'spec': { 'left': '#' }, + \ 'specman': { 'left': '//' }, + \ 'spectre': { 'left': '//', 'leftAlt': '*' }, + \ 'spice': { 'left': '$' }, + \ 'sql': { 'left': '--' }, + \ 'sqlforms': { 'left': '--' }, + \ 'sqlj': { 'left': '--' }, + \ 'sqr': { 'left': '!' }, + \ 'squid': { 'left': '#' }, + \ 'st': { 'left': '"' }, + \ 'stp': { 'left': '--' }, + \ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tags': { 'left': ';' }, + \ 'tak': { 'left': '$' }, + \ 'tasm': { 'left': ';' }, + \ 'tcl': { 'left': '#' }, + \ 'texinfo': { 'left': "@c " }, + \ 'texmf': { 'left': '%' }, + \ 'tf': { 'left': ';' }, + \ 'tidy': { 'left': '#' }, + \ 'tli': { 'left': '#' }, + \ 'tmux': { 'left': '#' }, + \ 'trasys': { 'left': "$" }, + \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tsscl': { 'left': '#' }, + \ 'tssgm': { 'left': "comment = '", 'right': "'" }, + \ 'txt2tags': { 'left': '%' }, + \ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'uil': { 'left': '!' }, + \ 'vb': { 'left': "'" }, + \ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' }, + \ 'vera': { 'left': '/*','right': '*/', 'leftAlt': '//' }, + \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'vgrindefs': { 'left': '#' }, + \ 'vhdl': { 'left': '--' }, + \ 'vimperator': { 'left': '"' }, + \ 'virata': { 'left': '%' }, + \ 'vrml': { 'left': '#' }, + \ 'vsejcl': { 'left': '/*' }, + \ 'webmacro': { 'left': '##' }, + \ 'wget': { 'left': '#' }, + \ 'Wikipedia': { 'left': '' }, + \ 'winbatch': { 'left': ';' }, + \ 'wml': { 'left': '#' }, + \ 'wvdial': { 'left': ';' }, + \ 'xdefaults': { 'left': '!' }, + \ 'xkb': { 'left': '//' }, + \ 'xmath': { 'left': '#' }, + \ 'xpm2': { 'left': '!' }, + \ 'xquery': { 'left': '(:', 'right': ':)' }, + \ 'z8a': { 'left': ';' } + \ } " Section: Comment mapping functions, autocommands and commands {{{1 " ============================================================================ @@ -88,677 +397,33 @@ augroup END " This function is responsible for setting up buffer scoped variables for the " given filetype. " -" These variables include the comment delimiters for the given filetype and calls -" MapDelimiters or MapDelimitersWithAlternative passing in these delimiters. -" " Args: " -filetype: the filetype to set delimiters for " -forceReset: 1 if the delimiters should be reset if they have already be " set for this buffer. " function s:SetUpForNewFiletype(filetype, forceReset) - "if we have already set the delimiters for this buffer then dont go thru - "it again - if !a:forceReset && exists("b:NERDLeft") && b:NERDLeft != '' - return - endif - let b:NERDSexyComMarker = '' - "check the filetype against all known filetypes to see if we have - "hardcoded the comment delimiters to use - if a:filetype ==? "" - call s:MapDelimiters('', '') - elseif a:filetype ==? "aap" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "abc" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "acedb" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "actionscript" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "ada" - call s:MapDelimitersWithAlternative('--','', '-- ', '') - elseif a:filetype ==? "ahdl" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "ahk" - call s:MapDelimitersWithAlternative(';', '', '/*', '*/') - elseif a:filetype ==? "amiga" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "aml" - call s:MapDelimiters('/*', '') - elseif a:filetype ==? "ampl" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "apache" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "apachestyle" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "asciidoc" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "applescript" - call s:MapDelimitersWithAlternative('--', '', '(*', '*)') - elseif a:filetype ==? "asm68k" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "asm" - call s:MapDelimitersWithAlternative(';', '', '#', '') - elseif a:filetype ==? "asn" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "aspvbs" - call s:MapDelimiters('''', '') - elseif a:filetype ==? "asterisk" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "asy" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "atlas" - call s:MapDelimiters('C','$') - elseif a:filetype ==? "autohotkey" - call s:MapDelimiters(';','') - elseif a:filetype ==? "autoit" - call s:MapDelimiters(';','') - elseif a:filetype ==? "ave" - call s:MapDelimiters("'",'') - elseif a:filetype ==? "awk" - call s:MapDelimiters('#','') - elseif a:filetype ==? "basic" - call s:MapDelimitersWithAlternative("'",'', 'REM ', '') - elseif a:filetype ==? "bbx" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "bc" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "bib" - call s:MapDelimiters('%','') - elseif a:filetype ==? "bindzone" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "bst" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "btm" - call s:MapDelimiters('::', '') - elseif a:filetype ==? "caos" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "calibre" - call s:MapDelimiters('//','') - elseif a:filetype ==? "catalog" - call s:MapDelimiters('--','--') - elseif a:filetype ==? "c" - call s:MapDelimitersWithAlternative('/*','*/', '//', '') - elseif a:filetype ==? "cfg" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "cg" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "ch" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "cl" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "clean" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "clipper" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "clojure" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "cmake" - call s:MapDelimiters('#','') - elseif a:filetype ==? "conkyrc" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "cpp" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "crontab" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "cs" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "csp" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "cterm" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "cucumber" - call s:MapDelimiters('#','') - elseif a:filetype ==? "cvs" - call s:MapDelimiters('CVS:','') - elseif a:filetype ==? "d" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "dcl" - call s:MapDelimiters('$!', '') - elseif a:filetype ==? "dakota" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "debcontrol" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "debsources" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "def" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "desktop" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "dhcpd" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "diff" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "django" - call s:MapDelimitersWithAlternative('', '{#', '#}') - elseif a:filetype ==? "docbk" - call s:MapDelimiters('') - elseif a:filetype ==? "dns" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "dosbatch" - call s:MapDelimitersWithAlternative('REM ','', '::', '') - elseif a:filetype ==? "dosini" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "dot" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "dracula" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "dsl" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "dtml" - call s:MapDelimiters('','') - elseif a:filetype ==? "dylan" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? 'ebuild' - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ecd" - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'eclass' - call s:MapDelimiters('#', '') - elseif a:filetype ==? "eiffel" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "elf" - call s:MapDelimiters("'", '') - elseif a:filetype ==? "elmfilt" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "erlang" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "eruby" - call s:MapDelimitersWithAlternative('<%#', '%>', '') - elseif a:filetype ==? "expect" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "exports" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "factor" - call s:MapDelimitersWithAlternative('! ', '', '!# ', '') - elseif a:filetype ==? "fgl" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "focexec" - call s:MapDelimiters('-*', '') - elseif a:filetype ==? "form" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "foxpro" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "fstab" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "fvwm" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "fx" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "gams" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "gdb" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "gdmo" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "geek" - call s:MapDelimiters('GEEK_COMMENT:', '') - elseif a:filetype ==? "genshi" - call s:MapDelimitersWithAlternative('', '{#', '#}') - elseif a:filetype ==? "gentoo-conf-d" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "gentoo-env-d" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "gentoo-init-d" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "gentoo-make-conf" - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'gentoo-package-keywords' - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'gentoo-package-mask' - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'gentoo-package-use' - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'gitcommit' - call s:MapDelimiters('#', '') - elseif a:filetype ==? 'gitconfig' - call s:MapDelimiters(';', '') - elseif a:filetype ==? 'gitrebase' - call s:MapDelimiters('#', '') - elseif a:filetype ==? "gnuplot" - call s:MapDelimiters('#','') - elseif a:filetype ==? "groovy" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "gtkrc" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "haskell" - call s:MapDelimitersWithAlternative('{-','-}', '--', '') - elseif a:filetype ==? "hb" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "h" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "haml" - call s:MapDelimitersWithAlternative('-#', '', '/', '') - elseif a:filetype ==? "hercules" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "hog" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "hostsaccess" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "htmlcheetah" - call s:MapDelimiters('##','') - elseif a:filetype ==? "htmldjango" - call s:MapDelimitersWithAlternative('', '{#', '#}') - elseif a:filetype ==? "htmlos" - call s:MapDelimiters('#','/#') - elseif a:filetype ==? "ia64" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "icon" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "idlang" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "idl" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "inform" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "inittab" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ishd" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "iss" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "ist" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "java" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "javacc" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "javascript" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype == "javascript.jquery" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "jess" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "jgraph" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "jproperties" - call s:MapDelimiters('#','') - elseif a:filetype ==? "jsp" - call s:MapDelimiters('<%--', '--%>') - elseif a:filetype ==? "kix" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "kscript" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "lace" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "ldif" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "lilo" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "lilypond" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "liquid" - call s:MapDelimiters('{%', '%}') - elseif a:filetype ==? "lisp" - call s:MapDelimitersWithAlternative(';','', '#|', '|#') - elseif a:filetype ==? "llvm" - call s:MapDelimiters(';','') - elseif a:filetype ==? "lotos" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "lout" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "lprolog" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "lscript" - call s:MapDelimiters("'", '') - elseif a:filetype ==? "lss" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "lua" - call s:MapDelimitersWithAlternative('--','', '--[[', ']]') - elseif a:filetype ==? "lynx" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "lytex" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "mail" - call s:MapDelimiters('> ','') - elseif a:filetype ==? "mako" - call s:MapDelimiters('##', '') - elseif a:filetype ==? "man" - call s:MapDelimiters('."', '') - elseif a:filetype ==? "map" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "maple" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "markdown" - call s:MapDelimiters('') - elseif a:filetype ==? "masm" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "mason" - call s:MapDelimiters('<% #', '%>') - elseif a:filetype ==? "master" - call s:MapDelimiters('$', '') - elseif a:filetype ==? "matlab" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "mel" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "mib" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "mkd" - call s:MapDelimiters('>', '') - elseif a:filetype ==? "mma" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "model" - call s:MapDelimiters('$','$') - elseif a:filetype =~ "moduala." - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "modula2" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "modula3" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "monk" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "mush" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "named" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "nasm" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "nastran" - call s:MapDelimiters('$', '') - elseif a:filetype ==? "natural" - call s:MapDelimiters('/*', '') - elseif a:filetype ==? "ncf" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "newlisp" - call s:MapDelimiters(';','') - elseif a:filetype ==? "nroff" - call s:MapDelimiters('\"', '') - elseif a:filetype ==? "nsis" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ntp" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "objc" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "objcpp" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "objj" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "ocaml" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "occam" - call s:MapDelimiters('--','') - elseif a:filetype ==? "omlet" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "omnimark" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "openroad" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "opl" - call s:MapDelimiters("REM", "") - elseif a:filetype ==? "ora" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ox" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "pascal" - call s:MapDelimitersWithAlternative('{','}', '(*', '*)') - elseif a:filetype ==? "patran" - call s:MapDelimitersWithAlternative('$','','/*', '*/') - elseif a:filetype ==? "pcap" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "pccts" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "pdf" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "pfmain" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "php" - call s:MapDelimitersWithAlternative('//','','/*', '*/') - elseif a:filetype ==? "pic" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "pike" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "pilrc" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "pine" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "plm" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "plsql" - call s:MapDelimitersWithAlternative('--', '', '/*', '*/') - elseif a:filetype ==? "po" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "postscr" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "pov" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "povini" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "ppd" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "ppwiz" - call s:MapDelimiters(';;', '') - elseif a:filetype ==? "processing" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "prolog" - call s:MapDelimitersWithAlternative('%','','/*','*/') - elseif a:filetype ==? "ps1" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "psf" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ptcap" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "radiance" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "ratpoison" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "r" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "rc" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "rebol" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "registry" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "remind" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "resolv" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "rgb" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "rib" - call s:MapDelimiters('#','') - elseif a:filetype ==? "robots" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "sa" - call s:MapDelimiters('--','') - elseif a:filetype ==? "samba" - call s:MapDelimitersWithAlternative(';','', '#', '') - elseif a:filetype ==? "sass" - call s:MapDelimitersWithAlternative('//','', '/*', '') - elseif a:filetype ==? "sather" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "scala" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "scilab" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "scsh" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "sed" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "sgmldecl" - call s:MapDelimiters('--','--') - elseif a:filetype ==? "sgmllnx" - call s:MapDelimiters('') - elseif a:filetype ==? "sicad" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "simula" - call s:MapDelimitersWithAlternative('%', '', '--', '') - elseif a:filetype ==? "sinda" - call s:MapDelimiters('$', '') - elseif a:filetype ==? "skill" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "slang" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "slice" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "slrnrc" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "sm" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "smarty" - call s:MapDelimiters('{*', '*}') - elseif a:filetype ==? "smil" - call s:MapDelimiters('') - elseif a:filetype ==? "smith" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "sml" - call s:MapDelimiters('(*','*)') - elseif a:filetype ==? "snnsnet" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "snnspat" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "snnsres" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "snobol4" - call s:MapDelimiters('*', '') - elseif a:filetype ==? "spec" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "specman" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "spectre" - call s:MapDelimitersWithAlternative('//', '', '*', '') - elseif a:filetype ==? "spice" - call s:MapDelimiters('$', '') - elseif a:filetype ==? "sql" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "sqlforms" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "sqlj" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "sqr" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "squid" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "st" - call s:MapDelimiters('"','') - elseif a:filetype ==? "stp" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "systemverilog" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "tads" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "tags" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "tak" - call s:MapDelimiters('$', '') - elseif a:filetype ==? "tasm" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "tcl" - call s:MapDelimiters('#','') - elseif a:filetype ==? "texinfo" - call s:MapDelimiters("@c ", "") - elseif a:filetype ==? "texmf" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "tf" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "tidy" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "tli" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "trasys" - call s:MapDelimiters("$", "") - elseif a:filetype ==? "tsalt" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "tsscl" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "tssgm" - call s:MapDelimiters("comment = '","'") - elseif a:filetype ==? "txt2tags" - call s:MapDelimiters('%','') - elseif a:filetype ==? "uc" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "uil" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "vb" - call s:MapDelimiters("'","") - elseif a:filetype ==? "velocity" - call s:MapDelimitersWithAlternative("##","", '#*', '*#') - elseif a:filetype ==? "vera" - call s:MapDelimitersWithAlternative('/*','*/','//','') - elseif a:filetype ==? "verilog" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "verilog_systemverilog" - call s:MapDelimitersWithAlternative('//','', '/*','*/') - elseif a:filetype ==? "vgrindefs" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "vhdl" - call s:MapDelimiters('--', '') - elseif a:filetype ==? "vimperator" - call s:MapDelimiters('"','') - elseif a:filetype ==? "virata" - call s:MapDelimiters('%', '') - elseif a:filetype ==? "vrml" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "vsejcl" - call s:MapDelimiters('/*', '') - elseif a:filetype ==? "webmacro" - call s:MapDelimiters('##', '') - elseif a:filetype ==? "wget" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "Wikipedia" - call s:MapDelimiters('') - elseif a:filetype ==? "winbatch" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "wml" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "wvdial" - call s:MapDelimiters(';', '') - elseif a:filetype ==? "xdefaults" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "xkb" - call s:MapDelimiters('//', '') - elseif a:filetype ==? "xmath" - call s:MapDelimiters('#', '') - elseif a:filetype ==? "xpm2" - call s:MapDelimiters('!', '') - elseif a:filetype ==? "xquery" - call s:MapDelimiters('(:',':)') - elseif a:filetype ==? "z8a" - call s:MapDelimiters(';', '') - + if has_key(s:delimiterMap, a:filetype) + let b:NERDCommenterDelims = s:delimiterMap[a:filetype] + for i in ['left', 'leftAlt', 'right', 'rightAlt'] + if !has_key(b:NERDCommenterDelims, i) + let b:NERDCommenterDelims[i] = '' + endif + endfor else - - "extract the delims from &commentstring - let left= substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', '') - let right= substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g') - call s:MapDelimiters(left,right) - + let b:NERDCommenterDelims = s:CreateDelimMapFromCms() endif -endfunction -" Function: s:MapDelimiters(left, right) function {{{2 -" This function is a wrapper for s:MapDelimiters(left, right, leftAlt, rightAlt, useAlt) and is called when there -" is no alternative comment delimiters for the current filetype -" -" Args: -" -left: the left comment delimiter -" -right: the right comment delimiter -function s:MapDelimiters(left, right) - call s:MapDelimitersWithAlternative(a:left, a:right, "", "") endfunction -" Function: s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt) function {{{2 -" this function sets up the comment delimiter buffer variables -" -" Args: -" -left: the string defining the comment start delimiter -" -right: the string defining the comment end delimiter -" -leftAlt: the string for the alternative comment style defining the comment start delimiter -" -rightAlt: the string for the alternative comment style defining the comment end delimiter -function s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt) - if !exists('g:NERD_' . &filetype . '_alt_style') - let b:NERDLeft = a:left - let b:NERDRight = a:right - let b:NERDLeftAlt = a:leftAlt - let b:NERDRightAlt = a:rightAlt - else - let b:NERDLeft = a:leftAlt - let b:NERDRight = a:rightAlt - let b:NERDLeftAlt = a:left - let b:NERDRightAlt = a:right - endif +function s:CreateDelimMapFromCms() + return { + \ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''), + \ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'), + \ 'leftAlt': '', + \ 'rightAlt': '' } endfunction " Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2 @@ -773,7 +438,7 @@ endfunction function s:SwitchToAlternativeDelimiters(printMsgs) "if both of the alternative delimiters are empty then there is no "alternative comment style so bail out - if b:NERDLeftAlt == "" && b:NERDRightAlt == "" + if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == '' if a:printMsgs call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0) endif @@ -781,22 +446,20 @@ function s:SwitchToAlternativeDelimiters(printMsgs) endif "save the current delimiters - let tempLeft = b:NERDLeft - let tempRight = b:NERDRight + let tempLeft = s:Left() + let tempRight = s:Right() "swap current delimiters for alternative - let b:NERDLeft = b:NERDLeftAlt - let b:NERDRight = b:NERDRightAlt + let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt'] + let b:NERDCommenterDelims['right'] = b:NERDCommenterDelims['rightAlt'] "set the previously current delimiters to be the new alternative ones - let b:NERDLeftAlt = tempLeft - let b:NERDRightAlt = tempRight + let b:NERDCommenterDelims['leftAlt'] = tempLeft + let b:NERDCommenterDelims['rightAlt'] = tempRight "tell the user what comment delimiters they are now using if a:printMsgs - let leftNoEsc = b:NERDLeft - let rightNoEsc = b:NERDRight - call s:NerdEcho("Now using " . leftNoEsc . " " . rightNoEsc . " to delimit comments", 1) + call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1) endif return 1 @@ -808,8 +471,8 @@ endfunction " This function appends comment delimiters at the EOL and places the cursor in " position to start typing the comment function s:AppendCommentToLine() - let left = s:GetLeft(0,1,0) - let right = s:GetRight(0,1,0) + let left = s:Left({'space': 1}) + let right = s:Right({'space': 1}) " get the len of the right delim let lenRight = strlen(right) @@ -915,8 +578,8 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) call setline(currentLine, theLine) if s:CanPlaceCursor(currentLine, lSide) - let leftSpaced = s:GetLeft(0,1,0) - let rightSpaced = s:GetRight(0,1,0) + let leftSpaced = s:Left({'space': 1}) + let rightSpaced = s:Right({'space': 1}) "stick the left delimiter down let theLine = strpart(theLine, 0, lSide-1) . leftSpaced . strpart(theLine, lSide-1) @@ -925,19 +588,19 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) "stick the right delimiter down let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced)) - let firstLeftDelim = s:FindDelimiterIndex(b:NERDLeft, theLine) - let lastRightDelim = s:LastIndexOfDelim(b:NERDRight, theLine) + let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine) + let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine) if firstLeftDelim != -1 && lastRightDelim != -1 let searchStr = strpart(theLine, 0, lastRightDelim) - let searchStr = strpart(searchStr, firstLeftDelim+strlen(b:NERDLeft)) + let searchStr = strpart(searchStr, firstLeftDelim+strlen(s:Left())) "replace the outter most delims in searchStr with "place-holders - let theLineWithPlaceHolders = s:ReplaceDelims(b:NERDLeft, b:NERDRight, g:NERDLPlace, g:NERDRPlace, searchStr) + let theLineWithPlaceHolders = s:ReplaceDelims(s:Left(), s:Right(), g:NERDLPlace, g:NERDRPlace, searchStr) "add the right delimiter onto the line - let theLine = strpart(theLine, 0, firstLeftDelim+strlen(b:NERDLeft)) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim) + let theLine = strpart(theLine, 0, firstLeftDelim+strlen(s:Left())) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim) endif endif endif @@ -977,7 +640,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " gotta add the length of the left delimiter onto the rightAlignIndx cos " we'll be adding a left delim to the line - let rightAlignIndx = rightAlignIndx + strlen(s:GetLeft(0,1,0)) + let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) " now we actually comment the lines. Do it line by line let currentLine = a:firstLine @@ -996,19 +659,19 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " find out if the line is commented using normal delims and/or " alternate ones - let isCommented = s:IsCommented(b:NERDLeft, b:NERDRight, theLine) || s:IsCommented(b:NERDLeftAlt, b:NERDRightAlt, theLine) + let isCommented = s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine) " check if we can comment this line if !isCommented || g:NERDUsePlaceHolders || s:Multipart() if a:align == "left" || a:align == "both" - let theLine = s:AddLeftDelimAligned(s:GetLeft(0,1,0), theLine, leftAlignIndx) + let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) else - let theLine = s:AddLeftDelim(s:GetLeft(0,1,0), theLine) + let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) endif if a:align == "both" - let theLine = s:AddRightDelimAligned(s:GetRight(0,1,0), theLine, rightAlignIndx) + let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) else - let theLine = s:AddRightDelim(s:GetRight(0,1,0), theLine) + let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) endif endif endif @@ -1039,7 +702,7 @@ function s:CommentLinesMinimal(firstLine, lastLine) "if we need to use place holders for the comment, make sure they are "enabled for this filetype if !g:NERDUsePlaceHolders && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine) - throw 'NERDCommenter.Settings exception: Placeoholders are required but disabled.' + throw 'NERDCommenter.Settings exception: Place holders are required but disabled.' endif "get the left and right delims to smack on @@ -1145,13 +808,25 @@ function s:CommentLinesSexy(topline, bottomline) " add the left delimiter one line above the lines that are to be commented call cursor(a:topline, 1) execute 'normal! O' - call setline(a:topline, repeat(' ', leftAlignIndx) . left ) + let theLine = repeat(' ', leftAlignIndx) . left + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:topline, theLine) " add the right delimiter after bottom line (we have to add 1 cos we moved " the lines down when we added the left delim call cursor(a:bottomline+1, 1) execute 'normal! o' - call setline(a:bottomline+2, repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right ) + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:bottomline+2, theLine) endif @@ -1206,8 +881,8 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine) endif - let theLine = s:AddLeftDelim(s:GetLeft(0, 1, 0), theLine) - let theLine = s:AddRightDelim(s:GetRight(0, 1, 0), theLine) + let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) + let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) endif " restore leading tabs if appropriate @@ -1265,7 +940,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) endif "stick the cursor back on the char it was on before the comment - call cursor(a:topLine, a:topCol + strlen(b:NERDLeft) + g:NERDSpaceDelims) + call cursor(a:topLine, a:topCol + strlen(s:Left()) + g:NERDSpaceDelims) "if we switched delims then we gotta go back to what they were before if switchedDelims == 1 @@ -1290,7 +965,7 @@ function s:InvertComment(firstLine, lastLine) let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine) " if the line is commented normally, uncomment it - if s:IsCommentedFromStartOfLine(b:NERDLeft, theLine) || s:IsCommentedFromStartOfLine(b:NERDLeftAlt, theLine) + if s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) call s:UncommentLines(currentLine, currentLine) let currentLine = currentLine + 1 @@ -1301,7 +976,7 @@ function s:InvertComment(firstLine, lastLine) "move to the line after last line of the sexy comment let numLinesAfterSexyComRemoved = s:NumLinesInBuf() - let currentLine = bottomBound - (numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved) + 1 + let currentLine = sexyComBounds[1] - (numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved) + 1 " the line isnt commented else @@ -1326,6 +1001,10 @@ function! NERDComment(isVisual, type) range let oldIgnoreCase = &ignorecase set noignorecase + if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1 + call s:NerdEcho("filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on", 0) + endif + if a:isVisual let firstLine = line("'<") let lastLine = line("'>") @@ -1373,7 +1052,7 @@ function! NERDComment(isVisual, type) range elseif a:type == 'toggle' let theLine = getline(firstLine) - if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(b:NERDLeft, theLine) || s:IsCommentedFromStartOfLine(b:NERDLeftAlt, theLine) + 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) @@ -1421,8 +1100,8 @@ endfunction " cursor between them function s:PlaceDelimitersAndInsBetween() " get the left and right delimiters without any escape chars in them - let left = s:GetLeft(0, 1, 0) - let right = s:GetRight(0, 1, 0) + let left = s:Left({'space': 1}) + let right = s:Right({'space': 1}) let theLine = getline(".") let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab) @@ -1690,54 +1369,54 @@ function s:UncommentLineNormal(line) let line = a:line "get the comment status on the line so we know how it is commented - let lineCommentStatus = s:IsCommentedOuttermost(b:NERDLeft, b:NERDRight, b:NERDLeftAlt, b:NERDRightAlt, line) + let lineCommentStatus = s:IsCommentedOuttermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line) - "it is commented with b:NERDLeft and b:NERDRight so remove these delims + "it is commented with s:Left() and s:Right() so remove these delims if lineCommentStatus == 1 - let line = s:RemoveDelimiters(b:NERDLeft, b:NERDRight, line) + let line = s:RemoveDelimiters(s:Left(), s:Right(), line) - "it is commented with b:NERDLeftAlt and b:NERDRightAlt so remove these delims + "it is commented with s:Left({'alt': 1}) and s:Right({'alt': 1}) so remove these delims elseif lineCommentStatus == 2 && g:NERDRemoveAltComs - let line = s:RemoveDelimiters(b:NERDLeftAlt, b:NERDRightAlt, line) + let line = s:RemoveDelimiters(s:Left({'alt': 1}), s:Right({'alt': 1}), line) "it is not properly commented with any delims so we check if it has "any random left or right delims on it and remove the outtermost ones else "get the positions of all delim types on the line - let indxLeft = s:FindDelimiterIndex(b:NERDLeft, line) - let indxLeftAlt = s:FindDelimiterIndex(b:NERDLeftAlt, line) - let indxRight = s:FindDelimiterIndex(b:NERDRight, line) - let indxRightAlt = s:FindDelimiterIndex(b:NERDRightAlt, line) + let indxLeft = s:FindDelimiterIndex(s:Left(), line) + let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line) + let indxRight = s:FindDelimiterIndex(s:Right(), line) + let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line) "remove the outter most left comment delim if indxLeft != -1 && (indxLeft < indxLeftAlt || indxLeftAlt == -1) - let line = s:RemoveDelimiters(b:NERDLeft, '', line) + let line = s:RemoveDelimiters(s:Left(), '', line) elseif indxLeftAlt != -1 - let line = s:RemoveDelimiters(b:NERDLeftAlt, '', line) + let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line) endif "remove the outter most right comment delim if indxRight != -1 && (indxRight < indxRightAlt || indxRightAlt == -1) - let line = s:RemoveDelimiters('', b:NERDRight, line) + let line = s:RemoveDelimiters('', s:Right(), line) elseif indxRightAlt != -1 - let line = s:RemoveDelimiters('', b:NERDRightAlt, line) + let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line) endif endif - let indxLeft = s:FindDelimiterIndex(b:NERDLeft, line) - let indxLeftAlt = s:FindDelimiterIndex(b:NERDLeftAlt, line) + let indxLeft = s:FindDelimiterIndex(s:Left(), line) + let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line) let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line) let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line) - let indxRightAlt = s:FindDelimiterIndex(b:NERDRightAlt, line) + let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line) let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line) - let right = b:NERDRight - let left = b:NERDLeft + let right = s:Right() + let left = s:Left() if !s:Multipart() - let right = b:NERDRightAlt - let left = b:NERDLeftAlt + let right = s:Right({'alt': 1}) + let left = s:Left({'alt': 1}) endif @@ -1828,7 +1507,7 @@ endfunction " Function: s:AltMultipart() {{{2 " returns 1 if the alternative delims are multipart function s:AltMultipart() - return b:NERDRightAlt != '' + return b:NERDCommenterDelims['rightAlt'] != '' endfunction " Function: s:CanCommentLine(forceNested, line) {{{2 @@ -1899,7 +1578,7 @@ endfunction " -lineNum: the line num of the line to check for commentability function s:CanToggleCommentLine(forceNested, lineNum) let theLine = getline(a:lineNum) - if (s:IsCommentedFromStartOfLine(b:NERDLeft, theLine) || s:IsCommentedFromStartOfLine(b:NERDLeftAlt, theLine)) && !a:forceNested + if (s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)) && !a:forceNested return 0 endif @@ -2019,9 +1698,9 @@ endfunction function s:DoesBlockHaveMultipartDelim(top, bottom) if s:HasMultipartDelims() if s:Multipart() - return s:DoesBlockHaveDelim(b:NERDLeft, a:top, a:bottom) || s:DoesBlockHaveDelim(b:NERDRight, a:top, a:bottom) + return s:DoesBlockHaveDelim(s:Left(), a:top, a:bottom) || s:DoesBlockHaveDelim(s:Right(), a:top, a:bottom) else - return s:DoesBlockHaveDelim(b:NERDLeftAlt, a:top, a:bottom) || s:DoesBlockHaveDelim(b:NERDRightAlt, a:top, a:bottom) + return s:DoesBlockHaveDelim(s:Left({'alt': 1}), a:top, a:bottom) || s:DoesBlockHaveDelim(s:Right({'alt': 1}), a:top, a:bottom) endif endif return 0 @@ -2105,11 +1784,11 @@ function s:FindBoundingLinesOfSexyCom(lineNum) let left = '' let right = '' if s:Multipart() - let left = s:GetLeft(0,0,1) - let right = s:GetRight(0,0,1) + let left = s:Left({'esc': 1}) + let right = s:Right({'esc': 1}) elseif s:AltMultipart() - let left = s:GetLeft(1,0,1) - let right = s:GetRight(1,0,1) + let left = s:Left({'alt': 1, 'esc': 1}) + let right = s:Right({'alt': 1, 'esc': 1}) else return [] endif @@ -2163,71 +1842,6 @@ function s:FindBoundingLinesOfSexyCom(lineNum) endfunction -" Function: s:GetLeft(alt, space, esc) {{{2 -" returns the left/left-alternative delimiter -" Args: -" -alt: specifies whether to get left or left-alternative delim -" -space: specifies whether the delim should be spaced or not -" (the space string will only be added if NERDSpaceDelims is set) -" -esc: specifies whether the tricky chars in the delim should be ESCed -function s:GetLeft(alt, space, esc) - let delim = b:NERDLeft - - if a:alt - if b:NERDLeftAlt == '' - return '' - else - let delim = b:NERDLeftAlt - endif - endif - if delim == '' - return '' - endif - - if a:space && g:NERDSpaceDelims - let delim = delim . s:spaceStr - endif - - if a:esc - let delim = s:Esc(delim) - endif - - return delim -endfunction - -" Function: s:GetRight(alt, space, esc) {{{2 -" returns the right/right-alternative delimiter -" Args: -" -alt: specifies whether to get right or right-alternative delim -" -space: specifies whether the delim should be spaced or not -" (the space string will only be added if NERDSpaceDelims is set) -" -esc: specifies whether the tricky chars in the delim should be ESCed -function s:GetRight(alt, space, esc) - let delim = b:NERDRight - - if a:alt - if !s:AltMultipart() - return '' - else - let delim = b:NERDRightAlt - endif - endif - if delim == '' - return '' - endif - - if a:space && g:NERDSpaceDelims - let delim = s:spaceStr . delim - endif - - if a:esc - let delim = s:Esc(delim) - endif - - return delim -endfunction - - " Function: s:GetSexyComMarker() {{{2 " Returns the sexy comment marker for the current filetype. " @@ -2252,14 +1866,14 @@ function s:GetSexyComMarker(space, esc) else "find a comment marker by getting the longest available left delim "(that has a corresponding right delim) and taking the last char - let lenLeft = strlen(b:NERDLeft) - let lenLeftAlt = strlen(b:NERDLeftAlt) + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) let left = '' let right = '' if s:Multipart() && lenLeft >= lenLeftAlt - let left = b:NERDLeft + let left = s:Left() elseif s:AltMultipart() - let left = b:NERDLeftAlt + let left = s:Left({'alt': 1}) else return -1 endif @@ -2288,8 +1902,8 @@ endfunction " (the space string will only be added if NERDSpaceDelims is set) " -esc: specifies whether the tricky chars in the string are ESCed function s:GetSexyComLeft(space, esc) - let lenLeft = strlen(b:NERDLeft) - let lenLeftAlt = strlen(b:NERDLeftAlt) + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) let left = '' "assume c style sexy comments if possible @@ -2298,9 +1912,9 @@ function s:GetSexyComLeft(space, esc) else "grab the longest left delim that has a right if s:Multipart() && lenLeft >= lenLeftAlt - let left = b:NERDLeft + let left = s:Left() elseif s:AltMultipart() - let left = b:NERDLeftAlt + let left = s:Left({'alt': 1}) else return -1 endif @@ -2326,8 +1940,8 @@ endfunction " is specified for the current filetype) " -esc: specifies whether the tricky chars in the string are ESCed function s:GetSexyComRight(space, esc) - let lenLeft = strlen(b:NERDLeft) - let lenLeftAlt = strlen(b:NERDLeftAlt) + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) let right = '' "assume c style sexy comments if possible @@ -2336,9 +1950,9 @@ function s:GetSexyComRight(space, esc) else "grab the right delim that pairs with the longest left delim if s:Multipart() && lenLeft >= lenLeftAlt - let right = b:NERDRight + let right = s:Right() elseif s:AltMultipart() - let right = b:NERDRightAlt + let right = s:Right({'alt': 1}) else return -1 endif @@ -2374,7 +1988,7 @@ endfunction " Function: s:HasCStyleComments() {{{2 " Returns 1 iff the current filetype has c style comment delimiters function s:HasCStyleComments() - return (b:NERDLeft == '/*' && b:NERDRight == '*/') || (b:NERDLeftAlt == '/*' && b:NERDRightAlt == '*/') + return (s:Left() == '/*' && s:Right() == '*/') || (s:Left({'alt': 1}) == '/*' && s:Right({'alt': 1}) == '*/') endfunction " Function: s:IsCommentedNormOrSexy(lineNum) {{{2 @@ -2387,7 +2001,7 @@ function s:IsCommentedNormOrSexy(lineNum) let theLine = getline(a:lineNum) "if the line is commented normally return 1 - if s:IsCommented(b:NERDLeft, b:NERDRight, theLine) || s:IsCommented(b:NERDLeftAlt, b:NERDRightAlt, theLine) + if s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine) return 1 endif @@ -2603,11 +2217,11 @@ function s:IsSexyComment(topline, bottomline) let left = '' let right = '' if s:Multipart() - let left = b:NERDLeft - let right = b:NERDRight + let left = s:Left() + let right = s:Right() elseif s:AltMultipart() - let left = b:NERDLeftAlt - let right = b:NERDRightAlt + let left = s:Left({'alt': 1}) + let right = s:Right({'alt': 1}) else return 0 endif @@ -2710,6 +2324,28 @@ function s:LastIndexOfDelim(delim, str) endfunction +" Function: s:Left(...) {{{2 +" returns left delimiter data +function s:Left(...) + let params = a:0 ? a:1 : {} + + let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['leftAlt'] : b:NERDCommenterDelims['left'] + + if delim == '' + return '' + endif + + if has_key(params, 'space') && g:NERDSpaceDelims + let delim = delim . s:spaceStr + endif + + if has_key(params, 'esc') + let delim = s:Esc(delim) + endif + + return delim +endfunction + " Function: s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 " This function takes in 2 line numbers and returns the index of the left most " char (that is not a space or a tab) on all of these lines. @@ -2732,7 +2368,7 @@ function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomlin " commented, check it let theLine = getline(currentLine) if a:countEmptyLines || theLine !~ '^[ \t]*$' - if a:countCommentedLines || (!s:IsCommented(b:NERDLeft, b:NERDRight, theLine) && !s:IsCommented(b:NERDLeftAlt, b:NERDRightAlt, 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 " this line and update leftMostIndx if need be let theLine = s:ConvertLeadingTabsToSpaces(theLine) @@ -2757,7 +2393,7 @@ endfunction " Function: s:Multipart() {{{2 " returns 1 if the current delims are multipart function s:Multipart() - return b:NERDRight != '' + return s:Right() != '' endfunction " Function: s:NerdEcho(msg, typeOfMsg) {{{2 @@ -2768,10 +2404,10 @@ endfunction function s:NerdEcho(msg, typeOfMsg) if a:typeOfMsg == 0 echohl WarningMsg - echo 'NERDCommenter:' . a:msg + echom 'NERDCommenter:' . a:msg echohl None elseif a:typeOfMsg == 1 - echo 'NERDCommenter:' . a:msg + echom 'NERDCommenter:' . a:msg endif endfunction @@ -2867,6 +2503,28 @@ function s:RestoreScreenState() call setpos(".", t:NERDComOldPos) endfunction +" Function: s:Right(...) {{{2 +" returns right delimiter data +function s:Right(...) + let params = a:0 ? a:1 : {} + + let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['rightAlt'] : b:NERDCommenterDelims['right'] + + if delim == '' + return '' + endif + + if has_key(params, 'space') && g:NERDSpaceDelims + let delim = s:spaceStr . delim + endif + + if has_key(params, 'esc') + let delim = s:Esc(delim) + endif + + return delim +endfunction + " Function: s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 " This function takes in 2 line numbers and returns the index of the right most " char on all of these lines. @@ -2888,7 +2546,7 @@ function s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomli let theLine = getline(currentLine) if a:countEmptyLines || theLine !~ '^[ \t]*$' - if a:countCommentedLines || (!s:IsCommented(b:NERDLeft, b:NERDRight, theLine) && !s:IsCommented(b:NERDLeftAlt, b:NERDRightAlt, theLine)) + if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)) " update rightMostIndx if need be let theLine = s:ConvertLeadingTabsToSpaces(theLine) @@ -2923,20 +2581,20 @@ endfunction function s:SwapOutterMultiPartDelimsForPlaceHolders(line) " find out if the line is commented using normal delims and/or " alternate ones - let isCommented = s:IsCommented(b:NERDLeft, b:NERDRight, a:line) - let isCommentedAlt = s:IsCommented(b:NERDLeftAlt, b:NERDRightAlt, a:line) + let isCommented = s:IsCommented(s:Left(), s:Right(), a:line) + let isCommentedAlt = s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), a:line) let line2 = a:line "if the line is commented and there is a right delimiter, replace "the delims with place-holders if isCommented && s:Multipart() - let line2 = s:ReplaceDelims(b:NERDLeft, b:NERDRight, g:NERDLPlace, g:NERDRPlace, a:line) + let line2 = s:ReplaceDelims(s:Left(), s:Right(), g:NERDLPlace, g:NERDRPlace, a:line) "similarly if the line is commented with the alternative "delimiters elseif isCommentedAlt && s:AltMultipart() - let line2 = s:ReplaceDelims(b:NERDLeftAlt, b:NERDRightAlt, g:NERDLPlace, g:NERDRPlace, a:line) + let line2 = s:ReplaceDelims(s:Left({'alt': 1}), s:Right({'alt': 1}), g:NERDLPlace, g:NERDRPlace, a:line) endif return line2 @@ -2952,11 +2610,11 @@ function s:SwapOutterPlaceHoldersForMultiPartDelims(line) let left = '' let right = '' if s:Multipart() - let left = b:NERDLeft - let right = b:NERDRight + let left = s:Left() + let right = s:Right() elseif s:AltMultipart() - let left = b:NERDLeftAlt - let right = b:NERDRightAlt + let left = s:Left({'alt': 1}) + let right = s:Right({'alt': 1}) endif let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, a:line) @@ -3072,21 +2730,21 @@ function! s:CreateMaps(target, combo) endfunction if g:NERDCreateDefaultMappings - call s:CreateMaps('NERDCommenterComment', ',cc') - call s:CreateMaps('NERDCommenterToggle', ',c') - call s:CreateMaps('NERDCommenterMinimal', ',cm') - call s:CreateMaps('NERDCommenterSexy', ',cs') - call s:CreateMaps('NERDCommenterInvert', ',ci') - call s:CreateMaps('NERDCommenterYank', ',cy') - call s:CreateMaps('NERDCommenterAlignLeft', ',cl') - call s:CreateMaps('NERDCommenterAlignBoth', ',cb') - call s:CreateMaps('NERDCommenterNest', ',cn') - call s:CreateMaps('NERDCommenterUncomment', ',cu') - call s:CreateMaps('NERDCommenterToEOL', ',c$') - call s:CreateMaps('NERDCommenterAppend', ',cA') + call s:CreateMaps('NERDCommenterComment', 'cc') + call s:CreateMaps('NERDCommenterToggle', 'c') + call s:CreateMaps('NERDCommenterMinimal', 'cm') + call s:CreateMaps('NERDCommenterSexy', 'cs') + call s:CreateMaps('NERDCommenterInvert', 'ci') + call s:CreateMaps('NERDCommenterYank', 'cy') + call s:CreateMaps('NERDCommenterAlignLeft', 'cl') + call s:CreateMaps('NERDCommenterAlignBoth', 'cb') + call s:CreateMaps('NERDCommenterNest', 'cn') + call s:CreateMaps('NERDCommenterUncomment', 'cu') + call s:CreateMaps('NERDCommenterToEOL', 'c$') + call s:CreateMaps('NERDCommenterAppend', 'cA') if !hasmapto('NERDCommenterAltDelims', 'n') - nmap ,ca NERDCommenterAltDelims + nmap ca NERDCommenterAltDelims endif endif