merge in upstream master

This commit is contained in:
ervandew
2011-02-05 14:24:10 -08:00
2 changed files with 68 additions and 13 deletions

View File

@@ -404,6 +404,8 @@ then the script would do a sexy comment on the last visual selection.
doing visual-block comments.
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDCustomDelimiters'| Add or override delimiters for any
filetypes.
|'NERDDefaultNesting'| Tells the script to use nested comments
by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu
@@ -553,7 +555,7 @@ Note that this option does not affect the behaviour of commenting in
|visual-block| mode.
------------------------------------------------------------------------------
*'NERDCreateDefaultMappings'*
*'NERDCreateDefaultMappings'*
Values: 0 or 1.
Default: 1.
@@ -561,6 +563,25 @@ If set to 0, none of the default mappings will be created.
See also |NERDComMappings|.
------------------------------------------------------------------------------
*'NERDCustomDelimiters'*
Values: A map (format specified below).
Default: {}
Use this option if you have new filetypes you want the script to handle, or if
you want to override the default delimiters of a filetype.
Example: >
let g:NERDCustomDelimiters = {
\ 'ruby': { 'left': '#', 'leftAlt': 'FOO', 'rightAlt': 'BAR' },
\ 'grondle': { 'left': '{{', 'right': '}}' }
\ }
<
Here we override the delimiter settings for ruby and add FOO/BAR as alternative
delimiters. We also add {{ and }} as delimiters for a new filetype called
'grondle'.
------------------------------------------------------------------------------
*'NERDRemoveAltComs'*
Values: 0 or 1.
@@ -803,6 +824,15 @@ The latest dev versions are on github
==============================================================================
8. Changelog *NERDComChangelog*
2.3.0
- remove all filetypes which have a &commentstring in the standard vim
runtime for vim > 7.0 unless the script stores an alternate set of
delimiters
- make the script complain if the user doesnt have filetype plugins enabled
- use <leader> instead of comma to start the default mappings
- fix a couple of bugs with sexy comments - thanks to Tim Smart
- lots of refactoring
2.2.2
- remove the NERDShutup option and the message is suppresses, this makes
the plugin silently rely on &commentstring for unknown filetypes.

View File

@@ -1,9 +1,9 @@
" ============================================================================
" File: NERD_commenter.vim
" Description: vim global plugin that provides easy code commenting
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
" Version: 2.2.2
" Last Change: 09th October, 2010
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" 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
@@ -47,7 +47,7 @@ endfunction
let s:spaceStr = ' '
let s:lenSpaceStr = strlen(s:spaceStr)
" Section: variable init calls {{{2
" Section: variable initialization {{{2
call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
@@ -61,11 +61,13 @@ call s:InitVariable("g:NERDRemoveAltComs", 1)
call s:InitVariable("g:NERDRemoveExtraSpaces", 1)
call s:InitVariable("g:NERDRPlace", "<]")
call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:NERDDelimiterRequests", 1)
call s:InitVariable("g:NERDDefaultAlign", "none")
if !exists("g:NERDCustomDelimiters")
let g:NERDCustomDelimiters = {}
endif
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
"vf ;;dA:hcs"'A {j^f(lyi(k$p0f{a A }0f{a 'left':jdd^
let s:delimiterMap = {
\ 'aap': { 'left': '#' },
@@ -209,7 +211,7 @@ let s:delimiterMap = {
\ 'ldif': { 'left': '#' },
\ 'lilo': { 'left': '#' },
\ 'lilypond': { 'left': '%' },
\ 'liquid': { 'left': '{%', 'right': '%}' },
\ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' },
\ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'llvm': { 'left': ';' },
\ 'lotos': { 'left': '(*', 'right': '*)' },
@@ -377,12 +379,17 @@ let s:delimiterMap = {
\ 'z8a': { 'left': ';' }
\ }
"merge in the custom delimiters
for ft in keys(g:NERDCustomDelimiters)
let s:delimiterMap[ft] = g:NERDCustomDelimiters[ft]
endfor
" Section: Comment mapping functions, autocommands and commands {{{1
" ============================================================================
" Section: Comment enabler autocommands {{{2
" ============================================================================
augroup commentEnablers
augroup NERDCommenter
"if the user enters a buffer or reads a buffer then we gotta set up
"the comment delimiters for that new filetype
@@ -404,10 +411,24 @@ augroup END
" set for this buffer.
"
function s:SetUpForNewFiletype(filetype, forceReset)
let ft = a:filetype
"for compound filetypes, if we dont know how to handle the full filetype
"then break it down and use the first part that we know how to handle
if ft =~ '\.' && !has_key(s:delimiterMap, ft)
let filetypes = split(a:filetype, '\.')
for i in filetypes
if has_key(s:delimiterMap, i)
let ft = i
break
endif
endfor
endif
let b:NERDSexyComMarker = ''
if has_key(s:delimiterMap, a:filetype)
let b:NERDCommenterDelims = s:delimiterMap[a:filetype]
if has_key(s:delimiterMap, ft)
let b:NERDCommenterDelims = s:delimiterMap[ft]
for i in ['left', 'leftAlt', 'right', 'rightAlt']
if !has_key(b:NERDCommenterDelims, i)
let b:NERDCommenterDelims[i] = ''
@@ -1016,6 +1037,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("'>")
@@ -2415,10 +2440,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