+++ /dev/null
-" These are the mappings for snipMate.vim. Putting it here ensures that it
-" will be mapped after other plugins such as supertab.vim.
-if !exists('loaded_snips') || exists('s:did_snips_mappings')
- finish
-endif
-let s:did_snips_mappings = 1
-
-ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
-snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
-ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
-snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
-ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr>
-
-" The default mappings for these are annoying & sometimes break snipMate.
-" You can change them back if you want, I've put them here for convenience.
-snor <bs> b<bs>
-snor <right> <esc>a
-snor <left> <esc>bi
-snor ' b<bs>'
-snor ` b<bs>`
-snor % b<bs>%
-snor U b<bs>U
-snor ^ b<bs>^
-snor \ b<bs>\
-snor <c-x> b<bs><c-x>
-
-" By default load snippets in snippets_dir
-if empty(snippets_dir)
- finish
-endif
-
-call GetSnippets(snippets_dir, '_') " Get global snippets
-
-au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
-" vim:noet:sw=4:ts=4:ft=vim
+++ /dev/null
-"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
-"
-"=============================================================================
-" LOAD GUARD {{{1
-
-if exists('g:loaded_autoload_acp') || v:version < 702
- finish
-endif
-let g:loaded_autoload_acp = 1
-
-" }}}1
-"=============================================================================
-" GLOBAL FUNCTIONS: {{{1
-
-"
-function acp#enable()
- call acp#disable()
-
- augroup AcpGlobalAutoCommand
- autocmd!
- autocmd InsertEnter * unlet! s:posLast s:lastUncompletable
- autocmd InsertLeave * call s:finishPopup(1)
- augroup END
-
- if g:acp_mappingDriven
- call s:mapForMappingDriven()
- else
- autocmd AcpGlobalAutoCommand CursorMovedI * call s:feedPopup()
- endif
-
- nnoremap <silent> i i<C-r>=<SID>feedPopup()<CR>
- nnoremap <silent> a a<C-r>=<SID>feedPopup()<CR>
- nnoremap <silent> R R<C-r>=<SID>feedPopup()<CR>
-endfunction
-
-"
-function acp#disable()
- call s:unmapForMappingDriven()
- augroup AcpGlobalAutoCommand
- autocmd!
- augroup END
- nnoremap i <Nop> | nunmap i
- nnoremap a <Nop> | nunmap a
- nnoremap R <Nop> | nunmap R
-endfunction
-
-"
-function acp#lock()
- let s:lockCount += 1
-endfunction
-
-"
-function acp#unlock()
- let s:lockCount -= 1
- if s:lockCount < 0
- let s:lockCount = 0
- throw "AutoComplPop: not locked"
- endif
-endfunction
-
-"
-function acp#meetsForSnipmate(context)
- if g:acp_behaviorSnipmateLength < 0
- return 0
- endif
- let matches = matchlist(a:context, '\(^\|\s\|\<\)\(\u\{' .
- \ g:acp_behaviorSnipmateLength . ',}\)$')
- return !empty(matches) && !empty(s:getMatchingSnipItems(matches[2]))
-endfunction
-
-"
-function acp#meetsForKeyword(context)
- if g:acp_behaviorKeywordLength < 0
- return 0
- endif
- let matches = matchlist(a:context, '\(\k\{' . g:acp_behaviorKeywordLength . ',}\)$')
- if empty(matches)
- return 0
- endif
- for ignore in g:acp_behaviorKeywordIgnores
- if stridx(ignore, matches[1]) == 0
- return 0
- endif
- endfor
- return 1
-endfunction
-
-"
-function acp#meetsForFile(context)
- if g:acp_behaviorFileLength < 0
- return 0
- endif
- if has('win32') || has('win64')
- let separator = '[/\\]'
- else
- let separator = '\/'
- endif
- if a:context !~ '\f' . separator . '\f\{' . g:acp_behaviorFileLength . ',}$'
- return 0
- endif
- return a:context !~ '[*/\\][/\\]\f*$\|[^[:print:]]\f*$'
-endfunction
-
-"
-function acp#meetsForRubyOmni(context)
- if !has('ruby')
- return 0
- endif
- if g:acp_behaviorRubyOmniMethodLength >= 0 &&
- \ a:context =~ '[^. \t]\(\.\|::\)\k\{' .
- \ g:acp_behaviorRubyOmniMethodLength . ',}$'
- return 1
- endif
- if g:acp_behaviorRubyOmniSymbolLength >= 0 &&
- \ a:context =~ '\(^\|[^:]\):\k\{' .
- \ g:acp_behaviorRubyOmniSymbolLength . ',}$'
- return 1
- endif
- return 0
-endfunction
-
-"
-function acp#meetsForPythonOmni(context)
- return has('python') && g:acp_behaviorPythonOmniLength >= 0 &&
- \ a:context =~ '\k\.\k\{' . g:acp_behaviorPythonOmniLength . ',}$'
-endfunction
-
-"
-function acp#meetsForPerlOmni(context)
- return g:acp_behaviorPerlOmniLength >= 0 &&
- \ a:context =~ '\w->\k\{' . g:acp_behaviorPerlOmniLength . ',}$'
-endfunction
-
-"
-function acp#meetsForXmlOmni(context)
- return g:acp_behaviorXmlOmniLength >= 0 &&
- \ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
- \ g:acp_behaviorXmlOmniLength . ',}$'
-endfunction
-
-"
-function acp#meetsForHtmlOmni(context)
- return g:acp_behaviorHtmlOmniLength >= 0 &&
- \ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
- \ g:acp_behaviorHtmlOmniLength . ',}$'
-endfunction
-
-"
-function acp#meetsForCssOmni(context)
- if g:acp_behaviorCssOmniPropertyLength >= 0 &&
- \ a:context =~ '\(^\s\|[;{]\)\s*\k\{' .
- \ g:acp_behaviorCssOmniPropertyLength . ',}$'
- return 1
- endif
- if g:acp_behaviorCssOmniValueLength >= 0 &&
- \ a:context =~ '[:@!]\s*\k\{' .
- \ g:acp_behaviorCssOmniValueLength . ',}$'
- return 1
- endif
- return 0
-endfunction
-
-"
-function acp#completeSnipmate(findstart, base)
- if a:findstart
- let s:posSnipmateCompletion = len(matchstr(s:getCurrentText(), '.*\U'))
- return s:posSnipmateCompletion
- endif
- let lenBase = len(a:base)
- let items = filter(GetSnipsInCurrentScope(),
- \ 'strpart(v:key, 0, lenBase) ==? a:base')
- return map(sort(items(items)), 's:makeSnipmateItem(v:val[0], v:val[1])')
-endfunction
-
-"
-function acp#onPopupCloseSnipmate()
- let word = s:getCurrentText()[s:posSnipmateCompletion :]
- for trigger in keys(GetSnipsInCurrentScope())
- if word ==# trigger
- call feedkeys("\<C-r>=TriggerSnippet()\<CR>", "n")
- return 0
- endif
- endfor
- return 1
-endfunction
-
-"
-function acp#onPopupPost()
- " to clear <C-r>= expression on command-line
- echo ''
- if pumvisible()
- inoremap <silent> <expr> <C-h> acp#onBs()
- inoremap <silent> <expr> <BS> acp#onBs()
- " a command to restore to original text and select the first match
- return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>" ? "\<C-n>\<Up>"
- \ : "\<C-p>\<Down>")
- endif
- let s:iBehavs += 1
- if len(s:behavsCurrent) > s:iBehavs
- call s:setCompletefunc()
- return printf("\<C-e>%s\<C-r>=acp#onPopupPost()\<CR>",
- \ s:behavsCurrent[s:iBehavs].command)
- else
- let s:lastUncompletable = {
- \ 'word': s:getCurrentWord(),
- \ 'commands': map(copy(s:behavsCurrent), 'v:val.command')[1:],
- \ }
- call s:finishPopup(0)
- return "\<C-e>"
- endif
-endfunction
-
-"
-function acp#onBs()
- " using "matchstr" and not "strpart" in order to handle multi-byte
- " characters
- if call(s:behavsCurrent[s:iBehavs].meets,
- \ [matchstr(s:getCurrentText(), '.*\ze.')])
- return "\<BS>"
- endif
- return "\<C-e>\<BS>"
-endfunction
-
-" }}}1
-"=============================================================================
-" LOCAL FUNCTIONS: {{{1
-
-"
-function s:mapForMappingDriven()
- call s:unmapForMappingDriven()
- let s:keysMappingDriven = [
- \ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- \ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- \ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- \ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- \ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- \ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', '\',
- \ '<Space>', '<C-h>', '<BS>', ]
- for key in s:keysMappingDriven
- execute printf('inoremap <silent> %s %s<C-r>=<SID>feedPopup()<CR>',
- \ key, key)
- endfor
-endfunction
-
-"
-function s:unmapForMappingDriven()
- if !exists('s:keysMappingDriven')
- return
- endif
- for key in s:keysMappingDriven
- execute 'iunmap ' . key
- endfor
- let s:keysMappingDriven = []
-endfunction
-
-"
-function s:setTempOption(group, name, value)
- call extend(s:tempOptionSet[a:group], { a:name : eval('&' . a:name) }, 'keep')
- execute printf('let &%s = a:value', a:name)
-endfunction
-
-"
-function s:restoreTempOptions(group)
- for [name, value] in items(s:tempOptionSet[a:group])
- execute printf('let &%s = value', name)
- endfor
- let s:tempOptionSet[a:group] = {}
-endfunction
-
-"
-function s:getCurrentWord()
- return matchstr(s:getCurrentText(), '\k*$')
-endfunction
-
-"
-function s:getCurrentText()
- return strpart(getline('.'), 0, col('.') - 1)
-endfunction
-
-"
-function s:getPostText()
- return strpart(getline('.'), col('.') - 1)
-endfunction
-
-"
-function s:isModifiedSinceLastCall()
- if exists('s:posLast')
- let posPrev = s:posLast
- let nLinesPrev = s:nLinesLast
- let textPrev = s:textLast
- endif
- let s:posLast = getpos('.')
- let s:nLinesLast = line('$')
- let s:textLast = getline('.')
- if !exists('posPrev')
- return 1
- elseif posPrev[1] != s:posLast[1] || nLinesPrev != s:nLinesLast
- return (posPrev[1] - s:posLast[1] == nLinesPrev - s:nLinesLast)
- elseif textPrev ==# s:textLast
- return 0
- elseif posPrev[2] > s:posLast[2]
- return 1
- elseif has('gui_running') && has('multi_byte')
- " NOTE: auto-popup causes a strange behavior when IME/XIM is working
- return posPrev[2] + 1 == s:posLast[2]
- endif
- return posPrev[2] != s:posLast[2]
-endfunction
-
-"
-function s:makeCurrentBehaviorSet()
- let modified = s:isModifiedSinceLastCall()
- if exists('s:behavsCurrent[s:iBehavs].repeat') && s:behavsCurrent[s:iBehavs].repeat
- let behavs = [ s:behavsCurrent[s:iBehavs] ]
- elseif exists('s:behavsCurrent[s:iBehavs]')
- return []
- elseif modified
- let behavs = copy(exists('g:acp_behavior[&filetype]')
- \ ? g:acp_behavior[&filetype]
- \ : g:acp_behavior['*'])
- else
- return []
- endif
- let text = s:getCurrentText()
- call filter(behavs, 'call(v:val.meets, [text])')
- let s:iBehavs = 0
- if exists('s:lastUncompletable') &&
- \ stridx(s:getCurrentWord(), s:lastUncompletable.word) == 0 &&
- \ map(copy(behavs), 'v:val.command') ==# s:lastUncompletable.commands
- let behavs = []
- else
- unlet! s:lastUncompletable
- endif
- return behavs
-endfunction
-
-"
-function s:feedPopup()
- " NOTE: CursorMovedI is not triggered while the popup menu is visible. And
- " it will be triggered when popup menu is disappeared.
- if s:lockCount > 0 || pumvisible() || &paste
- return ''
- endif
- if exists('s:behavsCurrent[s:iBehavs].onPopupClose')
- if !call(s:behavsCurrent[s:iBehavs].onPopupClose, [])
- call s:finishPopup(1)
- return ''
- endif
- endif
- let s:behavsCurrent = s:makeCurrentBehaviorSet()
- if empty(s:behavsCurrent)
- call s:finishPopup(1)
- return ''
- endif
- " In case of dividing words by symbols (e.g. "for(int", "ab==cd") while a
- " popup menu is visible, another popup is not available unless input <C-e>
- " or try popup once. So first completion is duplicated.
- call insert(s:behavsCurrent, s:behavsCurrent[s:iBehavs])
- call s:setTempOption(s:GROUP0, 'spell', 0)
- call s:setTempOption(s:GROUP0, 'completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
- call s:setTempOption(s:GROUP0, 'complete', g:acp_completeOption)
- call s:setTempOption(s:GROUP0, 'ignorecase', g:acp_ignorecaseOption)
- " NOTE: With CursorMovedI driven, Set 'lazyredraw' to avoid flickering.
- " With Mapping driven, set 'nolazyredraw' to make a popup menu visible.
- call s:setTempOption(s:GROUP0, 'lazyredraw', !g:acp_mappingDriven)
- " NOTE: 'textwidth' must be restored after <C-e>.
- call s:setTempOption(s:GROUP1, 'textwidth', 0)
- call s:setCompletefunc()
- call feedkeys(s:behavsCurrent[s:iBehavs].command . "\<C-r>=acp#onPopupPost()\<CR>", 'n')
- return '' " this function is called by <C-r>=
-endfunction
-
-"
-function s:finishPopup(fGroup1)
- inoremap <C-h> <Nop> | iunmap <C-h>
- inoremap <BS> <Nop> | iunmap <BS>
- let s:behavsCurrent = []
- call s:restoreTempOptions(s:GROUP0)
- if a:fGroup1
- call s:restoreTempOptions(s:GROUP1)
- endif
-endfunction
-
-"
-function s:setCompletefunc()
- if exists('s:behavsCurrent[s:iBehavs].completefunc')
- call s:setTempOption(0, 'completefunc', s:behavsCurrent[s:iBehavs].completefunc)
- endif
-endfunction
-
-"
-function s:makeSnipmateItem(key, snip)
- if type(a:snip) == type([])
- let descriptions = map(copy(a:snip), 'v:val[0]')
- let snipFormatted = '[MULTI] ' . join(descriptions, ', ')
- else
- let snipFormatted = substitute(a:snip, '\(\n\|\s\)\+', ' ', 'g')
- endif
- return {
- \ 'word': a:key,
- \ 'menu': strpart(snipFormatted, 0, 80),
- \ }
-endfunction
-
-"
-function s:getMatchingSnipItems(base)
- let key = a:base . "\n"
- if !exists('s:snipItems[key]')
- let s:snipItems[key] = items(GetSnipsInCurrentScope())
- call filter(s:snipItems[key], 'strpart(v:val[0], 0, len(a:base)) ==? a:base')
- call map(s:snipItems[key], 's:makeSnipmateItem(v:val[0], v:val[1])')
- endif
- return s:snipItems[key]
-endfunction
-
-" }}}1
-"=============================================================================
-" INITIALIZATION {{{1
-
-let s:GROUP0 = 0
-let s:GROUP1 = 1
-let s:lockCount = 0
-let s:behavsCurrent = []
-let s:iBehavs = 0
-let s:tempOptionSet = [{}, {}]
-let s:snipItems = {}
-
-" }}}1
-"=============================================================================
-" vim: set fdm=marker:
+++ /dev/null
-fun! Filename(...)
- let filename = expand('%:t:r')
- if filename == '' | return a:0 == 2 ? a:2 : '' | endif
- return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
-endf
-
-fun s:RemoveSnippet()
- unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen
- \ s:lastBuf s:oldWord
- if exists('s:update')
- unl s:startCol s:origWordLen s:update
- if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif
- endif
- aug! snipMateAutocmds
-endf
-
-fun snipMate#expandSnip(snip, col)
- let lnum = line('.') | let col = a:col
-
- let snippet = s:ProcessSnippet(a:snip)
- " Avoid error if eval evaluates to nothing
- if snippet == '' | return '' | endif
-
- " Expand snippet onto current position with the tab stops removed
- let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
-
- let line = getline(lnum)
- let afterCursor = strpart(line, col - 1)
- " Keep text after the cursor
- if afterCursor != "\t" && afterCursor != ' '
- let line = strpart(line, 0, col - 1)
- let snipLines[-1] .= afterCursor
- else
- let afterCursor = ''
- " For some reason the cursor needs to move one right after this
- if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
- let col += 1
- endif
- endif
-
- call setline(lnum, line.snipLines[0])
-
- " Autoindent snippet according to previous indentation
- let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
- call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
-
- " Open any folds snippet expands into
- if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
-
- let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
-
- if s:snipLen
- aug snipMateAutocmds
- au CursorMovedI * call s:UpdateChangedSnip(0)
- au InsertEnter * call s:UpdateChangedSnip(1)
- aug END
- let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer
- let s:curPos = 0
- let s:endCol = g:snipPos[s:curPos][1]
- let s:endLine = g:snipPos[s:curPos][0]
-
- call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
- let s:prevLen = [line('$'), col('$')]
- if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
- else
- unl g:snipPos s:snipLen
- " Place cursor at end of snippet if no tab stop is given
- let newlines = len(snipLines) - 1
- call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
- \ + (newlines ? 0: col - 1))
- endif
- return ''
-endf
-
-" Prepare snippet to be processed by s:BuildTabStops
-fun s:ProcessSnippet(snip)
- let snippet = a:snip
- " Evaluate eval (`...`) expressions.
- " Using a loop here instead of a regex fixes a bug with nested "\=".
- if stridx(snippet, '`') != -1
- while match(snippet, '`.\{-}`') != -1
- let snippet = substitute(snippet, '`.\{-}`',
- \ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
- \ "\n\\%$", '', ''), '')
- endw
- let snippet = substitute(snippet, "\r", "\n", 'g')
- endif
-
- " Place all text after a colon in a tab stop after the tab stop
- " (e.g. "${#:foo}" becomes "${:foo}foo").
- " This helps tell the position of the tab stops later.
- let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
-
- " Update the a:snip so that all the $# become the text after
- " the colon in their associated ${#}.
- " (e.g. "${1:foo}" turns all "$1"'s into "foo")
- let i = 1
- while stridx(snippet, '${'.i) != -1
- let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
- if s != ''
- let snippet = substitute(snippet, '$'.i, s.'&', 'g')
- endif
- let i += 1
- endw
-
- if &et " Expand tabs to spaces if 'expandtab' is set.
- return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
- endif
- return snippet
-endf
-
-" Counts occurences of haystack in needle
-fun s:Count(haystack, needle)
- let counter = 0
- let index = stridx(a:haystack, a:needle)
- while index != -1
- let index = stridx(a:haystack, a:needle, index+1)
- let counter += 1
- endw
- return counter
-endf
-
-" Builds a list of a list of each tab stop in the snippet containing:
-" 1.) The tab stop's line number.
-" 2.) The tab stop's column number
-" (by getting the length of the string between the last "\n" and the
-" tab stop).
-" 3.) The length of the text after the colon for the current tab stop
-" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
-" 4.) If the "${#:}" construct is given, another list containing all
-" the matches of "$#", to be replaced with the placeholder. This list is
-" composed the same way as the parent; the first item is the line number,
-" and the second is the column.
-fun s:BuildTabStops(snip, lnum, col, indent)
- let snipPos = []
- let i = 1
- let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
- while stridx(a:snip, '${'.i) != -1
- let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
- let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
-
- let j = i - 1
- call add(snipPos, [0, 0, -1])
- let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
- let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
- if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
-
- " Get all $# matches in another list, if ${#:name} is given
- if stridx(withoutVars, '${'.i.':') != -1
- let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
- let dots = repeat('.', snipPos[j][2])
- call add(snipPos[j], [])
- let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
- while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1
- let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)')
- call add(snipPos[j][3], [0, 0])
- let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
- let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
- \ ? len(matchstr(beforeMark, '.*\n\zs.*'))
- \ : a:col + len(beforeMark))
- let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '')
- endw
- endif
- let i += 1
- endw
- return [snipPos, i - 1]
-endf
-
-fun snipMate#jumpTabStop(backwards)
- let leftPlaceholder = exists('s:origWordLen')
- \ && s:origWordLen != g:snipPos[s:curPos][2]
- if leftPlaceholder && exists('s:oldEndCol')
- let startPlaceholder = s:oldEndCol + 1
- endif
-
- if exists('s:update')
- call s:UpdatePlaceholderTabStops()
- else
- call s:UpdateTabStops()
- endif
-
- " Don't reselect placeholder if it has been modified
- if leftPlaceholder && g:snipPos[s:curPos][2] != -1
- if exists('startPlaceholder')
- let g:snipPos[s:curPos][1] = startPlaceholder
- else
- let g:snipPos[s:curPos][1] = col('.')
- let g:snipPos[s:curPos][2] = 0
- endif
- endif
-
- let s:curPos += a:backwards ? -1 : 1
- " Loop over the snippet when going backwards from the beginning
- if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif
-
- if s:curPos == s:snipLen
- let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
- call s:RemoveSnippet()
- return sMode ? "\<tab>" : TriggerSnippet()
- endif
-
- call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
-
- let s:endLine = g:snipPos[s:curPos][0]
- let s:endCol = g:snipPos[s:curPos][1]
- let s:prevLen = [line('$'), col('$')]
-
- return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord()
-endf
-
-fun s:UpdatePlaceholderTabStops()
- let changeLen = s:origWordLen - g:snipPos[s:curPos][2]
- unl s:startCol s:origWordLen s:update
- if !exists('s:oldVars') | return | endif
- " Update tab stops in snippet if text has been added via "$#"
- " (e.g., in "${1:foo}bar$1${2}").
- if changeLen != 0
- let curLine = line('.')
-
- for pos in g:snipPos
- if pos == g:snipPos[s:curPos] | continue | endif
- let changed = pos[0] == curLine && pos[1] > s:oldEndCol
- let changedVars = 0
- let endPlaceholder = pos[2] - 1 + pos[1]
- " Subtract changeLen from each tab stop that was after any of
- " the current tab stop's placeholders.
- for [lnum, col] in s:oldVars
- if lnum > pos[0] | break | endif
- if pos[0] == lnum
- if pos[1] > col || (pos[2] == -1 && pos[1] == col)
- let changed += 1
- elseif col < endPlaceholder
- let changedVars += 1
- endif
- endif
- endfor
- let pos[1] -= changeLen * changed
- let pos[2] -= changeLen * changedVars " Parse variables within placeholders
- " e.g., "${1:foo} ${2:$1bar}"
-
- if pos[2] == -1 | continue | endif
- " Do the same to any placeholders in the other tab stops.
- for nPos in pos[3]
- let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol
- for [lnum, col] in s:oldVars
- if lnum > nPos[0] | break | endif
- if nPos[0] == lnum && nPos[1] > col
- let changed += 1
- endif
- endfor
- let nPos[1] -= changeLen * changed
- endfor
- endfor
- endif
- unl s:endCol s:oldVars s:oldEndCol
-endf
-
-fun s:UpdateTabStops()
- let changeLine = s:endLine - g:snipPos[s:curPos][0]
- let changeCol = s:endCol - g:snipPos[s:curPos][1]
- if exists('s:origWordLen')
- let changeCol -= s:origWordLen
- unl s:origWordLen
- endif
- let lnum = g:snipPos[s:curPos][0]
- let col = g:snipPos[s:curPos][1]
- " Update the line number of all proceeding tab stops if <cr> has
- " been inserted.
- if changeLine != 0
- let changeLine -= 1
- for pos in g:snipPos
- if pos[0] >= lnum
- if pos[0] == lnum | let pos[1] += changeCol | endif
- let pos[0] += changeLine
- endif
- if pos[2] == -1 | continue | endif
- for nPos in pos[3]
- if nPos[0] >= lnum
- if nPos[0] == lnum | let nPos[1] += changeCol | endif
- let nPos[0] += changeLine
- endif
- endfor
- endfor
- elseif changeCol != 0
- " Update the column of all proceeding tab stops if text has
- " been inserted/deleted in the current line.
- for pos in g:snipPos
- if pos[1] >= col && pos[0] == lnum
- let pos[1] += changeCol
- endif
- if pos[2] == -1 | continue | endif
- for nPos in pos[3]
- if nPos[0] > lnum | break | endif
- if nPos[0] == lnum && nPos[1] >= col
- let nPos[1] += changeCol
- endif
- endfor
- endfor
- endif
-endf
-
-fun s:SelectWord()
- let s:origWordLen = g:snipPos[s:curPos][2]
- let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1,
- \ s:origWordLen)
- let s:prevLen[1] -= s:origWordLen
- if !empty(g:snipPos[s:curPos][3])
- let s:update = 1
- let s:endCol = -1
- let s:startCol = g:snipPos[s:curPos][1] - 1
- endif
- if !s:origWordLen | return '' | endif
- let l = col('.') != 1 ? 'l' : ''
- if &sel == 'exclusive'
- return "\<esc>".l.'v'.s:origWordLen."l\<c-g>"
- endif
- return s:origWordLen == 1 ? "\<esc>".l.'gh'
- \ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>"
-endf
-
-" This updates the snippet as you type when text needs to be inserted
-" into multiple places (e.g. in "${1:default text}foo$1bar$1",
-" "default text" would be highlighted, and if the user types something,
-" UpdateChangedSnip() would be called so that the text after "foo" & "bar"
-" are updated accordingly)
-"
-" It also automatically quits the snippet if the cursor is moved out of it
-" while in insert mode.
-fun s:UpdateChangedSnip(entering)
- if exists('g:snipPos') && bufnr(0) != s:lastBuf
- call s:RemoveSnippet()
- elseif exists('s:update') " If modifying a placeholder
- if !exists('s:oldVars') && s:curPos + 1 < s:snipLen
- " Save the old snippet & word length before it's updated
- " s:startCol must be saved too, in case text is added
- " before the snippet (e.g. in "foo$1${2}bar${1:foo}").
- let s:oldEndCol = s:startCol
- let s:oldVars = deepcopy(g:snipPos[s:curPos][3])
- endif
- let col = col('.') - 1
-
- if s:endCol != -1
- let changeLen = col('$') - s:prevLen[1]
- let s:endCol += changeLen
- else " When being updated the first time, after leaving select mode
- if a:entering | return | endif
- let s:endCol = col - 1
- endif
-
- " If the cursor moves outside the snippet, quit it
- if line('.') != g:snipPos[s:curPos][0] || col < s:startCol ||
- \ col - 1 > s:endCol
- unl! s:startCol s:origWordLen s:oldVars s:update
- return s:RemoveSnippet()
- endif
-
- call s:UpdateVars()
- let s:prevLen[1] = col('$')
- elseif exists('g:snipPos')
- if !a:entering && g:snipPos[s:curPos][2] != -1
- let g:snipPos[s:curPos][2] = -2
- endif
-
- let col = col('.')
- let lnum = line('.')
- let changeLine = line('$') - s:prevLen[0]
-
- if lnum == s:endLine
- let s:endCol += col('$') - s:prevLen[1]
- let s:prevLen = [line('$'), col('$')]
- endif
- if changeLine != 0
- let s:endLine += changeLine
- let s:endCol = col
- endif
-
- " Delete snippet if cursor moves out of it in insert mode
- if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1]))
- \ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0]
- call s:RemoveSnippet()
- endif
- endif
-endf
-
-" This updates the variables in a snippet when a placeholder has been edited.
-" (e.g., each "$1" in "${1:foo} $1bar $1bar")
-fun s:UpdateVars()
- let newWordLen = s:endCol - s:startCol + 1
- let newWord = strpart(getline('.'), s:startCol, newWordLen)
- if newWord == s:oldWord || empty(g:snipPos[s:curPos][3])
- return
- endif
-
- let changeLen = g:snipPos[s:curPos][2] - newWordLen
- let curLine = line('.')
- let startCol = col('.')
- let oldStartSnip = s:startCol
- let updateTabStops = changeLen != 0
- let i = 0
-
- for [lnum, col] in g:snipPos[s:curPos][3]
- if updateTabStops
- let start = s:startCol
- if lnum == curLine && col <= start
- let s:startCol -= changeLen
- let s:endCol -= changeLen
- endif
- for nPos in g:snipPos[s:curPos][3][(i):]
- " This list is in ascending order, so quit if we've gone too far.
- if nPos[0] > lnum | break | endif
- if nPos[0] == lnum && nPos[1] > col
- let nPos[1] -= changeLen
- endif
- endfor
- if lnum == curLine && col > start
- let col -= changeLen
- let g:snipPos[s:curPos][3][i][1] = col
- endif
- let i += 1
- endif
-
- " "Very nomagic" is used here to allow special characters.
- call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'.
- \ escape(s:oldWord, '\'), escape(newWord, '\&'), ''))
- endfor
- if oldStartSnip != s:startCol
- call cursor(0, startCol + s:startCol - oldStartSnip)
- endif
-
- let s:oldWord = newWord
- let g:snipPos[s:curPos][2] = newWordLen
-endf
-" vim:noet:sw=4:ts=4:ft=vim
+++ /dev/null
-*EasyGrep.txt*
-==============================================================================
- EasyGrep *EasyGrep*
-==============================================================================
-
-Author: Dan Price vim@danprice.fastmail.net *EasyGrep_Author*
-
-Goal: To be an easy to use, powerful find and |EasyGrep_Motivation|
- replace tool for users of all skill levels.
-Version: 0.98 |EasyGrep_History|
-
-License: Public domain, no restrictions whatsoever |EasyGrep_License|
-Contribute: Please report any bugs or suggestions |EasyGrep_Bugs|
- to the address above. |EasyGrep_Future|
-
-
-==============================================================================
- Table of Contents *EasyGrep_Contents*
-==============================================================================
-
-
- 1. Motivation.................|EasyGrep_Motivation|
- 2. Operation..................|EasyGrep_Operation|
- 2.1 Modes..................|EasyGrep_OperationModes|
- 3. Keymaps....................|EasyGrep_Keymaps|
- 3.1 Option Mappings........|EasyGrep_KeymapsOptions|
- 3.2 Mapping Customization..|EasyGrep_KeymapsCustomization|
- 4. Commands...................|EasyGrep_Commands|
- 5. Options....................|EasyGrep_Options|
- 5.1 Summary...............|EasyGrep_OptionsSummary|
- 5.2 Explorer..............|EasyGrep_OptionsExplorer|
- 5.3 Details...............|EasyGrep_OptionsDetail|
- 6. Bugs.......................|EasyGrep_Bugs|
- 7. Future.....................|EasyGrep_Future|
- 8. History....................|EasyGrep_History|
- 9. License....................|EasyGrep_License|
-
-
-==============================================================================
- Motivation *EasyGrep_Motivation*
-==============================================================================
-
-EasyGrep's main goal is to make search and replace in files easy. Other Vim
-plugins provide similar functionality, but few provide the same level of
-functionality with as little configuration as EasyGrep does. In the common
-case, all it takes to search for a string across multiple files is three
-keypresses: <leader>vv. No clicks, no commands, no project/tags setup -- just
-three keys. When you need a substitution, it also takes the same number of
-keys to start a replace in files. After using EasyGrep, you'll wonder at how
-you got around without it.
-
-While EasyGrep's default configuration will satisfy many users, it provides
-more than a dozen options for those who need more control |EasyGrep_Options|.
-When you need to change options, EasyGrep provides an options explorer that
-indicates which files will be searched and allows visual customization of its
-options |EasyGrep_OptionsExplorer|. When this isn't fast enough, EasyGrep
-provides key mappings for each option to toggle its value
-|EasyGrep_KeymapsOptions|. If you can't find an option you need, contact me
-|EasyGrep_Author| and if it doesn't already exist, we'll make it happen.
-
-I hope that EasyGrep makes Vim more fun, productive, and easy for you to use.
-
- Happy Vimming!
-
-
-==============================================================================
- Operation *EasyGrep_Operation*
-==============================================================================
-
-EasyGrep makes using Vim's grep capabilities easier. When using EasyGrep,
-searching for a word is as easy as typing a three keypress mapping
-|EasyGrep_Keymaps|. In addition to keymaps, search and replace can be invoked
-through commands |EasyGrep_Commands|.
-
-To determine which files to search, EasyGrep provides three modes, described
-in the next section.
-
-
-Search Modes |EasyGrep_OperationModes|
-
-All
- All files will be searched (default).
-
-Buffers
- Files currently open in vim will be searched. Recursion has no meaning in
- this mode, and will be turned off.
-
-TrackExt
- Files that match the extension of the currently opened file will be
- searched. Additionally, this extension can be mapped to a user defined
- set of extensions that will also be searched |EasyGrepFileAssociations|.
-
- For example: in the default configuration, when test.cpp is open, files
- that match any one of
-
- *.cpp *.hpp *.cxx *.hxx *.cc *.c *.h
-
- will be searched when a Grep is initiated. I find this mode to be the
- most useful.
-
-User
- Specify a custom set of file extensions to search.
-
-
-These modes can be quickly changed through the |EasyGrep_OptionsExplorer| or
-|EasyGrep_KeymapsOptions|.
-
-
-==============================================================================
- Keymaps *EasyGrep_Keymaps*
-==============================================================================
-
-EasyGrep uses Vim's leader key, which is by default '\'. For information on
-this key, type ":help mapleader".
-
-<Leader>vv - Grep for the word under the cursor, match all occurences,
- like 'g*'. See ":help gstar".
-<Leader>vV - Grep for the word under the cursor, match whole word, like
- '*'. See ":help star".
-<Leader>va - Like vv, but add to existing list.
-<Leader>vA - Like vV, but add to existing list.
-
-<Leader>vr - Perform a global search on the word under the cursor
- and prompt for a pattern with which to replace it.
-<Leader>vR - Like vr, but match whole word.
-
-Each of these commands has an 'all occurences' and 'whole word' option,
-designated by the case of the last character. If you would prefer that these
-be reversed, see |EasyGrepInvertWholeWord|.
-
-In addition to grepping the word under the cursor, text may be visually
-selected and these mappings may be used analogously to as they are used above.
-Visual selections will automatically be escaped so as not to confuse the
-selection with a regular expression.
-
- e.g. Selecting the text inside the quotes here "/<word\>" will match
- against "\<word\>" but not against "word".
-
-To search with a regular expression, see the :Grep command |EasyGrep_Commands|
-
-Each of the above commands will search files according to settings
-controlled by:
-
-<Leader>vo - Open an options explorer to select the files to search in and
- set grep options.
-
-For the options provided, see |EasyGrep_Options|.
-
-
- *EasyGrep_KeymapsOptions*
-
-For each of the options presented in the options explorer, there is a mapping
-that allows a direct change of this option. The pattern is <Leader>vy* ,
-where star is the value listed in the options window for each of the options.
-
- e.g. To toggle recursive mode, type '\vyr'
-
-See |EasyGrepOptionPrefix| to change the prefix from '\vy' or to turn these
-keymappings off.
-
-
- *EasyGrep_KeymapsCustomization*
-
-Beyond EasyGrepOptionPrefix, other keymaps may be remapped to your liking.
-See the "Keymaps" section of EasyGrep.vim for the names of these items.
-
-Mappings take the form:
-
- map <silent> (keycombination) <plug>(MappingName)
-e.g.
- map <silent> ,op <plug>EgMapGrepOptions
-
-
-==============================================================================
- Commands *EasyGrep_Commands*
-==============================================================================
-
-:Grep [arg]
- Search for the specified arg, like <Leader>vv. When an ! is added,
- search like <Leader>vV
-
-:GrepAdd [arg]
- Search for the specified arg, add to existing file list, as in
- <Leader>va. When an ! is added, search like <Leader>vA
-
- The Above commands can additionally accept command switches:
- -r Perform a recursive search
- -R Perform a recursive search
- -i Perform a case-insensitive search
- -I Perform a case-sensitive search
- -m Specify the number of matches to get
-
-:Replace [target] [replacement]
-:Replace /[target]/[replacement]/
- Perform a global search and replace. The function searches
- the same set of files a grep for the desired target and opens a dialog to
- confirm replacement. In the second, forward slash delineated form, back
- and forward slashes must be explicitly escaped.
-
-:ReplaceUndo
- Undoes the last :Replace operation. Does not stack successive
- searches; only the last replace may be undone. This function may not
- work well when edits are made between a call to Replace and a call to
- ReplaceUndo.
-
-:GrepOptions
- Open the options explorer to set options.
-
-
-For each of the search and replace commands, searching with regular
-expressions is supported. Note that regular expressions are handled as
-indicated by the 'magic' option (see ":help 'magic'").
-
-:FilterErrorlist [args]
- Removes entries from the error list according to whether or not they match
- a set of specified patterns. The default behaviour is to save all entries
- that match one of the patterns and remove those that do not.
-
- The Above command can additionally accept command switches:
- -v Switch the criteria for matching; remove entries matching one of the
- specified patterns instead of saving them
- -l Remove entries from the location list
-
-
-==============================================================================
- Options *EasyGrep_Options*
-==============================================================================
-
-Options Summary *EasyGrep_OptionsSummary*
-
- Option Description
-------------------------------------------------------------------------------
-|EasyGrepFileAssociations| Specifies the location of the EasyGrep
- file associations
-------------------------------------------------------------------------------
-|EasyGrepMode| Mode of operation
-------------------------------------------------------------------------------
-|EasyGrepCommand| Whether to use vimgrep or grepprg
-------------------------------------------------------------------------------
-|EasyGrepRecursive| Recursive searching
-------------------------------------------------------------------------------
-|EasyGrepIgnoreCase| Case-sensitivity in searches
-------------------------------------------------------------------------------
-|EasyGrepHidden| Include hidden files in searches
-------------------------------------------------------------------------------
-|EasyGrepAllOptionsInExplorer| How many options to show in the explorer
-------------------------------------------------------------------------------
-|EasyGrepWindow| Quickfix or location list
-------------------------------------------------------------------------------
-|EasyGrepWindowPosition| Where the error list window is opened
-------------------------------------------------------------------------------
-|EasyGrepOpenWindowOnMatch| Open grep window on successful match
-------------------------------------------------------------------------------
-|EasyGrepEveryMatch| Match multiple times per line
-------------------------------------------------------------------------------
-|EasyGrepJumpToMatch| Jump to first match
-------------------------------------------------------------------------------
-|EasyGrepSearchCurrentBufferDir| Whether to search current buffers dir
- in addition to working dir
-------------------------------------------------------------------------------
-|EasyGrepInvertWholeWord| Invert the meaning of whole word for vv
- and vV keymaps
-------------------------------------------------------------------------------
-|EasyGrepFileAssociationsInExplorer| Whether to show the file associations
- list in the options explorer
-------------------------------------------------------------------------------
-|EasyGrepReplaceWindowMode| Controls whether to use tabs or splits
- when replacing in files
-------------------------------------------------------------------------------
-|EasyGrepReplaceAllPerFile| Replace on per file or global basis
-------------------------------------------------------------------------------
-|EasyGrepOptionPrefix| Specify the keymap for toggling options
-------------------------------------------------------------------------------
-|EasyGrepExtraWarnings| Whether to show extra warnings
-------------------------------------------------------------------------------
-
-
-Options Explorer *EasyGrep_OptionsExplorer*
-
- To invoke the options explorer, type '\vo' (default). The options
- explorer presents all of EasyGrep's customizable options and provides
- information on the file patterns that will be searched when invoking a
- Grep.
-
- A useful exercise for beginners is to toggle between EasyGrep's options
- and modes (|EasyGrep_OperationModes|) and type 'e' to see which files will
- be searched for a given configuration.
-
-
-Options Details *EasyGrep_OptionsDetail*
-
-*EasyGrepFileAssociations*
-Specifies the location of a file that contains groups of files that should be
-associated with one another. When set to an empty string "", no file read
-will be attempted.
-
-This file has a simple syntax used to logically link different files types.
-A simple configuration is shown below:
-
- C=*.c *.h
- C++=*.cpp *.hpp *.cxx *.hxx *.cc <C>
- VHDL=*.hdl *.vhd *.vhdl *.vbe *.vst
- Web=*.htm *.html *.js
-
-For example, in this configuration, whenever the active file has the .c
-extension, files with the .h extension will also be search. A special feature
-of this syntax is the ability to link groups together. For example, the C++
-group links to all files that are in the C group.
-
-
-*EasyGrepMode*
-Specifies the mode in which to start.
-0 - All files
-1 - Open Buffers
-2 - Track the current extension
-
-Note: I find option 2 to be the most powerful, but option 0 is activated by
-default because it is the most intuitive for users who haven't take the
-time to understand how the script works. See |EasyGrep_OperationModes|.
-
-*EasyGrepCommand*
-Specifies the grep command to use.
-
-0 - vimgrep
-1 - grep (follows grepprg)
-
-*EasyGrepRecursive*
-Specifies that recursive search be activated on start.
-
-*EasyGrepIgnoreCase*
-Specifies the case sensitivity of searches. Note that this can be further
-overrided for vimgrep searches with \c and \C.
-
-*EasyGrepHidden*
-Specifies that hidden files search be activated on start. Note that hidden
-implies the unix meaning of those files that are prepended with a '.', and not
-the Windows meaning of those files with a hidden attribute.
-
-*EasyGrepAllOptionsInExplorer*
-Specifies that all options be included in the explorer window.
-
-Note: settting this option is very useful when you want to try out and
-learn all of the options available in this script.
-
-*EasyGrepWindow*
-Specifies the window to use for matches.
-0 - quickfix
-1 - location list
-
-*EasyGrepWindowPosition*
-Specifies where the error list window is opened. The value of this option
-must match one of Vim's splitting positional window commands, such as topleft
-or botright.
-
-*EasyGrepOpenWindowOnMatch*
-Specifies whether to open the with matches after a search.
-
-*EasyGrepEveryMatch*
-Specifies that multiple matches on the same line be treated as different
-matches, like the g option to vimgrep.
-
-*EasyGrepJumpToMatch*
-Specifies that jump to first match be activated, like the j option to vimgrep.
-
-*EasyGrepSearchCurrentBufferDir*
-Setting this option causes EasyGrep to search the current buffer's
-directory in addition to the current working directory.
-
-*EasyGrepInvertWholeWord*
-Specifies that the whole word search keys should be inverted from their
-default meaning. For example, when this option is activated, <Leader>vv
-matches whole word, while <Leader>vV matches everything that includes the
-word. Note that this affects both keymappings and commands.
-
-*EasyGrepFileAssociationsInExplorer*
-Specifies whether to show the file associations list in the options explorer
-window.
-
-*EasyGrepOptionPrefix*
-Specifies the prefix that is used when building keymaps for setting options
-directly. To specify that no option keymaps be created, set this to the empty
-string.
-
-Default:
- let g:EasyGrepOptionPrefix='<leader>vy'
-Custom:
- let g:EasyGrepOptionPrefix=',oe'
-None:
- let g:EasyGrepOptionPrefix=''
-
-
-*EasyGrepReplaceWindowMode*
-Specifies the mode that the script will use when a buffer needs to be changed
-while performing a global replace.
-0 - Open a new tab for each window
-1 - Perform a split of the current window with the next window
-2 - autowriteall; create no new windows
-
-Note: Option 1 has the possibility of running out of vertical space to
-split more windows. Actions are taken to make this a non-issue, but this
-option can often be more clunky than other options.
-Note: As a result of the limitation above, option 0 is the only mode that
-won't require saving the files during a replace.
-
-*EasyGrepReplaceAllPerFile*
-Specifies that selecting 'a' (for all) will apply the replacements on a per
-file basis, as opposed to globally as is the default.
-
-*EasyGrepExtraWarnings*
-Specifies that warnings be issued for conditions that may be valid but confuse
-some users.
-
-
-==============================================================================
- Future *EasyGrep_Future*
-==============================================================================
-
-------------------------------------------------------------------------------
-Show search progress?
-------------------------------------------------------------------------------
-Allow entries in the file associations list to be regular expressions
-------------------------------------------------------------------------------
-create capability to include paths other than the active directories in a
-search. e.g. ../../include, $INCLUDE, etc.
-------------------------------------------------------------------------------
-set file/directory exclusions
-------------------------------------------------------------------------------
-
-==============================================================================
- Bugs *EasyGrep_Bugs*
-==============================================================================
-
-If you discover any bugs not listed here, please contact the |EasyGrep_Author|
-
-------------------------------------------------------------------------------
-Successive warning messages can hide a previous message
-------------------------------------------------------------------------------
-ReplaceUndo opens a window even if it is already open?
-------------------------------------------------------------------------------
-Report that a swap file can't be opened
-------------------------------------------------------------------------------
-Don't warn when the current file will actually be searched because recursion
-is on and it is below the current directory
-------------------------------------------------------------------------------
-Patterns with backslashes in them require double-backslash to be searched from
-the command line. This behaviour matches the builtin / command but it may be
-unintuitive.
-------------------------------------------------------------------------------
-
-
-
-==============================================================================
- History *EasyGrep_History*
-==============================================================================
-
- 0.98
- Highlight: The Replace and ReplaceUndo commands were reimplemented. The
- granularity of matches inside of a Replace call were improved so that
- you can now decide replacements individually per line.
- Additionally, Complex operations such as replacing x[i][j][k] with
- x(i,j,k) and following it up with a ReplaceUndo are now possible.
-
- e.g.
- :Replace /x\[\([^]]\+\)\]\[\([^]]\+\)\]\[\([^]]\+\)\]/x(\1,\2,\3)/
- :ReplaceUndo
-
- Please report any regressions with either of these functions.
-
- Feature: Added count command line option (-m 4 or -4)
- Feature: Improved Grep options window keybindings; searching within the
- options explorer window is now possible
- Feature: Expanded searches to include all of the active buffers'
- directories
- Bugfix: Fixed recursive operation and expanded search from reporting
- duplicate results
- Bugfix: Fixed <C-e> and <C-y> in replace mode
- Feature: Added EasyGrepWindowPosition for specifying where the error
- list window will be opened
- Feature: Added FilterErrorlist command for filtering the results within
- the quickfix or location list windows
- Feature: Improved printout when no matches are found
- Feature: Improved searching when an entire line is selected
- 0.96
- Feature: Expanded upon the list of file associations
- Feature: Expanded searches to the current buffer's directory
- in addition to the current working directory
- Feature: Added command line arguments to :Grep and :Replace for
- recursive searches and case sensitivity
- Feature: Added toggle for window replace mode
- Feature: Added toggle for showing file associations list in options
- explorer
- Bugfix: Case insensitivity would fail in replacing some patterns
- 0.95
- Feature: Added search and replace on visual selections
- Feature: Improved Grepping for items that can be interpreted as regular
- expressions. Selections are assumed to be literal, whereas explicit
- commands are assumed to be regular expressions.
- Feature: Removed option g:EasyGrepNoDirectMappings in favor of
- g:EasyGrepOptionPrefix, which allows the option prefix to be changed.
- Bugfix: The tracked extension would sometimes fail to be updated when
- switching between buffers
- Documentation: Split the documentation into its own file; greatly
- expanded upon its contents
- Change: Activating a mode that is already activated will no longer
- deactivate it
- Change: GrepOptions no longer accepts an argument; use user mode instead
- Change: Clarified mapping names; custom mappings will need to
- be reset.
- 0.9
- Feature: Added forward slash delineated pattern to the Replace command
- e.g. :Replace /target/replacement/
- that allows more complicated replacements; you can now work with
- patterns that have spaces in them.
- Bugfix: If cursorline is off at the start of a replace, now ensuring
- that cursorline is turned off for all buffers, and not just the last one
- Bugfix: fixed an issue with an extra tab being opened during a
- replacement
- 0.8
- Implemented case sensitivity that is independent of ignorecase, thanks
- to Doro Wu for contributing to this functionality
- Changed shortcut key for hidden files from 'i' to 'h'
- 0.7
- Expanded search of EasyGrepFileAssociations list to every component of
- 'runtimepath'. This solves a starting message for those who placed
- EasyGrepFileAssociations in a location other than the first location in
- 'runtimepath'.
- 0.6
- Fixed paths with spaces in them
- Folds will now be disabled where replacements are to be made
- Fixed an error with checking for extra warnings
- Better highlighting while replacing
- Recursive mode can no longer be activated when Buffers mode is activated
- 0.5
- Fixed an issue with tracking the file extension where sometimes the
- desired extension wouldn't be registered.
- Better reporting when no files match.
- Now warning when searching from a working directory that doesn't match
- the current file's directory.
- Added g:EasyGrepExtraWarnings option.
- 0.4
- Improved Replace and ReplaceUndo
- Added two configurable modes for how the windows operate when doing a
- global replace.
- Fixed an issue with linked filetypes.
- 0.3
- Added experimental :Replace and :ReplaceUndo commands; keymapped
- <leader>vr for :Replace
- Improved response when no matches
- 0.2
- Added option to toggle showing fewer or more options; showing fewer
- options by default.
- Added option '?' to print the current configuration and save it to a
- register.
- Now creating direct mappings by default; see g:EasyGrepNoDirectMappings
- to turn this off.
- 0.1
- Initial version
-
-
-==============================================================================
- License *EasyGrep_License*
-==============================================================================
-
- Public domain, no restrictions whatsoever
-
-When writing EasyGrep, I wanted it to be free in the broadest sense. Of
-course, most (if not all) plugins for Vim are free, but I wanted mine to be
-freer still: I've released EasyGrep in the public domain. It took a lot of
-time and learning to get EasyGrep to work, and I want anyone to take advantage
-of my contribution. If you see some (or many) snippets of EasyGrep's code
-that you need, use it -- you don't need to ask me, think about any copyright,
-worry about violating a license, or even note that the code came from me, just
-use it. My only request is that if you are thinking of forking EasyGrep (or
-enhancing, as some authors claim to do), please contact me to let me know what
-you feel is lacking in EasyGrep, and I promise I'll be receptive to correcting
-these issues.
-
-
-==============================================================================
-vim:tw=78:ts=4:ft=help:norl:fdm=marker
+++ /dev/null
-*NERD_commenter.txt* Plugin for commenting code
-
-
- NERD COMMENTER REFERENCE MANUAL~
-
-
-
-
-
-==============================================================================
-CONTENTS *NERDCommenterContents*
-
- 1.Intro...................................|NERDCommenter|
- 2.Installation............................|NERDComInstallation|
- 3.Functionality provided..................|NERDComFunctionality|
- 3.1 Functionality Summary.............|NERDComFunctionalitySummary|
- 3.2 Functionality Details.............|NERDComFunctionalityDetails|
- 3.2.1 Comment map.................|NERDComComment|
- 3.2.2 Nested comment map..........|NERDComNestedComment|
- 3.2.3 Toggle comment map..........|NERDComToggleComment|
- 3.2.4 Minimal comment map.........|NERDComMinimalComment|
- 3.2.5 Invert comment map..........|NERDComInvertComment|
- 3.2.6 Sexy comment map............|NERDComSexyComment|
- 3.2.7 Yank comment map............|NERDComYankComment|
- 3.2.8 Comment to EOL map..........|NERDComEOLComment|
- 3.2.9 Append com to line map......|NERDComAppendComment|
- 3.2.10 Insert comment map.........|NERDComInsertComment|
- 3.2.11 Use alternate delims map...|NERDComAltDelim|
- 3.2.12 Comment aligned maps.......|NERDComAlignedComment|
- 3.2.13 Uncomment line map.........|NERDComUncommentLine|
- 3.4 Sexy Comments.....................|NERDComSexyComments|
- 3.5 The NERDComment function..........|NERDComNERDComment|
- 4.Options.................................|NERDComOptions|
- 4.1 Options summary...................|NERDComOptionsSummary|
- 4.2 Options details...................|NERDComOptionsDetails|
- 4.3 Default delimiter Options.........|NERDComDefaultDelims|
- 5. Customising key mappings...............|NERDComMappings|
- 6. Issues with the script.................|NERDComIssues|
- 6.1 Delimiter detection heuristics....|NERDComHeuristics|
- 6.2 Nesting issues....................|NERDComNesting|
- 7.About.. ............................|NERDComAbout|
- 8.Changelog...............................|NERDComChangelog|
- 9.Credits.................................|NERDComCredits|
- 10.License................................|NERDComLicense|
-
-==============================================================================
-1. Intro *NERDCommenter*
-
-The NERD commenter provides many different commenting operations and styles
-which are invoked via key mappings and a menu. These operations are available
-for most filetypes.
-
-There are also options that allow to tweak the commenting engine to your
-taste.
-
-==============================================================================
-2. Installation *NERDComInstallation*
-
-The NERD Commenter requires Vim 7 or higher.
-
-Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You
-should have 2 files: >
- plugin/NERD_commenter.vim
- doc/NERD_commenter.txt
-<
-Next, to finish installing the help file run: >
- :helptags ~/.vim/doc
-<
-See |add-local-help| for more details.
-
-Make sure that you have filetype plugins enabled, as the script makes use of
-|'commentstring'| where possible (which is usually set in a filetype plugin).
-See |filetype-plugin-on| for details, but basically, stick this in your vimrc >
- filetype plugin on
-<
-
-==============================================================================
-3. Functionality provided *NERDComFunctionality*
-
-------------------------------------------------------------------------------
-3.1 Functionality summary *NERDComFunctionalitySummary*
-
-The following key mappings are provided by default (there is also a menu
-with items corresponding to all the mappings below):
-
-[count]<leader>cc |NERDComComment|
-Comment out the current line or text selected in visual mode.
-
-
-[count]<leader>cn |NERDComNestedComment|
-Same as <leader>cc but forces nesting.
-
-
-[count]<leader>c<space> |NERDComToggleComment|
-Toggles the comment state of the selected line(s). If the topmost selected
-line is commented, all selected lines are uncommented and vice versa.
-
-
-[count]<leader>cm |NERDComMinimalComment|
-Comments the given lines using only one set of multipart delimiters.
-
-
-[count]<leader>ci |NERDComInvertComment|
-Toggles the comment state of the selected line(s) individually.
-
-
-[count]<leader>cs |NERDComSexyComment|
-Comments out the selected lines ``sexily''
-
-
-[count]<leader>cy |NERDComYankComment|
-Same as <leader>cc except that the commented line(s) are yanked first.
-
-
-<leader>c$ |NERDComEOLComment|
-Comments the current line from the cursor to the end of line.
-
-
-<leader>cA |NERDComAppendComment|
-Adds comment delimiters to the end of line and goes into insert mode between
-them.
-
-
-|NERDComInsertComment|
-Adds comment delimiters at the current cursor position and inserts between.
-Disabled by default.
-
-
-<leader>ca |NERDComAltDelim|
-Switches to the alternative set of delimiters.
-
-
-[count]<leader>cl
-[count]<leader>cb |NERDComAlignedComment|
-Same as |NERDComComment| except that the delimiters are aligned down the
-left side (<leader>cl) or both sides (<leader>cb).
-
-
-[count]<leader>cu |NERDComUncommentLine|
-Uncomments the selected line(s).
-
-------------------------------------------------------------------------------
-3.2 Functionality details *NERDComFunctionalityDetails*
-
-------------------------------------------------------------------------------
-3.2.1 Comment map *NERDComComment*
-
-Default mapping: [count]<leader>cc
-Mapped to: <plug>NERDCommenterComment
-Applicable modes: normal visual visual-line visual-block.
-
-
-Comments out the current line. If multiple lines are selected in visual-line
-mode, they are all commented out. If some text is selected in visual or
-visual-block mode then the script will try to comment out the exact text that
-is selected using multi-part delimiters if they are available.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-------------------------------------------------------------------------------
-3.2.2 Nested comment map *NERDComNestedComment*
-
-Default mapping: [count]<leader>cn
-Mapped to: <plug>NERDCommenterNest
-Applicable modes: normal visual visual-line visual-block.
-
-Performs nested commenting. Works the same as <leader>cc except that if a line
-is already commented then it will be commented again.
-
-If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
-be replaced by place-holder delimiters if needed. Otherwise the nested
-comment will only be added if the current commenting delimiters have no right
-delimiter (to avoid syntax errors)
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-Related options:
-|'NERDDefaultNesting'|
-
-------------------------------------------------------------------------------
-3.2.3 Toggle comment map *NERDComToggleComment*
-
-Default mapping: [count]<leader>c<space>
-Mapped to: <plug>NERDCommenterToggle
-Applicable modes: normal visual-line.
-
-Toggles commenting of the lines selected. The behaviour of this mapping
-depends on whether the first line selected is commented or not. If so, all
-selected lines are uncommented and vice versa.
-
-With this mapping, a line is only considered to be commented if it starts with
-a left delimiter.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-------------------------------------------------------------------------------
-3.2.4 Minimal comment map *NERDComMinimalComment*
-
-Default mapping: [count]<leader>cm
-Mapped to: <plug>NERDCommenterMinimal
-Applicable modes: normal visual-line.
-
-Comments the selected lines using one set of multipart delimiters if possible.
-
-For example: if you are programming in c and you select 5 lines and press
-<leader>cm then a '/*' will be placed at the start of the top line and a '*/'
-will be placed at the end of the last line.
-
-Sets of multipart comment delimiters that are between the top and bottom
-selected lines are replaced with place holders (see |'NERDLPlace'|) if
-|'NERDUsePlaceHolders'| is set for the current filetype. If it is not, then
-the comment will be aborted if place holders are required to prevent illegal
-syntax.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-------------------------------------------------------------------------------
-3.2.5 Invert comment map *NERDComInvertComment*
-
-Default mapping: <leader>ci
-Mapped to: <plug>NERDCommenterInvert
-Applicable modes: normal visual-line.
-
-Inverts the commented state of each selected line. If the a selected line is
-commented then it is uncommented and vice versa. Each line is examined and
-commented/uncommented individually.
-
-With this mapping, a line is only considered to be commented if it starts with
-a left delimiter.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-------------------------------------------------------------------------------
-3.2.6 Sexy comment map *NERDComSexyComment*
-
-Default mapping: [count]<leader>cs
-Mapped to: <plug>NERDCommenterSexy
-Applicable modes: normal, visual-line.
-
-Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
-a description of what sexy comments are. Can only be done on filetypes for
-which there is at least one set of multipart comment delimiters specified.
-
-Sexy comments cannot be nested and lines inside a sexy comment cannot be
-commented again.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-Related options:
-|'NERDCompactSexyComs'|
-
-------------------------------------------------------------------------------
-3.2.7 Yank comment map *NERDComYankComment*
-
-Default mapping: [count]<leader>cy
-Mapped to: <plug>NERDCommenterYank
-Applicable modes: normal visual visual-line visual-block.
-
-Same as <leader>cc except that it yanks the line(s) that are commented first.
-
-------------------------------------------------------------------------------
-3.2.8 Comment to EOL map *NERDComEOLComment*
-
-Default mapping: <leader>c$
-Mapped to: <plug>NERDCommenterToEOL
-Applicable modes: normal.
-
-Comments the current line from the current cursor position up to the end of
-the line.
-
-------------------------------------------------------------------------------
-3.2.9 Append com to line map *NERDComAppendComment*
-
-Default mapping: <leader>cA
-Mapped to: <plug>NERDCommenterAppend
-Applicable modes: normal.
-
-Appends comment delimiters to the end of the current line and goes
-to insert mode between the new delimiters.
-
-------------------------------------------------------------------------------
-3.2.10 Insert comment map *NERDComInsertComment*
-
-Default mapping: disabled by default.
-Map it to: <plug>NERDCommenterInInsert
-Applicable modes: insert.
-
-Adds comment delimiters at the current cursor position and inserts
-between them.
-
-NOTE: prior to version 2.1.17 this was mapped to ctrl-c. To restore this
-mapping add >
- let NERDComInsertMap='<c-c>'
-<
-to your vimrc.
-
-------------------------------------------------------------------------------
-3.2.11 Use alternate delims map *NERDComAltDelim*
-
-Default mapping: <leader>ca
-Mapped to: <plug>NERDCommenterAltDelims
-Applicable modes: normal.
-
-Changes to the alternative commenting style if one is available. For example,
-if the user is editing a c++ file using // comments and they hit <leader>ca
-then they will be switched over to /**/ comments.
-
-See also |NERDComDefaultDelims|
-
-------------------------------------------------------------------------------
-3.2.12 Comment aligned maps *NERDComAlignedComment*
-
-Default mappings: [count]<leader>cl [count]<leader>cb
-Mapped to: <plug>NERDCommenterAlignLeft
- <plug>NERDCommenterAlignBoth
-Applicable modes: normal visual-line.
-
-Same as <leader>cc except that the comment delimiters are aligned on the left
-side or both sides respectively. These comments are always nested if the
-line(s) are already commented.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-------------------------------------------------------------------------------
-3.2.13 Uncomment line map *NERDComUncommentLine*
-
-Default mapping: [count]<leader>cu
-Mapped to: <plug>NERDCommenterUncomment
-Applicable modes: normal visual visual-line visual-block.
-
-Uncomments the current line. If multiple lines are selected in
-visual mode then they are all uncommented.
-
-When uncommenting, if the line contains multiple sets of delimiters then the
-``outtermost'' pair of delimiters will be removed.
-
-The script uses a set of heurisics to distinguish ``real'' delimiters from
-``fake'' ones when uncommenting. See |NERDComIssues| for details.
-
-If a [count] is given in normal mode, the mapping works as though that many
-lines were selected in visual-line mode.
-
-Related options:
-|'NERDRemoveAltComs'|
-|'NERDRemoveExtraSpaces'|
-
-------------------------------------------------------------------------------
-3.3 Sexy Comments *NERDComSexyComments*
-These are comments that use one set of multipart comment delimiters as well as
-one other marker symbol. For example: >
- /*
- * This is a c style sexy comment
- * So there!
- */
-
- /* This is a c style sexy comment
- * So there!
- * But this one is ``compact'' style */
-<
-Here the multipart delimiters are /* and */ and the marker is *.
-
-------------------------------------------------------------------------------
-3.4 The NERDComment function *NERDComNERDComment*
-
-All of the NERD commenter mappings and menu items invoke a single function
-which delegates the commenting work to other functions. This function is
-public and has the prototype: >
- function! NERDComment(isVisual, type)
-<
-The arguments to this function are simple:
- - isVisual: if you wish to do any kind of visual comment then set this to
- 1 and the function will use the '< and '> marks to find the comment
- boundries. If set to 0 then the function will operate on the current
- line.
- - type: is used to specify what type of commenting operation is to be
- performed, and it can be one of the following: "sexy", "invert",
- "minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
- "toEOL", "append", "insert", "uncomment", "yank"
-
-For example, if you typed >
- :call NERDComment(1, 'sexy')
-<
-then the script would do a sexy comment on the last visual selection.
-
-
-==============================================================================
-4. Options *NERDComOptions*
-
-------------------------------------------------------------------------------
-4.1 Options summary *NERDComOptionsSummary*
-
-|'loaded_nerd_comments'| Turns off the script.
-|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
- be used when commenting in
- visual/visual-block mode.
-|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
- doing visual-block comments.
-|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
-|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
-|'NERDDefaultNesting'| Tells the script to use nested comments
- by default.
-|'NERDMenuMode'| Specifies how the NERD commenter menu
- will appear (if at all).
-|'NERDLPlace'| Specifies what to use as the left
- delimiter placeholder when nesting
- comments.
-|'NERDUsePlaceHolders'| Specifies which filetypes may use
- placeholders when nesting comments.
-|'NERDRemoveAltComs'| Tells the script whether to remove
- alternative comment delimiters when
- uncommenting.
-|'NERDRemoveExtraSpaces'| Tells the script to always remove the
- extra spaces when uncommenting
- (regardless of whether NERDSpaceDelims
- is set)
-|'NERDRPlace'| Specifies what to use as the right
- delimiter placeholder when nesting
- comments.
-|'NERDSpaceDelims'| Specifies whether to add extra spaces
- around delimiters when commenting, and
- whether to remove them when
- uncommenting.
-|'NERDCompactSexyComs'| Specifies whether to use the compact
- style sexy comments.
-
-------------------------------------------------------------------------------
-4.3 Options details *NERDComOptionsDetails*
-
-To enable any of the below options you should put the given line in your
-~/.vimrc
-
- *'loaded_nerd_comments'*
-If this script is driving you insane you can turn it off by setting this
-option >
- let loaded_nerd_comments=1
-<
-------------------------------------------------------------------------------
- *'NERDAllowAnyVisualDelims'*
-Values: 0 or 1.
-Default: 1.
-
-If set to 1 then, when doing a visual or visual-block comment (but not a
-visual-line comment), the script will choose the right delimiters to use for
-the comment. This means either using the current delimiters if they are
-multipart or using the alternative delimiters if THEY are multipart. For
-example if we are editing the following java code: >
- float foo = 1221;
- float bar = 324;
- System.out.println(foo * bar);
-<
-If we are using // comments and select the "foo" and "bar" in visual-block
-mode, as shown left below (where '|'s are used to represent the visual-block
-boundary), and comment it then the script will use the alternative delims as
-shown on the right: >
-
- float |foo| = 1221; float /*foo*/ = 1221;
- float |bar| = 324; float /*bar*/ = 324;
- System.out.println(foo * bar); System.out.println(foo * bar);
-<
-------------------------------------------------------------------------------
- *'NERDBlockComIgnoreEmpty'*
-Values: 0 or 1.
-Default: 1.
-
-This option affects visual-block mode commenting. If this option is turned
-on, lines that begin outside the right boundary of the selection block will be
-ignored.
-
-For example, if you are commenting this chunk of c code in visual-block mode
-(where the '|'s are used to represent the visual-block boundary) >
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- |int| main(){
- | | printf("SUCK THIS\n");
- | | while(1){
- | | fork();
- | | }
- |} |
-<
-If NERDBlockComIgnoreEmpty=0 then this code will become: >
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- /*int*/ main(){
- /* */ printf("SUCK THIS\n");
- /* */ while(1){
- /* */ fork();
- /* */ }
- /*} */
-<
-Otherwise, the code block would become: >
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- /*int*/ main(){
- printf("SUCK THIS\n");
- while(1){
- fork();
- }
- /*} */
-<
-------------------------------------------------------------------------------
- *'NERDCommentWholeLinesInVMode'*
-Values: 0, 1 or 2.
-Default: 0.
-
-By default the script tries to comment out exactly what is selected in visual
-mode (v). For example if you select and comment the following c code (using |
-to represent the visual boundary): >
- in|t foo = 3;
- int bar =| 9;
- int baz = foo + bar;
-<
-This will result in: >
- in/*t foo = 3;*/
- /*int bar =*/ 9;
- int baz = foo + bar;
-<
-But some people prefer it if the whole lines are commented like: >
- /*int foo = 3;*/
- /*int bar = 9;*/
- int baz = foo + bar;
-<
-If you prefer the second option then stick this line in your vimrc: >
- let NERDCommentWholeLinesInVMode=1
-<
-
-If the filetype you are editing only has no multipart delimiters (for example
-a shell script) and you hadnt set this option then the above would become >
- in#t foo = 3;
- #int bar = 9;
-<
-(where # is the comment delimiter) as this is the closest the script can
-come to commenting out exactly what was selected. If you prefer for whole
-lines to be commented out when there is no multipart delimiters but the EXACT
-text that was selected to be commented out if there IS multipart delimiters
-then stick the following line in your vimrc: >
- let NERDCommentWholeLinesInVMode=2
-<
-
-Note that this option does not affect the behaviour of commenting in
-|visual-block| mode.
-
-------------------------------------------------------------------------------
- *'NERDCreateDefaultMappings'*
-Values: 0 or 1.
-Default: 1.
-
-If set to 0, none of the default mappings will be created.
-
-See also |NERDComMappings|.
-
-------------------------------------------------------------------------------
- *'NERDRemoveAltComs'*
-Values: 0 or 1.
-Default: 1.
-
-When uncommenting a line (for a filetype with an alternative commenting style)
-this option tells the script whether to look for, and remove, comment
-delimiters of the alternative style.
-
-For example, if you are editing a c++ file using // style comments and you go
-<leader>cu on this line: >
- /* This is a c++ comment baby! */
-<
-It will not be uncommented if the NERDRemoveAltComs is set to 0.
-
-------------------------------------------------------------------------------
- *'NERDRemoveExtraSpaces'*
-Values: 0 or 1.
-Default: 1.
-
-By default, the NERD commenter will remove spaces around comment delimiters if
-either:
-1. |'NERDSpaceDelims'| is set to 1.
-2. NERDRemoveExtraSpaces is set to 1.
-
-This means that if we have the following lines in a c code file: >
- /* int foo = 5; */
- /* int bar = 10; */
- int baz = foo + bar
-<
-If either of the above conditions hold then if these lines are uncommented
-they will become: >
- int foo = 5;
- int bar = 10;
- int baz = foo + bar
-<
-Otherwise they would become: >
- int foo = 5;
- int bar = 10;
- int baz = foo + bar
-<
-If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
-set NERDRemoveExtraSpaces to 0.
-
-------------------------------------------------------------------------------
- *'NERDLPlace'*
- *'NERDRPlace'*
-Values: arbitrary string.
-Default:
- NERDLPlace: "[>"
- NERDRPlace: "<]"
-
-These options are used to control the strings used as place-holder delimiters.
-Place holder delimiters are used when performing nested commenting when the
-filetype supports commenting styles with both left and right delimiters.
-To set these options use lines like: >
- let NERDLPlace="FOO"
- let NERDRPlace="BAR"
-<
-Following the above example, if we have line of c code: >
- /* int horse */
-<
-and we comment it with <leader>cn it will be changed to: >
- /*FOO int horse BAR*/
-<
-When we uncomment this line it will go back to what it was.
-
-------------------------------------------------------------------------------
- *'NERDMenuMode'*
-Values: 0, 1, 2, 3.
-Default: 3
-
-This option can take 4 values:
- "0": Turns the menu off.
- "1": Turns the 'comment' menu on with no menu shortcut.
- "2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
- "3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
-
-------------------------------------------------------------------------------
- *'NERDUsePlaceHolders'*
-Values: 0 or 1.
-Default 1.
-
-This option is used to specify whether place-holder delimiters should be used
-when creating a nested comment.
-
-------------------------------------------------------------------------------
- *'NERDSpaceDelims'*
-Values: 0 or 1.
-Default 0.
-
-Some people prefer a space after the left delimiter and before the right
-delimiter like this: >
- /* int foo=2; */
-<
-as opposed to this: >
- /*int foo=2;*/
-<
-If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
-
-See also |'NERDRemoveExtraSpaces'|.
-
-------------------------------------------------------------------------------
- *'NERDCompactSexyComs'*
-Values: 0 or 1.
-Default 0.
-
-Some people may want their sexy comments to be like this: >
- /* Hi There!
- * This is a sexy comment
- * in c */
-<
-As opposed to like this: >
- /*
- * Hi There!
- * This is a sexy comment
- * in c
- */
-<
-If this option is set to 1 then the top style will be used.
-
-------------------------------------------------------------------------------
- *'NERDDefaultNesting'*
-Values: 0 or 1.
-Default 1.
-
-When this option is set to 1, comments are nested automatically. That is, if
-you hit <leader>cc on a line that is already commented it will be commented
-again.
-
-------------------------------------------------------------------------------
-3.3 Default delimiter customisation *NERDComDefaultDelims*
-
-If you want the NERD commenter to use the alternative delimiters for a
-specific filetype by default then put a line of this form into your vimrc: >
- let NERD_<filetype>_alt_style=1
-<
-Example: java uses // style comments by default, but you want it to default to
-/* */ style comments instead. You would put this line in your vimrc: >
- let NERD_java_alt_style=1
-<
-
-See |NERDComAltDelim| for switching commenting styles at runtime.
-
-==============================================================================
-5. Key mapping customisation *NERDComMappings*
-
-To change a mapping just map another key combo to the internal <plug> mapping.
-For example, to remap the |NERDComComment| mapping to ",omg" you would put
-this line in your vimrc: >
- map ,omg <plug>NERDCommenterComment
-<
-This will stop the corresponding default mappings from being created.
-
-See the help for the mapping in question to see which <plug> mapping to
-map to.
-
-See also |'NERDCreateDefaultMappings'|.
-
-==============================================================================
-6. Issues with the script *NERDComIssues*
-
-
-------------------------------------------------------------------------------
-6.1 Delimiter detection heuristics *NERDComHeuristics*
-
-Heuristics are used to distinguish the real comment delimiters
-
-Because we have comment mappings that place delimiters in the middle of lines,
-removing comment delimiters is a bit tricky. This is because if comment
-delimiters appear in a line doesnt mean they really ARE delimiters. For
-example, Java uses // comments but the line >
- System.out.println("//");
-<
-clearly contains no real comment delimiters.
-
-To distinguish between ``real'' comment delimiters and ``fake'' ones we use a
-set of heuristics. For example, one such heuristic states that any comment
-delimiter that has an odd number of non-escaped " characters both preceding
-and following it on the line is not a comment because it is probably part of a
-string. These heuristics, while usually pretty accurate, will not work for all
-cases.
-
-------------------------------------------------------------------------------
-6.2 Nesting issues *NERDComNesting*
-
-If we have some line of code like this: >
- /*int foo */ = /*5 + 9;*/
-<
-This will not be uncommented legally. The NERD commenter will remove the
-"outter most" delimiters so the line will become: >
- int foo */ = /*5 + 9;
-<
-which almost certainly will not be what you want. Nested sets of comments will
-uncomment fine though. Eg: >
- /*int/* foo =*/ 5 + 9;*/
-<
-will become: >
- int/* foo =*/ 5 + 9;
-<
-(Note that in the above examples I have deliberately not used place holders
-for simplicity)
-
-==============================================================================
-7. About *NERDComAbout*
-
-The author of the NERD commenter is Martyzillatron --- the half robot, half
-dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
-metropolises and eating tourist busses.
-
-Drop him a line at martin_grenfell at msn.com. He would love to hear from you.
-its a lonely life being the worlds premier terror machine. How would you feel
-if your face looked like a toaster and a t-rex put together? :(
-
-The latest stable versions can be found at
- http://www.vim.org/scripts/script.php?script_id=1218
-
-The latest dev versions are on github
- http://github.com/scrooloose/nerdcommenter
-
-==============================================================================
-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.
- - add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and
- udevrules. Thanks to Thilo Six.
- - match filetypes case insensitively
- - add support for mp (metapost), thanks to Andrey Skvortsov.
- - add support for htmlcheetah, thanks to Simon Hengel.
- - add support for javacc, thanks to Matt Tolton.
- - make <%# %> the default delims for eruby, thanks to tpope.
- - add support for javascript.jquery, thanks to Ivan Devat.
- - add support for cucumber and pdf. Fix sass and railslog delims,
- thanks to tpope
-
-2.2.1
- - add support for newlisp and clojure, thanks to Matthew Lee Hinman.
- - fix automake comments, thanks to Elias Pipping
- - make haml comments default to -# with / as the alternative delimiter,
- thanks to tpope
- - add support for actionscript and processing thanks to Edwin Benavides
- - add support for ps1 (powershell), thanks to Jason Mills
- - add support for hostsaccess, thanks to Thomas Rowe
- - add support for CVScommit
- - add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich.
- - use # for gitcommit comments, thanks to Simon Ruderich.
- - add support for mako and genshi, thanks to Keitheis.
- - add support for conkyrc, thanks to David
- - add support for SVNannotate, thanks to Miguel Jaque Barbero.
- - add support for sieve, thanks to Stefan Walk
- - add support for objj, thanks to Adam Thorsen.
-
-2.2.0
- - rewrote the mappings system to be more "standard".
- - removed all the mapping options. Now, mappings to <plug> mappings are
- used
- - see :help NERDComMappings, and :help NERDCreateDefaultMappings for
- more info
- - remove "prepend comments" and "right aligned comments".
- - add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo.
- Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John
- O'Shea, François and Giacomo Mariani respectively.
- - bugfix for haskell delimiters. Thanks to mntnoe.
-2.1.18
- - add support for llvm. Thanks to nicothakis.
- - add support for xquery. Thanks to Phillip Kovalev.
-2.1.17
- - fixed haskell delimiters (hackily). Thanks to Elias Pipping.
- - add support for mailcap. Thanks to Pascal Brueckner.
- - add support for stata. Thanks to Jerónimo Carballo.
- - applied a patch from ewfalor to fix an error in the help file with the
- NERDMapleader doc
- - disable the insert mode ctrl-c mapping by default, see :help
- NERDComInsertComment if you wish to restore it
-
-==============================================================================
-9. Credits *NERDComCredits*
-
-Thanks to the follow people for suggestions and patches:
-
-Nick Brettell
-Matthew Hawkins
-Mathieu Clabaut
-Greg Searle
-Nguyen
-Litchi
-Jorge Scandaliaris
-Shufeng Zheng
-Martin Stubenschrott
-Markus Erlmann
-Brent Rice
-Richard Willis
-Igor Prischepoff
-Harry
-David Bourgeois
-Eike Von Seggern
-Torsten Blix
-Alexander Bosecke
-Stefano Zacchiroli
-Norick Chen
-Joseph Barker
-Gary Church
-Tim Carey-Smith
-Markus Klinik
-Anders
-Seth Mason
-James Hales
-Heptite
-Cheng Fang
-Yongwei Wu
-David Miani
-Jeremy Hinegardner
-Marco
-Ingo Karkat
-Zhang Shuhan
-tpope
-Ben Schmidt
-David Fishburn
-Erik Falor
-JaGoTerr
-Elias Pipping
-mntnoe
-Mark S.
-
-
-Thanks to the following people for sending me new filetypes to support:
-
-The hackers The filetypes~
-Sam R verilog
-Jonathan Derque context, plaintext and mail
-Vigil fetchmail
-Michael Brunner kconfig
-Antono Vasiljev netdict
-Melissa Reid omlet
-Ilia N Ternovich quickfix
-John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit
-Anders occam
-Mark Woodward csv
-fREW gentoo-package-mask,
- gentoo-package-keywords,
- gentoo-package-use, and vo_base
-Alexey verilog_systemverilog, systemverilog
-Lizendir fstab
-Michael Böhler autoit, autohotkey and docbk
-Aaron Small cmake
-Ramiro htmldjango and django
-Stefano Zacchiroli debcontrol, debchangelog, mkd
-Alex Tarkovsky ebuild and eclass
-Jorge Rodrigues gams
-Rainer Müller Objective C
-Jason Mills Groovy, ps1
-Normandie Azucena vera
-Florian Apolloner ldif
-David Fishburn lookupfile
-Niels Aan de Brugh rst
-Don Hatlestad ahk
-Christophe Benz Desktop and xsd
-Eyolf Østrem lilypond, bbx and lytex
-Ingo Karkat dosbatch
-Nicolas Weber markdown, objcpp
-tinoucas gentoo-conf-d
-Greg Weber D, haml
-Bruce Sherrod velocity
-timberke cobol, calibre
-Aaron Schaefer factor
-Mr X asterisk, mplayerconf
-Kuchma Michael plsql
-Brett Warneke spectre
-Pipp lhaskell
-Renald Buter scala
-Vladimir Lomov asymptote
-Marco mrxvtrc, aap
-nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate,
- SVNdiff, gitAnnotate, gitdiff, dtrace
- llvm, applescript
-Chen Xing Wikipedia
-Jacobo Diaz dakota, patran
-Li Jin gentoo-env-d, gentoo-init-d,
- gentoo-make-conf, grub, modconf, sudoers
-SpookeyPeanut rib
-Greg Jandl pyrex/cython
-Christophe Benz services, gitcommit
-A Pontus vimperator
-Stromnov slice, bzr
-Martin Kustermann pamconf
-Indriði Einarsson mason
-Chris map
-Krzysztof A. Adamski group
-Pascal Brueckner mailcap
-Jerónimo Carballo stata
-Phillip Kovalev xquery
-Bernhard Grotz potwiki
-sgronblo man
-François txt2tags
-Giacomo Mariani SVNinfo
-Matthew Lee Hinman newlisp, clojure
-Elias Pipping automake
-Edwin Benavides actionscript, processing
-Thomas Rowe hostsaccess
-Simon Ruderich asciidoc, git, gitcommit, gitrebase
-Keitheis mako, genshi
-David conkyrc
-Miguel Jaque Barbero SVNannotate
-Stefan Walk sieve
-Adam Thorsen objj
-Thilo Six dhcpd, limits, ntp, resolv, rgb, sysctl,
- udevconf, udevrules
-Andrey Skvortsov mp
-Simon Hengel htmlcheetah
-Matt Tolton javacc
-Ivan Devat javascript.jquery
-tpope cucumber,pdf
-==============================================================================
-10. License *NERDComLicense*
-
-The NERD commenter is released under the wtfpl.
-See http://sam.zoy.org/wtfpl/COPYING.
Close the NERD tree in this tab.
:NERDTreeFind *:NERDTreeFind*
- Find the current file in the tree. If no tree exists for the current tab,
- or the file is not under the current root, then initialize a new tree where
- the root is the directory of the current file.
+ Find the current file in the tree.
+
+ If not tree exists and the current file is under vim's CWD, then init a
+ tree at the CWD and reveal the file. Otherwise init a tree in the current
+ file's directory.
+
+ In any case, the current file is revealed and the cursor is placed on it.
------------------------------------------------------------------------------
2.2. Bookmarks *NERDTreeBookmarks*
:Bookmark <name>
Bookmark the current node as <name>. If there is already a <name>
bookmark, it is overwritten. <name> must not contain spaces.
+ If <name> is not provided, it defaults to the file or directory name.
+ For directories, a trailing slash is present.
:BookmarkToRoot <bookmark>
Make the directory corresponding to <bookmark> the new root. If a treenode
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
opened.
+|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
+ 'Press ? for help' text.
+
+|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
+ + ~ chars when displaying directories.
+
------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeOptionDetails*
This option is used to change the size of the NERD tree when it is loaded.
+------------------------------------------------------------------------------
+ *'NERDTreeMinimalUI'*
+Values: 0 or 1
+Default: 0
+
+This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
+of the following lines to set this option: >
+ let NERDTreeMinimalUI=0
+ let NERDTreeMinimalUI=1
+<
+
+------------------------------------------------------------------------------
+ *'NERDTreeDirArrows'*
+Values: 0 or 1
+Default: 0.
+
+This option is used to change the default look of directory nodes displayed in
+the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
+1 it shows right and down arrows. Use one of the follow lines to set this
+option: >
+ let NERDTreeDirArrows=0
+ let NERDTreeDirArrows=1
+<
+
==============================================================================
4. The NERD tree API *NERDTreeAPI*
==============================================================================
6. Changelog *NERDTreeChangelog*
+4.2.0
+ - Add NERDTreeDirArrows option to make the UI use pretty arrow chars
+ instead of the old +~| chars to define the tree structure (sickill)
+ - shift the syntax highlighting out into its own syntax file (gnap)
+ - add some mac specific options to the filesystem menu - for macvim
+ only (andersonfreitas)
+ - Add NERDTreeMinimalUI option to remove some non functional parts of the
+ nerdtree ui (camthompson)
+ - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
+ new behaviour (benjamingeiger)
+ - if no name is given to :Bookmark, make it default to the name of the
+ target file/dir (minyoung)
+ - use 'file' completion when doing copying, create, and move
+ operations (EvanDotPro)
+ - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
+ Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
+
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
Ricky
jfilip1024
Chris Chambers
+ Vitaly Bogdanov
+ Patrick O'Loughlin (paddyoloughlin)
+ Cam Thompson (camthompson)
+ Marcin Kulik (sickill)
+ Steve DeWald (sdewald)
+ Ivan Necas (iNecas)
+ George Ang (gnap)
+ Evan Coury (EvanDotPro)
+ Andrew Radev (AndrewRadev)
+ Matt Gauger (mathias)
+ Scott Stevenson (scottstvnsn)
+ Anderson Freitas (andersonfreitas)
+ Kamil K. Lemański (kml)
+ Yehuda Katz (wycats)
+ Min-Young Wu (minyoung)
+ Benjamin Geiger (benjamingeiger)
==============================================================================
8. License *NERDTreeLicense*
+++ /dev/null
-*acp.txt* 補完メニューの自動ポップアップ
-
- Copyright (c) 2007-2009 Takeshi NISHIDA
-
-AutoComplPop *autocomplpop* *acp*
-
-概要 |acp-introduction|
-インストール |acp-installation|
-使い方 |acp-usage|
-コマンド |acp-commands|
-オプション |acp-options|
-SPECIAL THANKS |acp-thanks|
-CHANGELOG |acp-changelog|
-あばうと |acp-about|
-
-
-==============================================================================
-概要 *acp-introduction*
-
-このプラグインは、インサートモードで文字を入力したりカーソルを動かしたときに補
-完メニューを自動的に開くようにします。しかし、続けて文字を入力するのを妨げたり
-はしません。
-
-
-==============================================================================
-インストール *acp-installation*
-
-ZIPファイルをランタイムディレクトリに展開します。
-
-以下のようにファイルが配置されるはずです。
->
- <your runtime directory>/plugin/acp.vim
- <your runtime directory>/doc/acp.txt
- ...
-<
-もしランタイムディレクトリが他のプラグインとごた混ぜになるのが嫌なら、ファイル
-を新規ディレクトリに配置し、そのディレクトリのパスを 'runtimepath' に追加して
-ください。アンインストールも楽になります。
-
-その後 FuzzyFinder のヘルプを有効にするためにタグファイルを更新してください。
-詳しくは|add-local-help|を参照してください。
-
-
-==============================================================================
-使い方 *acp-usage*
-
-このプラグインがインストールされていれば、自動ポップアップは vim の開始時から
-有効になります。
-
-カーソル直前のテキストに応じて、利用する補完の種類を切り替えます。デフォルトの
-補完動作は次の通りです:
-
- 補完モード filetype カーソル直前のテキスト ~
- キーワード補完 * 2文字のキーワード文字
- ファイル名補完 * ファイル名文字 + パスセパレータ
- + 0文字以上のファイル名文字
- オムニ補完 ruby ".", "::" or 単語を構成する文字以外 + ":"
- オムニ補完 python "."
- オムニ補完 xml "<", "</" or ("<" + ">"以外の文字列 + " ")
- オムニ補完 html/xhtml "<", "</" or ("<" + ">"以外の文字列 + " ")
- オムニ補完 css (":", ";", "{", "^", "@", or "!")
- + 0個または1個のスペース
-
-さらに、設定を行うことで、ユーザー定義補完と snipMate トリガー補完
-(|acp-snipMate|) を自動ポップアップさせることができます。
-
-これらの補完動作はカスタマイズ可能です。
-
- *acp-snipMate*
-snipMate トリガー補完 ~
-
-snipMate トリガー補完では、snipMate プラグイン
-(http://www.vim.org/scripts/script.php?script_id=2540) が提供するスニペットの
-トリガーを補完してそれを展開することができます。
-
-この自動ポップアップを有効にするには、次の関数を plugin/snipMate.vim に追加す
-る必要があります:
->
- fun! GetSnipsInCurrentScope()
- let snips = {}
- for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
- call extend(snips, get(s:snippets, scope, {}), 'keep')
- call extend(snips, get(s:multi_snips, scope, {}), 'keep')
- endfor
- return snips
- endf
-<
-そして|g:acp_behaviorSnipmateLength|オプションを 1 にしてください。
-
-この自動ポップアップには制限があり、カーソル直前の単語は大文字英字だけで構成さ
-れていなければなりません。
-
- *acp-perl-omni*
-Perl オムニ補完 ~
-
-AutoComplPop は perl-completion.vim
-(http://www.vim.org/scripts/script.php?script_id=2852) をサポートしています。
-
-この自動ポップアップを有効にするには、|g:acp_behaviorPerlOmniLength|オプション
-を 0 以上にしてください。
-
-
-==============================================================================
-コマンド *acp-commands*
-
- *:AcpEnable*
-:AcpEnable
- 自動ポップアップを有効にします。
-
- *:AcpDisable*
-:AcpDisable
- 自動ポップアップを無効にします。
-
- *:AcpLock*
-:AcpLock
- 自動ポップアップを一時的に停止します。
-
- 別のスクリプトへの干渉を回避する目的なら、このコマンドと|:AcpUnlock|
- を利用することを、|:AcpDisable|と|:AcpEnable| を利用するよりも推奨しま
- す。
-
- *:AcpUnlock*
-:AcpUnlock
- |:AcpLock| で停止された自動ポップアップを再開します。
-
-
-==============================================================================
-オプション *acp-options*
-
- *g:acp_enableAtStartup* >
- let g:acp_enableAtStartup = 1
-<
- 真なら vim 開始時から自動ポップアップが有効になります。
-
- *g:acp_mappingDriven* >
- let g:acp_mappingDriven = 0
-<
- 真なら|CursorMovedI|イベントではなくキーマッピングで自動ポップアップを
- 行うようにします。カーソルを移動するたびに補完が行われることで重いなど
- の不都合がある場合に利用してください。ただし他のプラグインとの相性問題
- や日本語入力での不具合が発生する可能性があります。(逆も然り。)
-
- *g:acp_ignorecaseOption* >
- let g:acp_ignorecaseOption = 1
-<
- 自動ポップアップ時に、'ignorecase' に一時的に設定する値
-
- *g:acp_completeOption* >
- let g:acp_completeOption = '.,w,b,k'
-<
- 自動ポップアップ時に、'complete' に一時的に設定する値
-
- *g:acp_completeoptPreview* >
- let g:acp_completeoptPreview = 0
-<
- 真なら自動ポップアップ時に、 'completeopt' へ "preview" を追加します。
-
- *g:acp_behaviorUserDefinedFunction* >
- let g:acp_behaviorUserDefinedFunction = ''
-<
- ユーザー定義補完の|g:acp_behavior-completefunc|。空ならこの補完は行わ
- れません。。
-
- *g:acp_behaviorUserDefinedMeets* >
- let g:acp_behaviorUserDefinedMeets = ''
-<
- ユーザー定義補完の|g:acp_behavior-meets|。空ならこの補完は行われません
- 。
-
- *g:acp_behaviorSnipmateLength* >
- let g:acp_behaviorSnipmateLength = -1
-<
- snipMate トリガー補完の自動ポップアップを行うのに必要なカーソルの直前
- のパターン。
-
- *g:acp_behaviorKeywordCommand* >
- let g:acp_behaviorKeywordCommand = "\<C-n>"
-<
- キーワード補完のコマンド。このオプションには普通 "\<C-n>" か "\<C-p>"
- を設定します。
-
- *g:acp_behaviorKeywordLength* >
- let g:acp_behaviorKeywordLength = 2
-<
- キーワード補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
- ード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorKeywordIgnores* >
- let g:acp_behaviorKeywordIgnores = []
-<
- 文字列のリスト。カーソル直前の単語がこれらの内いずれかの先頭部分にマッ
- チする場合、この補完は行われません。
-
- 例えば、 "get" で始まる補完キーワードが多過ぎて、"g", "ge", "get" を入
- 力したときの自動ポップアップがレスポンスの低下を引き起こしている場合、
- このオプションに ["get"] を設定することでそれを回避することができます。
-
- *g:acp_behaviorFileLength* >
- let g:acp_behaviorFileLength = 0
-<
- ファイル名補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
- ード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorRubyOmniMethodLength* >
- let g:acp_behaviorRubyOmniMethodLength = 0
-<
- メソッド補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
- なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorRubyOmniSymbolLength* >
- let g:acp_behaviorRubyOmniSymbolLength = 1
-<
- シンボル補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
- なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorPythonOmniLength* >
- let g:acp_behaviorPythonOmniLength = 0
-<
- Python オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキ
- ーワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorPerlOmniLength* >
- let g:acp_behaviorPerlOmniLength = -1
-<
- Perl オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
- ワード文字数。負数ならこの補完は行われません。
-
- See also: |acp-perl-omni|
-
- *g:acp_behaviorXmlOmniLength* >
- let g:acp_behaviorXmlOmniLength = 0
-<
- XML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
- ード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorHtmlOmniLength* >
- let g:acp_behaviorHtmlOmniLength = 0
-<
- HTML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
- ワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorCssOmniPropertyLength* >
- let g:acp_behaviorCssOmniPropertyLength = 1
-<
- プロパティ補完のための、CSS オムニ補完の自動ポップアップを行うのに必要
- なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behaviorCssOmniValueLength* >
- let g:acp_behaviorCssOmniValueLength = 0
-<
- 値補完のための、CSS オムニ補完の自動ポップアップを行うのに必要なカーソ
- ルの直前のキーワード文字数。負数ならこの補完は行われません。
-
- *g:acp_behavior* >
- let g:acp_behavior = {}
-<
-
- これは内部仕様がわかっている人向けのオプションで、他のオプションでの設
- 定より優先されます。
-
- |Dictionary|型で、キーはファイルタイプに対応します。 '*' はデフォルト
- を表します。値はリスト型です。補完候補が得られるまでリストの先頭アイテ
- ムから順に評価します。各要素は|Dictionary|で詳細は次の通り:
-
- "command": *g:acp_behavior-command*
- 補完メニューをポップアップするためのコマンド。
-
- "completefunc": *g:acp_behavior-completefunc*
- 'completefunc' に設定する関数。 "command" が "<C-x><C-u>" のときだけ
- 意味があります。
-
- "meets": *g:acp_behavior-meets*
- この補完を行うかどうかを判断する関数の名前。この関数はカーソル直前の
- テキストを引数に取り、補完を行うなら非 0 の値を返します。
-
- "onPopupClose": *g:acp_behavior-onPopupClose*
- この補完のポップアップメニューが閉じられたときに呼ばれる関数の名前。
- この関数が 0 を返した場合、続いて行われる予定の補完は抑制されます。
-
- "repeat": *g:acp_behavior-repeat*
- 真なら最後の補完が自動的に繰り返されます。
-
-
-==============================================================================
-あばうと *acp-about* *acp-contact* *acp-author*
-
-作者: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
-ライセンス: MIT Licence
-URL: http://www.vim.org/scripts/script.php?script_id=1879
- http://bitbucket.org/ns9tks/vim-autocomplpop/
-
-バグや要望など ~
-
-こちらへどうぞ: http://bitbucket.org/ns9tks/vim-autocomplpop/issues/
-
-==============================================================================
- vim:tw=78:ts=8:ft=help:norl:
-
+++ /dev/null
-*acp.txt* Automatically opens popup menu for completions.
-
- Copyright (c) 2007-2009 Takeshi NISHIDA
-
-AutoComplPop *autocomplpop* *acp*
-
-INTRODUCTION |acp-introduction|
-INSTALLATION |acp-installation|
-USAGE |acp-usage|
-COMMANDS |acp-commands|
-OPTIONS |acp-options|
-SPECIAL THANKS |acp-thanks|
-CHANGELOG |acp-changelog|
-ABOUT |acp-about|
-
-
-==============================================================================
-INTRODUCTION *acp-introduction*
-
-With this plugin, your vim comes to automatically opens popup menu for
-completions when you enter characters or move the cursor in Insert mode. It
-won't prevent you continuing entering characters.
-
-
-==============================================================================
-INSTALLATION *acp-installation*
-
-Put all files into your runtime directory. If you have the zip file, extract
-it to your runtime directory.
-
-You should place the files as follows:
->
- <your runtime directory>/plugin/acp.vim
- <your runtime directory>/doc/acp.txt
- ...
-<
-If you disgust to jumble up this plugin and other plugins in your runtime
-directory, put the files into new directory and just add the directory path to
-'runtimepath'. It's easy to uninstall the plugin.
-
-And then update your help tags files to enable fuzzyfinder help. See
-|add-local-help| for details.
-
-
-==============================================================================
-USAGE *acp-usage*
-
-Once this plugin is installed, auto-popup is enabled at startup by default.
-
-Which completion method is used depends on the text before the cursor. The
-default behavior is as follows:
-
- kind filetype text before the cursor ~
- Keyword * two keyword characters
- Filename * a filename character + a path separator
- + 0 or more filename character
- Omni ruby ".", "::" or non-word character + ":"
- (|+ruby| required.)
- Omni python "." (|+python| required.)
- Omni xml "<", "</" or ("<" + non-">" characters + " ")
- Omni html/xhtml "<", "</" or ("<" + non-">" characters + " ")
- Omni css (":", ";", "{", "^", "@", or "!")
- + 0 or 1 space
-
-Also, you can make user-defined completion and snipMate's trigger completion
-(|acp-snipMate|) auto-popup if the options are set.
-
-These behavior are customizable.
-
- *acp-snipMate*
-snipMate's Trigger Completion ~
-
-snipMate's trigger completion enables you to complete a snippet trigger
-provided by snipMate plugin
-(http://www.vim.org/scripts/script.php?script_id=2540) and expand it.
-
-
-To enable auto-popup for this completion, add following function to
-plugin/snipMate.vim:
->
- fun! GetSnipsInCurrentScope()
- let snips = {}
- for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
- call extend(snips, get(s:snippets, scope, {}), 'keep')
- call extend(snips, get(s:multi_snips, scope, {}), 'keep')
- endfor
- return snips
- endf
-<
-And set |g:acp_behaviorSnipmateLength| option to 1.
-
-There is the restriction on this auto-popup, that the word before cursor must
-consist only of uppercase characters.
-
- *acp-perl-omni*
-Perl Omni-Completion ~
-
-AutoComplPop supports perl-completion.vim
-(http://www.vim.org/scripts/script.php?script_id=2852).
-
-To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength|
-option to 0 or more.
-
-
-==============================================================================
-COMMANDS *acp-commands*
-
- *:AcpEnable*
-:AcpEnable
- enables auto-popup.
-
- *:AcpDisable*
-:AcpDisable
- disables auto-popup.
-
- *:AcpLock*
-:AcpLock
- suspends auto-popup temporarily.
-
- For the purpose of avoiding interruption to another script, it is
- recommended to insert this command and |:AcpUnlock| than |:AcpDisable|
- and |:AcpEnable| .
-
- *:AcpUnlock*
-:AcpUnlock
- resumes auto-popup suspended by |:AcpLock| .
-
-
-==============================================================================
-OPTIONS *acp-options*
-
- *g:acp_enableAtStartup* >
- let g:acp_enableAtStartup = 1
-<
- If non-zero, auto-popup is enabled at startup.
-
- *g:acp_mappingDriven* >
- let g:acp_mappingDriven = 0
-<
- If non-zero, auto-popup is triggered by key mappings instead of
- |CursorMovedI| event. This is useful to avoid auto-popup by moving
- cursor in Insert mode.
-
- *g:acp_ignorecaseOption* >
- let g:acp_ignorecaseOption = 1
-<
- Value set to 'ignorecase' temporarily when auto-popup.
-
- *g:acp_completeOption* >
- let g:acp_completeOption = '.,w,b,k'
-<
- Value set to 'complete' temporarily when auto-popup.
-
- *g:acp_completeoptPreview* >
- let g:acp_completeoptPreview = 0
-<
- If non-zero, "preview" is added to 'completeopt' when auto-popup.
-
- *g:acp_behaviorUserDefinedFunction* >
- let g:acp_behaviorUserDefinedFunction = ''
-<
- |g:acp_behavior-completefunc| for user-defined completion. If empty,
- this completion will be never attempted.
-
- *g:acp_behaviorUserDefinedMeets* >
- let g:acp_behaviorUserDefinedMeets = ''
-<
- |g:acp_behavior-meets| for user-defined completion. If empty, this
- completion will be never attempted.
-
- *g:acp_behaviorSnipmateLength* >
- let g:acp_behaviorSnipmateLength = -1
-<
- Pattern before the cursor, which are needed to attempt
- snipMate-trigger completion.
-
- *g:acp_behaviorKeywordCommand* >
- let g:acp_behaviorKeywordCommand = "\<C-n>"
-<
- Command for keyword completion. This option is usually set "\<C-n>" or
- "\<C-p>".
-
- *g:acp_behaviorKeywordLength* >
- let g:acp_behaviorKeywordLength = 2
-<
- Length of keyword characters before the cursor, which are needed to
- attempt keyword completion. If negative value, this completion will be
- never attempted.
-
- *g:acp_behaviorKeywordIgnores* >
- let g:acp_behaviorKeywordIgnores = []
-<
- List of string. If a word before the cursor matches to the front part
- of one of them, keyword completion won't be attempted.
-
- E.g., when there are too many keywords beginning with "get" for the
- completion and auto-popup by entering "g", "ge", or "get" causes
- response degradation, set ["get"] to this option and avoid it.
-
- *g:acp_behaviorFileLength* >
- let g:acp_behaviorFileLength = 0
-<
- Length of filename characters before the cursor, which are needed to
- attempt filename completion. If negative value, this completion will
- be never attempted.
-
- *g:acp_behaviorRubyOmniMethodLength* >
- let g:acp_behaviorRubyOmniMethodLength = 0
-<
- Length of keyword characters before the cursor, which are needed to
- attempt ruby omni-completion for methods. If negative value, this
- completion will be never attempted.
-
- *g:acp_behaviorRubyOmniSymbolLength* >
- let g:acp_behaviorRubyOmniSymbolLength = 1
-<
- Length of keyword characters before the cursor, which are needed to
- attempt ruby omni-completion for symbols. If negative value, this
- completion will be never attempted.
-
- *g:acp_behaviorPythonOmniLength* >
- let g:acp_behaviorPythonOmniLength = 0
-<
- Length of keyword characters before the cursor, which are needed to
- attempt python omni-completion. If negative value, this completion
- will be never attempted.
-
- *g:acp_behaviorPerlOmniLength* >
- let g:acp_behaviorPerlOmniLength = -1
-<
- Length of keyword characters before the cursor, which are needed to
- attempt perl omni-completion. If negative value, this completion will
- be never attempted.
-
- See also: |acp-perl-omni|
-
- *g:acp_behaviorXmlOmniLength* >
- let g:acp_behaviorXmlOmniLength = 0
-<
- Length of keyword characters before the cursor, which are needed to
- attempt XML omni-completion. If negative value, this completion will
- be never attempted.
-
- *g:acp_behaviorHtmlOmniLength* >
- let g:acp_behaviorHtmlOmniLength = 0
-<
- Length of keyword characters before the cursor, which are needed to
- attempt HTML omni-completion. If negative value, this completion will
- be never attempted.
-
- *g:acp_behaviorCssOmniPropertyLength* >
- let g:acp_behaviorCssOmniPropertyLength = 1
-<
- Length of keyword characters before the cursor, which are needed to
- attempt CSS omni-completion for properties. If negative value, this
- completion will be never attempted.
-
- *g:acp_behaviorCssOmniValueLength* >
- let g:acp_behaviorCssOmniValueLength = 0
-<
- Length of keyword characters before the cursor, which are needed to
- attempt CSS omni-completion for values. If negative value, this
- completion will be never attempted.
-
- *g:acp_behavior* >
- let g:acp_behavior = {}
-<
- This option is for advanced users. This setting overrides other
- behavior options. This is a |Dictionary|. Each key corresponds to a
- filetype. '*' is default. Each value is a list. These are attempted in
- sequence until completion item is found. Each element is a
- |Dictionary| which has following items:
-
- "command": *g:acp_behavior-command*
- Command to be fed to open popup menu for completions.
-
- "completefunc": *g:acp_behavior-completefunc*
- 'completefunc' will be set to this user-provided function during the
- completion. Only makes sense when "command" is "<C-x><C-u>".
-
- "meets": *g:acp_behavior-meets*
- Name of the function which dicides whether or not to attempt this
- completion. It will be attempted if this function returns non-zero.
- This function takes a text before the cursor.
-
- "onPopupClose": *g:acp_behavior-onPopupClose*
- Name of the function which is called when popup menu for this
- completion is closed. Following completions will be suppressed if
- this function returns zero.
-
- "repeat": *g:acp_behavior-repeat*
- If non-zero, the last completion is automatically repeated.
-
-
-==============================================================================
-SPECIAL THANKS *acp-thanks*
-
-- Daniel Schierbeck
-- Ingo Karkat
-
-
-==============================================================================
-CHANGELOG *acp-changelog*
-
-2.14.1
- - Changed the way of auto-popup for avoiding an issue about filename
- completion.
- - Fixed a bug that popup menu was opened twice when auto-popup was done.
-
-2.14
- - Added the support for perl-completion.vim.
-
-2.13
- - Changed to sort snipMate's triggers.
- - Fixed a bug that a wasted character was inserted after snipMate's trigger
- completion.
-
-2.12.1
- - Changed to avoid a strange behavior with Microsoft IME.
-
-2.12
- - Added g:acp_behaviorKeywordIgnores option.
- - Added g:acp_behaviorUserDefinedMeets option and removed
- g:acp_behaviorUserDefinedPattern.
- - Changed to do auto-popup only when a buffer is modified.
- - Changed the structure of g:acp_behavior option.
- - Changed to reflect a change of behavior options (named g:acp_behavior*)
- any time it is done.
- - Fixed a bug that completions after omni completions or snipMate's trigger
- completion were never attempted when no candidate for the former
- completions was found.
-
-2.11.1
- - Fixed a bug that a snipMate's trigger could not be expanded when it was
- completed.
-
-2.11
- - Implemented experimental feature which is snipMate's trigger completion.
-
-2.10
- - Improved the response by changing not to attempt any completion when
- keyword characters are entered after a word which has been found that it
- has no completion candidate at the last attempt of completions.
- - Improved the response by changing to close popup menu when <BS> was
- pressed and the text before the cursor would not match with the pattern of
- current behavior.
-
-2.9
- - Changed default behavior to support XML omni completion.
- - Changed default value of g:acp_behaviorKeywordCommand option.
- The option with "\<C-p>" cause a problem which inserts a match without
- <CR> when 'dictionary' has been set and keyword completion is done.
- - Changed to show error message when incompatible with a installed vim.
-
-2.8.1
- - Fixed a bug which inserted a selected match to the next line when
- auto-wrapping (enabled with 'formatoptions') was performed.
-
-2.8
- - Added g:acp_behaviorUserDefinedFunction option and
- g:acp_behaviorUserDefinedPattern option for users who want to make custom
- completion auto-popup.
- - Fixed a bug that setting 'spell' on a new buffer made typing go crazy.
-
-2.7
- - Changed naming conventions for filenames, functions, commands, and options
- and thus renamed them.
- - Added g:acp_behaviorKeywordCommand option. If you prefer the previous
- behavior for keyword completion, set this option "\<C-n>".
- - Changed default value of g:acp_ignorecaseOption option.
-
- The following were done by Ingo Karkat:
-
- - ENH: Added support for setting a user-provided 'completefunc' during the
- completion, configurable via g:acp_behavior.
- - BUG: When the configured completion is <C-p> or <C-x><C-p>, the command to
- restore the original text (in on_popup_post()) must be reverted, too.
- - BUG: When using a custom completion function (<C-x><C-u>) that also uses
- an s:...() function name, the s:GetSidPrefix() function dynamically
- determines the wrong SID. Now calling s:DetermineSidPrefix() once during
- sourcing and caching the value in s:SID.
- - BUG: Should not use custom defined <C-X><C-...> completion mappings. Now
- consistently using unmapped completion commands everywhere. (Beforehand,
- s:PopupFeeder.feed() used mappings via feedkeys(..., 'm'), but
- s:PopupFeeder.on_popup_post() did not due to its invocation via
- :map-expr.)
-
-2.6:
- - Improved the behavior of omni completion for HTML/XHTML.
-
-2.5:
- - Added some options to customize behavior easily:
- g:AutoComplPop_BehaviorKeywordLength
- g:AutoComplPop_BehaviorFileLength
- g:AutoComplPop_BehaviorRubyOmniMethodLength
- g:AutoComplPop_BehaviorRubyOmniSymbolLength
- g:AutoComplPop_BehaviorPythonOmniLength
- g:AutoComplPop_BehaviorHtmlOmniLength
- g:AutoComplPop_BehaviorCssOmniPropertyLength
- g:AutoComplPop_BehaviorCssOmniValueLength
-
-2.4:
- - Added g:AutoComplPop_MappingDriven option.
-
-2.3.1:
- - Changed to set 'lazyredraw' while a popup menu is visible to avoid
- flickering.
- - Changed a behavior for CSS.
- - Added support for GetLatestVimScripts.
-
-2.3:
- - Added a behavior for Python to support omni completion.
- - Added a behavior for CSS to support omni completion.
-
-2.2:
- - Changed not to work when 'paste' option is set.
- - Fixed AutoComplPopEnable command and AutoComplPopDisable command to
- map/unmap "i" and "R".
-
-2.1:
- - Fixed the problem caused by "." command in Normal mode.
- - Changed to map "i" and "R" to feed completion command after starting
- Insert mode.
- - Avoided the problem caused by Windows IME.
-
-2.0:
- - Changed to use CursorMovedI event to feed a completion command instead of
- key mapping. Now the auto-popup is triggered by moving the cursor.
- - Changed to feed completion command after starting Insert mode.
- - Removed g:AutoComplPop_MapList option.
-
-1.7:
- - Added behaviors for HTML/XHTML. Now supports the omni completion for
- HTML/XHTML.
- - Changed not to show expressions for CTRL-R =.
- - Changed not to set 'nolazyredraw' while a popup menu is visible.
-
-1.6.1:
- - Changed not to trigger the filename completion by a text which has
- multi-byte characters.
-
-1.6:
- - Redesigned g:AutoComplPop_Behavior option.
- - Changed default value of g:AutoComplPop_CompleteOption option.
- - Changed default value of g:AutoComplPop_MapList option.
-
-1.5:
- - Implemented continuous-completion for the filename completion. And added
- new option to g:AutoComplPop_Behavior.
-
-1.4:
- - Fixed the bug that the auto-popup was not suspended in fuzzyfinder.
- - Fixed the bug that an error has occurred with Ruby-omni-completion unless
- Ruby interface.
-
-1.3:
- - Supported Ruby-omni-completion by default.
- - Supported filename completion by default.
- - Added g:AutoComplPop_Behavior option.
- - Added g:AutoComplPop_CompleteoptPreview option.
- - Removed g:AutoComplPop_MinLength option.
- - Removed g:AutoComplPop_MaxLength option.
- - Removed g:AutoComplPop_PopupCmd option.
-
-1.2:
- - Fixed bugs related to 'completeopt'.
-
-1.1:
- - Added g:AutoComplPop_IgnoreCaseOption option.
- - Added g:AutoComplPop_NotEnableAtStartup option.
- - Removed g:AutoComplPop_LoadAndEnable option.
-1.0:
- - g:AutoComplPop_LoadAndEnable option for a startup activation is added.
- - AutoComplPopLock command and AutoComplPopUnlock command are added to
- suspend and resume.
- - 'completeopt' and 'complete' options are changed temporarily while
- completing by this script.
-
-0.4:
- - The first match are selected when the popup menu is Opened. You can insert
- the first match with CTRL-Y.
-
-0.3:
- - Fixed the problem that the original text is not restored if 'longest' is
- not set in 'completeopt'. Now the plugin works whether or not 'longest' is
- set in 'completeopt', and also 'menuone'.
-
-0.2:
- - When completion matches are not found, insert CTRL-E to stop completion.
- - Clear the echo area.
- - Fixed the problem in case of dividing words by symbols, popup menu is
- not opened.
-
-0.1:
- - First release.
-
-
-==============================================================================
-ABOUT *acp-about* *acp-contact* *acp-author*
-
-Author: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
-Licence: MIT Licence
-URL: http://www.vim.org/scripts/script.php?script_id=1879
- http://bitbucket.org/ns9tks/vim-autocomplpop/
-
-Bugs/Issues/Suggestions/Improvements ~
-
-Please submit to http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ .
-
-==============================================================================
- vim:tw=78:ts=8:ft=help:norl:
-
+++ /dev/null
-*bufexplorer.txt* Buffer Explorer Last Change: 22 Oct 2010
-
-Buffer Explorer *buffer-explorer* *bufexplorer*
- Version 7.2.8
-
-Plugin for easily exploring (or browsing) Vim |:buffers|.
-
-|bufexplorer-installation| Installation
-|bufexplorer-usage| Usage
-|bufexplorer-windowlayout| Window Layout
-|bufexplorer-customization| Customization
-|bufexplorer-changelog| Change Log
-|bufexplorer-todo| Todo
-|bufexplorer-credits| Credits
-
-For Vim version 7.0 and above.
-This plugin is only available if 'compatible' is not set.
-
-{Vi does not have any of this}
-
-==============================================================================
-INSTALLATION *bufexplorer-installation*
-
-To install:
- - Download the bufexplorer.zip.
- - Extract the zip archive into your runtime directory.
- The archive contains plugin/bufexplorer.vim, and doc/bufexplorer.txt.
- - Start Vim or goto an existing instance of Vim.
- - Execute the following command:
->
- :helptag <your runtime directory>/doc
-<
- This will generate all the help tags for any file located in the doc
- directory.
-
-==============================================================================
-USAGE *bufexplorer-usage*
-
-To start exploring in the current window, use: >
- \be or :BufExplorer
-To start exploring in a newly split horizontal window, use: >
- \bs or :BufExplorerHorizontalSplit
-To start exploring in a newly split vertical window, use: >
- \bv or :BufExplorerVerticalSplit
-
-If you would like to use something other than '\', you may simply change the
-leader (see |mapleader|).
-
-Note: If the current buffer is modified when bufexplorer started, the current
- window is always split and the new bufexplorer is displayed in that new
- window.
-
-Commands to use once exploring:
-
- <F1> Toggle help information.
- <enter> Opens the buffer that is under the cursor into the current
- window.
- <leftmouse> Opens the buffer that is under the cursor into the current
- window.
- <shift-enter> Opens the buffer that is under the cursor in another tab.
- d |:delete|the buffer under the cursor from the list. The
- buffer's 'buflisted' is cleared. This allows for the buffer to
- be displayed again using the 'show unlisted' command.
- R Toggles relative path/absolute path.
- T Toggles to show only buffers for this tab or not.
- D |:wipeout|the buffer under the cursor from the list. When a
- buffers is wiped, it will not be shown when unlisted buffer are
- displayed.
- f Toggles whether you are taken to the active window when
- selecting a buffer or not.
- o Opens the buffer that is under the cursor into the current
- window.
- p Toggles the showing of a split filename/pathname.
- q Quit exploring.
- r Reverses the order the buffers are listed in.
- s Selects the order the buffers are listed in. Either by buffer
- number, file name, file extension, most recently used (MRU), or
- full path.
- t Opens the buffer that is under the cursor in another tab.
- u Toggles the showing of "unlisted" buffers.
-
-Once invoked, Buffer Explorer displays a sorted list (MRU is the default
-sort method) of all the buffers that are currently opened. You are then
-able to move the cursor to the line containing the buffer's name you are
-wanting to act upon. Once you have selected the buffer you would like,
-you can then either open it, close it(delete), resort the list, reverse
-the sort, quit exploring and so on...
-
-===============================================================================
-WINDOW LAYOUT *bufexplorer-windowlayout*
-
--------------------------------------------------------------------------------
-" Press <F1> for Help
-" Sorted by mru | Locate buffer | Absolute Split path
-"=
- 01 %a bufexplorer.txt C:\Vim\vimfiles\doc line 87
- 02 # bufexplorer.vim c:\Vim\vimfiles\plugin line 1
--------------------------------------------------------------------------------
- | | | | |
- | | | | +-- Current Line #.
- | | | +-- Relative/Full Path
- | | +-- Buffer Name.
- | +-- Buffer Attributes. See|:buffers|for more information.
- +-- Buffer Number. See|:buffers|for more information.
-
-===============================================================================
-CUSTOMIZATION *bufexplorer-customization*
-
- *g:bufExplorerChgWin*
-If set, bufexplorer will bring up the selected buffer in the window specified
-by g:bufExplorerChgWin.
-
- *g:bufExplorerDefaultHelp*
-To control whether the default help is displayed or not, use: >
- let g:bufExplorerDefaultHelp=0 " Do not show default help.
- let g:bufExplorerDefaultHelp=1 " Show default help.
-The default is to show the default help.
-
- *g:bufExplorerDetailedHelp*
-To control whether detailed help is display by, use: >
- let g:bufExplorerDetailedHelp=0 " Do not show detailed help.
- let g:bufExplorerDetailedHelp=1 " Show detailed help.
-The default is NOT to show detailed help.
-
- *g:bufExplorerFindActive*
-To control whether you are taken to the active window when selecting a buffer,
-use: >
- let g:bufExplorerFindActive=0 " Do not go to active window.
- let g:bufExplorerFindActive=1 " Go to active window.
-The default is to be taken to the active window.
-
- *g:bufExplorerFuncRef*
-When a buffer is selected, the functions specified either singly or as a list
-will be called.
-
- *g:bufExplorerReverseSort*
-To control whether to sort the buffer in reverse order or not, use: >
- let g:bufExplorerReverseSort=0 " Do not sort in reverse order.
- let g:bufExplorerReverseSort=1 " Sort in reverse order.
-The default is NOT to sort in reverse order.
-
- *g:bufExplorerShowDirectories*
-Directories usually show up in the list from using a command like ":e .".
-To control whether to show directories in the buffer list or not, use: >
- let g:bufExplorerShowDirectories=1 " Show directories.
- let g:bufExplorerShowDirectories=0 " Don't show directories.
-The default is to show directories.
-
- *g:bufExplorerShowRelativePath*
-To control whether to show absolute paths or relative to the current
-directory, use: >
- let g:bufExplorerShowRelativePath=0 " Show absolute paths.
- let g:bufExplorerShowRelativePath=1 " Show relative paths.
-The default is to show absolute paths.
-
- *g:bufExplorerShowTabBuffer*
-To control weither or not to show buffers on for the specific tab or not, use: >
- let g:bufExplorerShowTabBuffer=0 " No.
- let g:bufExplorerShowTabBuffer=1 " Yes.
-The default is not to show.
-
- *g:bufExplorerShowUnlisted*
-To control whether to show unlisted buffer or not, use: >
- let g:bufExplorerShowUnlisted=0 " Do not show unlisted buffers.
- let g:bufExplorerShowUnlisted=1 " Show unlisted buffers.
-The default is to NOT show unlisted buffers.
-
- *g:bufExplorerSortBy*
-To control what field the buffers are sorted by, use: >
- let g:bufExplorerSortBy='extension' " Sort by file extension.
- let g:bufExplorerSortBy='fullpath' " Sort by full file path name.
- let g:bufExplorerSortBy='mru' " Sort by most recently used.
- let g:bufExplorerSortBy='name' " Sort by the buffer's name.
- let g:bufExplorerSortBy='number' " Sort by the buffer's number.
-The default is to sort by mru.
-
- *g:bufExplorerSplitBelow*
-To control where the new split window will be placed above or below the
-current window, use: >
- let g:bufExplorerSplitBelow=1 " Split new window below current.
- let g:bufExplorerSplitBelow=0 " Split new window above current.
-The default is to use what ever is set by the global &splitbelow
-variable.
-
- *g:bufExplorerSplitOutPathName*
-To control whether to split out the path and file name or not, use: >
- let g:bufExplorerSplitOutPathName=1 " Split the path and file name.
- let g:bufExplorerSplitOutPathName=0 " Don't split the path and file
- " name.
-The default is to split the path and file name.
-
- *g:bufExplorerSplitRight*
-To control where the new vsplit window will be placed to the left or right of
-current window, use: >
- let g:bufExplorerSplitRight=0 " Split left.
- let g:bufExplorerSplitRight=1 " Split right.
-The default is to use the global &splitright.
-
-===============================================================================
-CHANGE LOG *bufexplorer-changelog*
-
-7.2.8 - Enhancements:
- * Thanks to Charles Campbell for integrating bufexplorer with GDBMGR.
- http://mysite.verizon.net/astronaut/vim/index.html#GDBMGR
-7.2.7 - Fix:
- * My 1st attempt to fix the "cache" issue where buffers information
- has changed but the cache/display does not reflect those changes.
- More work still needs to be done.
-7.2.6 - Fix:
- * Thanks to Michael Henry for pointing out that I totally forgot to
- update the inline help to reflect the previous change to the 'd'
- and 'D' keys. Opps!
-7.2.5 - Fix:
- * Philip Morant suggested switching the command (bwipe) associated
- with the 'd' key with the command (bdelete) associated with the 'D'
- key. This made sense since the 'd' key is more likely to be used
- compared to the 'D' key.
-7.2.4 - Fix:
- * I did not implement the patch provided by Godefroid Chapelle
- correctly. I missed one line which happened to be the most
- important one :)
-7.2.3 - Enhancements:
- * Thanks to David Fishburn for helping me out with a much needed
- code overhaul as well as some awesome performance enhancements.
- He also reworked the handling of tabs.
- * Thanks to Vladimir Dobriakov for making the suggestions on
- enhancing the documentation to include a better explaination of
- what is contained in the main bufexplorer window.
- * Thanks to Yuriy Ershov for added code that when the bufexplorer
- window is opened, the cursor is now positioned at the line with the
- active buffer (useful in non-MRU sort modes).
- * Yuriy also added the abiltiy to cycle through the sort fields in
- reverse order.
- Fixes:
- * Thanks to Michael Henry for supplying a patch that allows
- bufexplorer to be opened even when there is one buffer or less.
- * Thanks to Godefroid Chapelle for supplying a patch that fixed
- MRU sort order after loading a session.
-7.2.2 - Fixes:
- * Thanks to David L. Dight for spotting and fixing an issue when
- using ctrl^. bufexplorer would incorrectly handle the previous
- buffer so that when ctrl^ was pressed the incorrect file was opened.
-7.2.1 - Fixes:
- * Thanks to Dimitar for spotting and fixing a feature that was
- inadvertently left out of the previous version. The feature was
- when bufexplorer was used together with WinManager, you could use
- the tab key to open a buffer in a split window.
-7.2.0 - Enhancements:
- * For all those missing the \bs and \bv commands, these have now
- returned. Thanks to Phil O'Connell for asking for the return of
- these missing features and helping test out this version.
- Fixes:
- * Fixed problem with the bufExplorerFindActive code not working
- correctly.
- * Fixed an incompatibility between bufexplorer and netrw that caused
- buffers to be incorrectly removed from the MRU list.
-7.1.7 - Fixes:
- * TaCahiroy fixed several issues related to opening a buffer in a
- tab.
-7.1.6 - Fixes:
- * Removed ff=unix from modeline in bufexplorer.txt. Found by Bill
- McCarthy.
-7.1.5 - Fixes:
- * Could not open unnamed buffers. Fixed by TaCahiroy.
-7.1.4 - Fixes:
- * Sometimes when a file's path has 'white space' in it, extra buffers
- would be created containing each piece of the path. i.e:
- opening c:\document and settings\test.txt would create a buffer
- named "and" and a buffer named "Documents". This was reported and
- fixed by TaCa Yoss.
-7.1.3 - Fixes:
- * Added code to allow only one instance of the plugin to run at a
- time. Thanks Dennis Hostetler.
-7.1.2 - Fixes:
- * Fixed a jumplist issue spotted by JiangJun. I overlooked the
- 'jumplist' and with a couple calls to 'keepjumps', everything is
- fine again.
- * Went back to just having a plugin file, no autoload file. By having
- the autoload, WinManager was no longer working and without really
- digging into the cause, it was easier to go back to using just a
- plugin file.
-7.1.1 - Fixes:
- * A problem spotted by Thomas Arendsen Hein.
- When running Vim (7.1.94), error E493 was being thrown.
- Enhancements:
- * Added 'D' for 'delete' buffer as the 'd' command was a 'wipe'
- buffer.
-7.1.0 - Another 'major' update, some by Dave Larson, some by me.
- * Making use of 'autoload' now to make the plugin load quicker.
- * Removed '\bs' and '\bv'. These are now controlled by the user. The
- user can issue a ':sp' or ':vs' to create a horizontal or vertical
- split window and then issue a '\be'
- * Added handling of tabs.
-7.0.17 - Fixed issue with 'drop' command.
- Various enhancements and improvements.
-7.0.16 - Fixed issue reported by Liu Jiaping on non Windows systems, which was
- ...
- Open file1, open file2, modify file1, open bufexplorer, you get the
- following error:
-
- --------8<--------
- Error detected while processing function
- <SNR>14_StartBufExplorer..<SNR>14_SplitOpen:
- line 4:
- E37: No write since last change (add ! to override)
-
- But the worse thing is, when I want to save the current buffer and
- type ':w', I get another error message:
- E382: Cannot write, 'buftype' option is set
- --------8<--------
-
-7.0.15 - Thanks to Mark Smithfield for suggesting bufexplorer needed to handle
- the ':args' command.
-7.0.14 - Thanks to Randall Hansen for removing the requirement of terminal
- versions to be recompiled with 'gui' support so the 'drop' command
- would work. The 'drop' command is really not needed in terminal
- versions.
-7.0.13 - Fixed integration with WinManager.
- Thanks to Dave Eggum for another update.
- - Fix: The detailed help didn't display the mapping for toggling
- the split type, even though the split type is displayed.
- - Fixed incorrect description in the detailed help for toggling
- relative or full paths.
- - Deprecated s:ExtractBufferNbr(). Vim's str2nr() does the same
- thing.
- - Created a s:Set() function that sets a variable only if it hasn't
- already been defined. It's useful for initializing all those
- default settings.
- - Removed checks for repetitive command definitions. They were
- unnecessary.
- - Made the help highlighting a little more fancy.
- - Minor reverse compatibility issue: Changed ambiguous setting
- names to be more descriptive of what they do (also makes the code
- easier to follow):
- Changed bufExplorerSortDirection to bufExplorerReverseSort
- Changed bufExplorerSplitType to bufExplorerSplitVertical
- Changed bufExplorerOpenMode to bufExplorerUseCurrentWindow
- - When the BufExplorer window closes, all the file-local marks are
- now deleted. This may have the benefit of cleaning up some of the
- jumplist.
- - Changed the name of the parameter for StartBufExplorer from
- "split" to "open". The parameter is a string which specifies how
- the buffer will be open, not if it is split or not.
- - Deprecated DoAnyMoreBuffersExist() - it is a one line function
- only used in one spot.
- - Created four functions (SplitOpen(), RebuildBufferList(),
- UpdateHelpStatus() and ReSortListing()) all with one purpose - to
- reduce repeated code.
- - Changed the name of AddHeader() to CreateHelp() to be more
- descriptive of what it does. It now returns an array instead of
- updating the window directly. This has the benefit of making the
- code more efficient since the text the function returns is used a
- little differently in the two places the function is called.
- - Other minor simplifications.
-7.0.12 - MAJOR Update.
- This version will ONLY run with Vim version 7.0 or greater.
- Dave Eggum has made some 'significant' updates to this latest
- version:
- - Added BufExplorerGetAltBuf() global function to be used in the
- user\92s rulerformat.
- - Added g:bufExplorerSplitRight option.
- - Added g:bufExplorerShowRelativePath option with mapping.
- - Added current line highlighting.
- - The split type can now be changed whether bufexplorer is opened
- in split mode or not.
- - Various major and minor bug fixes and speed improvements.
- - Sort by extension.
- Other improvements/changes:
- - Changed the help key from '?' to <F1> to be more 'standard'.
- - Fixed splitting of vertical bufexplorer window.
- Hopefully I have not forgot something :)
-7.0.11 - Fixed a couple of highlighting bugs, reported by David Eggum. He also
- changed passive voice to active on a couple of warning messages.
-7.0.10 - Fixed bug report by Xiangjiang Ma. If the 'ssl' option is set,
- the slash character used when displaying the path was incorrect.
-7.0.9 - Martin Grenfell found and eliminated an annoying bug in the
- bufexplorer/winmanager integration. The bug was were an
- annoying message would be displayed when a window was split or
- a new file was opened in a new window. Thanks Martin!
-7.0.8 - Thanks to Mike Li for catching a bug in the WinManager integration.
- The bug was related to the incorrect displaying of the buffer
- explorer's window title.
-7.0.7 - Thanks to Jeremy Cowgar for adding a new enhancement. This
- enhancement allows the user to press 'S', that is capital S, which
- will open the buffer under the cursor in a newly created split
- window.
-7.0.6 - Thanks to Larry Zhang for finding a bug in the "split" buffer code.
- If you force set g:bufExplorerSplitType='v' in your vimrc, and if you
- tried to do a \bs to split the bufexplorer window, it would always
- split horizontal, not vertical. He also found that I had a typeo in
- that the variable g:bufExplorerSplitVertSize was all lower case in
- the documentation which was incorrect.
-7.0.5 - Thanks to Mun Johl for pointing out a bug that if a buffer was
- modified, the '+' was not showing up correctly.
-7.0.4 - Fixed a problem discovered first by Xiangjiang Ma. Well since I've
- been using vim 7.0 and not 6.3, I started using a function (getftype)
- that is not in 6.3. So for backward compatibility, I conditionaly use
- this function now. Thus, the g:bufExplorerShowDirectories feature is
- only available when using vim 7.0 and above.
-7.0.3 - Thanks to Erwin Waterlander for finding a problem when the last
- buffer was deleted. This issue got me to rewrite the buffer display
- logic (which I've wanted to do for sometime now).
- Also great thanks to Dave Eggum for coming up with idea for
- g:bufExplorerShowDirectories. Read the above information about this
- feature.
-7.0.2 - Thanks to Thomas Arendsen Hein for finding a problem when a user
- has the default help turned off and then brought up the explorer. An
- E493 would be displayed.
-7.0.1 - Thanks to Erwin Waterlander for finding a couple problems.
- The first problem allowed a modified buffer to be deleted. Opps! The
- second problem occurred when several files were opened, BufExplorer
- was started, the current buffer was deleted using the 'd' option, and
- then BufExplorer was exited. The deleted buffer was still visible
- while it is not in the buffers list. Opps again!
-7.0.0 - Thanks to Shankar R. for suggesting to add the ability to set
- the fixed width (g:bufExplorerSplitVertSize) of a new window
- when opening bufexplorer vertically and fixed height
- (g:bufExplorerSplitHorzSize) of a new window when opening
- bufexplorer horizontally. By default, the windows are normally
- split to use half the existing width or height.
-6.3.0 - Added keepjumps so that the jumps list would not get cluttered with
- bufexplorer related stuff.
-6.2.3 - Thanks to Jay Logan for finding a bug in the vertical split position
- of the code. When selecting that the window was to be split
- vertically by doing a '\bv', from then on, all splits, i.e. '\bs',
- were split vertically, even though g:bufExplorerSplitType was not set
- to 'v'.
-6.2.2 - Thanks to Patrik Modesto for adding a small improvement. For some
- reason his bufexplorer window was always showing up folded. He added
- 'setlocal nofoldenable' and it was fixed.
-6.2.1 - Thanks goes out to Takashi Matsuo for added the 'fullPath' sorting
- logic and option.
-6.2.0 - Thanks goes out to Simon Johann-Ganter for spotting and fixing a
- problem in that the last search pattern is overridden by the search
- pattern for blank lines.
-6.1.6 - Thanks to Artem Chuprina for finding a pesky bug that has been around
- for sometime now. The <esc> key mapping was causing the buffer
- explored to close prematurely when vim was run in an xterm. The <esc>
- key mapping is now removed.
-6.1.5 - Thanks to Khorev Sergey. Added option to show default help or not.
-6.1.4 - Thanks goes out to Valery Kondakoff for suggesting the addition of
- setlocal nonumber and foldcolumn=0. This allows for line numbering
- and folding to be turned off temporarily while in the explorer.
-6.1.3 - Added folding. Did some code cleanup. Added the ability to force the
- newly split window to be temporarily vertical, which was suggested by
- Thomas Glanzmann.
-6.1.2 - Now pressing the <esc> key will quit, just like 'q'.
- Added folds to hide winmanager configuration.
- If anyone had the 'C' option in their cpoptions they would receive
- a E10 error on startup of BufExplorer. cpo is now saved, updated and
- restored. Thanks to Charles E Campbell, Jr.
- Attempted to make sure there can only be one BufExplorer window open
- at a time.
-6.1.1 - Thanks to Brian D. Goodwin for adding toupper to FileNameCmp. This
- way buffers sorted by name will be in the correct order regardless of
- case.
-6.0.16 - Thanks to Andre Pang for the original patch/idea to get bufexplorer
- to work in insertmode/modeless mode (evim). Added Initialize
- and Cleanup autocommands to handle commands that need to be
- performed when starting or leaving bufexplorer.
-6.0.15 - Srinath Avadhanulax added a patch for winmanager.vim.
-6.0.14 - Fix a few more bug that I thought I already had fixed. Thanks
- to Eric Bloodworth for adding 'Open Mode/Edit in Place'. Added
- vertical splitting.
-6.0.13 - Thanks to Charles E Campbell, Jr. for pointing out some embarrassing
- typos that I had in the documentation. I guess I need to run
- the spell checker more :o)
-6.0.12 - Thanks to Madoka Machitani, for the tip on adding the augroup command
- around the MRUList autocommands.
-6.0.11 - Fixed bug report by Xiangjiang Ma. '"=' was being added to the
- search history which messed up hlsearch.
-6.0.10 - Added the necessary hooks so that the Srinath Avadhanula's
- winmanager.vim script could more easily integrate with this script.
- Tried to improve performance.
-6.0.9 - Added MRU (Most Recently Used) sort ordering.
-6.0.8 - Was not resetting the showcmd command correctly.
- Added nifty help file.
-6.0.7 - Thanks to Brett Carlane for some great enhancements. Some are added,
- some are not, yet. Added highlighting of current and alternate
- filenames. Added splitting of path/filename toggle. Reworked
- ShowBuffers().
- Changed my email address.
-6.0.6 - Copyright notice added. Needed this so that it could be distributed
- with Debian Linux. Fixed problem with the SortListing() function
- failing when there was only one buffer to display.
-6.0.5 - Fixed problems reported by David Pascoe, in that you where unable to
- hit 'd' on a buffer that belonged to a files that no longer existed
- and that the 'yank' buffer was being overridden by the help text when
- the bufexplorer was opened.
-6.0.4 - Thanks to Charles Campbell, Jr. for making this plugin more plugin
- *compliant*, adding default keymappings of <Leader>be and <Leader>bs
- as well as fixing the 'w:sortDirLabel not being defined' bug.
-6.0.3 - Added sorting capabilities. Sort taken from explorer.vim.
-6.0.2 - Can't remember. (2001-07-25)
-6.0.1 - Initial release.
-
-===============================================================================
-TODO *bufexplorer-todo*
-
-- Nothing as of now, buf if you have any suggestions, drop me an email.
-
-===============================================================================
-CREDITS *bufexplorer-credits*
-
-Author: Jeff Lanzarotta <delux256-vim at yahoo dot com>
-
-Credit must go out to Bram Moolenaar and all the Vim developers for
-making the world's best editor (IMHO). I also want to thank everyone who
-helped and gave me suggestions. I wouldn't want to leave anyone out so I
-won't list names.
-
-===============================================================================
-vim:tw=78:noet:wrap:ts=8:ft=help:norl:
+++ /dev/null
-*ConqueTerm* Plugin to run a shell inside a Vim buffer
-
-The ConqueTerm plugin will turn a Vim buffer into a terminal emulator, allowing
-you to run and interact with a shell or shell application inside the buffer.
-
- 1. Installation |conque-term-setup|
- 1.1 Requirements for Unix |conque-term-requirements|
- 1.2 Requirements for Windows |conque-term-windows|
- 1.3 Installation |conque-term-installation|
- 2. Usage |conque-term-usage|
- 2.1 General Usage |conque-term-gen-usage|
- 2.2 Special keys |conque-term-special-keys|
- 2.2.1 Send text to Conque |conque-term-send|
- 2.2.2 Toggle terminal input mode |conque-term-input-mode|
- 2.2.3 Sending the <Esc> key press |conque-term-esc|
- 3. Configuration |conque-term-options|
- 3.1 General |conque-config-general|
- 3.1.1 Python version |ConqueTerm_PyVersion|
- 3.1.2 Fast mode |ConqueTerm_FastMode|
- 3.1.3 Color support |ConqueTerm_Color|
- 3.1.4 Session Support |ConqueTerm_SessionSupport|
- 3.1.5 Keep updating terminal buffer |ConqueTerm_ReadUnfocused|
- 3.1.6 Insert mode when entering buffer |ConqueTerm_InsertOnEnter|
- 3.1.7 Close buffer when program exits |ConqueTerm_CloseOnEnd|
- 3.1.8 Hide start messages |ConqueTerm_StartMessages|
- 3.1.9 Regex for highlighting your prompt |ConqueTerm_PromptRegex|
- 3.1.10 Syntax type |ConqueTerm_Syntax|
- 3.2 Keyboard |conque-config-keyboard|
- 3.2.1 The <Esc> key |ConqueTerm_EscKey|
- 3.2.2 Toggle terminal input mode |ConqueTerm_ToggleKey|
- 3.2.3 Enable <C-w> in insert mode |ConqueTerm_CWInsert|
- 3.2.4 Execute current file in Conque |ConqueTerm_ExecFileKey|
- 3.2.5 Send current file contents to Conque|ConqueTerm_SendFileKey|
- 3.2.6 Send selected text to Conque |ConqueTerm_SendVisKey|
- 3.2.7 Function Keys |ConqueTerm_SendFunctionKeys|
- 3.3 Unix |conque-config-unix|
- 3.3.1 Choose your terminal type |ConqueTerm_TERM|
- 3.4 Windows |conque-config-windows|
- 3.4.1 Python executable |ConqueTerm_PyExe|
- 3.4.2 Windows character code page |ConqueTerm_CodePage|
- 3.4.3 Terminal color method |ConqueTerm_ColorMode|
- 4. VimScript API |conque-term-api|
- 4.1 conque_term#open() |conque-term-open|
- 4.2 conque_term#subprocess() |conque-term-subprocess|
- 4.3 conque_term#get_instance() |conque-term-get-instance|
- 4.4 CONQUE_OBJECT.write() |conque-term-write|
- 4.5 CONQUE_OBJECT.writeln() |conque-term-writeln|
- 4.6 CONQUE_OBJECT.read() |conque-term-read|
- 4.7 CONQUE_OBJECT.set_callback() |conque-term-set-callback|
- 4.8 CONQUE_OBJECT.close() |conque-term-close|
- 4.9 Registering functions |conque-term-events|
- 5. Misc |conque-term-misc|
- 5.1 Known bugs |conque-term-bugs|
- 5.2 Contribute |conque-term-contribute|
- 5.3 Feedback |conque-term-feedback|
-
-==============================================================================
-
-1. Installation *conque-term-setup*
-
-Conque is designed for both Unix and Windows operating systems, however the
-requirements are slightly different. Please check section below corresponding
-to your installed OS.
-
-1.1 Requirements for Unix *conque-term-requirements*
-
- * [G]Vim 7.0+ with +python and/or +python3
- * Python 2.3+ and/or 3.x
- * Unix-like OS: Linux, OS X, Solaris, Cygwin, etc
-
-The most common stumbling block is getting a version of Vim which has the
-python interface enabled. Most all software package managers will have a copy
-of Vim with Python support, so that is often the easiest way to get it. If
-you're compiling Vim from source, be sure to use the --enable-pythoninterp
-option, or --enable-python3interp for Python 3. On OS X the best option is
-MacVim, which installs with Python support by default.
-
-1.2 Requirements for Windows *conque-term-windows*
-
- * [G]Vim 7.3 with +python and/or +python3
- * Python 2.7 and/or 3.1
- * Modern Windows OS (XP or later)
-
-Conque only officially supports the latest GVim 7.3 Windows installer
-available at www.vim.org. If you are currently using Vim 7.2 or earlier you
-will need to upgrade to 7.3 for Windows support. The Windows installer already
-has the +python/+python3 interface built in.
-
-The official 7.3 release of Vim for Windows only works with Python versions
-2.7 and/or 3.1. You can download and install Python from their website
-http://www.python.org/download
-
-If you are compiling Vim + Python from source on Windows, the requirements
-become only Vim 7.3+ and Python 2.7+.
-
-
-1.3 Installation *conque-term-installation*
-
-Download the latest vimball from http://conque.googlecode.com
-
-Open the .vba file with Vim and run the following commands:
->
- :so %
- :q
-<
-That's it! The :ConqueTerm command will be available the next time you start
-Vim. You can delete the .vba file when you've verified Conque was successfully
-installed.
-
-==============================================================================
-
-2. Usage *conque-term-usage*
-
-2.1 General Usage *conque-term-gen-usage*
-
-Type :ConqueTerm <command> to launch an application in the current buffer. Eg:
->
- :ConqueTerm bash
- :ConqueTerm mysql -h localhost -u joe_lunchbox Menu
- :ConqueTerm Powershell.exe
-<
-Use :ConqueTermSplit or :ConqueTermVSplit to open Conque in a new horizontal
-or vertical buffer. Use :ConqueTermTab to open Conque in a new tab.
-
-In insert mode you can interact with the shell as you would expect in a
-normal terminal. All key presses will be sent to the terminal, including
-control characters. See |conque-term-special-keys| for more information,
-particularly regarding the <Esc> key.
-
-In normal mode you can use Vim commands to browse your terminal output and
-scroll back through the history. Most all Vim functionality will work, such
-as searching, yanking or highlighting text.
-
-
-2.2 Special keys *conque-term-special-keys*
-
-There are several keys which can be configured to have special behavior with
-Conque.
-
-2.2.1 Send text to Conque *conque-term-send*
-
-Conque gives you three different commands to send text from a different
-buffer, probably a source code file, to the Conque terminal buffer. All three
-are configurable to use your choice of key combinations.
-
-To send a visually selected range of text to an existing terminal buffer,
-press the <F9> key.
-
-To send the entire contents of the file you are editing to an existing
-terminal buffer, press the <F10> key.
-
-Finally, to execute the current file in a new terminal buffer press the <F11>
-key. This will split the screen with a new Conque buffer. The file you are
-editing must be executable for this command to work.
-
-See |conque-term-options| for information about configuring these commands.
-
-2.2.2 Toggle terminal input mode *conque-term-input-mode*
-
-If you want to use insert mode to edit the terminal screen, press <F8>. You
-will now be able to edit the terminal output freely without your cursor
-jumping the the active prompt line. This may be useful if you want to reformat
-terminal output for readability.
-
-While the terminal is paused new output will not be displayed on the screen
-until you press <F8> again to resume.
-
-You can configure Conque to use a different key with the |ConqueTerm_ToggleKey|
-option.
-
-2.2.3 Sending the <Esc> key press *conque-term-esc*
-
-By default if you press the <Esc> key in a Conque buffer you will leave insert
-mode. But what if you want the <Esc> character to be sent to your terminal?
-There are two options. By default, pressing <Esc> twice will send one <Esc>
-character to the terminal and you will remain in insert mode, while pressing
-it once will leave insert mode.
-
-Alternatively you can use the |ConqueTerm_EscKey| option to choose a
-different key for leaving insert mode. If a custom key is set, then all <Esc>
-key presses will be sent to the terminal.
-
-2.3 Registering functions *conque-term-register*
-
-Conque allows you to write your own VimScript functions which will be called
-at certain events. See the API section |conque-term-events| for more.
-
-==============================================================================
-
-3. Options *conque-term-options*
-
-You can set the following options in your .vimrc (default values shown)
-
-3.1 General *conque-config-general*
-
-3.1.1 Python version *ConqueTerm_PyVersion*
-
-Conque will work with either Python 2.x or 3.x, assuming the interfaces have
-been installed. By default it will try to use Python 2 first, then will try
-Python 3. If you want Conque to use Python 3, set this variable to 3.
-
-Note: even if you set this to 3, if you don't have the python3 interface
-Conque will fall back to using Python 2.
->
- let g:ConqueTerm_PyVersion = 2
-<
-3.1.2 Fast Mode *ConqueTerm_FastMode*
-
-Disable features which could make Conque run slowly. This includes most
-terminal colors and some unicode support. Set this to 1 to enable fast mode.
->
- let g:ConqueTerm_FastMode = 0
-<
-3.1.3 Color support *ConqueTerm_Color*
-
-Terminal colors have the potential to slow down terminal screen rendering,
-depending on how many colors are used and how fast the computer is. This
-option allows you to choose how much color support will be enabled.
-
-If set to 0, terminal colors will be disabled. This will allow the terminal to
-render most quickly. Syntax highlighting will still work. For example
-highlighting quoted strings or MySQL output.
-
-If set to 1, terminal colors will be enabled, but only for the most recent 200
-lines of terminal output. Older output will be periodically stripped of color
-highlighting to keep the display responsive.
-
-If set to 2, terminal colors will always be enabled. If your programs don't
-use color output very frequently this is a good choice.
-
-Note: Color support is automatically disabled in "fast mode".
->
- let g:ConqueTerm_Color = 1
-<
-3.1.4 Session Support *ConqueTerm_SessionSupport*
-
-Vim's :mksession command allows you to save your current buffer configuration
-to a file, which can be loaded at a later time after you've closed Vim.
-
-By default, Conque buffers are not restored. This is mostly for safety
-reasons; you may not want Vim to automatically re-run a destructive command.
-
-However, if you're not working with missile launch code, and want Vim to
-restart your Conque buffers when you load a session file, set this variable
-to 1. Note your original subprocess and shell output will not be restored, but
-the same command will be started in your buffer.
->
- let g:ConqueTerm_SessionSupport = 0
-<
-3.1.5 Keep updating terminal buffer *ConqueTerm_ReadUnfocused*
-
-If set to 1 then your Conque buffers will continue to update after you've
-switched to another buffer.
-
-Note: Conque buffers may continue to update, but they will not scroll down as
-new lines are added beyond the bottom of the visible buffer area. This is a
-limitation of the Vim scripting language for which I haven't found a
-workaround.
->
- let g:ConqueTerm_ReadUnfocused = 1
-<
-3.1.6 Insert mode when entering buffer *ConqueTerm_InsertOnEnter*
-
-If set to 1 then you will automatically go into insert mode when you enter the
-buffer. This diverges from normal Vim behavior. If 0 you will still be in
-normal mode.
->
- let g:ConqueTerm_InsertOnEnter = 0
-<
-3.1.7 Close buffer when program exits *ConqueTerm_CloseOnEnd*
-
-If you want your terminal buffer to be closed and permanently deleted when the
-program running inside of it exits, set this option to 1. Otherwise the buffer
-will become a simple text buffer after the program exits, and you can edit the
-program output in insert mode.
->
- let g:ConqueTerm_CloseOnEnd = 0
-<
-3.1.8 Hide start messages *ConqueTerm_StartMessages*
-
-Unused. Startup messages are always hidden.
->
- let g:ConqueTerm_StartMessages = 0
-<
-3.1.9 Regex for highlighting your prompt *ConqueTerm_PromptRegex*
-
-Use this regular expression for sytax highlighting your terminal prompt. Your
-terminal will generally run faster if you use Vim highlighting instead of
-terminal colors for your prompt. You can also use it to do more advanced
-syntax highlighting for the prompt line.
->
- let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
-<
-3.1.10 Choose Vim syntax type *ConqueTerm_Syntax*
-
-Set the buffer syntax. The default 'conque' has highlighting for MySQL, but
-not much else.
->
- let g:ConqueTerm_Syntax = 'conque'
-<
-3.2 Keyboard *conque-config-keyboard*
-
-3.2.1 The <Esc> key *ConqueTerm_EscKey*
-
-If a custom key is set, then all <Esc> key presses will be sent to the
-terminal and you must use this custom key to leave insert mode. If left to the
-default value of '<Esc>' then you must press it twice to send the escape
-character to the terminal, while pressing it once will leave insert mode.
-
-Note: You cannot use a key which is internally coded with the escape
-character. This includes the <F-> keys and often the <A-> and <M-> keys.
-Picking a control key, such as <C-k> will be your best bet.
->
- let g:ConqueTerm_EscKey = '<Esc>'
-<
-3.2.2 Toggle terminal input mode *ConqueTerm_ToggleKey*
-
-Press this key to pause terminal input and output display. You will then be
-able to edit the terminal screen as if it were a normal text buffer. Press
-this key again to resume terminal mode.
->
- let g:ConqueTerm_ToggleKey = '<F8>'
-<
-3.2.3 Enable <C-w> in insert mode *ConqueTerm_CWInsert*
-
-If set to 1 then you can leave the Conque buffer using the <C-w> commands
-while you're still in insert mode. If set to 0 then the <C-w> character will
-be sent to the terminal. If both this option and ConqueTerm_InsertOnEnter are
-set you can go in and out of the terminal buffer while never leaving insert
-mode.
->
- let g:ConqueTerm_CWInsert = 0
-<
-3.2.4 Execute current file in Conque *ConqueTerm_ExecFileKey*
-
-Press this key to execute the file you're currently editing in a Conque
-buffer. Is equivelent to running the command :ConqueTermSplit YOUR_FILE. Your
-file must be executable for this command to work correctly.
->
- let g:ConqueTerm_ExecFileKey = '<F11>'
-<
-3.2.5 Send current file contents to Conque *ConqueTerm_SendFileKey*
-
-Press this key to send your entire file contents to the most recently opened
-Conque buffer as keyboard input.
->
- let g:ConqueTerm_SendFileKey = '<F10>'
-<
-3.2.6 Send selected text to Conque *ConqueTerm_SendVisKey*
-
-Use this key to send the currently selected text to the most recently created
-Conque buffer.
->
- let g:ConqueTerm_SendVisKey = '<F9>'
-<
-3.2.7 Function Keys *ConqueTerm_SendFunctionKeys*
-
-By default, function keys (the F1-F12 row at the top of your keyboard) are not
-passed to the terminal. Set this option to 1 to send these key events.
-
-Note: Unless you configured |ConqueTerm_SendVisKey| and |ConqueTerm_ToggleKey|
-to use different keys, <F8> and <F9> will not be sent to the terminal even if
-you set this option to 1.
->
- let g:ConqueTerm_SendFunctionKeys = 0
-<
-3.3 Unix *conque-config-unix*
-
-3.3.1 Choose your terminal type, Unix ONLY *ConqueTerm_TERM*
-
-Use this option to tell Conque what type of terminal it should identify itself
-as. Conque officially uses the more limited VT100 terminal type for
-developement and testing, although it supports some more advanced features
-such as colors and title strings.
-
-You can change this setting to a more advanced type, namely 'xterm', but your
-results may vary depending on which programs you're running.
->
- let g:ConqueTerm_TERM = 'vt100'
-<
-3.4 Windows *conque-config-windows*
-
-3.4.1 Python executable, Windows ONLY *ConqueTerm_PyExe*
-
-The Windows version of Conque needs to know the path to the python.exe
-executable for the version of Python Conque is using. If you installed Python
-in the default location, or added the Python directory to your system path,
-Conque should be able to find python.exe without you changing this variable.
-
-For example, you might set this to 'C:\Program Files\Python27\python.exe'
->
- let g:ConqueTerm_PyExe = ''
-<
-3.4.2 Windows character code page *ConqueTerm_CodePage*
-
-Set the "code page" Windows will use for your console. Leave this value set to
-zero to use the environment code page.
-
-Note: Displaying unicode characters on Conque for Windows needs work.
->
- let g:ConqueTerm_CodePage = 0
-<
-3.4.3 Terminal color method, Windows ONLY *ConqueTerm_ColorMode*
-
-Vim syntax highlighting by coordinate (e.g. the 3-7th characters on the 42nd
-line) can be very slow. If you set this variable to 'conceal', you can use
-the new conceal feature to render terminal colors. Requires Vim 7.3 and only
-works on the Windows version of Conque. This will make colors render faster,
-however it will also add hidden characters to the screen, which may be
-annoying if you're copying and pasting terminal output out of the Conque
-buffer. Set this to an empty string '' to disable concealed highlighting.
->
- let g:ConqueTerm_ColorMode = 'conceal'
-<
-==============================================================================
-
-4. VimScript API (Beta) *conque-term-api*
-
-The Conque scripting API allows you to create and interact with Conque
-terminals with the VimScript language. This API is still in beta stage.
-
-4.1 conque_term#open({command}, [buf_opts], [remain]) *conque-term-open*
-
-The open() function will create a new terminal buffer and start your command.
-
-The {command} must be an executable, either an absolute path or relative to
-your system path.
-
-You can pass in a list of vim commands [buf_opts] which will be executed after
-the new buffer is created but before the command is started. These are
-typically commands to alter the size, position or configuration of the buffer
-window.
-
-Note: If you don't pass in a command such as 'split', the terminal will open
-in the current buffer.
-
-If you don't want the new terminal buffer to become the new active buffer, set
- [remain] to 1. Only works if you create a split screen using [options].
-
-Returns a Conque terminal object.
-
-Examples:
->
- let my_terminal = conque_term#open('/bin/bash')
- let my_terminal = conque_term#open('ipython', ['split', 'resize 20'], 1)
-<
-4.2 conque_term#subprocess({command}) *conque-term-subprocess*
-
-Starts a new subprocess with your {command}, but no terminal buffer is ever
-created. This may be useful if you need asynchronous interaction with a
-subprocess, but want to handle the output on your own.
-
-Returns a Conque terminal object.
-
-Example:
->
- let my_subprocess = conque_term#subprocess('tail -f /var/log/foo.log')
-<
-4.3 conque_term#get_instance( [terminal_number] ) *conque-term-get-instance*
-
-Use the get_instance() function to retrieve an existing terminal object. The
-terminal could have been created either with the user command :ConqueTerm or
-with an API call to conque_term#open() or subprocess().
-
-Use the optional [terminal_number] to retrieve a specific terminal instance.
-Otherwise if the current buffer is a Conque terminal, it will be returned,
-else the most recently created terminal. The terminal number is what you see
-at the end of a terminal buffer name, e.g. "bash - 2".
-
-Returns a Conque terminal object.
-
-Example:
->
- nnoremap <F4> :call conque_term#get_instance().writeln('clear')<CR>
-<
-4.4 CONQUE_OBJECT.write({text}) *conque-term-write*
-
-Once you have a terminal object from open(), subprocess() or get_instance()
-you can send text input to it with the write() method.
-
-No return value.
-
-Examples:
->
- call my_terminal.write("whoami\n")
- call my_terminal.write("\<C-c>")
-<
-4.5 CONQUE_OBJECT.writeln({text}) *conque-term-writeln*
-
-The same as write() except adds a \n character to the end if your input.
-
-Examples:
->
- call my_subprocess.writeln('make')
-<
-4.6 CONQUE_OBJECT.read( [timeout], [update_buffer] ) *conque-term-read*
-
-Read new output from a Conque terminal subprocess. New output will be returned
-as a string, and the terminal buffer will also be updated by default.
-
-If you are reading immediately after calling the write() method, you may want
-to wait [timeout] milliseconds for output to be ready.
-
-If you want to prevent the output from being displayed in the terminal buffer,
-set [update_buffer] to 0. This option has no effect if the terminal was
-created with the subprocess() function, since there never is a buffer to
-update.
-
-Returns output string.
-
-Note: The terminal buffer will not automatically scroll down if the new output
-extends beyond the bottom of the visible buffer. Vim doesn't allow "unfocused"
-buffers to be scrolled at the current version, although hopefully this will
-change.
-
-Examples:
->
- call my_terminal.writeln('whoami')
- let output = my_terminal.read(500)
- call my_terminal.writeln('ls -lha')
- let output = my_terminal.read(1000, 1)
-<
-4.7 CONQUE_OBJECT.set_callback( {funcname} ) *conque-term-set-callback*
-
-Register a callback function for this subprocess instance. This function will
-automatically be called whenever new output is available. Only practical with
-subprocess() objects.
-
-Conque checkes for new subprocess output once a second when Vim is idle. If
-new output is found your function will be called.
-
-Pass in the callback function name {funcname} as a string.
-
-No return value.
-
-Note: this method requires the g:ConqueTerm_ReadUnfocused option to be set.
-
-Note: this method is experimental, results may vary.
-
-Example:
->
- let sp = conque_term#subprocess('tail -f /home/joe/log/error_log')
-
- function! MyErrorAlert(output)
- echo a:output
- endfunction
-
- call sp.set_callback('MyErrorAlert')
-<
-4.8 CONQUE_OBJECT.close() *conque-term-close*
-
-Kill your terminal subprocess. Sends the ABORT signal. You probably want to
-close your subprocess in a more graceful manner with the write() method, but
-this can be used when needed. Does not close the terminal buffer, if it
-exists.
-
-This method will be called on all existing Conque subprocesses when Vim exits.
-
-Example:
->
- let term = conque_term#open('ping google.com', ['belowright split'])
- call term.read(5000)
- call term.close()
-<
-4.9 Registering functions *conque-term-events*
-
-Conque provides the option to register callback functions which will be
-executed at several different events. The currently available events are:
-
- after_startup After your application has loaded into the buffer.
- buffer_enter When you switch to a Conque buffer.
- buffer_leave When you leave a Conque buffer.
-
-You may use the function conque_term#register_function(event, function_name)
-to add additional hooks at a particular event. The second argument should be
-the name of a callback function which has one parameter, the current
-terminal object (see|conque-term-api|for more about terminal objects).
-
-For example:
->
- function MyConqueStartup(term)
-
- " set buffer syntax using the name of the program currently running
- let syntax_associations = { 'ipython': 'python', 'irb': 'ruby' }
-
- if has_key(syntax_associations, a:term.program_name)
- execute 'setlocal syntax=' . syntax_associations[a:term.program_name]
- else
- execute 'setlocal syntax=' . a:term.program_name
- endif
-
- " shrink window height to 10 rows
- resize 10
-
- " silly example of terminal api usage
- if a:term.program_name == 'bash'
- call a:term.writeln('svn up ~/projects/*')
- endif
-
- endfunction
-
- call conque_term#register_function('after_startup', 'MyConqueStartup')
-<
-
-==============================================================================
-
-5. Misc *conque-term-misc*
-
-
-5.1 Known bugs *conque-term-bugs*
-
-The following are known limitations:
-
- - Font/color highlighting is imperfect and slow. If you don't care about
- color in your shell, set g:ConqueTerm_Color = 0 in your .vimrc
- - Conque only supports the extended ASCII character set for input, not utf-8.
- - VT100 escape sequence support is not complete.
- - Alt/Meta key support in Vim isn't great in general, and conque is no
- exception. Pressing <Esc><Esc>x or <Esc><M-x> instead of <M-x> works in
- most cases.
-
-
-5.2 Contribute *conque-term-contribute*
-
-The two contributions most in need are improvements to Vim itself. I currently
-use hacks to capture key press input from the user, and to poll the terminal
-for more output. The Vim todo.txt document lists proposed improvements to give
-users this behavior without hacks. Having a key press event should allow
-Conque to work with multi- byte input. If you are a Vim developer, please
-consider prioritizing these two items:
-
- - todo.txt (Autocommands, line ~3137)
- 8 Add an event like CursorHold that is triggered repeatedly, not just
- once after typing something.
-
-
-5.3 Feedback *conque-term-feedback*
-
-Bugs, suggestions and patches are all welcome.
-
-For more information visit http://conque.googlecode.com
-
-Check out the latest from svn at http://conque.googlecode.com/svn/trunk/
-
- vim:tw=78:ts=8:ft=help:norl:
+++ /dev/null
-*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
-
-snipMate *snippet* *snippets* *snipMate*
-Last Change: July 13, 2009
-
-|snipMate-description| Description
-|snipMate-syntax| Snippet syntax
-|snipMate-usage| Usage
-|snipMate-settings| Settings
-|snipMate-features| Features
-|snipMate-disadvantages| Disadvantages to TextMate
-|snipMate-contact| Contact
-
-For Vim version 7.0 or later.
-This plugin only works if 'compatible' is not set.
-{Vi does not have any of these features.}
-
-==============================================================================
-DESCRIPTION *snipMate-description*
-
-snipMate.vim implements some of TextMate's snippets features in Vim. A
-snippet is a piece of often-typed text that you can insert into your
-document using a trigger word followed by a <tab>.
-
-For instance, in a C file using the default installation of snipMate.vim, if
-you type "for<tab>" in insert mode, it will expand a typical for loop in C: >
-
- for (i = 0; i < count; i++) {
-
- }
-
-
-To go to the next item in the loop, simply <tab> over to it; if there is
-repeated code, such as the "i" variable in this example, you can simply
-start typing once it's highlighted and all the matches specified in the
-snippet will be updated. To go in reverse, use <shift-tab>.
-
-==============================================================================
-SYNTAX *snippet-syntax*
-
-Snippets can be defined in two ways. They can be in their own file, named
-after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be
-defined together in a 'snippets/<filetype>.snippets' file. Note that dotted
-'filetype' syntax is supported -- e.g., you can use >
-
- :set ft=html.eruby
-
-to activate snippets for both HTML and eRuby for the current file.
-
-The syntax for snippets in *.snippets files is the following: >
-
- snippet trigger
- expanded text
- more expanded text
-
-Note that the first hard tab after the snippet trigger is required, and not
-expanded in the actual snippet. The syntax for *.snippet files is the same,
-only without the trigger declaration and starting indentation.
-
-Also note that snippets must be defined using hard tabs. They can be expanded
-to spaces later if desired (see |snipMate-indenting|).
-
-"#" is used as a line-comment character in *.snippets files; however, they can
-only be used outside of a snippet declaration. E.g.: >
-
- # this is a correct comment
- snippet trigger
- expanded text
- snippet another_trigger
- # this isn't a comment!
- expanded text
-<
-This should hopefully be obvious with the included syntax highlighting.
-
- *snipMate-${#}*
-Tab stops ~
-
-By default, the cursor is placed at the end of a snippet. To specify where the
-cursor is to be placed next, use "${#}", where the # is the number of the tab
-stop. E.g., to place the cursor first on the id of a <div> tag, and then allow
-the user to press <tab> to go to the middle of it:
- >
- snippet div
- <div id="${1}">
- ${2}
- </div>
-<
- *snipMate-placeholders* *snipMate-${#:}* *snipMate-$#*
-Placeholders ~
-
-Placeholder text can be supplied using "${#:text}", where # is the number of
-the tab stop. This text then can be copied throughout the snippet using "$#",
-given # is the same number as used before. So, to make a C for loop: >
-
- snippet for
- for (${2:i}; $2 < ${1:count}; $1++) {
- ${4}
- }
-
-This will cause "count" to first be selected and change if the user starts
-typing. When <tab> is pressed, the "i" in ${2}'s position will be selected;
-all $2 variables will default to "i" and automatically be updated if the user
-starts typing.
-NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate.
-
-Variables within variables are also possible. For instance: >
-
- snippet opt
- <option value="${1:option}">${2:$1}</option>
-
-Will, as usual, cause "option" to first be selected and update all the $1
-variables if the user starts typing. Since one of these variables is inside of
-${2}, this text will then be used as a placeholder for the next tab stop,
-allowing the user to change it if he wishes.
-
-To copy a value throughout a snippet without supplying default text, simply
-use the "${#:}" construct without the text; e.g.: >
-
- snippet foo
- ${1:}bar$1
-< *snipMate-commands*
-Interpolated Vim Script ~
-
-Snippets can also contain Vim script commands that are executed (via |eval()|)
-when the snippet is inserted. Commands are given inside backticks (`...`); for
-TextMates's functionality, use the |system()| function. E.g.: >
-
- snippet date
- `system("date +%Y-%m-%d")`
-
-will insert the current date, assuming you are on a Unix system. Note that you
-can also (and should) use |strftime()| for this example.
-
-Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
-
-Since the current filename is used often in snippets, a default function
-has been defined for it in snipMate.vim, appropriately called Filename().
-
-With no arguments, the default filename without an extension is returned;
-the first argument specifies what to place before or after the filename,
-and the second argument supplies the default text to be used if the file
-has not been named. "$1" in the first argument is replaced with the filename;
-if you only want the filename to be returned, the first argument can be left
-blank. Examples: >
-
- snippet filename
- `Filename()`
- snippet filename_with_default
- `Filename('', 'name')`
- snippet filename_foo
- `filename('$1_foo')`
-
-The first example returns the filename if it the file has been named, and an
-empty string if it hasn't. The second returns the filename if it's been named,
-and "name" if it hasn't. The third returns the filename followed by "_foo" if
-it has been named, and an empty string if it hasn't.
-
- *multi_snip*
-To specify that a snippet can have multiple matches in a *.snippets file, use
-this syntax: >
-
- snippet trigger A description of snippet #1
- expand this text
- snippet trigger A description of snippet #2
- expand THIS text!
-
-In this example, when "trigger<tab>" is typed, a numbered menu containing all
-of the descriptions of the "trigger" will be shown; when the user presses the
-corresponding number, that snippet will then be expanded.
-
-To create a snippet with multiple matches using *.snippet files,
-simply place all the snippets in a subdirectory with the trigger name:
-'snippets/<filetype>/<trigger>/<name>.snippet'.
-
-==============================================================================
-USAGE *snipMate-usage*
-
- *'snippets'* *g:snippets_dir*
-Snippets are by default looked for any 'snippets' directory in your
-'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or
-'$HOME\vimfiles\snippets\' on Windows. To change that location or add another
-one, change the g:snippets_dir variable in your |.vimrc| to your preferred
-directory, or use the |ExtractSnips()|function. This will be used by the
-|globpath()| function, and so accepts the same syntax as it (e.g.,
-comma-separated paths).
-
-ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets*
-
-ExtractSnipsFile() extracts the specified *.snippets file for the given
-filetype. A .snippets file contains multiple snippet declarations for the
-filetype. It is further explained above, in |snippet-syntax|.
-
-ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet*
-
-ExtractSnips() extracts *.snippet files from the specified directory and
-defines them as snippets for the given filetype. The directory tree should
-look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
-multiple matches, it should look like this:
-'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
-
- *ResetSnippets()*
-The ResetSnippets() function removes all snippets from memory. This is useful
-to put at the top of a snippet setup file for if you would like to |:source|
-it multiple times.
-
- *list-snippets* *i_CTRL-R_<Tab>*
-If you would like to see what snippets are available, simply type <c-r><tab>
-in the current buffer to show a list via |popupmenu-completion|.
-
-==============================================================================
-SETTINGS *snipMate-settings* *g:snips_author*
-
-The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
-to your name; it can then be used in snippets to automatically add it. E.g.: >
-
- let g:snips_author = 'Hubert Farnsworth'
- snippet name
- `g:snips_author`
-<
- *snipMate-expandtab* *snipMate-indenting*
-If you would like your snippets to be expanded using spaces instead of tabs,
-just enable 'expandtab' and set 'softtabstop' to your preferred amount of
-spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
-
- *snipMate-remap*
-snipMate does not come with a setting to customize the trigger key, but you
-can remap it easily in the two lines it's defined in the 'after' directory
-under 'plugin/snipMate.vim'. For instance, to change the trigger key
-to CTRL-J, just change this: >
-
- ino <tab> <c-r>=TriggerSnippet()<cr>
- snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
-
-to this: >
- ino <c-j> <c-r>=TriggerSnippet()<cr>
- snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
-
-==============================================================================
-FEATURES *snipMate-features*
-
-snipMate.vim has the following features among others:
- - The syntax of snippets is very similar to TextMate's, allowing
- easy conversion.
- - The position of the snippet is kept transparently (i.e. it does not use
- markers/placeholders written to the buffer), which allows you to escape
- out of an incomplete snippet, something particularly useful in Vim.
- - Variables in snippets are updated as-you-type.
- - Snippets can have multiple matches.
- - Snippets can be out of order. For instance, in a do...while loop, the
- condition can be added before the code.
- - [New] File-based snippets are supported.
- - [New] Triggers after non-word delimiters are expanded, e.g. "foo"
- in "bar.foo".
- - [New] <shift-tab> can now be used to jump tab stops in reverse order.
-
-==============================================================================
-DISADVANTAGES *snipMate-disadvantages*
-
-snipMate.vim currently has the following disadvantages to TextMate's snippets:
- - There is no $0; the order of tab stops must be explicitly stated.
- - Placeholders within placeholders are not possible. E.g.: >
-
- '<div${1: id="${2:some_id}}">${3}</div>'
-<
- In TextMate this would first highlight ' id="some_id"', and if
- you hit delete it would automatically skip ${2} and go to ${3}
- on the next <tab>, but if you didn't delete it it would highlight
- "some_id" first. You cannot do this in snipMate.vim.
- - Regex cannot be performed on variables, such as "${1/.*/\U&}"
- - Placeholders cannot span multiple lines.
- - Activating snippets in different scopes of the same file is
- not possible.
-
-Perhaps some of these features will be added in a later release.
-
-==============================================================================
-CONTACT *snipMate-contact* *snipMate-author*
-
-To contact the author (Michael Sanders), please email:
- msanders42+snipmate <at> gmail <dot> com
-
-I greatly appreciate any suggestions or improvements offered for the script.
-
-==============================================================================
-
-vim:tw=78:ts=8:ft=help:norl:
+++ /dev/null
-'NERDAllowAnyVisualDelims' NERD_commenter.txt /*'NERDAllowAnyVisualDelims'*
-'NERDBlockComIgnoreEmpty' NERD_commenter.txt /*'NERDBlockComIgnoreEmpty'*
-'NERDChristmasTree' NERD_tree.txt /*'NERDChristmasTree'*
-'NERDCommentWholeLinesInVMode' NERD_commenter.txt /*'NERDCommentWholeLinesInVMode'*
-'NERDCompactSexyComs' NERD_commenter.txt /*'NERDCompactSexyComs'*
-'NERDCreateDefaultMappings' NERD_commenter.txt /*'NERDCreateDefaultMappings'*
-'NERDDefaultNesting' NERD_commenter.txt /*'NERDDefaultNesting'*
-'NERDLPlace' NERD_commenter.txt /*'NERDLPlace'*
-'NERDMenuMode' NERD_commenter.txt /*'NERDMenuMode'*
-'NERDRPlace' NERD_commenter.txt /*'NERDRPlace'*
-'NERDRemoveAltComs' NERD_commenter.txt /*'NERDRemoveAltComs'*
-'NERDRemoveExtraSpaces' NERD_commenter.txt /*'NERDRemoveExtraSpaces'*
-'NERDSpaceDelims' NERD_commenter.txt /*'NERDSpaceDelims'*
-'NERDTreeAutoCenter' NERD_tree.txt /*'NERDTreeAutoCenter'*
-'NERDTreeAutoCenterThreshold' NERD_tree.txt /*'NERDTreeAutoCenterThreshold'*
-'NERDTreeBookmarksFile' NERD_tree.txt /*'NERDTreeBookmarksFile'*
-'NERDTreeCaseSensitiveSort' NERD_tree.txt /*'NERDTreeCaseSensitiveSort'*
-'NERDTreeChDirMode' NERD_tree.txt /*'NERDTreeChDirMode'*
-'NERDTreeHighlightCursorline' NERD_tree.txt /*'NERDTreeHighlightCursorline'*
-'NERDTreeHijackNetrw' NERD_tree.txt /*'NERDTreeHijackNetrw'*
-'NERDTreeIgnore' NERD_tree.txt /*'NERDTreeIgnore'*
-'NERDTreeMouseMode' NERD_tree.txt /*'NERDTreeMouseMode'*
-'NERDTreeQuitOnOpen' NERD_tree.txt /*'NERDTreeQuitOnOpen'*
-'NERDTreeShowBookmarks' NERD_tree.txt /*'NERDTreeShowBookmarks'*
-'NERDTreeShowFiles' NERD_tree.txt /*'NERDTreeShowFiles'*
-'NERDTreeShowHidden' NERD_tree.txt /*'NERDTreeShowHidden'*
-'NERDTreeShowLineNumbers' NERD_tree.txt /*'NERDTreeShowLineNumbers'*
-'NERDTreeSortOrder' NERD_tree.txt /*'NERDTreeSortOrder'*
-'NERDTreeStatusline' NERD_tree.txt /*'NERDTreeStatusline'*
-'NERDTreeWinPos' NERD_tree.txt /*'NERDTreeWinPos'*
-'NERDTreeWinSize' NERD_tree.txt /*'NERDTreeWinSize'*
-'NERDUsePlaceHolders' NERD_commenter.txt /*'NERDUsePlaceHolders'*
-'loaded_nerd_comments' NERD_commenter.txt /*'loaded_nerd_comments'*
-'loaded_nerd_tree' NERD_tree.txt /*'loaded_nerd_tree'*
-'snippets' snipMate.txt /*'snippets'*
-.snippet snipMate.txt /*.snippet*
-.snippets snipMate.txt /*.snippets*
-:AcpDisable acp.txt /*:AcpDisable*
-:AcpEnable acp.txt /*:AcpEnable*
-:AcpLock acp.txt /*:AcpLock*
-:AcpUnlock acp.txt /*:AcpUnlock*
-:NERDTree NERD_tree.txt /*:NERDTree*
-:NERDTreeClose NERD_tree.txt /*:NERDTreeClose*
-:NERDTreeFind NERD_tree.txt /*:NERDTreeFind*
-:NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark*
-:NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror*
-:NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle*
-ConqueTerm conque_term.txt /*ConqueTerm*
-ConqueTerm_CWInsert conque_term.txt /*ConqueTerm_CWInsert*
-ConqueTerm_CloseOnEnd conque_term.txt /*ConqueTerm_CloseOnEnd*
-ConqueTerm_CodePage conque_term.txt /*ConqueTerm_CodePage*
-ConqueTerm_Color conque_term.txt /*ConqueTerm_Color*
-ConqueTerm_ColorMode conque_term.txt /*ConqueTerm_ColorMode*
-ConqueTerm_EscKey conque_term.txt /*ConqueTerm_EscKey*
-ConqueTerm_ExecFileKey conque_term.txt /*ConqueTerm_ExecFileKey*
-ConqueTerm_FastMode conque_term.txt /*ConqueTerm_FastMode*
-ConqueTerm_InsertOnEnter conque_term.txt /*ConqueTerm_InsertOnEnter*
-ConqueTerm_PromptRegex conque_term.txt /*ConqueTerm_PromptRegex*
-ConqueTerm_PyExe conque_term.txt /*ConqueTerm_PyExe*
-ConqueTerm_PyVersion conque_term.txt /*ConqueTerm_PyVersion*
-ConqueTerm_ReadUnfocused conque_term.txt /*ConqueTerm_ReadUnfocused*
-ConqueTerm_SendFileKey conque_term.txt /*ConqueTerm_SendFileKey*
-ConqueTerm_SendFunctionKeys conque_term.txt /*ConqueTerm_SendFunctionKeys*
-ConqueTerm_SendVisKey conque_term.txt /*ConqueTerm_SendVisKey*
-ConqueTerm_SessionSupport conque_term.txt /*ConqueTerm_SessionSupport*
-ConqueTerm_StartMessages conque_term.txt /*ConqueTerm_StartMessages*
-ConqueTerm_Syntax conque_term.txt /*ConqueTerm_Syntax*
-ConqueTerm_TERM conque_term.txt /*ConqueTerm_TERM*
-ConqueTerm_ToggleKey conque_term.txt /*ConqueTerm_ToggleKey*
-ExtractSnips() snipMate.txt /*ExtractSnips()*
-ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
-Filename() snipMate.txt /*Filename()*
-NERDComAbout NERD_commenter.txt /*NERDComAbout*
-NERDComAlignedComment NERD_commenter.txt /*NERDComAlignedComment*
-NERDComAltDelim NERD_commenter.txt /*NERDComAltDelim*
-NERDComAppendComment NERD_commenter.txt /*NERDComAppendComment*
-NERDComChangelog NERD_commenter.txt /*NERDComChangelog*
-NERDComComment NERD_commenter.txt /*NERDComComment*
-NERDComCredits NERD_commenter.txt /*NERDComCredits*
-NERDComDefaultDelims NERD_commenter.txt /*NERDComDefaultDelims*
-NERDComEOLComment NERD_commenter.txt /*NERDComEOLComment*
-NERDComFunctionality NERD_commenter.txt /*NERDComFunctionality*
-NERDComFunctionalityDetails NERD_commenter.txt /*NERDComFunctionalityDetails*
-NERDComFunctionalitySummary NERD_commenter.txt /*NERDComFunctionalitySummary*
-NERDComHeuristics NERD_commenter.txt /*NERDComHeuristics*
-NERDComInsertComment NERD_commenter.txt /*NERDComInsertComment*
-NERDComInstallation NERD_commenter.txt /*NERDComInstallation*
-NERDComInvertComment NERD_commenter.txt /*NERDComInvertComment*
-NERDComIssues NERD_commenter.txt /*NERDComIssues*
-NERDComLicense NERD_commenter.txt /*NERDComLicense*
-NERDComMappings NERD_commenter.txt /*NERDComMappings*
-NERDComMinimalComment NERD_commenter.txt /*NERDComMinimalComment*
-NERDComNERDComment NERD_commenter.txt /*NERDComNERDComment*
-NERDComNestedComment NERD_commenter.txt /*NERDComNestedComment*
-NERDComNesting NERD_commenter.txt /*NERDComNesting*
-NERDComOptions NERD_commenter.txt /*NERDComOptions*
-NERDComOptionsDetails NERD_commenter.txt /*NERDComOptionsDetails*
-NERDComOptionsSummary NERD_commenter.txt /*NERDComOptionsSummary*
-NERDComSexyComment NERD_commenter.txt /*NERDComSexyComment*
-NERDComSexyComments NERD_commenter.txt /*NERDComSexyComments*
-NERDComToggleComment NERD_commenter.txt /*NERDComToggleComment*
-NERDComUncommentLine NERD_commenter.txt /*NERDComUncommentLine*
-NERDComYankComment NERD_commenter.txt /*NERDComYankComment*
-NERDCommenter NERD_commenter.txt /*NERDCommenter*
-NERDCommenterContents NERD_commenter.txt /*NERDCommenterContents*
-NERDTree NERD_tree.txt /*NERDTree*
-NERDTree-? NERD_tree.txt /*NERDTree-?*
-NERDTree-A NERD_tree.txt /*NERDTree-A*
-NERDTree-B NERD_tree.txt /*NERDTree-B*
-NERDTree-C NERD_tree.txt /*NERDTree-C*
-NERDTree-C-J NERD_tree.txt /*NERDTree-C-J*
-NERDTree-C-K NERD_tree.txt /*NERDTree-C-K*
-NERDTree-D NERD_tree.txt /*NERDTree-D*
-NERDTree-F NERD_tree.txt /*NERDTree-F*
-NERDTree-I NERD_tree.txt /*NERDTree-I*
-NERDTree-J NERD_tree.txt /*NERDTree-J*
-NERDTree-K NERD_tree.txt /*NERDTree-K*
-NERDTree-O NERD_tree.txt /*NERDTree-O*
-NERDTree-P NERD_tree.txt /*NERDTree-P*
-NERDTree-R NERD_tree.txt /*NERDTree-R*
-NERDTree-T NERD_tree.txt /*NERDTree-T*
-NERDTree-U NERD_tree.txt /*NERDTree-U*
-NERDTree-X NERD_tree.txt /*NERDTree-X*
-NERDTree-cd NERD_tree.txt /*NERDTree-cd*
-NERDTree-contents NERD_tree.txt /*NERDTree-contents*
-NERDTree-e NERD_tree.txt /*NERDTree-e*
-NERDTree-f NERD_tree.txt /*NERDTree-f*
-NERDTree-gi NERD_tree.txt /*NERDTree-gi*
-NERDTree-go NERD_tree.txt /*NERDTree-go*
-NERDTree-gs NERD_tree.txt /*NERDTree-gs*
-NERDTree-i NERD_tree.txt /*NERDTree-i*
-NERDTree-m NERD_tree.txt /*NERDTree-m*
-NERDTree-o NERD_tree.txt /*NERDTree-o*
-NERDTree-p NERD_tree.txt /*NERDTree-p*
-NERDTree-q NERD_tree.txt /*NERDTree-q*
-NERDTree-r NERD_tree.txt /*NERDTree-r*
-NERDTree-s NERD_tree.txt /*NERDTree-s*
-NERDTree-t NERD_tree.txt /*NERDTree-t*
-NERDTree-u NERD_tree.txt /*NERDTree-u*
-NERDTree-x NERD_tree.txt /*NERDTree-x*
-NERDTreeAPI NERD_tree.txt /*NERDTreeAPI*
-NERDTreeAbout NERD_tree.txt /*NERDTreeAbout*
-NERDTreeAddKeyMap() NERD_tree.txt /*NERDTreeAddKeyMap()*
-NERDTreeAddMenuItem() NERD_tree.txt /*NERDTreeAddMenuItem()*
-NERDTreeAddMenuSeparator() NERD_tree.txt /*NERDTreeAddMenuSeparator()*
-NERDTreeAddSubmenu() NERD_tree.txt /*NERDTreeAddSubmenu()*
-NERDTreeBookmarkCommands NERD_tree.txt /*NERDTreeBookmarkCommands*
-NERDTreeBookmarkTable NERD_tree.txt /*NERDTreeBookmarkTable*
-NERDTreeBookmarks NERD_tree.txt /*NERDTreeBookmarks*
-NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog*
-NERDTreeCredits NERD_tree.txt /*NERDTreeCredits*
-NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality*
-NERDTreeGlobalCommands NERD_tree.txt /*NERDTreeGlobalCommands*
-NERDTreeInvalidBookmarks NERD_tree.txt /*NERDTreeInvalidBookmarks*
-NERDTreeKeymapAPI NERD_tree.txt /*NERDTreeKeymapAPI*
-NERDTreeLicense NERD_tree.txt /*NERDTreeLicense*
-NERDTreeMappings NERD_tree.txt /*NERDTreeMappings*
-NERDTreeMenu NERD_tree.txt /*NERDTreeMenu*
-NERDTreeMenuAPI NERD_tree.txt /*NERDTreeMenuAPI*
-NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails*
-NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary*
-NERDTreeOptions NERD_tree.txt /*NERDTreeOptions*
-NERDTreeRender() NERD_tree.txt /*NERDTreeRender()*
-NERD_commenter.txt NERD_commenter.txt /*NERD_commenter.txt*
-NERD_tree.txt NERD_tree.txt /*NERD_tree.txt*
-ResetSnippets() snipMate.txt /*ResetSnippets()*
-acp acp.txt /*acp*
-acp-about acp.txt /*acp-about*
-acp-author acp.txt /*acp-author*
-acp-changelog acp.txt /*acp-changelog*
-acp-commands acp.txt /*acp-commands*
-acp-contact acp.txt /*acp-contact*
-acp-installation acp.txt /*acp-installation*
-acp-introduction acp.txt /*acp-introduction*
-acp-options acp.txt /*acp-options*
-acp-perl-omni acp.txt /*acp-perl-omni*
-acp-snipMate acp.txt /*acp-snipMate*
-acp-thanks acp.txt /*acp-thanks*
-acp-usage acp.txt /*acp-usage*
-acp.txt acp.txt /*acp.txt*
-autocomplpop acp.txt /*autocomplpop*
-bufexplorer bufexplorer.txt /*bufexplorer*
-bufexplorer-changelog bufexplorer.txt /*bufexplorer-changelog*
-bufexplorer-credits bufexplorer.txt /*bufexplorer-credits*
-bufexplorer-customization bufexplorer.txt /*bufexplorer-customization*
-bufexplorer-installation bufexplorer.txt /*bufexplorer-installation*
-bufexplorer-todo bufexplorer.txt /*bufexplorer-todo*
-bufexplorer-usage bufexplorer.txt /*bufexplorer-usage*
-bufexplorer-windowlayout bufexplorer.txt /*bufexplorer-windowlayout*
-bufexplorer.txt bufexplorer.txt /*bufexplorer.txt*
-buffer-explorer bufexplorer.txt /*buffer-explorer*
-conque-config-general conque_term.txt /*conque-config-general*
-conque-config-keyboard conque_term.txt /*conque-config-keyboard*
-conque-config-unix conque_term.txt /*conque-config-unix*
-conque-config-windows conque_term.txt /*conque-config-windows*
-conque-term-api conque_term.txt /*conque-term-api*
-conque-term-bugs conque_term.txt /*conque-term-bugs*
-conque-term-close conque_term.txt /*conque-term-close*
-conque-term-contribute conque_term.txt /*conque-term-contribute*
-conque-term-esc conque_term.txt /*conque-term-esc*
-conque-term-events conque_term.txt /*conque-term-events*
-conque-term-feedback conque_term.txt /*conque-term-feedback*
-conque-term-gen-usage conque_term.txt /*conque-term-gen-usage*
-conque-term-get-instance conque_term.txt /*conque-term-get-instance*
-conque-term-input-mode conque_term.txt /*conque-term-input-mode*
-conque-term-installation conque_term.txt /*conque-term-installation*
-conque-term-misc conque_term.txt /*conque-term-misc*
-conque-term-open conque_term.txt /*conque-term-open*
-conque-term-options conque_term.txt /*conque-term-options*
-conque-term-read conque_term.txt /*conque-term-read*
-conque-term-register conque_term.txt /*conque-term-register*
-conque-term-requirements conque_term.txt /*conque-term-requirements*
-conque-term-send conque_term.txt /*conque-term-send*
-conque-term-set-callback conque_term.txt /*conque-term-set-callback*
-conque-term-setup conque_term.txt /*conque-term-setup*
-conque-term-special-keys conque_term.txt /*conque-term-special-keys*
-conque-term-subprocess conque_term.txt /*conque-term-subprocess*
-conque-term-usage conque_term.txt /*conque-term-usage*
-conque-term-windows conque_term.txt /*conque-term-windows*
-conque-term-write conque_term.txt /*conque-term-write*
-conque-term-writeln conque_term.txt /*conque-term-writeln*
-g:acp_behavior acp.txt /*g:acp_behavior*
-g:acp_behavior-command acp.txt /*g:acp_behavior-command*
-g:acp_behavior-completefunc acp.txt /*g:acp_behavior-completefunc*
-g:acp_behavior-meets acp.txt /*g:acp_behavior-meets*
-g:acp_behavior-onPopupClose acp.txt /*g:acp_behavior-onPopupClose*
-g:acp_behavior-repeat acp.txt /*g:acp_behavior-repeat*
-g:acp_behaviorCssOmniPropertyLength acp.txt /*g:acp_behaviorCssOmniPropertyLength*
-g:acp_behaviorCssOmniValueLength acp.txt /*g:acp_behaviorCssOmniValueLength*
-g:acp_behaviorFileLength acp.txt /*g:acp_behaviorFileLength*
-g:acp_behaviorHtmlOmniLength acp.txt /*g:acp_behaviorHtmlOmniLength*
-g:acp_behaviorKeywordCommand acp.txt /*g:acp_behaviorKeywordCommand*
-g:acp_behaviorKeywordIgnores acp.txt /*g:acp_behaviorKeywordIgnores*
-g:acp_behaviorKeywordLength acp.txt /*g:acp_behaviorKeywordLength*
-g:acp_behaviorPerlOmniLength acp.txt /*g:acp_behaviorPerlOmniLength*
-g:acp_behaviorPythonOmniLength acp.txt /*g:acp_behaviorPythonOmniLength*
-g:acp_behaviorRubyOmniMethodLength acp.txt /*g:acp_behaviorRubyOmniMethodLength*
-g:acp_behaviorRubyOmniSymbolLength acp.txt /*g:acp_behaviorRubyOmniSymbolLength*
-g:acp_behaviorSnipmateLength acp.txt /*g:acp_behaviorSnipmateLength*
-g:acp_behaviorUserDefinedFunction acp.txt /*g:acp_behaviorUserDefinedFunction*
-g:acp_behaviorUserDefinedMeets acp.txt /*g:acp_behaviorUserDefinedMeets*
-g:acp_behaviorXmlOmniLength acp.txt /*g:acp_behaviorXmlOmniLength*
-g:acp_completeOption acp.txt /*g:acp_completeOption*
-g:acp_completeoptPreview acp.txt /*g:acp_completeoptPreview*
-g:acp_enableAtStartup acp.txt /*g:acp_enableAtStartup*
-g:acp_ignorecaseOption acp.txt /*g:acp_ignorecaseOption*
-g:acp_mappingDriven acp.txt /*g:acp_mappingDriven*
-g:bufExplorerChgWin bufexplorer.txt /*g:bufExplorerChgWin*
-g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp*
-g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp*
-g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive*
-g:bufExplorerFuncRef bufexplorer.txt /*g:bufExplorerFuncRef*
-g:bufExplorerReverseSort bufexplorer.txt /*g:bufExplorerReverseSort*
-g:bufExplorerShowDirectories bufexplorer.txt /*g:bufExplorerShowDirectories*
-g:bufExplorerShowRelativePath bufexplorer.txt /*g:bufExplorerShowRelativePath*
-g:bufExplorerShowTabBuffer bufexplorer.txt /*g:bufExplorerShowTabBuffer*
-g:bufExplorerShowUnlisted bufexplorer.txt /*g:bufExplorerShowUnlisted*
-g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy*
-g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow*
-g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName*
-g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight*
-g:snippets_dir snipMate.txt /*g:snippets_dir*
-g:snips_author snipMate.txt /*g:snips_author*
-i_CTRL-R_<Tab> snipMate.txt /*i_CTRL-R_<Tab>*
-list-snippets snipMate.txt /*list-snippets*
-multi_snip snipMate.txt /*multi_snip*
-snipMate snipMate.txt /*snipMate*
-snipMate-$# snipMate.txt /*snipMate-$#*
-snipMate-${#:} snipMate.txt /*snipMate-${#:}*
-snipMate-${#} snipMate.txt /*snipMate-${#}*
-snipMate-author snipMate.txt /*snipMate-author*
-snipMate-commands snipMate.txt /*snipMate-commands*
-snipMate-contact snipMate.txt /*snipMate-contact*
-snipMate-description snipMate.txt /*snipMate-description*
-snipMate-disadvantages snipMate.txt /*snipMate-disadvantages*
-snipMate-expandtab snipMate.txt /*snipMate-expandtab*
-snipMate-features snipMate.txt /*snipMate-features*
-snipMate-filename snipMate.txt /*snipMate-filename*
-snipMate-indenting snipMate.txt /*snipMate-indenting*
-snipMate-placeholders snipMate.txt /*snipMate-placeholders*
-snipMate-remap snipMate.txt /*snipMate-remap*
-snipMate-settings snipMate.txt /*snipMate-settings*
-snipMate-usage snipMate.txt /*snipMate-usage*
-snipMate.txt snipMate.txt /*snipMate.txt*
-snippet snipMate.txt /*snippet*
-snippet-syntax snipMate.txt /*snippet-syntax*
-snippets snipMate.txt /*snippets*
+++ /dev/null
-!_TAG_FILE_ENCODING utf-8 //
-:AcpDisable acp.jax /*:AcpDisable*
-:AcpEnable acp.jax /*:AcpEnable*
-:AcpLock acp.jax /*:AcpLock*
-:AcpUnlock acp.jax /*:AcpUnlock*
-acp acp.jax /*acp*
-acp-about acp.jax /*acp-about*
-acp-author acp.jax /*acp-author*
-acp-commands acp.jax /*acp-commands*
-acp-contact acp.jax /*acp-contact*
-acp-installation acp.jax /*acp-installation*
-acp-introduction acp.jax /*acp-introduction*
-acp-options acp.jax /*acp-options*
-acp-perl-omni acp.jax /*acp-perl-omni*
-acp-snipMate acp.jax /*acp-snipMate*
-acp-usage acp.jax /*acp-usage*
-acp.txt acp.jax /*acp.txt*
-autocomplpop acp.jax /*autocomplpop*
-g:acp_behavior acp.jax /*g:acp_behavior*
-g:acp_behavior-command acp.jax /*g:acp_behavior-command*
-g:acp_behavior-completefunc acp.jax /*g:acp_behavior-completefunc*
-g:acp_behavior-meets acp.jax /*g:acp_behavior-meets*
-g:acp_behavior-onPopupClose acp.jax /*g:acp_behavior-onPopupClose*
-g:acp_behavior-repeat acp.jax /*g:acp_behavior-repeat*
-g:acp_behaviorCssOmniPropertyLength acp.jax /*g:acp_behaviorCssOmniPropertyLength*
-g:acp_behaviorCssOmniValueLength acp.jax /*g:acp_behaviorCssOmniValueLength*
-g:acp_behaviorFileLength acp.jax /*g:acp_behaviorFileLength*
-g:acp_behaviorHtmlOmniLength acp.jax /*g:acp_behaviorHtmlOmniLength*
-g:acp_behaviorKeywordCommand acp.jax /*g:acp_behaviorKeywordCommand*
-g:acp_behaviorKeywordIgnores acp.jax /*g:acp_behaviorKeywordIgnores*
-g:acp_behaviorKeywordLength acp.jax /*g:acp_behaviorKeywordLength*
-g:acp_behaviorPerlOmniLength acp.jax /*g:acp_behaviorPerlOmniLength*
-g:acp_behaviorPythonOmniLength acp.jax /*g:acp_behaviorPythonOmniLength*
-g:acp_behaviorRubyOmniMethodLength acp.jax /*g:acp_behaviorRubyOmniMethodLength*
-g:acp_behaviorRubyOmniSymbolLength acp.jax /*g:acp_behaviorRubyOmniSymbolLength*
-g:acp_behaviorSnipmateLength acp.jax /*g:acp_behaviorSnipmateLength*
-g:acp_behaviorUserDefinedFunction acp.jax /*g:acp_behaviorUserDefinedFunction*
-g:acp_behaviorUserDefinedMeets acp.jax /*g:acp_behaviorUserDefinedMeets*
-g:acp_behaviorXmlOmniLength acp.jax /*g:acp_behaviorXmlOmniLength*
-g:acp_completeOption acp.jax /*g:acp_completeOption*
-g:acp_completeoptPreview acp.jax /*g:acp_completeoptPreview*
-g:acp_enableAtStartup acp.jax /*g:acp_enableAtStartup*
-g:acp_ignorecaseOption acp.jax /*g:acp_ignorecaseOption*
-g:acp_mappingDriven acp.jax /*g:acp_mappingDriven*
+++ /dev/null
-au BufNewFile,BufRead *.clj set filetype=clojure
+++ /dev/null
-" Helper function for (x)html snippets
-if exists('s:did_snip_helper') || &cp || !exists('loaded_snips')
- finish
-endif
-let s:did_snip_helper = 1
-
-" Automatically closes tag if in xhtml
-fun! Close()
- return stridx(&ft, 'xhtml') == -1 ? '' : ' /'
-endf
let g:loaded_nerdtree_fs_menu = 1
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
-call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
-call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
+call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
+call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
+
+if has("gui_mac") || has("gui_macvim")
+ call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
+ call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
+ call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
+endif
+
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
let newNodeName = input("Add a childnode\n".
\ "==========================================================\n".
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
- \ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash())
+ \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
let newNodePath = input("Rename the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path for the node: \n" .
- \ "", curNode.path.str())
+ \ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
let newNodePath = input("Copy the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path to copy the node to: \n" .
- \ "", currentNode.path.str())
+ \ "", currentNode.path.str(), "file")
if newNodePath != ""
"strip trailing slash
if confirmed
try
let newNode = currentNode.copy(newNodePath)
- call NERDTreeRender()
- call newNode.putCursorHere(0, 0)
+ if !empty(newNode)
+ call NERDTreeRender()
+ call newNode.putCursorHere(0, 0)
+ endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
endtry
redraw
endfunction
+function! NERDTreeQuickLook()
+ let treenode = g:NERDTreeFileNode.GetSelected()
+ if treenode != {}
+ call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
+ endif
+endfunction
+
+function! NERDTreeRevealInFinder()
+ let treenode = g:NERDTreeFileNode.GetSelected()
+ if treenode != {}
+ let x = system("open -R '" . treenode.path.str() . "'")
+ endif
+endfunction
+
+function! NERDTreeExecuteFile()
+ let treenode = g:NERDTreeFileNode.GetSelected()
+ if treenode != {}
+ let x = system("open '" . treenode.path.str() . "'")
+ endif
+endfunction
+
" vim: set sw=4 sts=4 et fdm=marker:
+++ /dev/null
-" ============================================================================
-" File: NERD_commenter.vim
-" Description: vim global plugin that provides easy code commenting
-" 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
-" Want To Public License, Version 2, as published by Sam Hocevar.
-" See http://sam.zoy.org/wtfpl/COPYING for more details.
-"
-" ============================================================================
-
-" Section: script init stuff {{{1
-if exists("loaded_nerd_comments")
- finish
-endif
-if v:version < 700
- echoerr "NERDCommenter: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
- finish
-endif
-let loaded_nerd_comments = 1
-
-" Function: s:InitVariable() function {{{2
-" This function is used to initialise a given variable to a given value. The
-" variable is only initialised if it does not exist prior
-"
-" Args:
-" -var: the name of the var to be initialised
-" -value: the value to initialise var to
-"
-" Returns:
-" 1 if the var is set, 0 otherwise
-function s:InitVariable(var, value)
- if !exists(a:var)
- exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
- return 1
- endif
- return 0
-endfunction
-
-" Section: space string init{{{2
-" When putting spaces after the left delim and before the right we use
-" s:spaceStr for the space char. This way we can make it add anything after
-" the left and before the right by modifying this variable
-let s:spaceStr = ' '
-let s:lenSpaceStr = strlen(s:spaceStr)
-
-" Section: variable init calls {{{2
-call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
-call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
-call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
-call s:InitVariable("g:NERDCompactSexyComs", 0)
-call s:InitVariable("g:NERDCreateDefaultMappings", 1)
-call s:InitVariable("g:NERDDefaultNesting", 1)
-call s:InitVariable("g:NERDMenuMode", 3)
-call s:InitVariable("g:NERDLPlace", "[>")
-call s:InitVariable("g:NERDUsePlaceHolders", 1)
-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)
-
-let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
-"vf ;;dA:\ehcs"'A {\ej^f(lyi(k$p0f{a \eA }\e0f{a 'left':\ejdd^
-
-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': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
- \ 'docbk': { 'left': '<!--', 'right': '-->' },
- \ 'dns': { 'left': ';' },
- \ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' },
- \ 'dosini': { 'left': ';' },
- \ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
- \ 'dracula': { 'left': ';' },
- \ 'dsl': { 'left': ';' },
- \ 'dtml': { 'left': '<dtml-comment>', 'right': '</dtml-comment>' },
- \ 'dylan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
- \ 'ebuild': { 'left': '#' },
- \ 'ecd': { 'left': '#' },
- \ 'eclass': { 'left': '#' },
- \ 'eiffel': { 'left': '--' },
- \ 'elf': { 'left': "'" },
- \ 'elmfilt': { 'left': '#' },
- \ 'erlang': { 'left': '%' },
- \ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '<!--', 'rightAlt': '-->' },
- \ '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': '<!--','right': '-->', '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': '<!--','right': '-->', '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': '<!--', 'right': '-->' },
- \ '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': '<!--', 'right': '-->' },
- \ 'sicad': { 'left': '*' },
- \ 'simula': { 'left': '%', 'leftAlt': '--' },
- \ 'sinda': { 'left': '$' },
- \ 'skill': { 'left': ';' },
- \ 'slang': { 'left': '%' },
- \ 'slice': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
- \ 'slrnrc': { 'left': '%' },
- \ 'sm': { 'left': '#' },
- \ 'smarty': { 'left': '{*', 'right': '*}' },
- \ 'smil': { 'left': '<!', 'right': '>' },
- \ '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': '<!--', 'right': '-->' },
- \ '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
-" ============================================================================
-" Section: Comment enabler autocommands {{{2
-" ============================================================================
-
-augroup commentEnablers
-
- "if the user enters a buffer or reads a buffer then we gotta set up
- "the comment delimiters for that new filetype
- autocmd BufEnter,BufRead * :call s:SetUpForNewFiletype(&filetype, 0)
-
- "if the filetype of a buffer changes, force the script to reset the
- "delims for the buffer
- autocmd Filetype * :call s:SetUpForNewFiletype(&filetype, 1)
-augroup END
-
-
-" Function: s:SetUpForNewFiletype(filetype) function {{{2
-" This function is responsible for setting up buffer scoped variables for the
-" given filetype.
-"
-" 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)
- let b:NERDSexyComMarker = ''
-
- 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
- let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
- endif
-
-endfunction
-
-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
-" This function is used to swap the delimiters that are being used to the
-" alternative delimiters for that filetype. For example, if a c++ file is
-" being edited and // comments are being used, after this function is called
-" /**/ comments will be used.
-"
-" Args:
-" -printMsgs: if this is 1 then a message is echoed to the user telling them
-" if this function changed the delimiters or not
-function s:SwitchToAlternativeDelimiters(printMsgs)
- "if both of the alternative delimiters are empty then there is no
- "alternative comment style so bail out
- if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == ''
- if a:printMsgs
- call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0)
- endif
- return 0
- endif
-
- "save the current delimiters
- let tempLeft = s:Left()
- let tempRight = s:Right()
-
- "swap current delimiters for alternative
- 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:NERDCommenterDelims['leftAlt'] = tempLeft
- let b:NERDCommenterDelims['rightAlt'] = tempRight
-
- "tell the user what comment delimiters they are now using
- if a:printMsgs
- call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1)
- endif
-
- return 1
-endfunction
-
-" Section: Comment delimiter add/removal functions {{{1
-" ============================================================================
-" Function: s:AppendCommentToLine(){{{2
-" 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:Left({'space': 1})
- let right = s:Right({'space': 1})
-
- " get the len of the right delim
- let lenRight = strlen(right)
-
- let isLineEmpty = strlen(getline(".")) == 0
- let insOrApp = (isLineEmpty==1 ? 'i' : 'A')
-
- "stick the delimiters down at the end of the line. We have to format the
- "comment with spaces as appropriate
- execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right . " "
-
- " if there is a right delimiter then we gotta move the cursor left
- " by the len of the right delimiter so we insert between the delimiters
- if lenRight > 0
- let leftMoveAmount = lenRight
- execute ":normal! " . leftMoveAmount . "h"
- endif
- startinsert
-endfunction
-
-" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2
-" This function is used to comment out a region of code. This region is
-" specified as a bounding box by arguments to the function.
-"
-" Args:
-" -top: the line number for the top line of code in the region
-" -bottom: the line number for the bottom line of code in the region
-" -lSide: the column number for the left most column in the region
-" -rSide: the column number for the right most column in the region
-" -forceNested: a flag indicating whether comments should be nested
-function s:CommentBlock(top, bottom, lSide, rSide, forceNested )
- " we need to create local copies of these arguments so we can modify them
- let top = a:top
- let bottom = a:bottom
- let lSide = a:lSide
- let rSide = a:rSide
-
- "if the top or bottom line starts with tabs we have to adjust the left and
- "right boundaries so that they are set as though the tabs were spaces
- let topline = getline(top)
- let bottomline = getline(bottom)
- if s:HasLeadingTabs(topline, bottomline)
-
- "find out how many tabs are in the top line and adjust the left
- "boundary accordingly
- let numTabs = s:NumberOfLeadingTabs(topline)
- if lSide < numTabs
- let lSide = &ts * lSide
- else
- let lSide = (lSide - numTabs) + (&ts * numTabs)
- endif
-
- "find out how many tabs are in the bottom line and adjust the right
- "boundary accordingly
- let numTabs = s:NumberOfLeadingTabs(bottomline)
- let rSide = (rSide - numTabs) + (&ts * numTabs)
- endif
-
- "we must check that bottom IS actually below top, if it is not then we
- "swap top and bottom. Similarly for left and right.
- if bottom < top
- let temp = top
- let top = bottom
- let bottom = top
- endif
- if rSide < lSide
- let temp = lSide
- let lSide = rSide
- let rSide = temp
- endif
-
- "if the current delimiters arent multipart then we will switch to the
- "alternative delims (if THEY are) as the comment will be better and more
- "accurate with multipart delims
- let switchedDelims = 0
- if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart()
- let switchedDelims = 1
- call s:SwitchToAlternativeDelimiters(0)
- endif
-
- "start the commenting from the top and keep commenting till we reach the
- "bottom
- let currentLine=top
- while currentLine <= bottom
-
- "check if we are allowed to comment this line
- if s:CanCommentLine(a:forceNested, currentLine)
-
- "convert the leading tabs into spaces
- let theLine = getline(currentLine)
- let lineHasLeadTabs = s:HasLeadingTabs(theLine)
- if lineHasLeadTabs
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- endif
-
- "dont comment lines that begin after the right boundary of the
- "block unless the user has specified to do so
- if theLine !~ '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty
-
- "attempt to place the cursor in on the left of the boundary box,
- "then check if we were successful, if not then we cant comment this
- "line
- call setline(currentLine, theLine)
- if s:CanPlaceCursor(currentLine, lSide)
-
- 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)
-
- if s:Multipart()
- "stick the right delimiter down
- let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced))
-
- 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(s:Left()))
-
- "replace the outter most delims in searchStr with
- "place-holders
- 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(s:Left())) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim)
- endif
- endif
- endif
- endif
-
- "restore tabs if needed
- if lineHasLeadTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
- call setline(currentLine, theLine)
- endif
-
- let currentLine = currentLine + 1
- endwhile
-
- "if we switched delims then we gotta go back to what they were before
- if switchedDelims == 1
- call s:SwitchToAlternativeDelimiters(0)
- endif
-endfunction
-
-" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) {{{2
-" This function comments a range of lines.
-"
-" Args:
-" -forceNested: a flag indicating whether the called is requesting the comment
-" to be nested if need be
-" -align: should be "left" or "both" or "none"
-" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLines(forceNested, align, firstLine, lastLine)
- " we need to get the left and right indexes of the leftmost char in the
- " block of of lines and the right most char so that we can do alignment of
- " the delimiters if the user has specified
- let leftAlignIndx = s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
- let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a: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:Left({'space': 1}))
-
- " now we actually comment the lines. Do it line by line
- let currentLine = a:firstLine
- while currentLine <= a:lastLine
-
- " get the next line, check commentability and convert spaces to tabs
- let theLine = getline(currentLine)
- let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- if s:CanCommentLine(a:forceNested, currentLine)
- "if the user has specified forceNesting then we check to see if we
- "need to switch delimiters for place-holders
- if a:forceNested && g:NERDUsePlaceHolders
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
- endif
-
- " find out if the line is commented using normal delims and/or
- " alternate ones
- 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:Left({'space': 1}), theLine, leftAlignIndx)
- else
- let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
- endif
- if a:align == "both"
- let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx)
- else
- let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
- endif
- endif
- endif
-
- " restore leading tabs if appropriate
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
- " we are done with this line
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
- endwhile
-
-endfunction
-
-" Function: s:CommentLinesMinimal(firstLine, lastLine) {{{2
-" This function comments a range of lines in a minimal style. I
-"
-" Args:
-" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLinesMinimal(firstLine, lastLine)
- "check that minimal comments can be done on this filetype
- if !s:HasMultipartDelims()
- throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters'
- endif
-
- "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: Place holders are required but disabled.'
- endif
-
- "get the left and right delims to smack on
- let left = s:GetSexyComLeft(g:NERDSpaceDelims,0)
- let right = s:GetSexyComRight(g:NERDSpaceDelims,0)
-
- "make sure all multipart delims on the lines are replaced with
- "placeholders to prevent illegal syntax
- let currentLine = a:firstLine
- while(currentLine <= a:lastLine)
- let theLine = getline(currentLine)
- let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine)
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
- endwhile
-
- "add the delim to the top line
- let theLine = getline(a:firstLine)
- let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- let theLine = s:AddLeftDelim(left, theLine)
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
- call setline(a:firstLine, theLine)
-
- "add the delim to the bottom line
- let theLine = getline(a:lastLine)
- let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- let theLine = s:AddRightDelim(right, theLine)
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
- call setline(a:lastLine, theLine)
-endfunction
-
-" Function: s:CommentLinesSexy(topline, bottomline) function {{{2
-" This function is used to comment lines in the 'Sexy' style. eg in c:
-" /*
-" * This is a sexy comment
-" */
-" Args:
-" -topline: the line num of the top line in the sexy comment
-" -bottomline: the line num of the bottom line in the sexy comment
-function s:CommentLinesSexy(topline, bottomline)
- let left = s:GetSexyComLeft(0, 0)
- let right = s:GetSexyComRight(0, 0)
-
- "check if we can do a sexy comment with the available delimiters
- if left == -1 || right == -1
- throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.'
- endif
-
- "make sure the lines arent already commented sexually
- if !s:CanSexyCommentLines(a:topline, a:bottomline)
- throw 'NERDCommenter.Nesting exception: cannot nest sexy comments'
- endif
-
-
- let sexyComMarker = s:GetSexyComMarker(0,0)
- let sexyComMarkerSpaced = s:GetSexyComMarker(1,0)
-
-
- " we jam the comment as far to the right as possible
- let leftAlignIndx = s:LeftMostIndx(1, 1, a:topline, a:bottomline)
-
- "check if we should use the compact style i.e that the left/right
- "delimiters should appear on the first and last lines of the code and not
- "on separate lines above/below the first/last lines of code
- if g:NERDCompactSexyComs
- let spaceString = (g:NERDSpaceDelims ? s:spaceStr : '')
-
- "comment the top line
- let theLine = getline(a:topline)
- let lineHasTabs = s:HasLeadingTabs(theLine)
- if lineHasTabs
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- endif
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
- let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
- if lineHasTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
- call setline(a:topline, theLine)
-
- "comment the bottom line
- if a:bottomline != a:topline
- let theLine = getline(a:bottomline)
- let lineHasTabs = s:HasLeadingTabs(theLine)
- if lineHasTabs
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- endif
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
- endif
- let theLine = s:AddRightDelim(spaceString . right, theLine)
- if lineHasTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
- call setline(a:bottomline, theLine)
- else
-
- " add the left delimiter one line above the lines that are to be commented
- call cursor(a:topline, 1)
- execute 'normal! O'
- 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'
- 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
-
- " go thru each line adding the sexyComMarker marker to the start of each
- " line in the appropriate place to align them with the comment delims
- let currentLine = a:topline+1
- while currentLine <= a:bottomline + !g:NERDCompactSexyComs
- " get the line and convert the tabs to spaces
- let theLine = getline(currentLine)
- let lineHasTabs = s:HasLeadingTabs(theLine)
- if lineHasTabs
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- endif
-
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
-
- " add the sexyComMarker
- let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
-
- if lineHasTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
-
- " set the line and move onto the next one
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
- endwhile
-
-endfunction
-
-" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) {{{2
-" Applies "toggle" commenting to the given range of lines
-"
-" Args:
-" -forceNested: a flag indicating whether the called is requesting the comment
-" to be nested if need be
-" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLinesToggle(forceNested, firstLine, lastLine)
- let currentLine = a:firstLine
- while currentLine <= a:lastLine
-
- " get the next line, check commentability and convert spaces to tabs
- let theLine = getline(currentLine)
- let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- if s:CanToggleCommentLine(a:forceNested, currentLine)
-
- "if the user has specified forceNesting then we check to see if we
- "need to switch delimiters for place-holders
- if g:NERDUsePlaceHolders
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
- endif
-
- let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
- let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
- endif
-
- " restore leading tabs if appropriate
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
- " we are done with this line
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
- endwhile
-
-endfunction
-
-" Function: s:CommentRegion(topline, topCol, bottomLine, bottomCol) function {{{2
-" This function comments chunks of text selected in visual mode.
-" It will comment exactly the text that they have selected.
-" Args:
-" -topLine: the line num of the top line in the sexy comment
-" -topCol: top left col for this comment
-" -bottomline: the line num of the bottom line in the sexy comment
-" -bottomCol: the bottom right col for this comment
-" -forceNested: whether the caller wants comments to be nested if the
-" line(s) are already commented
-function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested)
-
- "switch delims (if we can) if the current set isnt multipart
- let switchedDelims = 0
- if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims
- let switchedDelims = 1
- call s:SwitchToAlternativeDelimiters(0)
- endif
-
- "if there is only one line in the comment then just do it
- if a:topLine == a:bottomLine
- call s:CommentBlock(a:topLine, a:bottomLine, a:topCol, a:bottomCol, a:forceNested)
-
- "there are multiple lines in the comment
- else
- "comment the top line
- call s:CommentBlock(a:topLine, a:topLine, a:topCol, strlen(getline(a:topLine)), a:forceNested)
-
- "comment out all the lines in the middle of the comment
- let topOfRange = a:topLine+1
- let bottomOfRange = a:bottomLine-1
- if topOfRange <= bottomOfRange
- call s:CommentLines(a:forceNested, "none", topOfRange, bottomOfRange)
- endif
-
- "comment the bottom line
- let bottom = getline(a:bottomLine)
- let numLeadingSpacesTabs = strlen(substitute(bottom, '^\([ \t]*\).*$', '\1', ''))
- call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
-
- endif
-
- "stick the cursor back on the char it was on before the comment
- 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
- call s:SwitchToAlternativeDelimiters(0)
- endif
-
-endfunction
-
-" Function: s:InvertComment(firstLine, lastLine) function {{{2
-" Inverts the comments on the lines between and including the given line
-" numbers i.e all commented lines are uncommented and vice versa
-" Args:
-" -firstLine: the top of the range of lines to be inverted
-" -lastLine: the bottom of the range of lines to be inverted
-function s:InvertComment(firstLine, lastLine)
-
- " go thru all lines in the given range
- let currentLine = a:firstLine
- while currentLine <= a:lastLine
- let theLine = getline(currentLine)
-
- let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine)
-
- " if the line is commented normally, uncomment it
- if s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
- call s:UncommentLines(currentLine, currentLine)
- let currentLine = currentLine + 1
-
- " check if the line is commented sexually
- elseif !empty(sexyComBounds)
- let numLinesBeforeSexyComRemoved = s:NumLinesInBuf()
- call s:UncommentLinesSexy(sexyComBounds[0], sexyComBounds[1])
-
- "move to the line after last line of the sexy comment
- let numLinesAfterSexyComRemoved = s:NumLinesInBuf()
- let currentLine = sexyComBounds[1] - (numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved) + 1
-
- " the line isnt commented
- else
- call s:CommentLinesToggle(1, currentLine, currentLine)
- let currentLine = currentLine + 1
- endif
-
- endwhile
-endfunction
-
-" Function: NERDComment(isVisual, type) function {{{2
-" This function is a Wrapper for the main commenting functions
-"
-" Args:
-" -isVisual: a flag indicating whether the comment is requested in visual
-" mode or not
-" -type: the type of commenting requested. Can be 'sexy', 'invert',
-" 'minimal', 'toggle', 'alignLeft', 'alignBoth', 'norm',
-" 'nested', 'toEOL', 'append', 'insert', 'uncomment', 'yank'
-function! NERDComment(isVisual, type) range
- " we want case sensitivity when commenting
- 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("'>")
- let firstCol = col("'<")
- let lastCol = col("'>") - (&selection == 'exclusive' ? 1 : 0)
- else
- let firstLine = a:firstline
- let lastLine = a:lastline
- endif
-
- let countWasGiven = (a:isVisual == 0 && firstLine != lastLine)
-
- let forceNested = (a:type == 'nested' || g:NERDDefaultNesting)
-
- if a:type == 'norm' || a:type == 'nested'
- if a:isVisual && visualmode() == "\16"
- call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested)
- elseif a:isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims()))
- call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested)
- else
- call s:CommentLines(forceNested, "none", firstLine, lastLine)
- endif
-
- elseif a:type == 'alignLeft' || a:type == 'alignBoth'
- let align = "none"
- if a:type == "alignLeft"
- let align = "left"
- elseif a:type == "alignBoth"
- let align = "both"
- endif
- call s:CommentLines(forceNested, align, firstLine, lastLine)
-
- elseif a:type == 'invert'
- call s:InvertComment(firstLine, lastLine)
-
- elseif a:type == 'sexy'
- try
- call s:CommentLinesSexy(firstLine, lastLine)
- catch /NERDCommenter.Delimiters/
- call s:CommentLines(forceNested, "none", firstLine, lastLine)
- catch /NERDCommenter.Nesting/
- call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0)
- 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)
- else
- call s:CommentLinesToggle(forceNested, firstLine, lastLine)
- endif
-
- elseif a:type == 'minimal'
- try
- call s:CommentLinesMinimal(firstLine, lastLine)
- catch /NERDCommenter.Delimiters/
- call s:NerdEcho("Minimal comments can only be used for filetypes that have multipart delimiters.", 0)
- catch /NERDCommenter.Settings/
- call s:NerdEcho("Place holders are required but disabled.", 0)
- endtry
-
- elseif a:type == 'toEOL'
- call s:SaveScreenState()
- call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1)
- call s:RestoreScreenState()
-
- elseif a:type == 'append'
- call s:AppendCommentToLine()
-
- elseif a:type == 'insert'
- call s:PlaceDelimitersAndInsBetween()
-
- elseif a:type == 'uncomment'
- call s:UncommentLines(firstLine, lastLine)
-
- elseif a:type == 'yank'
- if a:isVisual
- normal! gvy
- elseif countWasGiven
- execute firstLine .','. lastLine .'yank'
- else
- normal! yy
- endif
- execute firstLine .','. lastLine .'call NERDComment('. a:isVisual .', "norm")'
- endif
-
- let &ignorecase = oldIgnoreCase
-endfunction
-
-" Function: s:PlaceDelimitersAndInsBetween() function {{{2
-" This is function is called to place comment delimiters down and place the
-" cursor between them
-function s:PlaceDelimitersAndInsBetween()
- " get the left and right delimiters without any escape chars in them
- let left = s:Left({'space': 1})
- let right = s:Right({'space': 1})
-
- let theLine = getline(".")
- let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab)
-
- "convert tabs to spaces and adjust the cursors column to take this into
- "account
- let untabbedCol = s:UntabbedCol(theLine, col("."))
- call setline(line("."), s:ConvertLeadingTabsToSpaces(theLine))
- call cursor(line("."), untabbedCol)
-
- " get the len of the right delim
- let lenRight = strlen(right)
-
- let isDelimOnEOL = col(".") >= strlen(getline("."))
-
- " if the cursor is in the first col then we gotta insert rather than
- " append the comment delimiters here
- let insOrApp = (col(".")==1 ? 'i' : 'a')
-
- " place the delimiters down. We do it differently depending on whether
- " there is a left AND right delimiter
- if lenRight > 0
- execute ":normal! " . insOrApp . left . right
- execute ":normal! " . lenRight . "h"
- else
- execute ":normal! " . insOrApp . left
-
- " if we are tacking the delim on the EOL then we gotta add a space
- " after it cos when we go out of insert mode the cursor will move back
- " one and the user wont be in position to type the comment.
- if isDelimOnEOL
- execute 'normal! a '
- endif
- endif
- normal! l
-
- "if needed convert spaces back to tabs and adjust the cursors col
- "accordingly
- if lineHasLeadTabs
- let tabbedCol = s:TabbedCol(getline("."), col("."))
- call setline(line("."), s:ConvertLeadingSpacesToTabs(getline(".")))
- call cursor(line("."), tabbedCol)
- endif
-
- startinsert
-endfunction
-
-" Function: s:RemoveDelimiters(left, right, line) {{{2
-" this function is called to remove the first left comment delimiter and the
-" last right delimiter of the given line.
-"
-" The args left and right must be strings. If there is no right delimiter (as
-" is the case for e.g vim file comments) them the arg right should be ""
-"
-" Args:
-" -left: the left comment delimiter
-" -right: the right comment delimiter
-" -line: the line to remove the delimiters from
-function s:RemoveDelimiters(left, right, line)
-
- let l:left = a:left
- let l:right = a:right
- let lenLeft = strlen(left)
- let lenRight = strlen(right)
-
- let delimsSpaced = (g:NERDSpaceDelims || g:NERDRemoveExtraSpaces)
-
- let line = a:line
-
- "look for the left delimiter, if we find it, remove it.
- let leftIndx = s:FindDelimiterIndex(a:left, line)
- if leftIndx != -1
- let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+lenLeft)
-
- "if the user has specified that there is a space after the left delim
- "then check for the space and remove it if it is there
- if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) == s:spaceStr
- let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+s:lenSpaceStr)
- endif
- endif
-
- "look for the right delimiter, if we find it, remove it
- let rightIndx = s:FindDelimiterIndex(a:right, line)
- if rightIndx != -1
- let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight)
-
- "if the user has specified that there is a space before the right delim
- "then check for the space and remove it if it is there
- if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && s:Multipart()
- let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx)
- endif
- endif
-
- return line
-endfunction
-
-" Function: s:UncommentLines(topLine, bottomLine) {{{2
-" This function uncomments the given lines
-"
-" Args:
-" topLine: the top line of the visual selection to uncomment
-" bottomLine: the bottom line of the visual selection to uncomment
-function s:UncommentLines(topLine, bottomLine)
- "make local copies of a:firstline and a:lastline and, if need be, swap
- "them around if the top line is below the bottom
- let l:firstline = a:topLine
- let l:lastline = a:bottomLine
- if firstline > lastline
- let firstline = lastline
- let lastline = a:topLine
- endif
-
- "go thru each line uncommenting each line removing sexy comments
- let currentLine = firstline
- while currentLine <= lastline
-
- "check the current line to see if it is part of a sexy comment
- let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine)
- if !empty(sexyComBounds)
-
- "we need to store the num lines in the buf before the comment is
- "removed so we know how many lines were removed when the sexy com
- "was removed
- let numLinesBeforeSexyComRemoved = s:NumLinesInBuf()
-
- call s:UncommentLinesSexy(sexyComBounds[0], sexyComBounds[1])
-
- "move to the line after last line of the sexy comment
- let numLinesAfterSexyComRemoved = s:NumLinesInBuf()
- let numLinesRemoved = numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved
- let currentLine = sexyComBounds[1] - numLinesRemoved + 1
- let lastline = lastline - numLinesRemoved
-
- "no sexy com was detected so uncomment the line as normal
- else
- call s:UncommentLinesNormal(currentLine, currentLine)
- let currentLine = currentLine + 1
- endif
- endwhile
-
-endfunction
-
-" Function: s:UncommentLinesSexy(topline, bottomline) {{{2
-" This function removes all the comment characters associated with the sexy
-" comment spanning the given lines
-" Args:
-" -topline/bottomline: the top/bottom lines of the sexy comment
-function s:UncommentLinesSexy(topline, bottomline)
- let left = s:GetSexyComLeft(0,1)
- let right = s:GetSexyComRight(0,1)
-
-
- "check if it is even possible for sexy comments to exist with the
- "available delimiters
- if left == -1 || right == -1
- throw 'NERDCommenter.Delimiters exception: cannot uncomment sexy comments with available delimiters.'
- endif
-
- let leftUnEsc = s:GetSexyComLeft(0,0)
- let rightUnEsc = s:GetSexyComRight(0,0)
-
- let sexyComMarker = s:GetSexyComMarker(0, 1)
- let sexyComMarkerUnEsc = s:GetSexyComMarker(0, 0)
-
- "the markerOffset is how far right we need to move the sexyComMarker to
- "line it up with the end of the left delim
- let markerOffset = strlen(leftUnEsc)-strlen(sexyComMarkerUnEsc)
-
- " go thru the intermediate lines of the sexy comment and remove the
- " sexy comment markers (eg the '*'s on the start of line in a c sexy
- " comment)
- let currentLine = a:topline+1
- while currentLine < a:bottomline
- let theLine = getline(currentLine)
-
- " remove the sexy comment marker from the line. We also remove the
- " space after it if there is one and if appropriate options are set
- let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc)
- if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
- let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr)
- else
- let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc))
- endif
-
- let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
-
- let theLine = s:ConvertLeadingWhiteSpace(theLine)
-
- " move onto the next line
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
- endwhile
-
- " gotta make a copy of a:bottomline cos we modify the position of the
- " last line it if we remove the topline
- let bottomline = a:bottomline
-
- " get the first line so we can remove the left delim from it
- let theLine = getline(a:topline)
-
- " if the first line contains only the left delim then just delete it
- if theLine =~ '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs
- call cursor(a:topline, 1)
- normal! dd
- let bottomline = bottomline - 1
-
- " topline contains more than just the left delim
- else
-
- " remove the delim. If there is a space after it
- " then remove this too if appropriate
- let delimIndx = stridx(theLine, leftUnEsc)
- if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
- let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)+s:lenSpaceStr)
- else
- let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc))
- endif
- let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
- call setline(a:topline, theLine)
- endif
-
- " get the last line so we can remove the right delim
- let theLine = getline(bottomline)
-
- " if the bottomline contains only the right delim then just delete it
- if theLine =~ '^[ \t]*' . right . '[ \t]*$'
- call cursor(bottomline, 1)
- normal! dd
-
- " the last line contains more than the right delim
- else
- " remove the right delim. If there is a space after it and
- " if the appropriate options are set then remove this too.
- let delimIndx = s:LastIndexOfDelim(rightUnEsc, theLine)
- if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
- let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)+s:lenSpaceStr)
- else
- let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc))
- endif
-
- " if the last line also starts with a sexy comment marker then we
- " remove this as well
- if theLine =~ '^[ \t]*' . sexyComMarker
-
- " remove the sexyComMarker. If there is a space after it then
- " remove that too
- let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc)
- if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
- let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr)
- else
- let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc))
- endif
- endif
-
- let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
- call setline(bottomline, theLine)
- endif
-endfunction
-
-" Function: s:UncommentLineNormal(line) {{{2
-" uncomments the given line and returns the result
-" Args:
-" -line: the line to uncomment
-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(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)
-
- "it is commented with s:Left() and s:Right() so remove these delims
- if lineCommentStatus == 1
- let line = s:RemoveDelimiters(s:Left(), s:Right(), line)
-
- "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(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(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(s:Left(), '', line)
- elseif indxLeftAlt != -1
- 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('', s:Right(), line)
- elseif indxRightAlt != -1
- let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line)
- endif
- endif
-
-
- 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(s:Right({'alt': 1}), line)
- let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
-
- let right = s:Right()
- let left = s:Left()
- if !s:Multipart()
- let right = s:Right({'alt': 1})
- let left = s:Left({'alt': 1})
- endif
-
-
- "if there are place-holders on the line then we check to see if they are
- "the outtermost delimiters on the line. If so then we replace them with
- "real delimiters
- if indxLeftPlace != -1
- if (indxLeftPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1)
- let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line)
- endif
- elseif indxRightPlace != -1
- if (indxRightPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1)
- let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line)
- endif
-
- endif
-
- let line = s:ConvertLeadingWhiteSpace(line)
-
- return line
-endfunction
-
-" Function: s:UncommentLinesNormal(topline, bottomline) {{{2
-" This function is called to uncomment lines that arent a sexy comment
-" Args:
-" -topline/bottomline: the top/bottom line numbers of the comment
-function s:UncommentLinesNormal(topline, bottomline)
- let currentLine = a:topline
- while currentLine <= a:bottomline
- let line = getline(currentLine)
- call setline(currentLine, s:UncommentLineNormal(line))
- let currentLine = currentLine + 1
- endwhile
-endfunction
-
-
-" Section: Other helper functions {{{1
-" ============================================================================
-
-" Function: s:AddLeftDelim(delim, theLine) {{{2
-" Args:
-function s:AddLeftDelim(delim, theLine)
- return substitute(a:theLine, '^\([ \t]*\)', '\1' . a:delim, '')
-endfunction
-
-" Function: s:AddLeftDelimAligned(delim, theLine) {{{2
-" Args:
-function s:AddLeftDelimAligned(delim, theLine, alignIndx)
-
- "if the line is not long enough then bung some extra spaces on the front
- "so we can align the delim properly
- let theLine = a:theLine
- if strlen(theLine) < a:alignIndx
- let theLine = repeat(' ', a:alignIndx - strlen(theLine))
- endif
-
- return strpart(theLine, 0, a:alignIndx) . a:delim . strpart(theLine, a:alignIndx)
-endfunction
-
-" Function: s:AddRightDelim(delim, theLine) {{{2
-" Args:
-function s:AddRightDelim(delim, theLine)
- if a:delim == ''
- return a:theLine
- else
- return substitute(a:theLine, '$', a:delim, '')
- endif
-endfunction
-
-" Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2
-" Args:
-function s:AddRightDelimAligned(delim, theLine, alignIndx)
- if a:delim == ""
- return a:theLine
- else
-
- " when we align the right delim we are just adding spaces
- " so we get a string containing the needed spaces (it
- " could be empty)
- let extraSpaces = ''
- let extraSpaces = repeat(' ', a:alignIndx-strlen(a:theLine))
-
- " add the right delim
- return substitute(a:theLine, '$', extraSpaces . a:delim, '')
- endif
-endfunction
-
-" Function: s:AltMultipart() {{{2
-" returns 1 if the alternative delims are multipart
-function s:AltMultipart()
- return b:NERDCommenterDelims['rightAlt'] != ''
-endfunction
-
-" Function: s:CanCommentLine(forceNested, line) {{{2
-"This function is used to determine whether the given line can be commented.
-"It returns 1 if it can be and 0 otherwise
-"
-" Args:
-" -forceNested: a flag indicating whether the caller wants comments to be nested
-" if the current line is already commented
-" -lineNum: the line num of the line to check for commentability
-function s:CanCommentLine(forceNested, lineNum)
- let theLine = getline(a:lineNum)
-
- " make sure we don't comment lines that are just spaces or tabs or empty.
- if theLine =~ "^[ \t]*$"
- return 0
- endif
-
- "if the line is part of a sexy comment then just flag it...
- if s:IsInSexyComment(a:lineNum)
- return 0
- endif
-
- let isCommented = s:IsCommentedNormOrSexy(a:lineNum)
-
- "if the line isnt commented return true
- if !isCommented
- return 1
- endif
-
- "if the line is commented but nesting is allowed then return true
- if a:forceNested && (!s:Multipart() || g:NERDUsePlaceHolders)
- return 1
- endif
-
- return 0
-endfunction
-
-" Function: s:CanPlaceCursor(line, col) {{{2
-" returns 1 if the cursor can be placed exactly in the given position
-function s:CanPlaceCursor(line, col)
- let c = col(".")
- let l = line(".")
- call cursor(a:line, a:col)
- let success = (line(".") == a:line && col(".") == a:col)
- call cursor(l,c)
- return success
-endfunction
-
-" Function: s:CanSexyCommentLines(topline, bottomline) {{{2
-" Return: 1 if the given lines can be commented sexually, 0 otherwise
-function s:CanSexyCommentLines(topline, bottomline)
- " see if the selected regions have any sexy comments
- let currentLine = a:topline
- while(currentLine <= a:bottomline)
- if s:IsInSexyComment(currentLine)
- return 0
- endif
- let currentLine = currentLine + 1
- endwhile
- return 1
-endfunction
-" Function: s:CanToggleCommentLine(forceNested, line) {{{2
-"This function is used to determine whether the given line can be toggle commented.
-"It returns 1 if it can be and 0 otherwise
-"
-" Args:
-" -lineNum: the line num of the line to check for commentability
-function s:CanToggleCommentLine(forceNested, lineNum)
- let theLine = getline(a:lineNum)
- if (s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)) && !a:forceNested
- return 0
- endif
-
- " make sure we don't comment lines that are just spaces or tabs or empty.
- if theLine =~ "^[ \t]*$"
- return 0
- endif
-
- "if the line is part of a sexy comment then just flag it...
- if s:IsInSexyComment(a:lineNum)
- return 0
- endif
-
- return 1
-endfunction
-
-" Function: s:ConvertLeadingSpacesToTabs(line) {{{2
-" This function takes a line and converts all leading tabs on that line into
-" spaces
-"
-" Args:
-" -line: the line whose leading tabs will be converted
-function s:ConvertLeadingSpacesToTabs(line)
- let toReturn = a:line
- while toReturn =~ '^\t*' . s:TabSpace() . '\(.*\)$'
- let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , "")
- endwhile
-
- return toReturn
-endfunction
-
-
-" Function: s:ConvertLeadingTabsToSpaces(line) {{{2
-" This function takes a line and converts all leading spaces on that line into
-" tabs
-"
-" Args:
-" -line: the line whose leading spaces will be converted
-function s:ConvertLeadingTabsToSpaces(line)
- let toReturn = a:line
- while toReturn =~ '^\( *\)\t'
- let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , "")
- endwhile
-
- return toReturn
-endfunction
-
-" Function: s:ConvertLeadingWhiteSpace(line) {{{2
-" Converts the leading white space to tabs/spaces depending on &ts
-"
-" Args:
-" -line: the line to convert
-function s:ConvertLeadingWhiteSpace(line)
- let toReturn = a:line
- while toReturn =~ '^ *\t'
- let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), "g")
- endwhile
-
- if !&expandtab
- let toReturn = s:ConvertLeadingSpacesToTabs(toReturn)
- endif
-
- return toReturn
-endfunction
-
-
-" Function: s:CountNonESCedOccurances(str, searchstr, escChar) {{{2
-" This function counts the number of substrings contained in another string.
-" These substrings are only counted if they are not escaped with escChar
-" Args:
-" -str: the string to look for searchstr in
-" -searchstr: the substring to search for in str
-" -escChar: the escape character which, when preceding an instance of
-" searchstr, will cause it not to be counted
-function s:CountNonESCedOccurances(str, searchstr, escChar)
- "get the index of the first occurrence of searchstr
- let indx = stridx(a:str, a:searchstr)
-
- "if there is an instance of searchstr in str process it
- if indx != -1
- "get the remainder of str after this instance of searchstr is removed
- let lensearchstr = strlen(a:searchstr)
- let strLeft = strpart(a:str, indx+lensearchstr)
-
- "if this instance of searchstr is not escaped, add one to the count
- "and recurse. If it is escaped, just recurse
- if !s:IsEscaped(a:str, indx, a:escChar)
- return 1 + s:CountNonESCedOccurances(strLeft, a:searchstr, a:escChar)
- else
- return s:CountNonESCedOccurances(strLeft, a:searchstr, a:escChar)
- endif
- endif
-endfunction
-" Function: s:DoesBlockHaveDelim(delim, top, bottom) {{{2
-" Returns 1 if the given block of lines has a delimiter (a:delim) in it
-" Args:
-" -delim: the comment delimiter to check the block for
-" -top: the top line number of the block
-" -bottom: the bottom line number of the block
-function s:DoesBlockHaveDelim(delim, top, bottom)
- let currentLine = a:top
- while currentLine < a:bottom
- let theline = getline(currentLine)
- if s:FindDelimiterIndex(a:delim, theline) != -1
- return 1
- endif
- let currentLine = currentLine + 1
- endwhile
- return 0
-endfunction
-
-" Function: s:DoesBlockHaveMultipartDelim(top, bottom) {{{2
-" Returns 1 if the given block has a >= 1 multipart delimiter in it
-" Args:
-" -top: the top line number of the block
-" -bottom: the bottom line number of the block
-function s:DoesBlockHaveMultipartDelim(top, bottom)
- if s:HasMultipartDelims()
- if s:Multipart()
- return s:DoesBlockHaveDelim(s:Left(), a:top, a:bottom) || s:DoesBlockHaveDelim(s:Right(), a:top, a:bottom)
- else
- 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
-endfunction
-
-
-" Function: s:Esc(str) {{{2
-" Escapes all the tricky chars in the given string
-function s:Esc(str)
- let charsToEsc = '*/\."&$+'
- return escape(a:str, charsToEsc)
-endfunction
-
-" Function: s:FindDelimiterIndex(delimiter, line) {{{2
-" This function is used to get the string index of the input comment delimiter
-" on the input line. If no valid comment delimiter is found in the line then
-" -1 is returned
-" Args:
-" -delimiter: the delimiter we are looking to find the index of
-" -line: the line we are looking for delimiter on
-function s:FindDelimiterIndex(delimiter, line)
-
- "make sure the delimiter isnt empty otherwise we go into an infinite loop.
- if a:delimiter == ""
- return -1
- endif
-
-
- let l:delimiter = a:delimiter
- let lenDel = strlen(l:delimiter)
-
- "get the index of the first occurrence of the delimiter
- let delIndx = stridx(a:line, l:delimiter)
-
- "keep looping thru the line till we either find a real comment delimiter
- "or run off the EOL
- while delIndx != -1
-
- "if we are not off the EOL get the str before the possible delimiter
- "in question and check if it really is a delimiter. If it is, return
- "its position
- if delIndx != -1
- if s:IsDelimValid(l:delimiter, delIndx, a:line)
- return delIndx
- endif
- endif
-
- "we have not yet found a real comment delimiter so move past the
- "current one we are lookin at
- let restOfLine = strpart(a:line, delIndx + lenDel)
- let distToNextDelim = stridx(restOfLine , l:delimiter)
-
- "if distToNextDelim is -1 then there is no more potential delimiters
- "on the line so set delIndx to -1. Otherwise, move along the line by
- "distToNextDelim
- if distToNextDelim == -1
- let delIndx = -1
- else
- let delIndx = delIndx + lenDel + distToNextDelim
- endif
- endwhile
-
- "there is no comment delimiter on this line
- return -1
-endfunction
-
-" Function: s:FindBoundingLinesOfSexyCom(lineNum) {{{2
-" This function takes in a line number and tests whether this line number is
-" the top/bottom/middle line of a sexy comment. If it is then the top/bottom
-" lines of the sexy comment are returned
-" Args:
-" -lineNum: the line number that is to be tested whether it is the
-" top/bottom/middle line of a sexy com
-" Returns:
-" A string that has the top/bottom lines of the sexy comment encoded in it.
-" The format is 'topline,bottomline'. If a:lineNum turns out not to be the
-" top/bottom/middle of a sexy comment then -1 is returned
-function s:FindBoundingLinesOfSexyCom(lineNum)
-
- "find which delimiters to look for as the start/end delims of the comment
- let left = ''
- let right = ''
- if s:Multipart()
- let left = s:Left({'esc': 1})
- let right = s:Right({'esc': 1})
- elseif s:AltMultipart()
- let left = s:Left({'alt': 1, 'esc': 1})
- let right = s:Right({'alt': 1, 'esc': 1})
- else
- return []
- endif
-
- let sexyComMarker = s:GetSexyComMarker(0, 1)
-
- "initialise the top/bottom line numbers of the sexy comment to -1
- let top = -1
- let bottom = -1
-
- let currentLine = a:lineNum
- while top == -1 || bottom == -1
- let theLine = getline(currentLine)
-
- "check if the current line is the top of the sexy comment
- if currentLine <= a:lineNum && theLine =~ '^[ \t]*' . left && theLine !~ '.*' . right && currentLine < s:NumLinesInBuf()
- let top = currentLine
- let currentLine = a:lineNum
-
- "check if the current line is the bottom of the sexy comment
- elseif theLine =~ '^[ \t]*' . right && theLine !~ '.*' . left && currentLine > 1
- let bottom = currentLine
-
- "the right delimiter is on the same line as the last sexyComMarker
- elseif theLine =~ '^[ \t]*' . sexyComMarker . '.*' . right
- let bottom = currentLine
-
- "we have not found the top or bottom line so we assume currentLine is an
- "intermediate line and look to prove otherwise
- else
-
- "if the line doesnt start with a sexyComMarker then it is not a sexy
- "comment
- if theLine !~ '^[ \t]*' . sexyComMarker
- return []
- endif
-
- endif
-
- "if top is -1 then we havent found the top yet so keep looking up
- if top == -1
- let currentLine = currentLine - 1
- "if we have found the top line then go down looking for the bottom
- else
- let currentLine = currentLine + 1
- endif
-
- endwhile
-
- return [top, bottom]
-endfunction
-
-
-" Function: s:GetSexyComMarker() {{{2
-" Returns the sexy comment marker for the current filetype.
-"
-" C style sexy comments are assumed if possible. If not then the sexy comment
-" marker is the last char of the delimiter pair that has both left and right
-" delims and has the longest left delim
-"
-" Args:
-" -space: specifies whether the marker is to have a space string after it
-" (the space string will only be added if NERDSpaceDelims is set)
-" -esc: specifies whether the tricky chars in the marker are to be ESCed
-function s:GetSexyComMarker(space, esc)
- let sexyComMarker = b:NERDSexyComMarker
-
- "if there is no hardcoded marker then we find one
- if sexyComMarker == ''
-
- "if the filetype has c style comments then use standard c sexy
- "comments
- if s:HasCStyleComments()
- let sexyComMarker = '*'
- 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(s:Left())
- let lenLeftAlt = strlen(s:Left({'alt': 1}))
- let left = ''
- let right = ''
- if s:Multipart() && lenLeft >= lenLeftAlt
- let left = s:Left()
- elseif s:AltMultipart()
- let left = s:Left({'alt': 1})
- else
- return -1
- endif
-
- "get the last char of left
- let sexyComMarker = strpart(left, strlen(left)-1)
- endif
- endif
-
- if a:space && g:NERDSpaceDelims
- let sexyComMarker = sexyComMarker . s:spaceStr
- endif
-
- if a:esc
- let sexyComMarker = s:Esc(sexyComMarker)
- endif
-
- return sexyComMarker
-endfunction
-
-" Function: s:GetSexyComLeft(space, esc) {{{2
-" Returns the left delimiter for sexy comments for this filetype or -1 if
-" there is none. C style sexy comments are used if possible
-" Args:
-" -space: specifies if the delim has a space string on the end
-" (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(s:Left())
- let lenLeftAlt = strlen(s:Left({'alt': 1}))
- let left = ''
-
- "assume c style sexy comments if possible
- if s:HasCStyleComments()
- let left = '/*'
- else
- "grab the longest left delim that has a right
- if s:Multipart() && lenLeft >= lenLeftAlt
- let left = s:Left()
- elseif s:AltMultipart()
- let left = s:Left({'alt': 1})
- else
- return -1
- endif
- endif
-
- if a:space && g:NERDSpaceDelims
- let left = left . s:spaceStr
- endif
-
- if a:esc
- let left = s:Esc(left)
- endif
-
- return left
-endfunction
-
-" Function: s:GetSexyComRight(space, esc) {{{2
-" Returns the right delimiter for sexy comments for this filetype or -1 if
-" there is none. C style sexy comments are used if possible.
-" Args:
-" -space: specifies if the delim has a space string on the start
-" (the space string will only be added if NERDSpaceDelims
-" 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(s:Left())
- let lenLeftAlt = strlen(s:Left({'alt': 1}))
- let right = ''
-
- "assume c style sexy comments if possible
- if s:HasCStyleComments()
- let right = '*/'
- else
- "grab the right delim that pairs with the longest left delim
- if s:Multipart() && lenLeft >= lenLeftAlt
- let right = s:Right()
- elseif s:AltMultipart()
- let right = s:Right({'alt': 1})
- else
- return -1
- endif
- endif
-
- if a:space && g:NERDSpaceDelims
- let right = s:spaceStr . right
- endif
-
- if a:esc
- let right = s:Esc(right)
- endif
-
- return right
-endfunction
-
-" Function: s:HasMultipartDelims() {{{2
-" Returns 1 iff the current filetype has at least one set of multipart delims
-function s:HasMultipartDelims()
- return s:Multipart() || s:AltMultipart()
-endfunction
-
-" Function: s:HasLeadingTabs(...) {{{2
-" Returns 1 if any of the given strings have leading tabs
-function s:HasLeadingTabs(...)
- for s in a:000
- if s =~ '^\t.*'
- return 1
- end
- endfor
- return 0
-endfunction
-" Function: s:HasCStyleComments() {{{2
-" Returns 1 iff the current filetype has c style comment delimiters
-function s:HasCStyleComments()
- return (s:Left() == '/*' && s:Right() == '*/') || (s:Left({'alt': 1}) == '/*' && s:Right({'alt': 1}) == '*/')
-endfunction
-
-" Function: s:IsCommentedNormOrSexy(lineNum) {{{2
-"This function is used to determine whether the given line is commented with
-"either set of delimiters or if it is part of a sexy comment
-"
-" Args:
-" -lineNum: the line number of the line to check
-function s:IsCommentedNormOrSexy(lineNum)
- let theLine = getline(a:lineNum)
-
- "if the line is commented normally return 1
- if s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)
- return 1
- endif
-
- "if the line is part of a sexy comment return 1
- if s:IsInSexyComment(a:lineNum)
- return 1
- endif
- return 0
-endfunction
-
-" Function: s:IsCommented(left, right, line) {{{2
-"This function is used to determine whether the given line is commented with
-"the given delimiters
-"
-" Args:
-" -line: the line that to check if commented
-" -left/right: the left and right delimiters to check for
-function s:IsCommented(left, right, line)
- "if the line isnt commented return true
- if s:FindDelimiterIndex(a:left, a:line) != -1 && (s:FindDelimiterIndex(a:right, a:line) != -1 || !s:Multipart())
- return 1
- endif
- return 0
-endfunction
-
-" Function: s:IsCommentedFromStartOfLine(left, line) {{{2
-"This function is used to determine whether the given line is commented with
-"the given delimiters at the start of the line i.e the left delimiter is the
-"first thing on the line (apart from spaces\tabs)
-"
-" Args:
-" -line: the line that to check if commented
-" -left: the left delimiter to check for
-function s:IsCommentedFromStartOfLine(left, line)
- let theLine = s:ConvertLeadingTabsToSpaces(a:line)
- let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', ''))
- let delimIndx = s:FindDelimiterIndex(a:left, theLine)
- return delimIndx == numSpaces
-endfunction
-
-" Function: s:IsCommentedOuttermost(left, right, leftAlt, rightAlt, line) {{{2
-" Finds the type of the outtermost delims on the line
-"
-" Args:
-" -line: the line that to check if the outtermost comments on it are
-" left/right
-" -left/right: the left and right delimiters to check for
-" -leftAlt/rightAlt: the left and right alternative delimiters to check for
-"
-" Returns:
-" 0 if the line is not commented with either set of delims
-" 1 if the line is commented with the left/right delim set
-" 2 if the line is commented with the leftAlt/rightAlt delim set
-function s:IsCommentedOuttermost(left, right, leftAlt, rightAlt, line)
- "get the first positions of the left delims and the last positions of the
- "right delims
- let indxLeft = s:FindDelimiterIndex(a:left, a:line)
- let indxLeftAlt = s:FindDelimiterIndex(a:leftAlt, a:line)
- let indxRight = s:LastIndexOfDelim(a:right, a:line)
- let indxRightAlt = s:LastIndexOfDelim(a:rightAlt, a:line)
-
- "check if the line has a left delim before a leftAlt delim
- if (indxLeft <= indxLeftAlt || indxLeftAlt == -1) && indxLeft != -1
- "check if the line has a right delim after any rightAlt delim
- if (indxRight > indxRightAlt && indxRight > indxLeft) || !s:Multipart()
- return 1
- endif
-
- "check if the line has a leftAlt delim before a left delim
- elseif (indxLeftAlt <= indxLeft || indxLeft == -1) && indxLeftAlt != -1
- "check if the line has a rightAlt delim after any right delim
- if (indxRightAlt > indxRight && indxRightAlt > indxLeftAlt) || !s:AltMultipart()
- return 2
- endif
- else
- return 0
- endif
-
- return 0
-
-endfunction
-
-
-" Function: s:IsDelimValid(delimiter, delIndx, line) {{{2
-" This function is responsible for determining whether a given instance of a
-" comment delimiter is a real delimiter or not. For example, in java the
-" // string is a comment delimiter but in the line:
-" System.out.println("//");
-" it does not count as a comment delimiter. This function is responsible for
-" distinguishing between such cases. It does so by applying a set of
-" heuristics that are not fool proof but should work most of the time.
-"
-" Args:
-" -delimiter: the delimiter we are validating
-" -delIndx: the position of delimiter in line
-" -line: the line that delimiter occurs in
-"
-" Returns:
-" 0 if the given delimiter is not a real delimiter (as far as we can tell) ,
-" 1 otherwise
-function s:IsDelimValid(delimiter, delIndx, line)
- "get the delimiter without the escchars
- let l:delimiter = a:delimiter
-
- "get the strings before and after the delimiter
- let preComStr = strpart(a:line, 0, a:delIndx)
- let postComStr = strpart(a:line, a:delIndx+strlen(delimiter))
-
- "to check if the delimiter is real, make sure it isnt preceded by
- "an odd number of quotes and followed by the same (which would indicate
- "that it is part of a string and therefore is not a comment)
- if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', "\\"))
- return 0
- endif
- if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", "\\"))
- return 0
- endif
- if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "`", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "`", "\\"))
- return 0
- endif
-
-
- "if the comment delimiter is escaped, assume it isnt a real delimiter
- if s:IsEscaped(a:line, a:delIndx, "\\")
- return 0
- endif
-
- "vim comments are so fuckin stupid!! Why the hell do they have comment
- "delimiters that are used elsewhere in the syntax?!?! We need to check
- "some conditions especially for vim
- if &filetype == "vim"
- if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
- return 0
- endif
-
- "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
- if a:delIndx == 0 || a:line =~ "^[ \t]\\{" . a:delIndx . "\\}\".*$"
- return 1
- endif
-
- let numLeftParen =s:CountNonESCedOccurances(preComStr, "(", "\\")
- let numRightParen =s:CountNonESCedOccurances(preComStr, ")", "\\")
-
- "if the quote is inside brackets then assume it isnt a comment
- if numLeftParen > numRightParen
- return 0
- endif
-
- "if the line has an even num of unescaped "'s then we can assume that
- "any given " is not a comment delimiter
- if s:IsNumEven(s:CountNonESCedOccurances(a:line, "\"", "\\"))
- return 0
- endif
- endif
-
- return 1
-
-endfunction
-
-" Function: s:IsNumEven(num) {{{2
-" A small function the returns 1 if the input number is even and 0 otherwise
-" Args:
-" -num: the number to check
-function s:IsNumEven(num)
- return (a:num % 2) == 0
-endfunction
-
-" Function: s:IsEscaped(str, indx, escChar) {{{2
-" This function takes a string, an index into that string and an esc char and
-" returns 1 if the char at the index is escaped (i.e if it is preceded by an
-" odd number of esc chars)
-" Args:
-" -str: the string to check
-" -indx: the index into str that we want to check
-" -escChar: the escape char the char at indx may be ESCed with
-function s:IsEscaped(str, indx, escChar)
- "initialise numEscChars to 0 and look at the char before indx
- let numEscChars = 0
- let curIndx = a:indx-1
-
- "keep going back thru str until we either reach the start of the str or
- "run out of esc chars
- while curIndx >= 0 && strpart(a:str, curIndx, 1) == a:escChar
-
- "we have found another esc char so add one to the count and move left
- "one char
- let numEscChars = numEscChars + 1
- let curIndx = curIndx - 1
-
- endwhile
-
- "if there is an odd num of esc chars directly before the char at indx then
- "the char at indx is escaped
- return !s:IsNumEven(numEscChars)
-endfunction
-
-" Function: s:IsInSexyComment(line) {{{2
-" returns 1 if the given line number is part of a sexy comment
-function s:IsInSexyComment(line)
- return !empty(s:FindBoundingLinesOfSexyCom(a:line))
-endfunction
-
-" Function: s:IsSexyComment(topline, bottomline) {{{2
-" This function takes in 2 line numbers and returns 1 if the lines between and
-" including the given line numbers are a sexy comment. It returns 0 otherwise.
-" Args:
-" -topline: the line that the possible sexy comment starts on
-" -bottomline: the line that the possible sexy comment stops on
-function s:IsSexyComment(topline, bottomline)
-
- "get the delim set that would be used for a sexy comment
- let left = ''
- let right = ''
- if s:Multipart()
- let left = s:Left()
- let right = s:Right()
- elseif s:AltMultipart()
- let left = s:Left({'alt': 1})
- let right = s:Right({'alt': 1})
- else
- return 0
- endif
-
- "swap the top and bottom line numbers around if need be
- let topline = a:topline
- let bottomline = a:bottomline
- if bottomline < topline
- topline = bottomline
- bottomline = a:topline
- endif
-
- "if there is < 2 lines in the comment it cannot be sexy
- if (bottomline - topline) <= 0
- return 0
- endif
-
- "if the top line doesnt begin with a left delim then the comment isnt sexy
- if getline(a:topline) !~ '^[ \t]*' . left
- return 0
- endif
-
- "if there is a right delim on the top line then this isnt a sexy comment
- if s:FindDelimiterIndex(right, getline(a:topline)) != -1
- return 0
- endif
-
- "if there is a left delim on the bottom line then this isnt a sexy comment
- if s:FindDelimiterIndex(left, getline(a:bottomline)) != -1
- return 0
- endif
-
- "if the bottom line doesnt begin with a right delim then the comment isnt
- "sexy
- if getline(a:bottomline) !~ '^.*' . right . '$'
- return 0
- endif
-
- let sexyComMarker = s:GetSexyComMarker(0, 1)
-
- "check each of the intermediate lines to make sure they start with a
- "sexyComMarker
- let currentLine = a:topline+1
- while currentLine < a:bottomline
- let theLine = getline(currentLine)
-
- if theLine !~ '^[ \t]*' . sexyComMarker
- return 0
- endif
-
- "if there is a right delim in an intermediate line then the block isnt
- "a sexy comment
- if s:FindDelimiterIndex(right, theLine) != -1
- return 0
- endif
-
- let currentLine = currentLine + 1
- endwhile
-
- "we have not found anything to suggest that this isnt a sexy comment so
- return 1
-
-endfunction
-
-" Function: s:LastIndexOfDelim(delim, str) {{{2
-" This function takes a string and a delimiter and returns the last index of
-" that delimiter in string
-" Args:
-" -delim: the delimiter to look for
-" -str: the string to look for delim in
-function s:LastIndexOfDelim(delim, str)
- let delim = a:delim
- let lenDelim = strlen(delim)
-
- "set index to the first occurrence of delim. If there is no occurrence then
- "bail
- let indx = s:FindDelimiterIndex(delim, a:str)
- if indx == -1
- return -1
- endif
-
- "keep moving to the next instance of delim in str till there is none left
- while 1
-
- "search for the next delim after the previous one
- let searchStr = strpart(a:str, indx+lenDelim)
- let indx2 = s:FindDelimiterIndex(delim, searchStr)
-
- "if we find a delim update indx to record the position of it, if we
- "dont find another delim then indx is the last one so break out of
- "this loop
- if indx2 != -1
- let indx = indx + indx2 + lenDelim
- else
- break
- endif
- endwhile
-
- return indx
-
-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.
-" Args:
-" -countCommentedLines: 1 if lines that are commented are to be checked as
-" well. 0 otherwise
-" -countEmptyLines: 1 if empty lines are to be counted in the search
-" -topline: the top line to be checked
-" -bottomline: the bottom line to be checked
-function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline)
-
- " declare the left most index as an extreme value
- let leftMostIndx = 1000
-
- " go thru the block line by line updating leftMostIndx
- let currentLine = a:topline
- while currentLine <= a:bottomline
-
- " get the next line and if it is allowed to be commented, or is not
- " commented, check it
- let theLine = getline(currentLine)
- if a:countEmptyLines || theLine !~ '^[ \t]*$'
- 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)
- let leadSpaceOfLine = strlen( substitute(theLine, '\(^[ \t]*\).*$','\1','') )
- if leadSpaceOfLine < leftMostIndx
- let leftMostIndx = leadSpaceOfLine
- endif
- endif
- endif
-
- " move on to the next line
- let currentLine = currentLine + 1
- endwhile
-
- if leftMostIndx == 1000
- return 0
- else
- return leftMostIndx
- endif
-endfunction
-
-" Function: s:Multipart() {{{2
-" returns 1 if the current delims are multipart
-function s:Multipart()
- return s:Right() != ''
-endfunction
-
-" Function: s:NerdEcho(msg, typeOfMsg) {{{2
-" Args:
-" -msg: the message to echo
-" -typeOfMsg: 0 = warning message
-" 1 = normal message
-function s:NerdEcho(msg, typeOfMsg)
- if a:typeOfMsg == 0
- echohl WarningMsg
- echom 'NERDCommenter:' . a:msg
- echohl None
- elseif a:typeOfMsg == 1
- echom 'NERDCommenter:' . a:msg
- endif
-endfunction
-
-" Function: s:NumberOfLeadingTabs(s) {{{2
-" returns the number of leading tabs in the given string
-function s:NumberOfLeadingTabs(s)
- return strlen(substitute(a:s, '^\(\t*\).*$', '\1', ""))
-endfunction
-
-" Function: s:NumLinesInBuf() {{{2
-" Returns the number of lines in the current buffer
-function s:NumLinesInBuf()
- return line('$')
-endfunction
-
-" Function: s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) {{{2
-" This function takes in a string, 2 delimiters in that string and 2 strings
-" to replace these delimiters with.
-"
-" Args:
-" -toReplace1: the first delimiter to replace
-" -toReplace2: the second delimiter to replace
-" -replacor1: the string to replace toReplace1 with
-" -replacor2: the string to replace toReplace2 with
-" -str: the string that the delimiters to be replaced are in
-function s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str)
- let line = s:ReplaceLeftMostDelim(a:toReplace1, a:replacor1, a:str)
- let line = s:ReplaceRightMostDelim(a:toReplace2, a:replacor2, line)
- return line
-endfunction
-
-" Function: s:ReplaceLeftMostDelim(toReplace, replacor, str) {{{2
-" This function takes a string and a delimiter and replaces the left most
-" occurrence of this delimiter in the string with a given string
-"
-" Args:
-" -toReplace: the delimiter in str that is to be replaced
-" -replacor: the string to replace toReplace with
-" -str: the string that contains toReplace
-function s:ReplaceLeftMostDelim(toReplace, replacor, str)
- let toReplace = a:toReplace
- let replacor = a:replacor
- "get the left most occurrence of toReplace
- let indxToReplace = s:FindDelimiterIndex(toReplace, a:str)
-
- "if there IS an occurrence of toReplace in str then replace it and return
- "the resulting string
- if indxToReplace != -1
- let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
- return line
- endif
-
- return a:str
-endfunction
-
-" Function: s:ReplaceRightMostDelim(toReplace, replacor, str) {{{2
-" This function takes a string and a delimiter and replaces the right most
-" occurrence of this delimiter in the string with a given string
-"
-" Args:
-" -toReplace: the delimiter in str that is to be replaced
-" -replacor: the string to replace toReplace with
-" -str: the string that contains toReplace
-"
-function s:ReplaceRightMostDelim(toReplace, replacor, str)
- let toReplace = a:toReplace
- let replacor = a:replacor
- let lenToReplace = strlen(toReplace)
-
- "get the index of the last delim in str
- let indxToReplace = s:LastIndexOfDelim(toReplace, a:str)
-
- "if there IS a delimiter in str, replace it and return the result
- let line = a:str
- if indxToReplace != -1
- let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
- endif
- return line
-endfunction
-
-"FUNCTION: s:RestoreScreenState() {{{2
-"
-"Sets the screen state back to what it was when s:SaveScreenState was last
-"called.
-"
-function s:RestoreScreenState()
- 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(...) {{{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.
-" Args:
-" -countCommentedLines: 1 if lines that are commented are to be checked as
-" well. 0 otherwise
-" -countEmptyLines: 1 if empty lines are to be counted in the search
-" -topline: the top line to be checked
-" -bottomline: the bottom line to be checked
-function s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline)
- let rightMostIndx = -1
-
- " go thru the block line by line updating rightMostIndx
- let currentLine = a:topline
- while currentLine <= a:bottomline
-
- " get the next line and see if it is commentable, otherwise it doesnt
- " count
- let theLine = getline(currentLine)
- if a:countEmptyLines || theLine !~ '^[ \t]*$'
-
- 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)
- let lineLen = strlen(theLine)
- if lineLen > rightMostIndx
- let rightMostIndx = lineLen
- endif
- endif
- endif
-
- " move on to the next line
- let currentLine = currentLine + 1
- endwhile
-
- return rightMostIndx
-endfunction
-
-"FUNCTION: s:SaveScreenState() {{{2
-"Saves the current cursor position in the current buffer and the window
-"scroll position
-function s:SaveScreenState()
- let t:NERDComOldPos = getpos(".")
- let t:NERDComOldTopLine = line("w0")
-endfunction
-
-" Function: s:SwapOutterMultiPartDelimsForPlaceHolders(line) {{{2
-" This function takes a line and swaps the outter most multi-part delims for
-" place holders
-" Args:
-" -line: the line to swap the delims in
-"
-function s:SwapOutterMultiPartDelimsForPlaceHolders(line)
- " find out if the line is commented using normal delims and/or
- " alternate ones
- 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(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(s:Left({'alt': 1}), s:Right({'alt': 1}), g:NERDLPlace, g:NERDRPlace, a:line)
- endif
-
- return line2
-endfunction
-
-" Function: s:SwapOutterPlaceHoldersForMultiPartDelims(line) {{{2
-" This function takes a line and swaps the outtermost place holders for
-" multi-part delims
-" Args:
-" -line: the line to swap the delims in
-"
-function s:SwapOutterPlaceHoldersForMultiPartDelims(line)
- let left = ''
- let right = ''
- if s:Multipart()
- let left = s:Left()
- let right = s:Right()
- elseif s:AltMultipart()
- 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)
- return line
-endfunction
-" Function: s:TabbedCol(line, col) {{{2
-" Gets the col number for given line and existing col number. The new col
-" number is the col number when all leading spaces are converted to tabs
-" Args:
-" -line:the line to get the rel col for
-" -col: the abs col
-function s:TabbedCol(line, col)
- let lineTruncated = strpart(a:line, 0, a:col)
- let lineSpacesToTabs = substitute(lineTruncated, s:TabSpace(), '\t', 'g')
- return strlen(lineSpacesToTabs)
-endfunction
-"FUNCTION: s:TabSpace() {{{2
-"returns a string of spaces equal in length to &tabstop
-function s:TabSpace()
- let tabSpace = ""
- let spacesPerTab = &tabstop
- while spacesPerTab > 0
- let tabSpace = tabSpace . " "
- let spacesPerTab = spacesPerTab - 1
- endwhile
- return tabSpace
-endfunction
-
-" Function: s:UnEsc(str, escChar) {{{2
-" This function removes all the escape chars from a string
-" Args:
-" -str: the string to remove esc chars from
-" -escChar: the escape char to be removed
-function s:UnEsc(str, escChar)
- return substitute(a:str, a:escChar, "", "g")
-endfunction
-
-" Function: s:UntabbedCol(line, col) {{{2
-" Takes a line and a col and returns the absolute column of col taking into
-" account that a tab is worth 3 or 4 (or whatever) spaces.
-" Args:
-" -line:the line to get the abs col for
-" -col: the col that doesnt take into account tabs
-function s:UntabbedCol(line, col)
- let lineTruncated = strpart(a:line, 0, a:col)
- let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g')
- return strlen(lineTabsToSpaces)
-endfunction
-" Section: Comment mapping setup {{{1
-" ===========================================================================
-
-" switch to/from alternative delimiters
-nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>
-
-" comment out lines
-nnoremap <silent> <plug>NERDCommenterComment :call NERDComment(0, "norm")<cr>
-vnoremap <silent> <plug>NERDCommenterComment <ESC>:call NERDComment(1, "norm")<cr>
-
-" toggle comments
-nnoremap <silent> <plug>NERDCommenterToggle :call NERDComment(0, "toggle")<cr>
-vnoremap <silent> <plug>NERDCommenterToggle <ESC>:call NERDComment(1, "toggle")<cr>
-
-" minimal comments
-nnoremap <silent> <plug>NERDCommenterMinimal :call NERDComment(0, "minimal")<cr>
-vnoremap <silent> <plug>NERDCommenterMinimal <ESC>:call NERDComment(1, "minimal")<cr>
-
-" sexy comments
-nnoremap <silent> <plug>NERDCommenterSexy :call NERDComment(0, "sexy")<CR>
-vnoremap <silent> <plug>NERDCommenterSexy <ESC>:call NERDComment(1, "sexy")<CR>
-
-" invert comments
-nnoremap <silent> <plug>NERDCommenterInvert :call NERDComment(0, "invert")<CR>
-vnoremap <silent> <plug>NERDCommenterInvert <ESC>:call NERDComment(1, "invert")<CR>
-
-" yank then comment
-nmap <silent> <plug>NERDCommenterYank :call NERDComment(0, "yank")<CR>
-vmap <silent> <plug>NERDCommenterYank <ESC>:call NERDComment(1, "yank")<CR>
-
-" left aligned comments
-nnoremap <silent> <plug>NERDCommenterAlignLeft :call NERDComment(0, "alignLeft")<cr>
-vnoremap <silent> <plug>NERDCommenterAlignLeft <ESC>:call NERDComment(1, "alignLeft")<cr>
-
-" left and right aligned comments
-nnoremap <silent> <plug>NERDCommenterAlignBoth :call NERDComment(0, "alignBoth")<cr>
-vnoremap <silent> <plug>NERDCommenterAlignBoth <ESC>:call NERDComment(1, "alignBoth")<cr>
-
-" nested comments
-nnoremap <silent> <plug>NERDCommenterNest :call NERDComment(0, "nested")<cr>
-vnoremap <silent> <plug>NERDCommenterNest <ESC>:call NERDComment(1, "nested")<cr>
-
-" uncomment
-nnoremap <silent> <plug>NERDCommenterUncomment :call NERDComment(0, "uncomment")<cr>
-vnoremap <silent> <plug>NERDCommenterUncomment :call NERDComment(1, "uncomment")<cr>
-
-" comment till the end of the line
-nnoremap <silent> <plug>NERDCommenterToEOL :call NERDComment(0, "toEOL")<cr>
-
-" append comments
-nmap <silent> <plug>NERDCommenterAppend :call NERDComment(0, "append")<cr>
-
-" insert comments
-inoremap <silent> <plug>NERDCommenterInInsert <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>
-
-
-function! s:CreateMaps(target, combo)
- if !hasmapto(a:target, 'n')
- exec 'nmap ' . a:combo . ' ' . a:target
- endif
-
- if !hasmapto(a:target, 'v')
- exec 'vmap ' . a:combo . ' ' . a:target
- endif
-endfunction
-
-if g:NERDCreateDefaultMappings
- call s:CreateMaps('<plug>NERDCommenterComment', '<leader>cc')
- call s:CreateMaps('<plug>NERDCommenterToggle', '<leader>c<space>')
- call s:CreateMaps('<plug>NERDCommenterMinimal', '<leader>cm')
- call s:CreateMaps('<plug>NERDCommenterSexy', '<leader>cs')
- call s:CreateMaps('<plug>NERDCommenterInvert', '<leader>ci')
- call s:CreateMaps('<plug>NERDCommenterYank', '<leader>cy')
- call s:CreateMaps('<plug>NERDCommenterAlignLeft', '<leader>cl')
- call s:CreateMaps('<plug>NERDCommenterAlignBoth', '<leader>cb')
- call s:CreateMaps('<plug>NERDCommenterNest', '<leader>cn')
- call s:CreateMaps('<plug>NERDCommenterUncomment', '<leader>cu')
- call s:CreateMaps('<plug>NERDCommenterToEOL', '<leader>c$')
- call s:CreateMaps('<plug>NERDCommenterAppend', '<leader>cA')
-
- if !hasmapto('<plug>NERDCommenterAltDelims', 'n')
- nmap <leader>ca <plug>NERDCommenterAltDelims
- endif
-endif
-
-
-
-" Section: Menu item setup {{{1
-" ===========================================================================
-"check if the user wants the menu to be displayed
-if g:NERDMenuMode != 0
-
- let menuRoot = ""
- if g:NERDMenuMode == 1
- let menuRoot = 'comment'
- elseif g:NERDMenuMode == 2
- let menuRoot = '&comment'
- elseif g:NERDMenuMode == 3
- let menuRoot = '&Plugin.&comment'
- endif
-
- function! s:CreateMenuItems(target, desc, root)
- exec 'nmenu <silent> ' . a:root . '.' . a:desc . ' ' . a:target
- exec 'vmenu <silent> ' . a:root . '.' . a:desc . ' ' . a:target
- endfunction
- call s:CreateMenuItems("<plug>NERDCommenterComment", 'Comment', menuRoot)
- call s:CreateMenuItems("<plug>NERDCommenterToggle", 'Toggle', menuRoot)
- call s:CreateMenuItems('<plug>NERDCommenterMinimal', 'Minimal', menuRoot)
- call s:CreateMenuItems('<plug>NERDCommenterNest', 'Nested', menuRoot)
- exec 'nmenu <silent> '. menuRoot .'.To\ EOL <plug>NERDCommenterToEOL'
- call s:CreateMenuItems('<plug>NERDCommenterInvert', 'Invert', menuRoot)
- call s:CreateMenuItems('<plug>NERDCommenterSexy', 'Sexy', menuRoot)
- call s:CreateMenuItems('<plug>NERDCommenterYank', 'Yank\ then\ comment', menuRoot)
- exec 'nmenu <silent> '. menuRoot .'.Append <plug>NERDCommenterAppend'
- exec 'menu <silent> '. menuRoot .'.-Sep- :'
- call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot)
- call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot)
- exec 'menu <silent> '. menuRoot .'.-Sep2- :'
- call s:CreateMenuItems('<plug>NERDCommenterUncomment', 'Uncomment', menuRoot)
- exec 'nmenu <silent> '. menuRoot .'.Switch\ Delimiters <plug>NERDCommenterAltDelims'
- exec 'imenu <silent> '. menuRoot .'.Insert\ Comment\ Here <plug>NERDCommenterInInsert'
- exec 'menu <silent> '. menuRoot .'.-Sep3- :'
- exec 'menu <silent>'. menuRoot .'.Help :help NERDCommenterContents<CR>'
-endif
-" vim: set foldmethod=marker :
" File: NERD_tree.vim
" Description: vim global plugin that provides a nice tree explorer
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
-" Last Change: 1 December, 2009
+" Last Change: 28 December, 2011
" 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
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
-let s:NERD_tree_version = '4.1.0'
+let s:NERD_tree_version = '4.2.0'
" SECTION: Script init stuff {{{1
"============================================================
let s:old_cpo = &cpo
set cpo&vim
+let s:running_windows = has("win16") || has("win32") || has("win64")
+
"Function: s:initVariable() function {{{2
"This function is used to initialise a given variable to a given value. The
"variable is only initialised if it does not exist prior
"1 if the var is set, 0 otherwise
function! s:initVariable(var, value)
if !exists(a:var)
- exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
+ exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
return 1
endif
return 0
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
call s:initVariable("g:NERDTreeChDirMode", 0)
+call s:initVariable("g:NERDTreeMinimalUI", 0)
if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$']
endif
call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
+call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
call s:initVariable("g:NERDTreeWinPos", "left")
call s:initVariable("g:NERDTreeWinSize", 31)
-let s:running_windows = has("win16") || has("win32") || has("win64")
-
"init the shell commands that will be used to copy nodes, and remove dir trees
"
"Note: the space after the command is important
if s:running_windows
let s:escape_chars = " `\|\"#%&,?()\*^<>"
else
- let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
+ let s:escape_chars = " \\`\|\"#%&,?()\*^<>[]"
endif
let s:NERDTreeBufName = 'NERD_tree_'
let s:tree_wid = 2
-let s:tree_markup_reg = '^[ `|]*[\-+~]'
+let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]\+'
let s:tree_up_dir_line = '.. (up a dir)'
"the number to add to the nerd tree buffer name to make the buf name unique
augroup NERDTree
"Save the cursor position whenever we close the nerd tree
exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call <SID>saveScreenState()"
+
+ "disallow insert mode in the NERDTree
+ exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert"
+
"cache bookmarks when vim loads
autocmd VimEnter * call s:Bookmark.CacheBookmarks(0)
if self.validate()
let n = s:TreeFileNode.New(self.path)
call n.open()
+ call s:closeTreeIfQuitOnOpen()
endif
endif
endfunction
" FUNCTION: Bookmark.New(name, path) {{{3
" Create a new bookmark object with the given name and path object
function! s:Bookmark.New(name, path)
- if a:name =~ ' '
+ if a:name =~# ' '
throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
endif
tabnew
call s:initNerdTree(self.name)
else
- exec "tabedit " . bookmark.path.str({'format': 'Edit'})
+ exec "tabedit " . self.path.str({'format': 'Edit'})
endif
if has_key(a:options, 'stayInCurrentTab')
endfunction
"FUNCTION: MenuController._current(key) {{{3
-"get the MenuItem that is curently selected
+"get the MenuItem that is currently selected
function! s:MenuController._current()
return self.menuItems[self.selection]
endfunction
"FUNCTION: TreeFileNode.bookmark(name) {{{3
"bookmark this node with a:name
function! s:TreeFileNode.bookmark(name)
+
+ "if a bookmark exists with the same name and the node is cached then save
+ "it so we can update its display string
+ let oldMarkedNode = {}
try
let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1)
- call oldMarkedNode.path.cacheDisplayString()
catch /^NERDTree.BookmarkNotFoundError/
+ catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
call s:Bookmark.AddBookmark(a:name, self.path)
call self.path.cacheDisplayString()
call s:Bookmark.Write()
+
+ if !empty(oldMarkedNode)
+ call oldMarkedNode.path.cacheDisplayString()
+ endif
endfunction
"FUNCTION: TreeFileNode.cacheParent() {{{3
"initializes self.parent if it isnt already
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
+ return parent.findNode(newPath)
+ else
+ return {}
endif
- return parent.findNode(newPath)
endfunction
"FUNCTION: TreeFileNode.delete {{{3
"gets the line number of the root node
function! s:TreeFileNode.GetRootLineNum()
let rootLine = 1
- while getline(rootLine) !~ '^\(/\|<\)'
+ while getline(rootLine) !~# '^\(/\|<\)'
let rootLine = rootLine + 1
endwhile
return rootLine
"get all the leading spaces and vertical tree parts for this line
if a:depth > 1
for j in a:vertMap[0:-2]
- if j ==# 1
- let treeParts = treeParts . '| '
- else
+ if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
+ else
+ if j ==# 1
+ let treeParts = treeParts . '| '
+ else
+ let treeParts = treeParts . ' '
+ endif
endif
endfor
endif
"get the last vertical tree part for this line which will be different
"if this node is the last child of its parent
- if a:isLastChild
- let treeParts = treeParts . '`'
- else
- let treeParts = treeParts . '|'
+ if !g:NERDTreeDirArrows
+ if a:isLastChild
+ let treeParts = treeParts . '`'
+ else
+ let treeParts = treeParts . '|'
+ endif
endif
-
"smack the appropriate dir/file symbol on the line before the file/dir
"name itself
if self.path.isDirectory
if self.isOpen
- let treeParts = treeParts . '~'
+ if g:NERDTreeDirArrows
+ let treeParts = treeParts . '▾ '
+ else
+ let treeParts = treeParts . '~'
+ endif
else
- let treeParts = treeParts . '+'
+ if g:NERDTreeDirArrows
+ let treeParts = treeParts . '▸ '
+ else
+ let treeParts = treeParts . '+'
+ endif
endif
else
- let treeParts = treeParts . '-'
+ if g:NERDTreeDirArrows
+ let treeParts = treeParts . ' '
+ else
+ let treeParts = treeParts . '-'
+ endif
endif
let line = treeParts . self.displayString()
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"../ for path with strange chars (eg $)
- if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
+ if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
"put the next file in a new node and attach it
try
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"../ for path with strange chars (eg $)
- if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
+ if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
try
"create a new path and see if it exists in this nodes children
function! s:Path.AbsolutePathFor(str)
let prependCWD = 0
if s:running_windows
- let prependCWD = a:str !~ '^.:\(\\\|\/\)'
+ let prependCWD = a:str !~# '^.:\(\\\|\/\)'
else
- let prependCWD = a:str !~ '^/'
+ let prependCWD = a:str !~# '^/'
endif
let toReturn = a:str
try
"if it ends with a slash, assume its a dir create it
- if a:fullpath =~ '\(\\\|\/\)$'
+ if a:fullpath =~# '\(\\\|\/\)$'
"whack the trailing slash off the end if it exists
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
let dest = s:Path.WinToUnixPath(a:dest)
- let cmd = g:NERDTreeCopyCmd . " " . self.str() . " " . dest
+ let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), s:escape_chars) . " " . escape(dest, s:escape_chars)
let success = system(cmd)
if success != 0
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
function! s:Path.getSortOrderIndex()
let i = 0
while i < len(g:NERDTreeSortOrder)
- if self.getLastPathComponent(1) =~ g:NERDTreeSortOrder[i]
+ if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
return i
endif
let i = i + 1
"filter out the user specified paths to ignore
if b:NERDTreeIgnoreEnabled
for i in g:NERDTreeIgnore
- if lastPathComponent =~ i
+ if lastPathComponent =~# i
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
- if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~ '^\.'
+ if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~# '^\.'
return 1
endif
let self.isExecutable = 0
if !self.isDirectory
- let self.isExecutable = getfperm(a:fullpath) =~ 'x'
+ let self.isExecutable = getfperm(a:fullpath) =~# 'x'
endif
"grab the last part of the path (minus the trailing slash)
"we always wanna treat MS windows shortcuts as files for
"simplicity
- if hardPath !~ '\.lnk$'
+ if hardPath !~# '\.lnk$'
let self.symLinkDest = self.symLinkDest . '/'
endif
" FUNCTION: s:completeBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
function! s:completeBookmarks(A,L,P)
- return filter(s:Bookmark.BookmarkNames(), 'v:val =~ "^' . a:A . '"')
+ return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
endfunction
" FUNCTION: s:exec(cmd) {{{2
" same as :exec cmd but eventignore=all is set for the duration
" FUNCTION: s:findAndRevealPath() {{{2
function! s:findAndRevealPath()
try
- let p = s:Path.New(expand("%"))
+ let p = s:Path.New(expand("%:p"))
catch /^NERDTree.InvalidArgumentsError/
call s:echo("no file for the current buffer")
return
endtry
if !s:treeExistsForTab()
- call s:initNerdTree(p.getParent().str())
+ try
+ let cwd = s:Path.New(getcwd())
+ catch /^NERDTree.InvalidArgumentsError/
+ call s:echo("current directory does not exist.")
+ let cwd = p.getParent()
+ endtry
+
+ if p.isUnder(cwd)
+ call s:initNerdTree(cwd.str())
+ else
+ call s:initNerdTree(p.getParent().str())
+ endif
else
if !p.isUnder(s:TreeFileNode.GetRootForTab().path)
call s:initNerdTree(p.getParent().str())
let dir = a:name ==# '' ? getcwd() : a:name
"hack to get an absolute path if a relative path is given
- if dir =~ '^\.'
+ if dir =~# '^\.'
let dir = getcwd() . s:Path.Slash() . dir
endif
let dir = resolve(dir)
let b:NERDTreeRoot = s:TreeDirNode.New(path)
call b:NERDTreeRoot.open()
- "throwaway buffer options
- setlocal noswapfile
- setlocal buftype=nofile
- setlocal bufhidden=hide
- setlocal nowrap
- setlocal foldcolumn=0
- setlocal nobuflisted
- setlocal nospell
- if g:NERDTreeShowLineNumbers
- setlocal nu
- else
- setlocal nonu
- endif
-
- iabc <buffer>
-
- if g:NERDTreeHighlightCursorline
- setlocal cursorline
- endif
-
- call s:setupStatusline()
-
- let b:treeShowHelp = 0
- let b:NERDTreeIgnoreEnabled = 1
- let b:NERDTreeShowFiles = g:NERDTreeShowFiles
- let b:NERDTreeShowHidden = g:NERDTreeShowHidden
- let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
-
+ call s:setCommonBufOptions()
let b:NERDTreeType = "secondary"
- call s:bindMappings()
- setfiletype nerdtree
- " syntax highlighting
- if has("syntax") && exists("g:syntax_on")
- call s:setupSyntaxHighlighting()
- endif
-
call s:renderView()
endfunction
" FUNCTION: s:initNerdTreeMirror() {{{2
endif
if winnr("$") != 1
+ if winnr() == s:getTreeWinNum()
+ wincmd p
+ let bufnr = bufnr("")
+ wincmd p
+ else
+ let bufnr = bufnr("")
+ endif
+
call s:exec(s:getTreeWinNum() . " wincmd w")
close
- call s:exec("wincmd p")
+ call s:exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
endif
setlocal winfixwidth
-
- "throwaway buffer options
- setlocal noswapfile
- setlocal buftype=nofile
- setlocal nowrap
- setlocal foldcolumn=0
- setlocal nobuflisted
- setlocal nospell
- if g:NERDTreeShowLineNumbers
- setlocal nu
- else
- setlocal nonu
- endif
-
- iabc <buffer>
-
- if g:NERDTreeHighlightCursorline
- setlocal cursorline
- endif
-
- call s:setupStatusline()
-
- call s:bindMappings()
- setfiletype nerdtree
- " syntax highlighting
- if has("syntax") && exists("g:syntax_on")
- call s:setupSyntaxHighlighting()
- endif
+ call s:setCommonBufOptions()
endfunction
"FUNCTION: s:dumpHelp {{{2
let @h=@h."\" :OpenBookmark <name>\n"
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
- else
+ silent! put h
+ elseif g:NERDTreeMinimalUI == 0
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
+ silent! put h
endif
- silent! put h
-
let @h = old_h
endfunction
"FUNCTION: s:echo {{{2
return b:NERDTreeRoot.path
endif
- " in case called from outside the tree
- if line !~ '^ *[|`]' || line =~ '^$'
- return {}
+ if !g:NERDTreeDirArrows
+ " in case called from outside the tree
+ if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
+ return {}
+ endif
endif
if line ==# s:tree_up_dir_line
let curFile = s:stripMarkupFromLine(line, 0)
let wasdir = 0
- if curFile =~ '/$'
+ if curFile =~# '/$'
let wasdir = 1
let curFile = substitute(curFile, '/\?$', '/', "")
endif
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
break
endif
- if curLineStripped =~ '/$'
+ if curLineStripped =~# '/$'
let lpindent = s:indentLevelFor(curLine)
if lpindent < indent
let indent = indent - 1
endfunction
"FUNCTION: s:indentLevelFor(line) {{{2
function! s:indentLevelFor(line)
- return match(a:line, '[^ \-+~`|]') / s:tree_wid
+ let level = match(a:line, '[^ \-+~▸▾`|]') / s:tree_wid
+ " check if line includes arrows
+ if match(a:line, '[▸▾]') > -1
+ " decrement level as arrow uses 3 ascii chars
+ let level = level - 1
+ endif
+ return level
endfunction
"FUNCTION: s:isTreeOpen() {{{2
function! s:isTreeOpen()
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif
+ if g:NERDTreeMinimalUI
+ return cursor(1, 2)
+ endif
+
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
let line = 1
- while getline(line) !~ '^>-\+Bookmarks-\+$'
+ while getline(line) !~# '^>-\+Bookmarks-\+$'
let line = line + 1
if line >= rootNodeLine
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
endif
endwhile
- call cursor(line, 0)
+ call cursor(line, 2)
endfunction
"FUNCTION: s:putCursorInTreeWin(){{{2
"FUNCTION: s:renderBookmarks {{{2
function! s:renderBookmarks()
- call setline(line(".")+1, ">----------Bookmarks----------")
- call cursor(line(".")+1, col("."))
+ if g:NERDTreeMinimalUI == 0
+ call setline(line(".")+1, ">----------Bookmarks----------")
+ call cursor(line(".")+1, col("."))
+ endif
for i in s:Bookmark.Bookmarks()
call setline(line(".")+1, i.str())
call s:dumpHelp()
"delete the blank line before the help and add one after it
- call setline(line(".")+1, "")
- call cursor(line(".")+1, col("."))
+ if g:NERDTreeMinimalUI == 0
+ call setline(line(".")+1, "")
+ call cursor(line(".")+1, col("."))
+ endif
if b:NERDTreeShowBookmarks
call s:renderBookmarks()
endif
"add the 'up a dir' line
- call setline(line(".")+1, s:tree_up_dir_line)
- call cursor(line(".")+1, col("."))
+ if !g:NERDTreeMinimalUI
+ call setline(line(".")+1, s:tree_up_dir_line)
+ call cursor(line(".")+1, col("."))
+ endif
"draw the header line
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
endtry
endfunction
-"FUNCTION: s:setupStatusline() {{{2
-function! s:setupStatusline()
- if g:NERDTreeStatusline != -1
- let &l:statusline = g:NERDTreeStatusline
- endif
-endfunction
-"FUNCTION: s:setupSyntaxHighlighting() {{{2
-function! s:setupSyntaxHighlighting()
- "treeFlags are syntax items that should be invisible, but give clues as to
- "how things should be highlighted
- syn match treeFlag #\~#
- syn match treeFlag #\[RO\]#
-
- "highlighting for the .. (up dir) line at the top of the tree
- execute "syn match treeUp #". s:tree_up_dir_line ."#"
-
- "highlighting for the ~/+ symbols for the directory nodes
- syn match treeClosable #\~\<#
- syn match treeClosable #\~\.#
- syn match treeOpenable #+\<#
- syn match treeOpenable #+\.#he=e-1
-
- "highlighting for the tree structural parts
- syn match treePart #|#
- syn match treePart #`#
- syn match treePartFile #[|`]-#hs=s+1 contains=treePart
-
- "quickhelp syntax elements
- syn match treeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
- syn match treeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
- syn match treeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=treeFlag
- syn match treeToggleOn #".*(on)#hs=e-2,he=e-1 contains=treeHelpKey
- syn match treeToggleOff #".*(off)#hs=e-3,he=e-1 contains=treeHelpKey
- syn match treeHelpCommand #" :.\{-}\>#hs=s+3
- syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
-
- "highlighting for readonly files
- syn match treeRO #.*\[RO\]#hs=s+2 contains=treeFlag,treeBookmark,treePart,treePartFile
-
- "highlighting for sym links
- syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash
-
- "highlighing for directory nodes and file nodes
- syn match treeDirSlash #/#
- syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
- syn match treeExecFile #[|`]-.*\*\($\| \)# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
- syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile
- syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile
- syn match treeCWD #^/.*$#
-
- "highlighting for bookmarks
- syn match treeBookmark # {.*}#hs=s+1
-
- "highlighting for the bookmarks table
- syn match treeBookmarksLeader #^>#
- syn match treeBookmarksHeader #^>-\+Bookmarks-\+$# contains=treeBookmarksLeader
- syn match treeBookmarkName #^>.\{-} #he=e-1 contains=treeBookmarksLeader
- syn match treeBookmark #^>.*$# contains=treeBookmarksLeader,treeBookmarkName,treeBookmarksHeader
-
- if g:NERDChristmasTree
- hi def link treePart Special
- hi def link treePartFile Type
- hi def link treeFile Normal
- hi def link treeExecFile Title
- hi def link treeDirSlash Identifier
- hi def link treeClosable Type
+"FUNCTION: s:setCommonBufOptions() {{{2
+function! s:setCommonBufOptions()
+ "throwaway buffer options
+ setlocal noswapfile
+ setlocal buftype=nofile
+ setlocal bufhidden=hide
+ setlocal nowrap
+ setlocal foldcolumn=0
+ setlocal nobuflisted
+ setlocal nospell
+ if g:NERDTreeShowLineNumbers
+ setlocal nu
else
- hi def link treePart Normal
- hi def link treePartFile Normal
- hi def link treeFile Normal
- hi def link treeClosable Title
+ setlocal nonu
+ if v:version >= 703
+ setlocal nornu
+ endif
endif
- hi def link treeBookmarksHeader statement
- hi def link treeBookmarksLeader ignore
- hi def link treeBookmarkName Identifier
- hi def link treeBookmark normal
+ iabc <buffer>
- hi def link treeHelp String
- hi def link treeHelpKey Identifier
- hi def link treeHelpCommand Identifier
- hi def link treeHelpTitle Macro
- hi def link treeToggleOn Question
- hi def link treeToggleOff WarningMsg
+ if g:NERDTreeHighlightCursorline
+ setlocal cursorline
+ endif
- hi def link treeDir Directory
- hi def link treeUp Directory
- hi def link treeCWD Statement
- hi def link treeLink Macro
- hi def link treeOpenable Title
- hi def link treeFlag ignore
- hi def link treeRO WarningMsg
- hi def link treeBookmark Statement
+ call s:setupStatusline()
- hi def link NERDTreeCurrentNode Search
+
+ let b:treeShowHelp = 0
+ let b:NERDTreeIgnoreEnabled = 1
+ let b:NERDTreeShowFiles = g:NERDTreeShowFiles
+ let b:NERDTreeShowHidden = g:NERDTreeShowHidden
+ let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
+ setfiletype nerdtree
+ call s:bindMappings()
endfunction
+"FUNCTION: s:setupStatusline() {{{2
+function! s:setupStatusline()
+ if g:NERDTreeStatusline != -1
+ let &l:statusline = g:NERDTreeStatusline
+ endif
+endfunction
"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2
"returns the given line with all the tree parts stripped off
"
let line = substitute (line, '*\ze\($\| \)', "","")
let wasdir = 0
- if line =~ '/$'
+ if line =~# '/$'
let wasdir = 1
endif
let line = substitute (line,' -> .*',"","") " remove link to
"bind all the user custom maps
call s:KeyMap.BindAll()
- command! -buffer -nargs=1 Bookmark :call <SID>bookmarkNode('<args>')
+ command! -buffer -nargs=? Bookmark :call <SID>bookmarkNode('<args>')
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call <SID>revealBookmark('<args>')
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
" FUNCTION: s:bookmarkNode(name) {{{2
" Associate the current node with the given name
-function! s:bookmarkNode(name)
+function! s:bookmarkNode(...)
let currentNode = s:TreeFileNode.GetSelected()
if currentNode != {}
+ let name = a:1
+ if empty(name)
+ let name = currentNode.path.getLastPathComponent(0)
+ endif
try
- call currentNode.bookmark(a:name)
+ call currentNode.bookmark(name)
call s:renderView()
catch /^NERDTree.IllegalBookmarkNameError/
call s:echo("bookmark names must not contain spaces")
let currentNode = s:TreeFileNode.GetSelected()
if currentNode != {}
let startToCur = strpart(getline(line(".")), 0, col("."))
- let char = strpart(startToCur, strlen(startToCur)-1, 1)
- "if they clicked a dir, check if they clicked on the + or ~ sign
- "beside it
if currentNode.path.isDirectory
- if startToCur =~ s:tree_markup_reg . '$' && char =~ '[+~]'
+ if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$'
call s:activateNode(0)
return
endif
endif
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
- if char !~ s:tree_markup_reg && startToCur !~ '\/$'
+ let char = strpart(startToCur, strlen(startToCur)-1, 1)
+ if char !~# s:tree_markup_reg
call s:activateNode(0)
return
endif
"re-rendered
function! s:upDir(keepState)
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
- if cwd ==# "/" || cwd =~ '^[^/]..$'
+ if cwd ==# "/" || cwd =~# '^[^/]..$'
call s:echo("already at top dir")
else
if !a:keepState
+++ /dev/null
-"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
-"
-" GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop
-"=============================================================================
-" LOAD GUARD {{{1
-
-if exists('g:loaded_acp')
- finish
-elseif v:version < 702
- echoerr 'AutoComplPop does not support this version of vim (' . v:version . ').'
- finish
-endif
-let g:loaded_acp = 1
-
-" }}}1
-"=============================================================================
-" FUNCTION: {{{1
-
-"
-function s:defineOption(name, default)
- if !exists(a:name)
- let {a:name} = a:default
- endif
-endfunction
-
-"
-function s:makeDefaultBehavior()
- let behavs = {
- \ '*' : [],
- \ 'ruby' : [],
- \ 'python' : [],
- \ 'perl' : [],
- \ 'xml' : [],
- \ 'html' : [],
- \ 'xhtml' : [],
- \ 'css' : [],
- \ }
- "---------------------------------------------------------------------------
- if !empty(g:acp_behaviorUserDefinedFunction) &&
- \ !empty(g:acp_behaviorUserDefinedMeets)
- for key in keys(behavs)
- call add(behavs[key], {
- \ 'command' : "\<C-x>\<C-u>",
- \ 'completefunc' : g:acp_behaviorUserDefinedFunction,
- \ 'meets' : g:acp_behaviorUserDefinedMeets,
- \ 'repeat' : 0,
- \ })
- endfor
- endif
- "---------------------------------------------------------------------------
- for key in keys(behavs)
- call add(behavs[key], {
- \ 'command' : "\<C-x>\<C-u>",
- \ 'completefunc' : 'acp#completeSnipmate',
- \ 'meets' : 'acp#meetsForSnipmate',
- \ 'onPopupClose' : 'acp#onPopupCloseSnipmate',
- \ 'repeat' : 0,
- \ })
- endfor
- "---------------------------------------------------------------------------
- for key in keys(behavs)
- call add(behavs[key], {
- \ 'command' : g:acp_behaviorKeywordCommand,
- \ 'meets' : 'acp#meetsForKeyword',
- \ 'repeat' : 0,
- \ })
- endfor
- "---------------------------------------------------------------------------
- for key in keys(behavs)
- call add(behavs[key], {
- \ 'command' : "\<C-x>\<C-f>",
- \ 'meets' : 'acp#meetsForFile',
- \ 'repeat' : 1,
- \ })
- endfor
- "---------------------------------------------------------------------------
- call add(behavs.ruby, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForRubyOmni',
- \ 'repeat' : 0,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.python, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForPythonOmni',
- \ 'repeat' : 0,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.perl, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForPerlOmni',
- \ 'repeat' : 0,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.xml, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForXmlOmni',
- \ 'repeat' : 1,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.html, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForHtmlOmni',
- \ 'repeat' : 1,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.xhtml, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForHtmlOmni',
- \ 'repeat' : 1,
- \ })
- "---------------------------------------------------------------------------
- call add(behavs.css, {
- \ 'command' : "\<C-x>\<C-o>",
- \ 'meets' : 'acp#meetsForCssOmni',
- \ 'repeat' : 0,
- \ })
- "---------------------------------------------------------------------------
- return behavs
-endfunction
-
-" }}}1
-"=============================================================================
-" INITIALIZATION {{{1
-
-"-----------------------------------------------------------------------------
-call s:defineOption('g:acp_enableAtStartup', 1)
-call s:defineOption('g:acp_mappingDriven', 0)
-call s:defineOption('g:acp_ignorecaseOption', 1)
-call s:defineOption('g:acp_completeOption', '.,w,b,k')
-call s:defineOption('g:acp_completeoptPreview', 0)
-call s:defineOption('g:acp_behaviorUserDefinedFunction', '')
-call s:defineOption('g:acp_behaviorUserDefinedMeets', '')
-call s:defineOption('g:acp_behaviorSnipmateLength', -1)
-call s:defineOption('g:acp_behaviorKeywordCommand', "\<C-n>")
-call s:defineOption('g:acp_behaviorKeywordLength', 2)
-call s:defineOption('g:acp_behaviorKeywordIgnores', [])
-call s:defineOption('g:acp_behaviorFileLength', 0)
-call s:defineOption('g:acp_behaviorRubyOmniMethodLength', 0)
-call s:defineOption('g:acp_behaviorRubyOmniSymbolLength', 1)
-call s:defineOption('g:acp_behaviorPythonOmniLength', 0)
-call s:defineOption('g:acp_behaviorPerlOmniLength', -1)
-call s:defineOption('g:acp_behaviorXmlOmniLength', 0)
-call s:defineOption('g:acp_behaviorHtmlOmniLength', 0)
-call s:defineOption('g:acp_behaviorCssOmniPropertyLength', 1)
-call s:defineOption('g:acp_behaviorCssOmniValueLength', 0)
-call s:defineOption('g:acp_behavior', {})
-"-----------------------------------------------------------------------------
-call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep')
-"-----------------------------------------------------------------------------
-command! -bar -narg=0 AcpEnable call acp#enable()
-command! -bar -narg=0 AcpDisable call acp#disable()
-command! -bar -narg=0 AcpLock call acp#lock()
-command! -bar -narg=0 AcpUnlock call acp#unlock()
-"-----------------------------------------------------------------------------
-" legacy commands
-command! -bar -narg=0 AutoComplPopEnable AcpEnable
-command! -bar -narg=0 AutoComplPopDisable AcpDisable
-command! -bar -narg=0 AutoComplPopLock AcpLock
-command! -bar -narg=0 AutoComplPopUnlock AcpUnlock
-"-----------------------------------------------------------------------------
-if g:acp_enableAtStartup
- AcpEnable
-endif
-"-----------------------------------------------------------------------------
-
-" }}}1
-"=============================================================================
-" vim: set fdm=marker:
+++ /dev/null
-"==============================================================================
-" Plugin: Buffer Restore
-"
-" Description: This plugin keeps a stack of recently closed buffers and allows
-" the user to pop a file off of the stack at any time and restore that file
-" for editing.
-"==============================================================================
-
-"==============================================================================
-" Global Variables
-"==============================================================================
-let s:Recent_Files = []
-
-"==============================================================================
-" Functions
-"==============================================================================
-function! StoreBufferFilename(path)
- let buffer_name = a:path
- if !empty(buffer_name)
- let s:Recent_Files = [buffer_name] + s:Recent_Files
- endif
-endfunction
-
-function! BufferRestore()
- if len(s:Recent_Files) > 0
- let edit_command = ":edit " . s:Recent_Files[0]
- let s:Recent_Files = s:Recent_Files[1:]
- exec edit_command
- endif
-endfunction
-
-"==============================================================================
-" Auto Commands
-"==============================================================================
-augroup bufrestore
-autocmd!
-autocmd bufrestore BufDelete * :call StoreBufferFilename(expand("<afile>"))
-
+++ /dev/null
-" C Call-Tree Explorer (CCTree) <CCTree.vim>
-"
-"
-" Script Info and Documentation
-"=============================================================================
-" Copyright: Copyright (C) August 2008 - 2011, Hari Rangarajan
-" Permission is hereby granted to use and distribute this code,
-" with or without modifications, provided that this copyright
-" notice is copied with it. Like anything else that's free,
-" cctree.vim is provided *as is* and comes with no
-" warranty of any kind, either expressed or implied. In no
-" event will the copyright holder be liable for any damamges
-" resulting from the use of this software.
-"
-" Name Of File: CCTree.vim
-" Description: C Call-Tree Explorer Vim Plugin
-" Maintainer: Hari Rangarajan <hari.rangarajan@gmail.com>
-" URL: http://vim.sourceforge.net/scripts/script.php?script_id=2368
-" Last Change: April 22, 2011
-" Version: 1.40
-"
-"=============================================================================
-"
-" {{{ Description:
-" Plugin generates call-trees for any function or macro in real-time inside
-" Vim.
-" }}}
-" {{{ Requirements: 1) Vim 7.xx , 2) Cscope
-"
-" Tested on Unix and the following Win32 versions:
-" + Cscope, mlcscope (WIN32)
-" http://www.geocities.com/shankara_c/cscope.html
-" http://www.bell-labs.com/project/wwexptools/packages.html
-"
-"
-" }}}
-" {{{ Installation:
-" Copy this file to ~/.vim/plugins/
-" or to /vimfiles/plugins/ (on Win32 platforms)
-"
-" It might also be possible to load it as a filetype plugin
-" ~/.vim/ftplugin/c/
-"
-" Need to set :filetype plugin on
-"
-" }}}
-" {{{ Usage:
-" Build cscope database, for example:
-" > cscope -b -i cscope.files
-" [Tip: add -c option to build uncompressed databases for faster
-" load speeds]
-"
-" Load database with command ":CCTreeLoadDB"
-" (Please note that it might take a while depending on the
-" database size)
-"
-" Append database with command ":CCTreeAppendDB"
-" Allows multiple cscope files to be loaded and cross-referenced
-" Illustration:
-" :CCTreeAppendDB ./cscope.out
-" :CCTreeAppendDB ./dir1/cscope.out
-" :CCTreeAppendDB ./dir2/cscope.out
-"
-" A database name, i.e., my_cscope.out, can be specified with
-" the command. If not provided, a prompt will ask for the
-" filename; default is cscope.out.
-"
-" To show loaded databases, use command ":CCTreeShowLoadedDBs"
-"
-" To unload all databases, use command ":CCTreeUnLoadDB"
-" Note: There is no provision to unload databases individually
-"
-" To save the current set of databases loaded in to memory onto disk
-" in native CCTree XRef format, use command ":CCTreeSaveXRefDB"
-"
-" To load a saved native CCTree XRef format file, use
-" command ":CCTreeLoadXRefDB"
-"
-" To load a saved native CCTree XRef format file, use
-" command ":CCTreeLoadXRefDBFromDisk"
-"
-" Notes: No merging database support for CCTree native DB's [at present].
-"
-"
-" To have multiple CCTree preview windows, use ":CCTreeWindowSaveCopy"
-" Note: Once saved, only the depth of the preview window can be changed
-"
-" Default Mappings:
-" Get reverse call tree for symbol <C-\><
-" Get forward call tree for symbol <C-\>>
-" Increase depth of tree and update <C-\>=
-" Decrease depth of tree and update <C-\>-
-"
-" Open symbol in other window <CR>
-" Preview symbol in other window <Ctrl-P>
-"
-" Save copy of preview window <C-\>y
-" Highlight current call-tree flow <C-l>
-" Compress(Fold) call tree view zs
-" (This is useful for viewing long
-" call trees which span across
-" multiple pages)
-"
-" Custom user-mappings:
-" Users can custom-map the short-cut keys by
-" overriding the following variables in their
-" Vim start-up configuration
-"
-" g:CCTreeKeyTraceForwardTree = '<C-\>>'
-" g:CCTreeKeyTraceReverseTree = '<C-\><'
-" g:CCTreeKeyHilightTree = '<C-l>' " Static highlighting
-" g:CCTreeKeySaveWindow = '<C-\>y'
-" g:CCTreeKeyToggleWindow = '<C-\>w'
-" g:CCTreeKeyCompressTree = 'zs' " Compress call-tree
-" g:CCTreeKeyDepthPlus = '<C-\>='
-" g:CCTreeKeyDepthMinus = '<C-\>-'
-"
-" Command List:
-" CCTreeLoadDB <dbname>
-" CCTreeAppendDB <dbname>
-" CCTreeLoadXRefDB <dbname>
-" CCTreeSaveXRefDB <dbname>
-" CCTreeLoadDBFromDisk <dbname>
-"
-" CCTreeUnLoadDB
-" CCTreeShowLoadedDBs
-"
-" CCTreeTraceForward <symbolname>
-" CCTreeTraceReverse <symbolname>
-" CCTreeRecurseDepthPlus
-" CCTreeRecurseDepthMinus
-" CCTreeWindowSaveCopy
-"
-" Only in preview window:
-" CCTreeWindowHiCallTree (same as <C-l> shorcut)
-" Highlight calling tree for keyword at cursor
-"
-" Dynamic configuration:
-" CCTreeOptsEnable <option> (<tab> for auto-complete)
-" CCTreeOptsDisable <option> (<tab> for auto-complete)
-" CCTreeOptsToggle <option> (<tab> for auto-complete)
-" Options:
-" DynamicTreeHiLights: Control dynamic tree highlighting
-" UseUnicodeSymbols: Use of UTF-8 special characters for
-" tree
-"
-"
-"
-" Settings:
-" Customize behavior by changing the variable settings
-"
-" UTF-8 usage:
-" UTF-8 symbols should work fine on the majority of
-" X11 systems; however, some terminals might cause problems.
-"
-" To use symbols for drawing the tree, this option can be enabled.
-" g:CCTreeUseUTF8Symbols = 1
-" The options interface (CCTreeOptsxxx) can be used to
-" modify options on-the-fly.
-"
-" Cscope database file, g:CCTreeCscopeDb = "cscope.out"
-" Maximum call levels, g:CCTreeRecursiveDepth = 3
-" Maximum visible(unfolded) level, g:CCTreeMinVisibleDepth = 3
-" Orientation of window, g:CCTreeOrientation = "topleft"
-" (standard vim options for split: [right|left][above|below])
-"
-" Use Vertical window, g:CCTreeWindowVertical = 1
-" Min width for window, g:CCTreeWindowMinWidth = 40
-" g:CCTreeWindowWidth = -1, auto-select best width to fit
-"
-" Horizontal window, g:CCTreeWindowHeight, default is -1
-"
-"
-" Display format, g:CCTreeDisplayMode, default 1
-"
-" Values: 1 -- Ultra-compact (takes minimum screen width)
-" 2 -- Compact (Takes little more space)
-" 3 -- Wide (Takes copious amounts of space)
-"
-" For vertical splits, 1 and 2 are good, while 3 is good for
-" horizontal displays
-"
-" NOTE: To get older behavior, add the following to your vimrc
-" let g:CCTreeDisplayMode = 3
-" let g:CCTreeWindowVertical = 0
-"
-" Syntax Coloring:
-" CCTreeSymbol is the symbol name
-" CCTreeMarkers include "|","+--->"
-"
-" CCTreeHiSymbol is the highlighted call tree functions
-" CCTreeHiMarkers is the same as CCTreeMarkers except
-" these denote the highlighted call-tree
-"
-"
-" CCTreeHiXXXX allows dynamic highlighting of the call-tree.
-" To observe the effect, move the cursor to the function to
-" highlight the current call-tree. This option can be
-" turned off using the setting, g:CCTreeHilightCallTree.
-" For faster highlighting, the value of 'updatetime' can be
-" changed.
-"
-" Support for large database files:
-" Vimscript does not have an API for reading files line-by-line. This
-" becomes a problem when parsing large databases. CCTree can overcome
-" the limitation using an external utility (i.e., GNU coreutils: split)
-" or VimScript's perl interpreter interface (:version must indicate +perl)
-"
-" The following settings are tailored to suit GNU coreutils split; the default
-" settings should work with no changes on typical linux/unix distros
-" (Monopoly OSes will require installation of unixutils or equivalent)
-"
-" External command is setup with the following parameters:
-" g:CCTreeSplitProgCmd = 'PROG_SPLIT SPLIT_OPT SPLIT_SIZE IN_FILE OUT_FILE_PREFIX'
-"
-" Break-down of individual parameters:
-" The split utility is assumed to be on the path; otherwise, specify full path
-" g:CCTreeSplitProg = 'split'
-"
-" Option for splitting files (-C or -l)
-" g:CCTreeSplitProgOption = '-C'
-" If split program does not support -C, then this parameter must be set to
-" the number of lines in the split files
-" g:CCTreeDbFileSplitLines = -1
-" Largest filesize Vimscript can handle; file sizes greater than this will
-" be temporarily split
-" g:CCTreeDbFileMaxSize = 40000000 (40 Mbytes)
-"
-" Sample system command:
-" Typical:
-" split -C 40000000 inputFile outputFilePrefix
-"
-" When g:CCTreeDbFileSplitLines is set to 10000 (-C options will be ignored)
-" split -l 10000 inputFile outputFilePrefix
-"
-"
-" Using perl interface:
-" By default, perl usage is disabled. Set
-" g:CCTreeUsePerl = 1 to enable the perl interface.
-"
-" Perl interface is typically faster than native Vimscript.
-" This option can be used independent of the file size
-"
-" For more info on setting up perl interface
-" :help perl-using or :help perl-dynamic
-"
-" Writing large Xref Databases:
-" CCTree can use external utilities to write extremely large files beyond
-" VimScripts capabilities. It requires the use of an external tool that can
-" join text files (i.e., 'cat' in unix). This utility is triggered if the size
-" of the file being written exceeds g:CCTreeDbFileMaxSize (40 Mb or as configured)
-"
-" The join utility command is configured by default as follows:
-" let CCTreeJoinProgCmd = 'PROG_JOIN JOIN_OPT IN_FILES > OUT_FILE'
-"
-" let g:CCTreeJoinProg = 'cat' " PROG_JOIN
-" let g:CCTreeJoinProgOpts = "" " JOIN_OPT
-"
-"
-" }}}
-" {{{ Limitations:
-" The accuracy of the call-tree will only be as good as the cscope
-" database generation.
-" NOTE: Different flavors of Cscope have some known
-" limitations due to the lexical analysis engine. This results
-" in incorrectly identified function blocks, etc.
-" }}}
-" {{{ History:
-" Version 1.40: April 22, 2011
-" 1. Maintain order of functions called during forward tracing
-" Version 1.39: April 18, 2011
-" 1. Use +Conceal feature for highlighting (only Vim 7.3)
-" Version 1.33: April 5, 2011
-" 1. Load and trace CCTree native XRefDb directly from disk
-" 2. Fix AppendDB command when 'ignorecase' is set
-" Version 1.26: March 28, 2011
-" 1. Fix macro cross-referencing limitation
-" 2. Correct native xref file format
-" Version 1.21: March 21, 2011
-" 1. Support serialization of loaded
-" cscope databases (for faster loading)
-" Version 1.07: March 09, 2011
-" 1. Fix new keymaps incorrectly applied to buffer
-" 2. CCTreeOptsToggle command for toggling options
-"
-" Version 1.04: March 06, 2011
-" 1. Customization for key mappings
-" 2. Dynamic configuration of UI variables
-" 3. Folding long call-trees to show current path dynamically
-"
-" Version 1.01: March 04, 2011
-" 1. Make UTF-8 symbols for tree optional
-"
-" Version 1.00: March 02, 2011
-" 1. Staging release for upcoming features
-" - Complete refactoring of code to take
-" advantage of VimScript's OO features
-" 2. Faster decompression of symbols
-" 3. Display related changes
-" - Use of unicode symbols for tree
-" 4. Bugfixes related to multi-database loading
-"
-" Version 0.90: February 18, 2011
-" 1. Support for large databases using external split utility or perl
-" interface
-"
-" Version 0.85: February 9, 2011
-" 1. Significant increase in database loading and decompression speeds
-"
-" Version 0.80: February 4, 2011
-" 1. Reduce memory usage by removing unused xref symbols
-"
-" Version 0.75: June 23, 2010
-" 1. Support for saving CCTree preview window; multiple
-" CCTree windows can now be open
-"
-" Version 0.71: May 11, 2010
-" 1. Fix script bug
-
-" Version 0.70: May 8, 2010
-" 1. Functionality to load multiple cscope databases
-"
-" Version 0.65: July 12, 2009
-" 1. Toggle preview window
-"
-" Version 0.61: December 24, 2008
-" 1. Fixed bug when processing include files
-" 2. Remove 'set ruler' option
-"
-" Version 0.60: November 26, 2008
-" 1. Added support for source-file dependency tree
-"
-" Version 0.50: October 17, 2008
-" 1. Optimizations for compact memory foot-print and
-" improved compressed-database load speeds
-"
-" Version 0.41: October 6, 2008
-" 1. Minor fix: Compressed cscope databases will load
-" incorrectly if encoding is not 8-bit
-"
-" Version 0.4: September 28, 2008
-" 1. Rewrite of "tree-display" code
-" 2. New syntax hightlighting
-" 3. Dynamic highlighting for call-trees
-" 4. Support for new window modes (vertical, horizontal)
-" 5. New display format option for compact or wide call-trees
-" NOTE: defaults for tree-orientation set to vertical
-"
-" Version 0.3:
-" September 21, 2008
-" 1. Support compressed cscope databases
-" 2. Display window related bugs fixed
-" 3. More intuitive display and folding capabilities
-"
-" Version 0.2:
-" September 12, 2008
-" (Patches from Yegappan Lakshmanan, thanks!)
-" 1. Support for using the plugin in Vi-compatible mode.
-" 2. Filtering out unwanted lines before processing the db.
-" 3. Command-line completion for the commands.
-" 4. Using the cscope db from any directory.
-"
-" Version 0.1:
-" August 31,2008
-" 1. Cross-referencing support for only functions and macros
-" Functions inside macro definitions will be incorrectly
-" attributed to the top level calling function
-"
-" }}}
-" {{{ Thanks:
-"
-" Ben Fritz (ver 1.39 -- Suggestion/Testing for conceal feature)
-" Ben Fritz (ver 1.26 -- Bug report)
-" Frank Chang (ver 1.0x -- testing/UI enhancement ideas/bug fixes)
-" Arun Chaganty/Timo Tiefel (Ver 0.60 -- bug report)
-" Michael Wookey (Ver 0.4 -- Testing/bug report/patches)
-" Yegappan Lakshmanan (Ver 0.2 -- Patches)
-"
-" The Vim Community, ofcourse :)
-"=============================================================================
-" }}}
-
-" {{{ Init
-if !exists('loaded_cctree') && v:version >= 700
- " First time loading the cctree plugin
- let loaded_cctree = 1
-else
- finish
-endif
-
-" Line continuation used here
-let s:cpo_save = &cpoptions
-set cpoptions&vim
-
-" Trick to get the current script ID
-map <SID>xx <SID>xx
-let s:sid = substitute(maparg('<SID>xx'), '<SNR>\(\d\+_\)xx$', '\1', '')
-unmap <SID>xx
-"}}}
-" {{{ Global variables; Modify in .vimrc to modify default behavior
-" {{{General
-if !exists('CCTreeCscopeDb')
- let CCTreeCscopeDb = "cscope.out"
-endif
-" revisit
-if !exists('CCTreeDb')
- let CCTreeDb = "cctree.out"
-endif
-if !exists('CCTreeRecursiveDepth')
- let CCTreeRecursiveDepth = 3
-endif
-if !exists('CCTreeMinVisibleDepth')
- let CCTreeMinVisibleDepth = 3
-endif
-" }}}
-" {{{ Custom user-key mappings
-if !exists('CCTreeKeyTraceForwardTree')
- let g:CCTreeKeyTraceForwardTree = '<C-\>>'
-endif
-if !exists('CCTreeKeyTraceReverseTree')
- let g:CCTreeKeyTraceReverseTree = '<C-\><'
-endif
-if !exists('CCTreeKeyHilightTree')
- let g:CCTreeKeyHilightTree = '<C-l>' " Static highlighting
-endif
-if !exists('CCTreeKeySaveWindow ')
- let g:CCTreeKeySaveWindow = '<C-\>y'
-endif
-if !exists('CCTreeKeyToggleWindow ')
- let g:CCTreeKeyToggleWindow = '<C-\>w'
-endif
-if !exists('CCTreeKeyCompressTree ')
- let g:CCTreeKeyCompressTree = 'zs' " Compress call-tree
-endif
-if !exists('CCTreeKeyDepthPlus')
- let g:CCTreeKeyDepthPlus = '<C-\>='
-endif
-if !exists('CCTreeKeyDepthMinus')
- let g:CCTreeKeyDepthMinus = '<C-\>-'
-endif
-" }}}
-" {{{ CCTree UI settings
-if !exists('CCTreeOrientation')
- let CCTreeOrientation = "topleft"
-endif
-if !exists('CCTreeWindowVertical')
- let CCTreeWindowVertical = 1
-endif
-if !exists('CCTreeWindowWidth')
- " -1 is auto select best width
- let CCTreeWindowWidth = -1
-endif
-if !exists('CCTreeWindowMinWidth')
- let CCTreeWindowMinWidth = 25
-endif
-if !exists('CCTreeWindowHeight')
- let CCTreeWindowHeight = -1
-endif
-if !exists('CCTreeDisplayMode')
- let CCTreeDisplayMode = 1
-endif
-if !exists('CCTreeHilightCallTree')
- let CCTreeHilightCallTree = 1
-endif
-" }}}
-" {{{ Split prog
-if !exists('CCTreeSplitProgCmd')
- let CCTreeSplitProgCmd = 'PROG_SPLIT SPLIT_OPT SPLIT_SIZE IN_FILE OUT_FILE_PREFIX'
-endif
-
-if !exists('CCTreeSplitProg')
- "PROG_SPLIT
- let CCTreeSplitProg = 'split'
-endif
-
-if !exists('CCTreeSplitProgOption')
- "SPLIT_OPT
- let CCTreeSplitProgOption = '-C'
-endif
-
-if !exists('CCTreeDbFileSplitLines')
- " if SPLIT_OPT is -l
- " If split program does not support -C, then this parameter must be set to
- " the number of lines in the split files
- let CCTreeDbFileSplitLines = -1
-endif
-
-if !exists('CCTreeSplitProgCmd')
- let CCTreeSplitProgCmd = 'PROG_SPLIT SPLIT_OPT SPLIT_SIZE IN_FILE OUT_FILE_PREFIX'
-endif
-
-if !exists('CCTreeDbFileMaxSize')
- " if SPLIT_OPT is -C
- let CCTreeDbFileMaxSize = 40000000 "40 Mbytes
-endif
-
-" }}}
-" {{{ Join/Cat prog
-if !exists('CCTreeJoinProgCmd')
- let CCTreeJoinProgCmd = 'PROG_JOIN JOIN_OPT IN_FILES > OUT_FILE'
-endif
-
-if !exists('CCTreeJoinProg')
- "PROG_JOIN
- let CCTreeJoinProg = 'cat'
-endif
-
-if !exists('CCTreeJoinProgOpts')
- let CCTreeJoinProgOpts = ""
-endif
-" }}}
-" {{{ Misc (perl)
-if !exists('CCTreeUsePerl')
- " Disabled by default
- let CCTreeUsePerl = 0
-if 0 " Auto-detect perl interface (Experimental code)
- if has('perl)
-perl << PERL_EOF
- VIM::DoCommand("let CCTreeUsePerl = 1");
-PERL_EOF
- endif
-endif
-endif
-
-if has('conceal')
- let s:CCTreeUseConceal = 1
-else
- let s:CCTreeUseConceal = 0
-endif
-
-if !exists('CCTreeUseUTF8Symbols')
- let CCTreeUseUTF8Symbols = 0
-endif
-" }}}
-" }}}
-" {{{ Plugin related local variables
-let s:pluginname = 'CCTree'
-let s:windowtitle = 'CCTree-View'
-let s:windowsavetitle = 'CCTree-View-Copy'
-
-let s:DBClasses = { 'cscopeid': 'Cscope', 'cctreexref' : 'CCTree XRef'}
-let s:DBStorage = { 'memory': 'Memory', 'disk' : 'Disk'}
-
-" }}}
-" {{{ Turn on/off debugs
-let s:tag_debug=0
-
-" Use the Decho plugin for debugging
-function! DBGecho(...)
- if s:tag_debug
- Decho(a:000)
- endif
-endfunction
-
-function! DBGredir(...)
- if s:tag_debug
- Decho(a:000)
- endif
-endfunction
-
-function! Pause()
- call input("sasasD", "asdads")
-endfunction
-" }}}
-" {{{ Progress bar (generic, numeric, rolling)
-let s:GenericProgressBar= {
- \ 'depth': 0,
- \ 'depthChar': '',
- \ 'currentChar': 0,
- \ 'updateTime': 0,
- \ 'rangeChars': [],
- \ 'formatStr' : '',
- \ 'units' : ''
- \ }
-
-function! s:GenericProgressBar.mCreate(rangechars, depthchar, fmtStr)
- let pbr = deepcopy(s:GenericProgressBar)
- unlet pbr.mCreate
-
- let pbr.rangeChars = a:rangechars
- let pbr.depthChar = a:depthchar
- let pbr.formatStr = a:fmtStr
-
- return pbr
-endfunction
-
-function! s:GenericProgressBar.mSetDepth(val) dict
- let self.depth = a:val
-endfunction
-
-function! s:GenericProgressBar.mUpdate() dict
- let staticchars = repeat(self.depthChar, self.depth)
- let displayStr = substitute(self.formatStr, "\@PROGRESS\@",
- \ staticchars . self.rangeChars[self.currentChar], "")
- call s:StatusLine.mSetExtraInfo(displayStr)
-endfunction
-
-function! s:GenericProgressBar.mDone()
- call s:StatusLine.mSetExtraInfo("")
-endfunction
-
-let s:ProgressBarRoll = {
- \ 'updateTime' : 0,
- \ 'curTime' : 0
- \}
-
-function! s:ProgressBarRoll.mCreate(rollchars, depthChar) dict
- let gpbr = s:GenericProgressBar.mCreate(a:rollchars, a:depthChar, "\@PROGRESS\@")
- let pbr = extend(gpbr, deepcopy(s:ProgressBarRoll))
- unlet pbr.mCreate
-
- let pbr.curTime = localtime()
-
- return pbr
-endfunction
-
-function! s:ProgressBarRoll.mTick(count) dict
- if (localtime() - self.curTime) > self.updateTime
- let self.currentChar += 1
- if self.currentChar == len(self.rangeChars)
- let self.currentChar = 0
- endif
- let self.curTime = localtime()
- call self.mUpdate()
- endif
-endfunction
-
-let s:ProgressBarNumeric = {
- \ 'progress1current' : 0,
- \ 'progressmax' : 0,
- \ 'progress1percent' : 0,
- \ 'progresspercent' : 0,
- \}
-
-function! s:ProgressBarNumeric.mCreate(maxcount, unit) dict
- let gpbr = s:GenericProgressBar.mCreate(range(1,a:maxcount), '',
- \ "Processing \@PROGRESS\@\%, total ". a:maxcount . " " . a:unit)
- let progressbar = extend(gpbr, deepcopy(s:ProgressBarNumeric))
- unlet progressbar.mCreate
-
- let progressbar.progressmax = a:maxcount
- let progressbar.progress1percent = a:maxcount/100
-
- let progressbar.units = a:unit
-
- return progressbar
-endfunction
-
-
-function! s:ProgressBarNumeric.mTick(count) dict
- let self.progress1current += a:count
- if self.progress1percent <= self.progress1current
- let tmp = (self.progress1current/self.progress1percent)
- let self.progresspercent += tmp
- let self.progress1current -= tmp * self.progress1percent
- let self.currentChar += 1
- call self.mUpdate()
- endif
-endfunction
-
-" }}}
-" {{{ Status line
-let s:StatusLine = {
- \ 'symlastprogress' : 0,
- \ 'symprogress' : 0,
- \ 'cursym' : 0,
- \ 'savedStatusLine' : '',
- \ 'statusextra' : '',
- \ 'local':0
- \}
-
-function! s:StatusLine.mInit() dict
- let self.savedStatusLine = &l:statusline
- setlocal statusline=%{CCTreeStatusLine()}
-endfunction
-
-function! s:StatusLine.mRestore() dict
- let self.currentstatus = ''
- let self.statusextra = ''
-
- let &l:statusline = s:StatusLine.savedStatusLine
- redrawstatus
-endfunction
-
-function! s:StatusLine.mSetInfo(msg) dict
- let s:StatusLine.currentstatus = a:msg
- redrawstatus
-endfunction
-
-function! s:StatusLine.mSetExtraInfo(msg) dict
- let s:StatusLine.statusextra = a:msg
- redrawstatus
-endfunction
-
-function! CCTreeStatusLine()
- return s:pluginname. " ".
- \ s:StatusLine.currentstatus . " -- ".
- \ s:StatusLine.statusextra
-endfunction
-"}}}
-" {{{ Shell command interface
-
-let s:ShellCmds = {}
-
-function! s:ShellCmds.mSplit(inFile, outFile)
- let cmdEx = substitute(g:CCTreeSplitProgCmd, "PROG_SPLIT", g:CCTreeSplitProg,"")
- let cmdEx = substitute(cmdEx, "SPLIT_OPT", g:CCTreeSplitProgOption,"")
- if g:CCTreeDbFileSplitLines != -1
- let cmdEx = substitute(cmdEx, "SPLIT_SIZE", g:CCTreeDbFileSplitLines,"")
- else
- let cmdEx = substitute(cmdEx, "SPLIT_SIZE", g:CCTreeDbFileMaxSize,"")
- endif
- let cmdEx = substitute(cmdEx, "IN_FILE", a:inFile,"")
- let cmdEx = substitute(cmdEx, "OUT_FILE_PREFIX", a:outFile,"")
-
- return cmdEx
-endfunction
-
-function! s:ShellCmds.mJoin(inFileList, outFile)
- let cmdEx = substitute(g:CCTreeJoinProgCmd, "PROG_JOIN", g:CCTreeJoinProg,"")
- let cmdEx = substitute(cmdEx, "JOIN_OPT", g:CCTreeJoinProgOpts,"")
- let cmdEx = substitute(cmdEx, "IN_FILES", a:inFileList,"")
- let cmdEx = substitute(cmdEx, "OUT_FILE", a:outFile,"")
-
- return cmdEx
-endfunction
-
-function! s:ShellCmds.mExec(cmd)
- let cmdoutput = system(a:cmd)
- if cmdoutput != ''
- " Failed
- return s:CCTreeRC.Error
- endif
- return s:CCTreeRC.Success
-endfunction
-
-" }}}
-
-" {{{ Virtual file interface
-let s:vFile = {}
-
-function! s:vFile.mCreate(fname, mode)
- if a:mode == 'r'
- return s:vFileR.mCreate(a:fname)
- elseif a:mode == 'w'
- return s:vFileW.mCreate(a:fname)
- endif
- return -1
-endfunction
-
-let s:vFileW = {
- \ 'splitfiles' : [],
- \ 'totSplits' : 0,
- \ 'lines' : [],
- \ 'fileSize' : 0
- \}
-
-function! s:vFileW.mCreate(fname) dict
- let vfile = deepcopy(s:vFileW)
- unlet vfile.mCreate
- let vfile.link = a:fname
-
- return vfile
-endfunction
-
-function! s:vFileW.mCreateSplit() dict
- " first split, create name
- if self.totSplits == 0
- let self.tlink = tempname()
- endif
- let fname = self.tlink .'_'. self.totSplits
- call writefile(self.lines, fname)
- call add(self.splitfiles, fname)
- let self.lines = []
- let self.totSplits += 1
-endfunction
-
-function! s:vFileW.mTestForSplit() dict
- if self.fileSize > g:CCTreeDbFileMaxSize
- call self.mCreateSplit()
- endif
-endfunction
-
-function! s:vFileW.mAddFileSize(size) dict
- let self.fileSize += a:size
-endfunction
-
-function! s:vFileW.mWriteList(linelist) dict
- call extend(self.lines, a:linelist)
- call self.mTestForSplit()
-endfunction
-
-function! s:vFileW.mWriteLine(line) dict
- call add(self.lines, a:line)
- call self.mAddFileSize(len(a:line))
- call self.mTestForSplit()
-endfunction
-
-function! s:vFileW.mClose() dict
- if self.totSplits == 0
- call writefile(self.lines, self.link)
- else
- " force remaining lines into a new split
- call self.mCreateSplit()
- " now join all of them
- let filelist = join(self.splitfiles, " ")
- let cmdEx = s:ShellCmds.mJoin(filelist, self.link)
- if s:ShellCmds.mExec(cmdEx) != s:CCTreeRC.Success
- call s:CCTreeUtils.mWarningMsg("Shell command: ".cmdEx. " failed!")
- endif
- endif
- for afile in self.splitfiles
- call delete(afile)
- endfor
- return 0
-endfunction
-
-let s:vFileR = {
- \ 'splitfiles' : [],
- \ 'currentSplitIdx' : 0,
- \ 'totSplits' : 0,
- \ 'lines' : [],
- \ 'valid' : 0,
- \ 'mode' : ""
- \}
-
-
-function! s:vFileR.mIsLargeFile() dict
- if (getfsize(self.link) > g:CCTreeDbFileMaxSize)
- return 1
- endif
- return 0
-endfunction
-
-function! s:vFileR.mCreate(fname) dict
- let vfile = deepcopy(s:vFileR)
- unlet vfile.mCreate
- let vfile.link = a:fname
- let vfile.valid = filereadable(a:fname)
- let vfile.size = getfsize(a:fname)
-
- return vfile
-endfunction
-
-function! s:vFileR.mOpen() dict
- if self.mode == 'w'
- " no need to do anything
- return 0
- endif
-
- if self.mIsLargeFile() == 0
- "little trick to keep interface uniform when we don't split
- call add(self.splitfiles, self.link)
- let self.totSplits = 1
- else
- let tmpDb = tempname()
- let cmdEx = s:ShellCmds.mSplit(self.link, tmpDb)
-
- if s:ShellCmds.mExec(cmdEx) != s:CCTreeRC.Success
- call s:CCTreeUtils.mWarningMsg("Shell command: ".cmdEx. " failed!")
- return -1
- else
- let self.splitfiles = split(expand(tmpDb."*"), "\n")
- endif
- if empty(self.splitfiles)
- return -1
- endif
- endif
- let self.totSplits = len(self.splitfiles)
- return 0
-endfunction
-
-
-
-function! s:vFileR.mRead() dict
- if (self.currentSplitIdx >= len(self.splitfiles))
- " out of bounds
- return -1
- endif
- let self.lines = readfile(self.splitfiles[self.currentSplitIdx])
- let self.currentSplitIdx += 1
- return 0
-endfunction
-
-function! s:vFileR.mReset() dict
- let self.currentSplitIdx = 0
- let self.lines = []
-endfunction
-
-
-function! s:vFileR.mClose() dict
- if self.totSplits == 1
- return
- endif
- for afile in self.splitfiles
- call delete(afile)
- endfor
-endfunction
-"}}}
-" {{{Stop watch
-let s:StopWatch = {
- \ 'text' : "(no reltime feature)",
- \}
-
-function! s:StopWatch.mCreate() dict
- let stopWatch = deepcopy(s:StopWatch)
- unlet stopWatch.mCreate
-
- call stopWatch.mReset()
- return stopWatch
-endfunction
-
-function! s:StopWatch.mReset() dict
- if has('reltime')
- let self.startRTime = reltime()
- else
- let self.startRTime = localtime()
- endif
-endfunction
-
-function! s:StopWatch.mSnapElapsed() dict
- if has('reltime')
- let self.text = reltimestr(reltime(self.startRTime))
- else
- let self.text = localtime() - self.startRTime
- endif
-endfunction
-
-function! s:StopWatch.mGetText() dict
- return self.text
-endfunction
-"}}}
-" {{{ Digraph character compression/decompression routines
-
-let s:CharMaps = {
- \'savedEncoding' : '',
- \'mapkind' : ''
- \}
-
-" The encoding needs to be changed to 8-bit, otherwise we can't swap special
-" 8-bit characters; restore after done
-function! s:CharMaps.mInitTranslator() dict
- if self.mapkind == 'Alpha'
- let self.savedEncoding = &encoding
- let &encoding="latin1"
- endif
-endfunction
-
-function! s:CharMaps.mDoneTranslator() dict
- if self.mapkind == 'Alpha'
- let &encoding=self.savedEncoding
- endif
-endfunction
-
-function! s:CharMaps.CrossProduct(seq1, seq2) dict
- let cpSeq = []
- for dc1 in range(strlen(a:seq1))
- for dc2 in range(strlen(a:seq2))
- call add(cpSeq, a:seq1[dc1].a:seq2[dc2])
- endfor
- endfor
- return cpSeq
-endfunction
-
-let s:TranslateMap = {}
-
-function! s:TranslateMap.mCreate (srcsym, destsym, mapkind, regex) dict
- let dicttable = extend(deepcopy(s:CharMaps), deepcopy(s:TranslateMap))
- unlet dicttable.CrossProduct
-
- let dicttable.mappings = {}
-
- " map lower
- let maxsym = min([len(a:srcsym),len (a:destsym)])
-
- let index = 0
- while (index < maxsym)
- let dicttable.mappings[a:srcsym[index]] = a:destsym[index]
- let index += 1
- endwhile
- " Need mapping lens, we assume it's constant across the board
- let dicttable.mapsrclen = len(a:srcsym[0])
- let dicttable.regex = a:regex
-
-
- if a:mapkind == 'Alpha'
- let dicttable.mTranslate = dicttable.mTranslateAlpha
- elseif a:mapkind == 'Numeric'
- let dicttable.mTranslate = dicttable.mTranslateNumeric
- endif
-
- let dicttable.mapkind = a:mapkind
-
- unlet dicttable.mTranslateNumeric
- unlet dicttable.mTranslateAlpha
-
- return dicttable
-endfunction
-
-
-function! s:TranslateMap.mTranslateNumeric(value) dict
- let index = 0
- let retval = ""
-
- " remember to deal with multi-byte characters
- while index < len(a:value)
- let char1 = char2nr(a:value[index])
- if has_key(self.mappings, char1)
- let newmap = self.mappings[char1]
- else
- " take only the first character
- let newmap = a:value[index]
- endif
- let retval .= newmap
- let index += 1
- endwhile
- return retval
-endfunction
-
-function! s:TranslateMap.mTranslateAlpha(value) dict
- let retval = substitute(a:value, self.regex, '\=self.mappings[submatch(1)]', "g")
- return retval
-endfunction
-
-function! s:CCTreeGetXRefDbMaps(maptype, mapkind)
- let dichar1 = ",0123456789"
- let dichar2 = ",0123456789"
-
- return s:CCTreeCreateGenericMaps(a:maptype, a:mapkind, dichar1, dichar2)
-endfunction
-
-function! s:CCTreeGetCscopeMaps(maptype, mapkind)
- let dichar1 = " teisaprnl(of)=c"
- let dichar2 = " tnerpla"
-
- return s:CCTreeCreateGenericMaps(a:maptype, a:mapkind, dichar1, dichar2)
-endfunction
-
-
-function! s:CCTreeCreateGenericMaps(maptype, mapkind, dichar1, dichar2)
- let s:CharMaps.mapkind = a:mapkind
- call s:CharMaps.mInitTranslator()
- if a:mapkind == 'Numeric'
- let ab = map(range(128,255), 'v:val')
- elseif a:mapkind == 'Alpha'
- let ab = map(range(128,255), 'nr2char(v:val)')
- else
- return {}
- endif
- let ac = s:CharMaps.CrossProduct(a:dichar1, a:dichar2)
- if a:maptype == 'Compress'
- let maps = s:TranslateMap.mCreate(ac, ab, a:mapkind,
- \'\(['.a:dichar1.']['.a:dichar2.']\)\C')
- elseif a:maptype == 'Uncompress'
- let maps = s:TranslateMap.mCreate(ab, ac, a:mapkind,
- \'\([\d128-\d255]\)')
- endif
- call s:CharMaps.mDoneTranslator()
- return maps
-endfunction
-" }}}
-" {{{ Unique list filter object
-
-let s:UniqList = {}
-
-function! s:UniqList.mFilterEntries(lstval) dict
- let valdict = {}
- let reslist = ''
- for aval in a:lstval
- if !has_key(valdict, aval)
- let valdict[aval] = ''
- let reslist .= (aval . ",")
- endif
- endfor
- return reslist
-endfunction
-
-let s:CCTreeUniqListFilter = deepcopy(s:UniqList)
-function! s:CCTreeMakeCommaListUnique(clist)
- let entries = split(a:clist, ",")
- if len(entries) > 0
- return s:CCTreeUniqListFilter.mFilterEntries(entries)
- endif
- return ""
-endfunction
-" }}}
-" {{{ Buffer/Window
-func! s:FindOpenBuffer(filename)
- let bnrHigh = bufnr("$")
- "tabpagebuflist(tabpagenr())
-
- for bufnrs in range(1, bnrHigh)
- if (bufexists(bufnrs) == 1 && bufname(bufnrs) == a:filename && bufloaded(bufnrs) != 0 )
- return bufnrs
- endif
- endfor
- " Could not find the buffer
- return 0
-endfunction
-
-func! s:FindOpenWindow(filename)
- let bufnr = s:FindOpenBuffer(a:filename)
- if (bufnr > 0)
- let newWinnr = bufwinnr(bufnr)
- if newWinnr != -1
- exec newWinnr.'wincmd w'
- return 1
- endif
- endif
- " Could not find the buffer
- return 0
-endfunction
-" }}}
-" {{{ Utils library
-
-let s:Utils = {}
-
-" Use this function to determine the correct "g" flag
-" for substitution
-function! s:Utils.mGetSearchFlag(gvalue)
- let ret = (!a:gvalue)* (&gdefault) + (!&gdefault)*(a:gvalue)
- if ret == 1
- return 'g'
- endif
- return ''
-endfunc
-
-" Strlen works for multibyte characters
-function! s:Utils.mStrlenEx(val)
- return strlen(substitute(a:val, ".", "x", "g"))
-endfunc
-" }}}
-" {{{ Generic db loader interface
-let s:GenericDbLdr = {
- \ 'fDBName' : '',
- \ 'class' : 'Generic',
- \ }
-
-function! s:GenericDbLdr.mCreate(fname) dict
- let gdb = deepcopy(s:GenericDbLdr)
- unlet gdb.mCreate
- let gdb.fDBName = a:fname
-
- if !filereadable(a:fname)
- return s:CCTreeRC.Error
- endif
-
- return gdb
-endfunction
-
-function! s:GenericDbLdr.mParseDbHeader(gRdr)
- let header = readfile(self.fDBName, "", a:gRdr.headerLines)
- return a:gRdr.mParseDbHeader(header)
-endfunction
-
-let s:XRefMemDbLdr = {
- \ 'class' : s:DBStorage.memory
- \}
-
-function! s:XRefMemDbLdr.mCreate(fname) dict
- let gdb = s:GenericDbLdr.mCreate(a:fname)
- if type(gdb) != type({})
- return gdb
- endif
- let mdb = extend(gdb, deepcopy(s:XRefMemDbLdr))
- unlet mdb.mCreate
-
- return mdb
-endfunction
-
-if has('perl') && g:CCTreeUsePerl == 1
-" Perl function
-function! s:XRefMemDbLdr.mLoadFileIntoXRefDb(xRefDb, gRdr) dict
- call a:gRdr.mProcessingStateInit()
- call s:StatusLine.mSetInfo('(PERL) Loading database')
- let pBar = s:ProgressBarNumeric.mCreate(getfsize(self.fDBName), "bytes")
-perl << PERL_EOF
- #use strict;
- #use warnings FATAL => 'all';
- #use warnings NONFATAL => 'redefine';
-
- my $filebytes = 0;
- my $filterpat = VIM::Eval("a:gRdr.perl_opts");
-
- open (CSCOPEDB, VIM::Eval("self.fDBName")) or die "File trouble!";
- VIM::DoCommand("echomsg '".$filterpat."'");
-
- while (<CSCOPEDB>) {
- $filebytes += length($_);
- chomp($_);
-
- if ($_ !~ $filterpat) {
- next;
- }
- VIM::DoCommand("call pBar.mTick(".$filebytes.")");
- $filebytes = 0;
- VIM::DoCommand("call a:gRdr.mProcessSymbol(a:xRefDb, '".$_."')");
- }
- VIM::DoCommand("call pBar.mDone()");
- close(CSCOPEDB);
-PERL_EOF
- call a:gRdr.mProcessingStateDone()
-endfunction
-else
-" Native Vim function
-function! s:XRefMemDbLdr.mLoadFileIntoXRefDb(xRefDb, gRdr) dict
- let vDbFile = s:vFile.mCreate(self.fDBName, "r")
- if vDbFile.valid == 0
- return -1
- endif
- if vDbFile.mIsLargeFile() == 1
- call s:StatusLine.mSetExtraInfo('Database '
- \.' >'.g:CCTreeDbFileMaxSize .' bytes. Splitting '.
- \'into smaller chunks... (this may take some time)')
- endif
- try
- if vDbFile.mOpen() == 0
- call self.mReadFileIntoXRefDb(vDbFile,
- \ a:xRefDb,
- \ a:gRdr)
- endif
- finally
- call vDbFile.mClose()
- endtry
-endfunction
-endif
-
-function! s:XRefMemDbLdr.mReadFileIntoXRefDb(vDbFile, xrefdb, gRdr)
- call a:gRdr.mProcessingStateInit()
- while 1 == 1
- if a:vDbFile.mRead() == -1
- break
- endif
- let idxstr = '('.a:vDbFile.currentSplitIdx.'/'.a:vDbFile.totSplits.') '
- call s:StatusLine.mSetInfo('Reading database chunk '.idxstr)
- " Filter-out lines that doesn't have relevant information
- let plist = a:gRdr.mReadLinesFromFile(a:vDbFile, a:gRdr.opts)
- let pBar = s:ProgressBarNumeric.mCreate(len(plist), "items")
- call s:StatusLine.mSetInfo('Analyzing database chunk '.idxstr)
- call self.mProcessListIntoXrefDb(plist, a:gRdr, a:xrefdb, pBar)
- call pBar.mDone()
- endwhile
- call a:gRdr.mProcessingStateDone()
-endfunction
-
-function! s:XRefMemDbLdr.mProcessListIntoXrefDb(symbols, rdr, xrefdb, pbar)
- for a in a:symbols
- call a:pbar.mTick(1)
- call a:rdr.mProcessSymbol(a:xrefdb, a)
- endfor
-endfunction
-
-
-" }}}
-" {{{ Generic Disk DB Ldr
-let s:XRefDiskDbLdr = {
- \ 'class' : s:DBStorage.disk
- \ }
-
-function! s:XRefDiskDbLdr.mCreate(fname) dict
- let gdb = s:GenericDbLdr.mCreate(a:fname)
- if type(gdb) != type({})
- return gdb
- endif
- let mdb = extend(gdb, deepcopy(s:XRefDiskDbLdr))
- unlet mdb.mCreate
-
- return mdb
-endfunction
-
-function! s:XRefDiskDbLdr.mLoadFileIntoXRefDb(xRefDb, gRdr) dict
- call a:xRefDb.mSetLink(self.fDBName)
-endfunction
-
-"}}}
-" {{{ Xref disk DB
-let s:XRefDiskDb = {
- \ 'link':'',
- \ 'savedTags': '',
- \ 'class' : s:DBStorage.disk
- \ }
-
-function! s:XRefDiskDb.mCreate() dict
- let fdb = deepcopy(s:XRefDiskDb)
- unlet fdb.mCreate
- let fdb.maps = s:CCTreeGetXRefDbMaps('Uncompress', 'Numeric')
-
- return fdb
-endfunction
-
-function! s:XRefDiskDb.mSetLink(filedb) dict
- let self.link = a:filedb
- " revisit, do parse header here
-endfunction
-
-function! s:XRefDiskDb.mClear() dict
- " do nothing
-endfunction
-
-function! s:XRefDiskDb.mInitState() dict
- let self.savedTags = &tags
- let &tags = self.link
-endfunction
-
-function! s:XRefDiskDb.mRestoreState() dict
- let &tags = self.savedTags
-endfunction
-
-function! s:XRefDiskDb.mDecodeTagEntry(tagentry) dict
- "echomsg string(a:tagentry)
- let itms = split(a:tagentry.name, "#")
- let a:tagentry.n = itms[1]
- let a:tagentry.idx = itms[0]
-
- " Vim taglist() drops empty fields, so need to protect
- if has_key(a:tagentry, 'c')
- let a:tagentry.c = self.maps.mTranslate(a:tagentry.c)
- else
- let a:tagentry.c = ''
- endif
- if has_key(a:tagentry, 'p')
- let a:tagentry.p = self.maps.mTranslate(a:tagentry.p)
- else
- let a:tagentry.p = ''
- endif
-
- return a:tagentry
-endfunction
-
-function! s:XRefDiskDb.mGetSymbolIdFromName(symname) dict
- let symtagline = taglist('\#'.a:symname.'$')
- let g:xyz = symtagline
- let asym = self.mDecodeTagEntry(symtagline[0])
- return asym.idx
-endfunction
-
-function! s:XRefDiskDb.mGetSymbolFromId(symid) dict
- let symtagline = taglist('^'.a:symid.'\#')
- if empty(symtagline)
- echomsg "Failed to locate ".a:symid
- else
- return self.mDecodeTagEntry(symtagline[0])
- endif
- return {}
-endfunction
-
-function! s:XRefDiskDb.mGetSymbolIds() dict
- " illegal
- let symtaglines = taglist('^.')
- return keys(self.symidhash)
-endfunction
-
-function! s:XRefDiskDb.mGetSymbolNames(lead) dict
- if empty(a:lead)
- let symtaglines = taglist('^.')
- else
- let symtaglines = taglist('#'.a:lead)
- endif
- let alist = []
- for atag in symtaglines
- let acctreesym = self.mDecodeTagEntry(atag)
- call add(alist, acctreesym.n)
- endfor
- return alist
-endfunction
-" }}}
-" {{{ TagFile utils
-let s:CCTreeTagDbRdr = {'class': 'CCTreeXrefDb',
- \ 'headerLines' : 4,
- \ 'compressed' : 0,
- \ 'opts': ['v:val !~ "^[\!]"'],
- \ 'perl_opts': "^[^\!]",
- \ 'mapPreKeys': {'c':'','p':''},
- \ 'mapPostKeys': {'c':'','p':''}
- \ }
-
-function! s:CCTreeTagDbRdr.mCreate(fname) dict
- let cctxdbrdr = deepcopy(s:CCTreeTagDbRdr)
- unlet cctxdbrdr.mCreate
-
- return cctxdbrdr
-endfunction
-
-function! s:CCTreeTagDbRdr.mRequirePreProcessing() dict
- return s:CCTreeRC.False
-endfunction
-
-function! s:CCTreeTagDbRdr.mRequirePostProcessing() dict
- return s:CCTreeRC.True
-endfunction
-
-function! s:CCTreeTagDbRdr.mRequireCleanup() dict
- " Clean-up all symbols [never]
- return s:CCTreeRC.False
-endfunction
-
-function! s:CCTreeTagDbRdr.mGetPreProcessingMaps() dict
- return s:CCTreeGetXRefDbMaps('Compress', 'Alpha')
-endfunction
-
-function! s:CCTreeTagDbRdr.mGetPostProcessingMaps() dict
- return s:CCTreeGetXRefDbMaps('Uncompress', 'Alpha')
-endfunction
-
-
-function! s:CCTreeTagDbRdr.mParseDbHeader(hdr) dict
- " just check line 3 for sanity
- if a:hdr[2] =~ "CCTree"
- return s:CCTreeRC.Success
- endif
- return s:CCTreeRC.Error
-endfunction
-
-function! s:CCTreeTagDbRdr.mProcessingStateInit() dict
-endfunction
-
-function! s:CCTreeTagDbRdr.mProcessingStateDone() dict
-endfunction
-
-function! s:CCTreeTagDbRdr.mReadLinesFromFile(vdbFile, filtercmds) dict
- " Hard-coded assumptions here about format for performance
- if empty(get(a:vdbFile.lines, 0)) != 1 && a:vdbFile.lines[0][0] == "!"
- " filter out the first few lines starting with "!"
- call remove(a:vdbFile.lines, 0, self.headerLines-1)
- endif
- return a:vdbFile.lines
-endfunction
-
-function! s:CCTreeTagDbRdr.mProcessSymbol(xrefdb, aline) dict
- let cctreesym = self.mDecodeTagLine(a:aline)
- call a:xrefdb.mInsertSym(cctreesym.idx, cctreesym)
- " we really don't need idx any longer
- unlet cctreesym.idx
-endfunction
-
-function! s:CCTreeTagDbRdr.mDecodeTagLine(tagline) dict
-
- let items = split(a:tagline, "\t")
- let newsym = s:CCTreeSym.mCreate("")
- try
- let [newsym.idx, newsym.n] = split(items[0], '#')
- catch
- echomsg "problem decoding ". a:tagline
- endtry
-
- "let newsym.idx = strpart(items[0], 0, idxBr)
- "let newsym.n = items[0][ idxBr+1 : -2] "strpart(items[0], idxBr+1, strlen(items[0])-1)
- if empty(get(items, 3)) != 1
- let newsym.c = items[3][2:]
- endif
- if empty(get(items, 4)) != 1
- let newsym.p = items[4][2:]
- endif
- return newsym
-endfunction
-
-" }}}
-" {{{ Generic Db Serializer
-let s:GenericDbSerializer = {}
-
-function! s:GenericDbSerializer.mCreate(xrefdb) dict
- let gDbSerializer = deepcopy(s:GenericDbSerializer)
- let gDbSerializer.xrefdb = a:xrefdb
- return gDbSerializer
-endfunction
-
-function! s:GenericDbSerializer.mWriteXRefDbToFile(fname,
- \ gWriter) dict
- call s:StatusLine.mInit()
- try
- call s:StatusLine.mSetInfo('Writing XRefDb')
- let vDbFile = s:vFile.mCreate(a:fname, "w")
- call vDbFile.mWriteList(a:gWriter.mBuildHeader())
- call self.mWriteSymsToFile(vDbFile, a:gWriter)
- finally
- call vDbFile.mClose()
- call s:StatusLine.mRestore()
- endtry
-endfunction
-
-function! s:GenericDbSerializer.mWriteSymsToFile(dstVFile,
- \ gWriter) dict
- let pBar = s:ProgressBarNumeric.mCreate(self.xrefdb.mGetSymbolCount(),
- \ "items")
- call a:gWriter.mInitWriting()
- " write syms
- for asymid in sort(self.xrefdb.mGetSymbolIds())
- let acctreesym = self.xrefdb.mGetSymbolFromId(asymid)
- call a:dstVFile.mWriteLine(a:gWriter.mBuildTagLine(acctreesym,
- \ asymid))
- call pBar.mTick(1)
- endfor
- call pBar.mDone()
- call a:gWriter.mDoneWriting()
-endfunction
-" }}}
-" {{{ CCTreeTagDb Writer
-let s:CCTreeTagDbWriter = {}
-
-function! s:CCTreeTagDbWriter.mCreate(tmaps) dict
- let dbwriter = deepcopy(s:CCTreeTagDbWriter)
- unlet dbwriter.mCreate
-
-
- let dbwriter.tmaps = a:tmaps
- return dbwriter
-endfunction
-
-function! s:CCTreeTagDbWriter.mInitWriting() dict
- call self.tmaps.mInitTranslator()
-endfunction
-
-function! s:CCTreeTagDbWriter.mDoneWriting() dict
- call self.tmaps.mDoneTranslator()
-endfunction
-
-function! s:CCTreeTagDbWriter.mBuildHeader() dict
- let hdr = []
- call add(hdr, "!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;\" to lines/")
- call add(hdr, "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/")
- call add(hdr, "!_TAG_PROGRAM_NAME\t\tCCTree (Vim plugin)//")
- call add(hdr, "!_TAG_PROGRAM_URL\thttp://vim.sourceforge.net/scripts/script.php?script_id=2368\t/site/")
- return hdr
-endfunction
-
-
-function! s:CCTreeTagDbWriter.mBuildTagLine(sym, symid) dict
- let basetag = a:symid .'#'. a:sym.n."\t"."\t"."/^\$/".";\""
- let cm = self.tmaps.mTranslate(a:sym.c)
- let pm = self.tmaps.mTranslate(a:sym.p)
-
- let basetag .= "\tc:". self.tmaps.mTranslate(a:sym.c)
- let basetag .= "\tp:". self.tmaps.mTranslate(a:sym.p)
-
- return basetag
-endfunction
-" }}}
-" {{{ CCTree constants
-let s:CCTreeRC = {
- \ 'Error' : -1,
- \ 'True' : 1,
- \ 'False' : 0,
- \ 'Success' : 2
- \ }
-"}}}
-" {{{ CCTree DB Obj
-" Symbol definition
-
-let s:CCTreeSym = {
- \'n': "",
- \'c': "",
- \'p': ""
- \}
-
-function! s:CCTreeSym.mCreate(name)
- let sym = deepcopy(s:CCTreeSym)
- unlet sym.mCreate
- let sym.n = a:name
- return sym
-endfunction
-
-
-" }}}
-" {{{ GenericXref, XrefDb
-let s:GenericXRef = {}
-
-function! s:GenericXRef.mCreate(filedb) dict
- let gxref = deepcopy(s:GenericXRef)
- return gxref
-endfunction
-
-function! s:GenericXRef.mInitState() dict
-endfunction
-
-function! s:GenericXRef.mRestoreState() dict
-endfunction
-" {{{ XRef Database object
-let s:xRefMemDb = {
- \ 'symuniqid': 0,
- \ 'symidhash' : {},
- \ 'symnamehash' : {},
- \ 'class' : s:DBStorage.memory
- \}
-
-
-function s:xRefMemDb.mCreate() dict
- let dbObj = deepcopy(s:xRefMemDb)
- unlet dbObj.mCreate
-
- return dbObj
-endfunction
-
-function s:xRefMemDb.mInitState() dict
-endfunction
-
-function s:xRefMemDb.mRestoreState() dict
-endfunction
-
-function s:xRefMemDb.mClear() dict
- let self.symidhash = {}
- let self.symnamehash = {}
- let self.symuniqid = 0
-endfunction
-
-function! s:xRefMemDb.mInsertSym(idx, cctreesym) dict
- let self.symuniqid = max([self.symuniqid, a:idx])
- let self.symidhash[a:idx] = a:cctreesym
- let self.symnamehash[a:cctreesym.n] = a:idx
-endfunction
-
-function! s:xRefMemDb.mRemoveSymById(symidx) dict
- call self.mRemoveSymByName(acctreesym.n)
- call remove(self.symidhash, a:symidx)
-endfunction
-
-function! s:xRefMemDb.mRemoveSymByName(symname) dict
- call remove(self.symnamehash, a:symname)
-endfunction
-
-function! s:xRefMemDb.mAddSym(name) dict
- if !has_key(self.symnamehash, a:name)
- let self.symnamehash[a:name] = self.symuniqid
- let self.symidhash[self.symuniqid] = s:CCTreeSym.mCreate(a:name)
- let self.symuniqid += 1
- endif
- return self.symnamehash[a:name]
-endfunction
-
-function! s:xRefMemDb.mMarkXRefSyms(funcentryidx, newfuncidx) dict
- let self.symidhash[a:funcentryidx]['c'] .= (",". a:newfuncidx)
- let self.symidhash[a:newfuncidx]['p'] .= (",". a:funcentryidx)
-endfunction
-
-function! s:xRefMemDb.mGetSymbolFromName(symname) dict
- return self.symidhash[self.symnamehash[a:symname]]
-endfunction
-
-function! s:xRefMemDb.mGetSymbolIdFromName(symname) dict
- return self.symnamehash[a:symname]
-endfunction
-
-function! s:xRefMemDb.mGetSymbolFromId(symid) dict
- return self.symidhash[a:symid]
-endfunction
-
-function! s:xRefMemDb.mGetSymbolIds() dict
- return keys(self.symidhash)
-endfunction
-
-function! s:xRefMemDb.mGetSymbolNames(lead) dict
- let syms = keys(self.symnamehash)
- if empty(a:lead)
- return filter(syms, 'v:val =~? a:lead')
- endif
- return syms
-endfunction
-
-function! s:xRefMemDb.mGetSymbolCount() dict
- return len(self.symnamehash)
-endfunction
-
-function! s:xRefMemDb.mTranslateSymbols(map, tkeys) dict
- call a:map.mInitTranslator()
- let pBar = s:ProgressBarNumeric.mCreate(len(self.symnamehash), "items")
-
- for asym in keys(self.symnamehash)
- let idx = self.symnamehash[asym]
- let val = self.symidhash[idx]
- if has_key(a:tkeys, 'n')
- let uncmpname = a:map.mTranslate(asym)
- if (asym != uncmpname)
- "Set up new entry
- let self.symnamehash[uncmpname] = idx
- " free the old entry
- call remove(self.symnamehash, asym)
- " Set uncompressed name
- let val.n = uncmpname
- endif
- endif
- if has_key(a:tkeys, 'p')
- let val.p = a:map.mTranslate(val.p)
- endif
- if has_key(a:tkeys, 'c')
- let val.c = a:map.mTranslate(val.c)
- endif
- call pBar.mTick(1)
- endfor
- call pBar.mDone()
- call a:map.mDoneTranslator()
-endfunction
-
-function! s:xRefMemDb.mCleanSymbols () dict
- let pBar = s:ProgressBarNumeric.mCreate(len(self.symnamehash), "items")
- for asym in keys(self.symnamehash)
- let idx = self.symnamehash[asym]
- let val = self.symidhash[idx]
- if empty(val.p) && empty(val.c)
- call remove(self.symnamehash, asym)
- call remove(self.symidhash, idx)
- else
- let val.p = s:CCTreeMakeCommaListUnique(val.p)
- let val.c = s:CCTreeMakeCommaListUnique(val.c)
- endif
- call pBar.mTick(1)
- endfor
- call pBar.mDone()
-endfunction
-"}}}
-"}}} End of Xref
-" {{{ Tracer
-let s:CallTree = {
- \ 'symbol' : ""
- \ }
-function! s:CallTree.mCreate(name) dict
- let ct = deepcopy(s:CallTree)
- unlet ct.mCreate
-
- let ct.symbol = a:name
-
- return ct
-endfunction
-
-function! s:CallTree.mAddChildLink(childTree) dict
- if !has_key(self, 'childlinks')
- let self.childlinks = []
- endif
- call add(self.childlinks, a:childTree)
-endfunction
-
-let s:XRefTracer = {
- \}
-
-function! s:XRefTracer.mCreate(xrefdb) dict
- let xreftracer = deepcopy(s:XRefTracer)
- let xreftracer.xrefdb = a:xrefdb
-
- return xreftracer
-endfunction
-
-function! s:XRefTracer.mInitTracing() dict
- call self.xrefdb.mInitState()
-endfunction
-
-function! s:XRefTracer.mDoneTracing() dict
- call self.xrefdb.mRestoreState()
-endfunction
-
-function! s:XRefTracer.mGetSymbolIdXRef(symid, direction) dict
- let acctreesym = self.xrefdb.mGetSymbolFromId(a:symid)
- let symidslist = split(
- \s:CCTreeMakeCommaListUnique(acctreesym[a:direction]), ",")
- return symidslist
-endfunction
-
-function! s:XRefTracer.mBuildForSymbol(symid, curdepth, maxdepth,
- \ direction, pbar) dict
- if (a:curdepth > a:maxdepth)
- return {}
- endif
-
- call a:pbar.mSetDepth(a:curdepth)
- let asym = self.xrefdb.mGetSymbolFromId(a:symid)
- " revisit
- if empty(asym)
- return {}
- endif
-
- let rtree = s:CallTree.mCreate(asym['n'])
-
- for entry in self.mGetSymbolIdXRef(a:symid, a:direction)
- call a:pbar.mTick(1)
- let ctree =
- \self.mBuildForSymbol(entry, a:curdepth+1, a:maxdepth,
- \a:direction, a:pbar)
- call rtree.mAddChildLink(ctree)
- endfor
- return rtree
-endfunction
-" }}}
-
-" {{{ Cscope Reader
-
-
-let s:CscopeDbRdrState = {
- \'curfuncidx': -1,
- \'curfileidx': -1,
- \'curmacroidx': -1,
- \ }
-
-function! s:CscopeDbRdrState.mCreate() dict
- return deepcopy(s:CscopeDbRdrState)
-endfunction
-
-let s:CscopeDbRdr = {
- \ 'class': 'Cscope',
- \ 'headerLines' : 1,
- \ 'compressed' : 0,
- \ 'opts': ['v:val =~ "^\t[#`$}@\~\)]"'],
- \ 'perl_opts': '^\t[\`\#\$\}\@\~\)]',
- \ 'mapPreKeys': {'n':''},
- \ 'mapPostKeys': {'n':''}
- \}
-
-function! s:CscopeDbRdr.mCreate(fname) dict
- let csdbrdr = deepcopy(s:CscopeDbRdr)
- unlet csdbrdr.mCreate
-
- return csdbrdr
-endfunction
-
-function! s:CscopeDbRdr.mProcessingStateInit() dict
- let self.iState = s:CscopeDbRdrState.mCreate()
-endfunction
-
-function! s:CscopeDbRdr.mProcessingStateDone() dict
- " discard state
- unlet self.iState
-endfunction
-
-function! s:CscopeDbRdr.mReadLinesFromFile(vDbFile, filtercmds) dict
- return s:CCTreeUtils.mFilter(a:vDbFile.lines, a:filtercmds)
-endfunction
-
-function! s:CscopeDbRdr.mParseDbHeader(dbHeader) dict
- if a:dbHeader[0] =~ "cscope"
- if (a:dbHeader[0] !~ "cscope.*\-c")
- let self.compressed = s:CCTreeRC.True
- else
- let self.compressed = s:CCTreeRC.False
- endif
- return s:CCTreeRC.Success
- endif
- return s:CCTreeRC.Error
-endfunction
-
-function! s:CscopeDbRdr.mRequirePreProcessing() dict
- return (self.compressed == 1)? s:CCTreeRC.True : s:CCTreeRC.False
-endfunction
-
-function! s:CscopeDbRdr.mRequirePostProcessing() dict
- return (self.compressed == 1)? s:CCTreeRC.True : s:CCTreeRC.False
-endfunction
-
-function! s:CscopeDbRdr.mRequireCleanup() dict
- " Clean-up all symbols [always]
- return s:CCTreeRC.True
-endfunction
-
-function! s:CscopeDbRdr.mGetPreProcessingMaps() dict
- return s:CCTreeGetCscopeMaps('Compress', 'Alpha')
-endfunction
-
-function! s:CscopeDbRdr.mGetPostProcessingMaps() dict
- return s:CCTreeGetCscopeMaps('Uncompress', 'Alpha')
-endfunction
-
-function! s:CscopeDbRdr.mProcessSymbol(xrefdb, symbol) dict
- return self.mProcessTaggedSymbol(a:xrefdb, a:symbol)
-endfunction
-
-function! s:CscopeDbRdr.mProcessTaggedSymbol(xrefdb, symbol) dict
- if self.iState.curmacroidx != -1
- if a:symbol[1] == "`"
- call a:xrefdb.mMarkXRefSyms(self.iState.curmacroidx,
- \ a:xrefdb.mAddSym(a:symbol[2:]))
- elseif a:symbol[1] == ')'
- let self.iState.curmacroidx = -1
- endif
- elseif self.iState.curfuncidx != -1
- " inside function
- if a:symbol[1] == "`"
- call a:xrefdb.mMarkXRefSyms(self.iState.curfuncidx,
- \ a:xrefdb.mAddSym(a:symbol[2:]))
- elseif a:symbol[1] == "}"
- let self.iState.curfuncidx = -1
- elseif a:symbol[1] == "#"
- let self.iState.curmacroidx = a:xrefdb.mAddSym(a:symbol[2:])
- endif
- elseif a:symbol[1] == "$"
- let self.iState.curfuncidx = a:xrefdb.mAddSym(a:symbol[2:])
- elseif a:symbol[1] == "#"
- let self.iState.curmacroidx = a:xrefdb.mAddSym(a:symbol[2:])
- elseif a:symbol[1] == "~"
- call a:xrefdb.mMarkXRefSyms(self.iState.curfileidx,
- \a:xrefdb.mAddSym(a:symbol[3:]))
- elseif a:symbol[1] == "@"
- if a:symbol[2] != ""
- let self.iState.curfileidx =
- \a:xrefdb.mAddSym(a:symbol[2:])
- endif
- endif
-endfunction
-
-" }}}
-" {{{ CCTree helper library
-let s:CCTreeUtils = {}
-
-function! s:CCTreeUtils.mDetectDB(class)
- if a:class == s:DBClasses.cctreexref
- if filereadable(g:CCTreeDb)
- return g:CCTreeDb
- endif
- elseif a:class == s:DBClasses.cscopeid
- if filereadable(g:CCTreeCscopeDb)
- return g:CCTreeCscopeDb
- endif
- endif
- return ''
-endfunction
-
-function! s:CCTreeUtils.mFilter(lines, filtercmds) dict
- let retlst = []
- let progr = len(a:lines)/100
- let pBar = s:ProgressBarNumeric.mCreate(len(a:lines), "items")
- while len(a:lines) > 0
- if progr <= len(a:lines)
- let tmplist = remove(a:lines, 0, progr)
- else
- let tmplist = remove(a:lines, 0, len(a:lines)-1)
- endif
- for acmd in a:filtercmds
- call filter(tmplist, acmd)
- endfor
- call pBar.mTick(progr)
- call extend(retlst, tmplist)
- endwhile
- call pBar.mDone()
- return retlst
-endfunction
-
-function! s:CCTreeUtils.mWarningMsg(msg) dict
- echohl WarningMsg
- echomsg s:pluginname. ": ". a:msg
- echohl None
-endfunction
-
-function! s:CCTreeUtils.mInfoMsg(msg) dict
- echohl Title
- echomsg s:pluginname. ": ". a:msg
- echohl None
-endfunction
-
-function! s:CCTreeUtils.mWrite(msg) dict
- echo s:pluginname. ": ". a:msg
-endfunction
-
-" }}}
-" {{{ CCTree DB management
-let s:CCTreeXrefDbEntry = {
- \ 'type': '',
- \ 'fname' : '',
- \ 'fsize' : 0,
- \ 'fdate' : 0
- \}
-
-function! s:CCTreeXrefDbEntry.mCreate(fname, type) dict
- let xrefdbent = deepcopy(s:CCTreeXrefDbEntry)
- unlet xrefdbent.mCreate
-
- let xrefdbent.type = a:type
- let xrefdbent.fname = simplify(getcwd().'/'.a:fname)
- let xrefdbent.fsize = getfsize(a:fname)
- let xrefdbent.fdate = strftime("%c", getftime(a:fname))
- return xrefdbent
-endfunction
-
-let s:CCTreeDBList = {
- \'loadedDBs' : []
- \ }
-
-function! s:CCTreeDBList.mCreate() dict
- let dbList = deepcopy(s:CCTreeDBList)
- unlet dbList.mCreate
-
- return dbList
-endfunction
-
-function! s:CCTreeDBList.mShowLoaded() dict
- let i = 1
- call s:CCTreeUtils.mWrite(s:pluginname.": List of loaded cscope databases")
- call s:CCTreeUtils.mWrite("---------------------------------------")
- for aDBEnt in self.loadedDBs
- call s:CCTreeUtils.mWrite(i." ".aDBEnt.fname. " ".
- \ " (".aDBEnt.type.") ".
- \ aDBEnt.fsize. " bytes ".
- \ aDBEnt.fdate)
- let i = i + 1
- endfor
-endfunction
-
-function! s:CCTreeDBList.mClearAll() dict
- let self.loadedDBs = []
-endfunction
-
-function! s:CCTreeDBList.mIsEmpty() dict
- if empty(self.loadedDBs)
- return s:CCTreeRC.True
- endif
- return s:CCTreeRC.False
-endfunction
-
-" Load the cscope db into the global cctree xref db
-function! s:CCTreeDBList.mCreateDbLoaderAndReader(dbName, dbclass, storageclass) dict
- let dbUser = s:CCTreeCmdLine.mInputDBName('Load', a:dbName, a:dbclass)
- if dbUser == ''
- call s:CCTreeUtils.mWarningMsg('Filename required')
- "User cancel, do nothing
- return
- endif
-
- " Create generic Db loader object
- if a:storageclass == s:DBStorage.disk
- let gDbLdr = s:XRefDiskDbLdr.mCreate(dbUser)
- elseif a:storageclass == s:DBStorage.memory
- let gDbLdr = s:XRefMemDbLdr.mCreate(dbUser)
- endif
-
- if type(gDbLdr) != type({})
- call s:CCTreeUtils.mWarningMsg(a:dbclass.' database ' . a:dbName .
- \ ' not found.')
- return s:CCTreeRC.Error
- endif
-
- " Create new DB reader object
- if a:storageclass == s:DBStorage.memory
- if a:dbclass == s:DBClasses.cscopeid
- let gDbRdr = s:CscopeDbRdr.mCreate(dbUser)
- elseif a:dbclass == s:DBClasses.cctreexref
- let gDbRdr = s:CCTreeTagDbRdr.mCreate(dbUser)
- else
- return s:CCTreeRC.Error
- endif
- if gDbLdr.mParseDbHeader(gDbRdr) == s:CCTreeRC.Error
- call s:CCTreeUtils.mWarningMsg(gDbRdr.class.' database ' . a:dbName .
- \ ' format is not parseable.')
- return s:CCTreeRC.Error
- endif
- else
- let gDbRdr = {}
- endif
-
- return {'loader': gDbLdr, 'reader': gDbRdr}
-endfunction
-
-function! s:CCTreeDBList.mAddDbToList(dbName, type)
- let aDBEnt = s:CCTreeXrefDbEntry.mCreate(a:dbName, a:type)
- call add(self.loadedDBs, aDBEnt)
-endfunction
-
-" Merge the cscope db into the global cctree xref db
-function! s:CCTreeDBList.mMerge(dbName, xRefDb, class)
- " Check if merge can be supported
- if self.loadedDBs[0].type == s:DBStorage.disk
- call s:CCTreeUtils.mInfoMsg("Cannot merge with DBs traced from disk")
- return
- endif
- " Create db loader, reader
- let gObjs = self.mCreateDbLoaderAndReader(a:dbName, a:class, s:DBStorage.memory)
-
- if type(gObjs) == type({})
- " if Db is compressed, then we need to compress our symbols first
- let swatch = s:StopWatch.mCreate()
- if self.mLoadDB(gObjs.loader, a:xRefDb,
- \ gObjs.reader) != s:CCTreeRC.Error
- call self.mAddDbToList(gObjs.loader.fDBName, gObjs.loader.class)
- let msg = "Done merging databases. xRef Symbol Count: "
- \.a:xRefDb.mGetSymbolCount()
- \.". Time taken: ".swatch.mGetText()." secs"
- call s:CCTreeUtils.mInfoMsg(msg)
- endif
- " Load will auto decompress the symbols
- endif
-endfunction
-
-" Load the cscope db into the global cctree xref db
-function! s:CCTreeDBList.mAddNew(dbName, xRefDb, dbclass, storageclass)
- " Create db loader, reader
- echomsg a:dbName
- let gObjs = self.mCreateDbLoaderAndReader(a:dbName, a:dbclass, a:storageclass)
-
- if type(gObjs) == type({})
- let swatch = s:StopWatch.mCreate()
- if self.mLoadDB(gObjs.loader, a:xRefDb,
- \ gObjs.reader) != s:CCTreeRC.Error
- call self.mAddDbToList(gObjs.loader.fDBName, gObjs.loader.class)
- call swatch.mSnapElapsed()
- if a:storageclass == s:DBStorage.memory
- let msg = "Done loading database. xRef Symbol Count: "
- \.a:xRefDb.mGetSymbolCount()
- \.". Time taken: ".swatch.mGetText()." secs"
- else
- let msg = "Disk Xref database loaded for tracing"
- endif
- call s:CCTreeUtils.mInfoMsg(msg)
- endif
- endif
-endfunction
-
-function! s:CCTreeDBList.mLoadDB(gDbLdr, xRefDb, gRdr)
- let rc = s:CCTreeRC.Success
- try
- call s:StatusLine.mInit()
- " if compression, then we need to compress our symbols first
- if !empty(a:gRdr) && a:gRdr.mRequirePreProcessing() == s:CCTreeRC.True
- call s:StatusLine.mSetInfo('Pre-processing existing symbols')
- call a:xRefDb.mTranslateSymbols(a:gRdr.mGetPreProcessingMaps(),
- \ a:gRdr.mapPreKeys)
- endif
- call garbagecollect()
- call s:StatusLine.mSetInfo('Loading database')
- call a:gDbLdr.mLoadFileIntoXRefDb(a:xRefDb, a:gRdr)
- if !empty(a:gRdr) && a:gRdr.mRequireCleanup() == s:CCTreeRC.True
- call s:StatusLine.mSetInfo('Symbol clean-up')
- call a:xRefDb.mCleanSymbols()
- endif
- call garbagecollect()
- if !empty(a:gRdr) && a:gRdr.mRequirePostProcessing() == s:CCTreeRC.True
- call s:StatusLine.mSetInfo('Post-processing loaded symbols')
- call a:xRefDb.mTranslateSymbols(a:gRdr.mGetPostProcessingMaps(),
- \ a:gRdr.mapPostKeys)
- endif
- call garbagecollect()
- redraw
-
-
- catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C)
- call s:CCTreeUtils.mWarningMsg('Loading aborted.')
- let rc = s:CCTreeRC.Error
- finally
- call s:StatusLine.mRestore()
- endtry
- return rc
-endfunction
-"}}}
-" {{{ UI Input related
-let s:CCTreeUI = {}
-
-
-function! s:CCTreeUI.mInputDBName(dbName, class, action)
- let dbUser = a:dbName
- let dbUser = input(a:action. ' database ('. a:class. '): ', a:dbName, 'file')
- return dbUser
-endfunction
-" }}}
-" {{{ CCTree Markers
-let s:TreeMarkers_UTF8 = {
- \ 'splitT' : nr2char(0x251c),
- \ 'arrowR' : nr2char(0x25c0),
- \ 'arrowF' : nr2char(0x25B6),
- \ 'extV' : nr2char(0x2502),
- \ 'extH': nr2char(0x2500),
- \ 'depth': nr2char(0x25BC)
- \}
-
-let s:TreeMarkers_Text = {
- \ 'splitT' : '+',
- \ 'arrowF' : '>',
- \ 'arrowR' : '<',
- \ 'extV' : '|',
- \ 'extH': '-',
- \ 'depth': 'depth:'
- \}
-
-let s:CCTreeMarkers = {
- \ 'icons':{}
- \ }
-function! s:CCTreeMarkers.mCreate() dict
- let treeMarkers = deepcopy(s:CCTreeMarkers)
-
- if &encoding == 'utf-8' && g:CCTreeUseUTF8Symbols == 1
- let treeMarkers.icons = deepcopy(s:TreeMarkers_UTF8)
- else
- " default choice
- let treeMarkers.icons = deepcopy(s:TreeMarkers_Text)
- endif
-
- let treeMarkers.icons.arrowSyms = treeMarkers.icons.arrowF . treeMarkers.icons.arrowR
- let treeMarkers.icons.vertSyms = treeMarkers.icons.splitT . treeMarkers.icons.extV
-
- return treeMarkers
-endfunction
-
-function! s:CCTreeMarkers.mGetArrow(direction) dict
- if a:direction == 'p'
- return self.icons.arrowR
- elseif a:direction == 'c'
- return self.icons.arrowF
- endif
- return '?'
-endfunction
-" }}}
-" {{{ User key mappings
-let s:CCTreeKeyMappings = {
- \ 'CTreeF': g:CCTreeKeyTraceForwardTree,
- \ 'CTreeR': g:CCTreeKeyTraceReverseTree,
- \ 'CTreeHilight': g:CCTreeKeyHilightTree,
- \ 'CTreeWSave': g:CCTreeKeySaveWindow,
- \ 'CTreeWToggle': g:CCTreeKeyToggleWindow,
- \ 'CTreeCompress': g:CCTreeKeyCompressTree,
- \ 'CTreeDepthMinus': g:CCTreeKeyDepthMinus,
- \ 'CTreeDepthPlus': g:CCTreeKeyDepthPlus
- \}
-" }}}
-" {{{ CCTreeWindow
-let s:CCTreeWindow = {
- \ 'hiKeyword': '',
- \ 'hiKeywordLine':'',
- \ 'lastbufname':'',
- \ 'treeMarkers': s:CCTreeMarkers.mCreate()}
-
-function! s:CCTreeWindow.mCreate() dict
- let win = deepcopy(s:CCTreeWindow)
- unlet win.mCreate
-
- return win
-endfunction
-
-function! s:CCTreeWindow.mLeave()
- call s:FindOpenWindow(self.lastbufname)
-endfunction
-
-
-" Definition of a keyword...
-let s:CCTreeKeywordRegEx = '[A-Za-z0-9_\\\.\/]\+'
-
-function! s:CCTreeWindow.mGetKeywordAtCursor() dict
- let curline = line(".")
- let self.hiKeyword = ''
- if foldclosed(curline) == -1
- let curkeyword = matchstr(getline("."), s:CCTreeKeywordRegEx)
- if curkeyword != ''
- if curkeyword != self.hiKeyword || curline != self.hiKeywordLine
- let self.hiKeyword = curkeyword
- let self.hiKeywordLine = line(".")
- return s:CCTreeRC.Success
- endif
- else
- return s:CCTreeRC.Error
- endif
- endif
- if self.hiKeyword == ''
- return s:CCTreeRC.Error
- endif
- return s:CCTreeRC.Success
-endfunction
-
-function! s:CCTreeWindow.mBuildStatusLine(pState, title, items)
- let needcomma = 0
- let rtitle = a:title. ' ('. a:pState.keyword
- let rtitle .= '['
- if has_key(a:items, "depth")
- let rtitle .= self.treeMarkers.icons.depth
- let rtitle .= a:pState.depth
- let needcomma = 1
- endif
- if has_key(a:items, "direction")
- if needcomma == 1
- let rtitle .= ','
- endif
-
- let rtitle .= self.treeMarkers.mGetArrow(a:pState.direction)
- endif
- let rtitle .= '])'
-
- return rtitle
-endfunction
-
-function! CCTreeWindowPreviewStatusLine()
- " get global
- " this is a hack
- let pState = s:CCTreeGlobals.PreviewState
- let tMarkers = s:CCTreeGlobals.Window.treeMarkers
-
- return s:CCTreeGlobals.Window.mBuildStatusLine(
- \ s:CCTreeGlobals.PreviewState,
- \ s:windowtitle,
- \ {'depth':''}
- \)
-endfunction
-
-function! s:CCTreeWindow.mPreviewSave(savetitle) dict
- if s:FindOpenWindow(s:windowtitle) == 1
- setlocal modifiable
- call self.mClearMarks(b:displayTree)
- setlocal nomodifiable
- setlocal statusline=%-F
- silent! exec ":f ". a:savetitle
- return s:CCTreeRC.Success
- endif
- return s:CCTreeRC.Error
-endfunction
-
-function! s:CCTreeWindow.mIsOpen() dict
- if s:FindOpenBuffer(s:windowtitle) > 0
- return s:CCTreeRC.True
- endif
- return s:CCTreeRC.False
-endfunction
-
-function! s:CCTreeWindow.mClose() dict
- if s:FindOpenWindow(s:windowtitle) == 1
- silent! q!
- endif
-endfunction
-
-function! s:CCTreeWindow.mDisplayToggle() dict
- if s:FindOpenWindow(s:windowtitle) == 1
- silent! hide
- else
- let winbufnr = s:FindOpenBuffer(s:windowtitle)
- if winbufnr > 0
- call self.mEnter()
- silent! exec "buf ".winbufnr
- call self.mResize()
- silent! wincmd p
- else
- call s:CCTreeUtils.mWarningMsg(" No active window found.")
- endif
- endif
-endfunction
-
-function! s:CCTreeWindow.mResize() dict
- if g:CCTreeWindowVertical == 1
- if g:CCTreeWindowWidth == -1
- exec "vertical resize ". b:maxwindowlen
- else
- exec "vertical resize ". g:CCTreeWindowWidth
- endif
- else
- if g:CCTreeWindowHeight != -1
- let &winminheight = g:CCTreeWindowHeight
- exec "resize".g:CCTreeWindowHeight
- endif
- endif
-endfunction
-
-function! s:CCTreeWindow.mDisplayTree(atree, direction) dict
- let incctreewin = 1
- if (bufname('%') != s:windowtitle)
- let incctreewin = self.mEnter()
- endif
-
- setlocal modifiable
- silent 1,$d
- let b:maxwindowlen = g:CCTreeWindowMinWidth
- let b:displayTree = s:DisplayTree.mCreate(a:atree,
- \ a:direction, self.treeMarkers)
- call s:CCTreeDisplay.mPopulateTreeInCurrentBuffer(b:displayTree)
- exec "normal gg"
-
- " Need to force this again
- let &l:foldlevel=g:CCTreeMinVisibleDepth
- setlocal nomodifiable
- call self.mResize()
- if (incctreewin == 0)
- call s:CCTreeWindow.mLeave()
- endif
-endfunction
-
-function! s:CCTreeWindow.mExtractTreeSymbols(dtree)
- let symlist = {}
- for aentry in a:dtree.entries
- let symlist[aentry.symbol] = 0
- endfor
- return symlist
-endfunction
-
-function! s:CCTreeWindow.mEnter() dict
- let self.lastbufname = bufname("%")
- let foundWindow = s:FindOpenWindow(s:windowtitle)
- if foundWindow == 0
- if g:CCTreeWindowVertical == 1
- exec g:CCTreeOrientation." vsplit ". s:windowtitle
- set winfixwidth
- else
- exec g:CCTreeOrientation." split ". s:windowtitle
- set winfixheight
- endif
-
- setlocal buftype=nofile
- setlocal bufhidden=hide
- setlocal noswapfile
- setlocal nonumber
- setlocal nowrap
- setlocal nobuflisted
-
- if s:CCTreeUseConceal == 1
- setlocal cole=3
- setlocal cocu=nv
- endif
-
- setlocal statusline=%=%{CCTreeWindowPreviewStatusLine()}
-
- call self.mInitSyntax(self.treeMarkers.icons)
- let cpo_save = &cpoptions
- set cpoptions&vim
-
- call s:CCTreeBufferKeyMappingsCreate(s:CCTreeKeyMappings)
-
- command! -buffer -nargs=0 CCTreeWindowHiCallTree
- \ call s:CCTreeGlobals.mCursorHoldHandleEvent()
-
- exec 'nnoremap <buffer> <silent> '.s:CCTreeKeyMappings.CTreeHilight.
- \' :CCTreeWindowHiCallTree<CR>'
- exec 'nnoremap <buffer> <silent> '.s:CCTreeKeyMappings.CTreeCompress.
- \ ' :2,.foldclose!<CR>zv'
-
- nnoremap <buffer> <silent> <C-p> :CCTreePreviewBufferUsingTag<CR>
- nnoremap <buffer> <silent> <CR> :CCTreeLoadBufferUsingTag<CR>
- nnoremap <buffer> <silent> <2-LeftMouse> :CCTreeLoadBufferUsingTag<CR>
-
- let &cpoptions = cpo_save
- endif
- setlocal foldmethod=expr
- setlocal foldexpr=CCTreeFoldExpr(getline(v:lnum))
- setlocal foldtext=CCTreeFoldText()
- let &l:foldlevel=g:CCTreeMinVisibleDepth
-
- return foundWindow
-endfunction
-" }}}
-" {{{ Dynamic call-tree highlighting using
-" syntax highlight tricks
-"
-" There are 3 types of lines, marked with the start character [\s, !, #]
-" Also @ is used to mark the path that is going up
-
-function! s:CCTreeWindow.mMarkCallTree(dtree, keyword) dict
- let declevel = -1
- let treelst = a:dtree.entries
- let curLine = line(".")
-
- let declevel = treelst[curLine-1].level
-
- let targetlevel = declevel
- for idx in range(curLine, 1, -1)
- let aentry = treelst[idx-1]
-
-
- " Find our keyword
- let linemarker = 0
- " Skip folds
- if declevel != -1 && foldclosed(idx) == -1
- if targetlevel == aentry.level
- let linemarker = 1
- let targetlevel -= 1
- endif
- let aline = a:dtree.mGetNotationalTxt(aentry.level, targetlevel+1, linemarker, 1)
- \ . aentry.symbol
- call setline(idx, aline)
- endif
- endfor
-endfunction
-
-function! s:CCTreeWindow.mClearMarks(dtree) dict
- for idx in range(line(".")+1, line("$"))
- let breakout = (getline(idx)[0] !~ "[!#]")
- if breakout == 1
- break
- endif
- let aentry = a:dtree.entries[idx-1]
- let aline = a:dtree.mGetNotationalTxt(aentry.level, -1, 0, 0)
- \ . aentry.symbol
- call setline(idx, aline)
- endfor
-endfunction
-
-function! s:CCTreeWindow.mInitSyntax(markers) dict
- "syntax match CCTreePathMark /\s[|+]/ contained
- exec 'syntax match CCTreePathMark /\s['. a:markers.vertSyms . ']/ contained'
- "syntax match CCTreeArrow /-*[<>]/ contained
- exec 'syntax match CCTreeArrow /'.a:markers.extH.'*['. a:markers.arrowSyms .']/ contained'
-
- syntax match CCTreeSymbol / [A-Za-z0-9_\.\\\/]\+/ contained
- syntax region CCTreeSymbolLine start="^\s" end="$" contains=CCTreeArrow,CCTreePathMark,CCTreeSymbol oneline
-
- "syntax match CCTreeHiArrow /-*[<>]/ contained
- exec 'syntax match CCTreeHiArrow /'. a:markers.extH .'*['. a:markers.arrowSyms .']/ contained'
- syntax match CCTreeHiSymbol / [A-Za-z0-9_\.\\\/]\+/ contained
-
- "syntax match CCTreeHiPathMark /\s[|+]/ contained
- exec 'syntax match CCTreeHiPathMark /\s[' . a:markers.vertSyms . ']/ contained'
-
- if s:CCTreeUseConceal == 1
- syntax match CCTreeMarkExcl /^[!#]/ contained conceal
- syntax match CCTreeMarkTilde /@/ contained conceal
- else
- syntax match CCTreeMarkExcl /^[!#]/ contained
- syntax match CCTreeMarkTilde /@/ contained
- endif
- "syntax region CCTreeUpArrowBlock start="@" end=/[|+]/ contains=CCTreeMarkTilde contained oneline
- exec 'syntax region CCTreeUpArrowBlock start="@" end=/['. a:markers.vertSyms .']/ contains=CCTreeMarkTilde contained oneline'
-
- syntax region CCTreeHiSymbolLine start="!" end="$" contains=CCTreeMarkExcl,
- \ CCTreeUpArrowBlock,
- \ CCTreeHiSymbol,CCTreeHiArrow,CCTreeHiPathMark oneline
-
- syntax region CCTreeMarkedSymbolLine start="#" end="$" contains=CCTreeMarkExcl,
- \ CCTreeMarkTilde,CCTreePathMark,
- \ CCTreeArrow,CCTreeSymbol,CCTreeUpArrowBlock oneline
-endfunction
-
-
-" }}}
-" {{{ CCTreeDisplay
-
-let s:CCTreeDisplay = {}
-
-function! s:CCTreeDisplay.mPopulateTreeInCurrentBuffer(dtree)
- let linelist = []
- for aentry in a:dtree.entries
- let aline = a:dtree.mGetNotationalTxt(aentry.level, -1, 0, 0)
- \ . aentry.symbol
- let len = s:Utils.mStrlenEx(aline)
- let b:maxwindowlen = max([len+1, b:maxwindowlen])
- call add(linelist, aline)
- endfor
- call setline(".", linelist)
-endfunction
-
-
-
-" }}}
-" {{{ CCTree command line interface
-let s:CCTreeCmdLine = {}
-
-
-function! s:CCTreeCmdLine.mLoadDBFromDisk(dbName) dict
- call s:CCTreeGlobals.mUnLoadDBs()
- let s:CCTreeGlobals.XRefDb = s:XRefDiskDb.mCreate()
- call s:CCTreeGlobals.DbList.mAddNew(a:dbName,
- \ s:CCTreeGlobals.XRefDb, s:DBClasses.cctreexref, "Disk")
-endfunction
-
-" Unload current db's and load new one
-" There is no selective unloading
-function! s:CCTreeCmdLine.mLoadDB(db_name, class) dict
- call s:CCTreeGlobals.mSetupEncodingChangeAutoCmd(0)
- call s:CCTreeGlobals.mUnLoadDBs()
- let s:CCTreeGlobals.XRefDb = s:xRefMemDb.mCreate()
- call s:CCTreeGlobals.DbList.mAddNew(a:db_name,
- \ s:CCTreeGlobals.XRefDb, a:class, s:DBStorage.memory)
- call s:CCTreeGlobals.mSetupAutoCmds()
-endfunction
-
-function! s:CCTreeCmdLine.mInputDBName(action, dbName, class) dict
- if a:dbName == ''
- let dbUser = s:CCTreeUI.mInputDBName(
- \ s:CCTreeUtils.mDetectDB(a:class),
- \ a:class, a:action)
- else
- let dbUser = a:dbName
- endif
- return dbUser
-endfunction
-
-function! s:CCTreeCmdLine.mSaveDB(dbName, class) dict
- let dbUser = self.mInputDBName('Save', a:dbName, a:class)
- if dbUser == ''
- call s:CCTreeUtils.mWarningMsg('Filename required')
- return
- endif
- call s:CCTreeGlobals.Window.mClose()
- call s:CCTreeGlobals.mSetupEncodingChangeAutoCmd(0)
- call s:CCTreeGlobals.mWriteXRefDbToFile(dbUser)
- call s:CCTreeGlobals.mSetupAutoCmds()
- call s:CCTreeGlobals.mUpdateForCurrentSymbol()
-endfunction
-
-" Merge current db with new one
-function! s:CCTreeCmdLine.mMergeDB(db_name, class) dict
- "call s:CCTreeGlobals.Window.mClose()
- call s:CCTreeGlobals.DbList.mMerge(a:db_name, s:CCTreeGlobals.XRefDb, a:class)
-endfunction
-
-
-" }}}
-" {{{ CCTree Buffer mappings
-function! s:CCTreeWindowGetHiKeyword()
- let keyw = expand("<cword>")
- let keyf = expand("<cfile>")
-
- let syms = s:CCTreeGlobals.mGetPreviewTreeSymbols()
-
- if keyw != keyf
- if has_key(syms, keyf)
- return keyf
- elseif has_key(syms, keyw)
- return keyw
- endif
- else
- return keyw
- endif
- return ''
-endfunction
-
-
-" Keymappings used common to source files and CCTree window
-function! s:CCTreeBufferKeyMappingsCreate(kmaps)
- let func_expr = '<SNR>'.s:sid.'CCTreeWindowGetHiKeyword()'
- exec 'nnoremap <buffer> <silent> '.a:kmaps.CTreeR.' :CCTreeTraceReverse <C-R>='.
- \ func_expr.'<CR><CR>'
- exec 'nnoremap <buffer> <silent> '.a:kmaps.CTreeF.' :CCTreeTraceForward <C-R>='
- \ .func_expr.'<CR><CR>'
-
- exec 'nnoremap <silent> '.a:kmaps.CTreeWSave. ' :CCTreeWindowSaveCopy<CR>'
- exec 'nnoremap <silent> '.a:kmaps.CTreeWToggle. ' :CCTreeWindowToggle<CR>'
-
- exec 'nnoremap <buffer> <silent> '.a:kmaps.CTreeDepthPlus.
- \ ' :CCTreeRecurseDepthPlus<CR>'
- exec 'nnoremap <buffer> <silent> '.a:kmaps.CTreeDepthMinus.
- \ ' :CCTreeRecurseDepthMinus<CR>'
-endfunction
-
-augroup CCTreeMaps
-au!
-" Header files get detected as cpp?
-" This is a bug in Vim 7.2, a patch needs to be applied to the runtime c
-" syntax files
-" For now, use this hack to make *.h files work
-autocmd FileType * if &ft == 'c'|| &ft == 'cpp' |
- \ call s:CCTreeBufferKeyMappingsCreate(s:CCTreeKeyMappings)|
- \ endif
-augroup END
-
-
-" }}}
-" {{{ Tree building
-
-let s:DisplayTreeEntry = {
- \ 'symbol': "",
- \ 'level': -1
- \ }
-
-function! s:DisplayTreeEntry.mCreate(sym, level) dict
- let te = deepcopy(s:DisplayTreeEntry)
- let te.symbol = a:sym
- let te.level = a:level
- unlet te.mCreate
-
- return te
-endfunction
-
-let s:calltreemaxdepth = 10
-let s:DisplayTree = {
- \ 'entries': [],
- \ 'levelMaxLen': repeat([255], s:calltreemaxdepth),
- \ 'notTxt': {}
- \ }
-
-function! s:DisplayTree.mCreate(calltree, direction, markers) dict
- let dt = deepcopy(s:DisplayTree)
- call dt.mBuildTreeForLevel(a:calltree, 0)
- call dt.mBuildNotationalTxtMarkers(a:direction, a:markers.icons)
-
- unlet dt.mBuildTreeForLevel
- unlet dt.mCreate
-
- return dt
-endfunction
-
-function! s:DisplayTree.mBuildTreeForLevel(ctree, level)
- if !has_key(a:ctree, 'symbol')
- return
- endif
-
- if g:CCTreeDisplayMode == 3
- let curlevellen = strlen(a:ctree.symbol) + a:level + 2
- let self.levelMaxLen[a:level] = min([self.levelMaxLen[a:level],
- \ curlevellen])
- endif
-
-
- let aentry = s:DisplayTreeEntry.mCreate(a:ctree.symbol, a:level)
- call add(self.entries, aentry)
-
- if has_key(a:ctree, 'childlinks')
- for alink in a:ctree['childlinks']
- call self.mBuildTreeForLevel(alink, a:level+1)
- endfor
- endif
-endfunction
-
-
-function! s:DisplayTree.mBuildNotationalTxtMarkers(direction, markerSyms) dict
- " REVISIT
- if a:direction == 'p'
- let directiontxt = a:markerSyms.arrowR . " "
- elseif a:direction == 'c'
- let directiontxt = a:markerSyms.arrowF . " "
- endif
-
-
- let self.notTxt.arrowHead = a:markerSyms.splitT
- let self.notTxt.arrow = directiontxt
- let self.notTxt.arrowLead = a:markerSyms.extH
- let self.notTxt.sep = a:markerSyms.extV
- if s:CCTreeUseConceal == 1
- let concealspace = " "
- else
- let concealspace = ""
- endif
-
- let self.notTxt.symHighlighter= concealspace . "@"
-
- let self.notTxt.hiSymbolMarker = "!".concealspace
- let self.notTxt.hiBranchMarker = "#".concealspace
-
- let self.notTxt.cache = {}
-
-endfunction
-
-function! s:DisplayTree.mGetNotationalTxt(depth, hiDepth, hiSym, hiPath) dict
- let notkey = join(a:000, ":")
- if has_key(self.notTxt.cache,notkey) == 1
- return self.notTxt.cache[notkey]
- else
- return self.mBuildNotationalTxt(a:depth, a:hiDepth, a:hiSym, a:hiPath)
- endif
-endfunction
-
-function! s:DisplayTree.mBuildNotationalTxt(depth, hiDepth, hiSym, hiPath) dict
- let hiBranch = 0
- let curDepth = a:depth
- if 0
- let Aspace = "A"
- let Bspace = "B"
- let Cspace = "C"
- let Sspace = "S"
- let Xspace = "X"
- let Zspace = "Z"
- let Fspace = "1"
- else
- let Aspace = " "
- let Bspace = " "
- let Cspace = " "
- let Sspace = " "
- let Xspace = " "
- let Zspace = " "
- let Fspace = " "
- endif
-
- if g:CCTreeDisplayMode == 1
- let arrowLeads = self.notTxt.arrowLead
- elseif g:CCTreeDisplayMode >= 2
- let arrowLeads = repeat(self.notTxt.arrowLead, a:depth)
- endif
-
- let indentSpace = ""
- if g:CCTreeDisplayMode == 2
- if curDepth > 0
- let indentSpace = repeat(Aspace, curDepth)
- endif
- elseif g:CCTreeDisplayMode == 3
- if curDepth > 0
- let indentSpace = repeat(Aspace, self.levelMaxLen[curDepth-1])
- endif
- endif
- let notTxt = self.notTxt.arrowHead. arrowLeads . self.notTxt.arrow
- if a:hiDepth == a:depth
- let notTxt = indentSpace . self.notTxt.symHighlighter . notTxt
- let hiBranch = 1
- else
- let notTxt = indentSpace. Cspace. notTxt
- endif
- let curDepth -= 1
-
- let indentSpace = ""
- while (curDepth > 0)
- if g:CCTreeDisplayMode == 2
- let indentSpace = repeat(Bspace, curDepth)
- elseif g:CCTreeDisplayMode == 3
- let indentSpace = repeat(Bspace, self.levelMaxLen[curDepth-1])
- endif
- let notTxt = self.notTxt.sep . notTxt
- if a:hiDepth == curDepth && a:hiPath == 1
- let notTxt = indentSpace . self.notTxt.symHighlighter . notTxt
- let hiBranch = 1
- else
- let notTxt = indentSpace. Cspace. notTxt
- endif
- let curDepth -= 1
- endwhile
- if curDepth == 0
- " curdepth is 0
- if a:hiDepth == curDepth && a:hiPath == 1
- let notTxt = self.notTxt.symHighlighter . notTxt
- let hiBranch = 1
- else
- let notTxt = Fspace . notTxt
- endif
- let curDepth -= 1
- endif
- " adjust space
- if a:depth > 0
- let notTxt = Xspace . notTxt
- endif
- if hiBranch == 1
- if a:hiSym == 1
- let notTxt = self.notTxt.hiSymbolMarker . notTxt
- else
- let notTxt = self.notTxt.hiBranchMarker . notTxt
- endif
- else
- let notTxt = Sspace . notTxt
- endif
- return notTxt
-endfunction
-
-"}}}
-" {{{ Preview window Folding
-function! CCTreeFoldExpr(line)
- if !exists('b:displayTree') || v:lnum > len(b:displayTree.entries)
- return 0
- endif
-
- let lvl = b:displayTree.entries[v:lnum-1].level
- if lvl == 0
- let lvl = 1
- endif
- return '>'.lvl
-endfunction
-
-
-function! CCTreeFoldText()
- if s:CCTreeUseConceal == 1
- let line = substitute(getline(v:foldstart), '[!@#]', '' , 'g')
- else
- let line = substitute(getline(v:foldstart), '[!@#]', ' ' , 'g')
- endif
- return line. " (+". (v:foldend - v:foldstart).
- \ ')'. repeat(" ", winwidth(0))
-endfunction
-" }}}
-" {{{ Syntax coloring definitions
-"Standard display
-highlight default link CCTreeSymbol Function
-highlight default link CCTreeMarkers LineNr
-highlight default link CCTreeArrow CCTreeMarkers
-highlight default link CCTreePathMark CCTreeArrow
-highlight default link CCTreeHiPathMark CCTreePathMark
-
-" highlighted display
-highlight default link CCTreeHiKeyword Macro
-highlight default link CCTreeHiSymbol TODO
-highlight default link CCTreeHiMarkers NonText
-highlight default link CCTreeHiArrow CCTreeHiMarkers
-highlight default link CCTreeUpArrowBlock CCTreeHiArrow
-
-highlight default link CCTreeMarkExcl Ignore
-highlight default link CCTreeMarkTilde Ignore
-"}}}
-" {{{ CCTree global state
-
-let s:CCTreePreviewState = {
- \ 'keyword':'',
- \ 'direction': '',
- \ 'depth' : ''
- \}
-
-function! s:CCTreePreviewState.mCreate()
- let state = deepcopy(s:CCTreePreviewState)
- unlet state.mCreate
-
- return state
-endfunction
-
-function! s:CCTreePreviewState.mStore(symbol, direction)
- let self.keyword = a:symbol
- let self.direction = a:direction
-endfunction
-" }}}
-" {{{ CCTree global objects
-
-let s:CCTreeGlobals = {
- \ 'XRefDb': {},
- \ 'DbList': s:CCTreeDBList.mCreate(),
- \ 'PreviewState': s:CCTreePreviewState.mCreate(),
- \ 'Window': s:CCTreeWindow.mCreate()
- \}
-
-let g:CCTreeGlobals = s:CCTreeGlobals
-
-function! s:CCTreeGlobals.mEnable(opt) dict
- if (has_key(s:CCTreeOptions, a:opt))
- call s:CCTreeOptions[a:opt](1)
- else
- call s:CCTreeUtils.mWarningMsg('Invalid option')
- endif
-endfunction
-
-function! s:CCTreeGlobals.mDisable(opt) dict
- if (has_key(s:CCTreeOptions, a:opt))
- call s:CCTreeOptions[a:opt](0)
- else
- call s:CCTreeUtils.mWarningMsg('Invalid option')
- endif
-endfunction
-
-function! s:CCTreeGlobals.mToggle(opt) dict
- if (has_key(s:CCTreeOptions, a:opt))
- call s:CCTreeOptions[a:opt](-1)
- else
- call s:CCTreeUtils.mWarningMsg('Invalid option')
- endif
-endfunction
-
-function! s:CCTreeGlobals.mGetSymNames(lead) dict
- call self.XRefDb.mInitState()
- let syms = self.XRefDb.mGetSymbolNames(a:lead)
- call self.XRefDb.mRestoreState()
- return syms
-endfunction
-
-
-function! s:CCTreeGlobals.mGetCallsForSymbol(name, depth, direction) dict
- let pbar = s:ProgressBarRoll.mCreate(['-','\','|','/'], '*')
- call s:StatusLine.mSetInfo('Building ')
- redrawstatus!
- " Create tracer
- let xtracer = s:XRefTracer.mCreate(self.XRefDb)
- call xtracer.mInitTracing()
- let symid = self.XRefDb.mGetSymbolIdFromName(a:name)
- let xrefs = xtracer.mBuildForSymbol(symid,
- \ a:depth, self.PreviewState.depth, a:direction, pbar)
- call xtracer.mDoneTracing()
- return xrefs
-endfunction
-
-function! s:CCTreeGlobals.mShowLoadedDBs() dict
- call self.DbList.mShowLoaded()
-endfunction
-
-function! s:CCTreeGlobals.mUnLoadDBs() dict
- call s:CCTreeGlobals.Window.mClose()
- if !empty(s:CCTreeGlobals.XRefDb)
- call s:CCTreeGlobals.XRefDb.mClear()
- endif
- call s:CCTreeGlobals.DbList.mClearAll()
-endfunction
-
-function! s:CCTreeGlobals.mSetPreviewState(name, depth, direction) dict
- let self.PreviewState.keyword = a:name
- let self.PreviewState.direction = a:direction
- let self.PreviewState.depth = a:depth
-endfunction
-
-function! s:CCTreeGlobals.mUpdateForCurrentSymbol() dict
- if self.DbList.mIsEmpty() == s:CCTreeRC.True
- return s:CCTreeRC.Error
- endif
- if self.PreviewState.keyword != ''
- let swatch = s:StopWatch.mCreate()
- " Move this function to globals?
- call s:StatusLine.mInit()
- let atree = self.mGetCallsForSymbol(self.PreviewState.keyword,
- \ 0,
- \ self.PreviewState.direction)
- call s:StatusLine.mRestore()
- call self.Window.mDisplayTree(atree, self.PreviewState.direction)
-
- call swatch.mSnapElapsed()
- endif
-endfunction
-
-
-function! s:CCTreeGlobals.mGetPreviewTreeSymbols()
- " REVIST
- if exists('b:displayTree')
- return self.Window.mExtractTreeSymbols(b:displayTree)
- end
- return {}
-endfunction
-
-function! s:CCTreeGlobals.mSanitizeCallDepth() dict
- let error = 0
- if self.PreviewState.depth >= s:calltreemaxdepth
- self.PreviewState.depth = s:calltreemaxdepth
- let error = 1
- elseif self.PreviewState.depth < 1
- let self.PreviewState.depth = 1
- let error = 1
- endif
-
- if error == 1
- call s:CCTreeUtils.mWarningMsg('Depth out of bounds')
- endif
- return error
-endfunction
-
-function! s:CCTreeGlobals.mRecursiveDepthIncrease() dict
- let self.PreviewState.depth += 1
- if self.mSanitizeCallDepth() == 0
- call self.mUpdateForCurrentSymbol()
- endif
-endfunction
-
-function! s:CCTreeGlobals.mRecursiveDepthDecrease() dict
- let self.PreviewState.depth -= 1
- if self.mSanitizeCallDepth() == 0
- call self.mUpdateForCurrentSymbol()
- endif
-endfunction
-
-function! s:CCTreeGlobals.mDisplayToggle() dict
- call self.Window.mDisplayToggle()
-endfunction
-
-function! s:CCTreeGlobals.mSetupAutoCmds() dict
- augroup CCTreeGeneral
- au!
- augroup END
- call s:CCTreeGlobals.mSetupCursorMoveAutoCmd(g:CCTreeHilightCallTree)
- call s:CCTreeGlobals.mSetupEncodingChangeAutoCmd(g:CCTreeUseUTF8Symbols)
-endfunction
-
-function! s:CCTreeGlobals.mSetupCursorMoveAutoCmd(enable) dict
- if a:enable == 1
- exec 'autocmd CCTreeGeneral CursorMoved '.s:windowtitle.' call s:CCTreeGlobals.mCursorHoldHandleEvent()'
- else
- exec 'autocmd! CCTreeGeneral CursorMoved '.s:windowtitle
- endif
-endfunction
-
-function! s:CCTreeGlobals.mSetupEncodingChangeAutoCmd(enable) dict
- return
- if a:enable == 1
- autocmd CCTreeGeneral EncodingChanged * call s:CCTreeGlobals.mEncodingChangedHandleEvent()
- else
- autocmd! CCTreeGeneral EncodingChanged *
- endif
-endfunction
-
-function! s:CCTreeGlobals.mPreviewSave() dict
- let rtitle = s:CCTreeGlobals.Window.mBuildStatusLine(
- \ s:CCTreeGlobals.PreviewState,
- \ s:windowsavetitle,
- \ {'depth':'', 'direction':''}
- \)
-
- if self.Window.mPreviewSave(rtitle) == s:CCTreeRC.Success
- call s:CCTreeUtils.mInfoMsg('Window saved as '. rtitle .
- \ '. New window will be opened on next usage.')
- else
- call s:CCTreeUtils.mWarningMsg('No active window found to be saved.')
- endif
-endfunction
-
-function! s:CCTreeGlobals.mWriteXRefDbToFile(fname) dict
- " create db serializer and writer
- let gDbSz = s:GenericDbSerializer.mCreate(self.XRefDb)
- let gDbWriter = s:CCTreeTagDbWriter.mCreate(
- \ s:CCTreeGetXRefDbMaps('Compress', 'Alpha'))
- call gDbSz.mWriteXRefDbToFile(a:fname, gDbWriter)
-endfunction
-
-function! s:CCTreeGlobals.mReadToXRefDb(fname) dict
- call s:StatusLine.mInit()
- call s:StatusLine.mSetInfo('Reading XRefDb')
- let vDbFile = s:vFile.mCreate(a:fname, "r")
- if vDbFile.mIsLargeFile() == 1
- call s:StatusLine.mSetExtraInfo('Xref DB '
- \.' >'.g:CCTreeDbFileMaxSize .' bytes. Splitting '.
- \'into smaller chunks... (this may take some time)')
- endif
- try
- if vDbFile.mOpen() == 0
- call s:TagFile.mReadToXRefDb(self.XRefDb, vDbFile)
- endif
- finally
- call vDbFile.mClose()
- call s:StatusLine.mRestore()
- call self.DbList.mAddDbToList(a:fname, s:DBStorage.memory)
- endtry
-endfunction
-
-function! s:CCTreeGlobals.mCursorHoldHandleEvent() dict
- if self.Window.mGetKeywordAtCursor() != s:CCTreeRC.Error
- setlocal modifiable
- call self.Window.mClearMarks(b:displayTree)
- call self.Window.mMarkCallTree(b:displayTree,
- \ self.Window.hiKeyword)
- setlocal nomodifiable
- endif
-endfunction
-
-function! s:CCTreeGlobals.mEncodingChangedHandleEvent() dict
- let self.Window.treeMarkers = s:CCTreeMarkers.mCreate()
- if self.Window.mIsOpen() == s:CCTreeRC.True
- call self.Window.mClose()
- call self.mUpdateForCurrentSymbol()
- endif
-endfunction
-
-
-function! s:CCTreeGlobals.mInit() dict
- call self.mSetupAutoCmds()
-endfunction
-
-" }}}
-" {{{ CCTree options
-function! s:CCTreeSetUseCallTreeHiLights(val)
- if a:val == -1
- let g:CCTreeHilightCallTree = !g:CCTreeHilightCallTree
- else
- let g:CCTreeHilightCallTree = a:val
- endif
- call s:CCTreeGlobals.mSetupAutoCmds()
-endfunction
-
-function! s:CCTreeSetUseUtf8Symbols(val)
- if a:val == -1
- let g:CCTreeUseUTF8Symbols = !g:CCTreeUseUTF8Symbols
- else
- let g:CCTreeUseUTF8Symbols = a:val
- endif
- call s:CCTreeGlobals.mEncodingChangedHandleEvent()
-endfunction
-
-function! s:CCTreeSetUseConceal(val)
- if a:val == -1
- let s:CCTreeUseConceal = !s:CCTreeUseConceal
- else
- let s:CCTreeUseConceal = a:val
- endif
- if !has('conceal')
- call s:CCTreeUtils.mWarningMsg('+conceal feature not available')
- let s:CCTreeUseConceal = 0
- endif
-endfunction
-
-function! s:CCTreeOptionsList(arglead, cmdline, cursorpos)
- let opts = keys(s:CCTreeOptions)
- if a:arglead == ''
- return opts
- else
- return filter(opts, 'v:val =~? a:arglead')
- endif
-endfunction
-
-let s:CCTreeOptions = {'UseUnicodeSymbols': function('s:CCTreeSetUseUtf8Symbols'),
- \ 'DynamicTreeHiLights': function('s:CCTreeSetUseCallTreeHiLights'),
- \ 'UseConceal': function('s:CCTreeSetUseConceal')
- \}
-
-" }}}
-" {{{ Vim tags interface
-
-" CCTreeCompleteKwd
-" Command line completion function to return names from the db
-function! s:CCTreeCompleteKwd(arglead, cmdline, cursorpos)
- let syms = s:CCTreeGlobals.mGetSymNames(a:arglead)
- if a:arglead == ''
- return syms
- else
- return filter(syms, 'v:val =~? a:arglead')
- endif
-endfunction
-
-function! s:CCTreeTraceTreeForSymbol(sym_arg, direction)
- if s:CCTreeGlobals.DbList.mIsEmpty() == s:CCTreeRC.True
- call s:CCTreeUtils.mWarningMsg('No database loaded')
- return
- endif
-
- let symbol = a:sym_arg
- if symbol == ''
- let symbol = input('Trace symbol: ', expand('<cword>'),
- \ 'customlist,<SNR>' . s:sid . 'CCTreeCompleteKwd')
- if symbol == ''
- return
- endif
- endif
- let symmatch = s:CCTreeGlobals.mGetSymNames(symbol)
- if len(symmatch) > 0 && index(symmatch, symbol) >= 0
- call s:CCTreeGlobals.mSetPreviewState(symbol,
- \ g:CCTreeRecursiveDepth,
- \ a:direction)
- call s:CCTreeGlobals.mUpdateForCurrentSymbol()
- else
- call s:CCTreeUtils.mWarningMsg('Symbol not found')
- endif
-endfunction
-
-
-
-
-function! s:CCTreeGlobals.mLoadBufferFromKeyword()
- " REVISIT
- if s:CCTreeGlobals.Window.mGetKeywordAtCursor() == s:CCTreeRC.Error
- call s:CCTreeUtils.mWarningMsg('No keyword at cursor')
- return
- endif
-
- let hiKeyword = s:CCTreeGlobals.Window.hiKeyword
- try
- wincmd p
- catch
- call s:CCTreeUtils.mWarningMsg('No buffer to load file')
- finally
- if (cscope_connection() > 0)
- try
- exec "cs find g ". hiKeyword
- catch
- " cheap hack
- exec "cs find f ". hiKeyword
- endtry
- else
- try
- " Ctags is smart enough to figure the path
- exec "tag ".fnamemodify(hiKeyword, ":t")
- catch /^Vim\%((\a\+)\)\=:E433/
- call s:CCTreeUtils.mWarningMsg('Tag file not found')
- catch /^Vim\%((\a\+)\)\=:E426/
- call s:CCTreeUtils.mWarningMsg('Tag '. hiKeyword .' not found')
- wincmd p
- endtry
- endif
- endtry
-endfunction
-
-function! s:CCTreeGlobals.mPreviewBufferFromKeyword()
- if self.Window.mGetKeywordAtCursor() == s:CCTreeRC.Error
- call s:CCTreeUtils.mWarningMsg('No keyword found')
- return
- endif
-
- let hiKeyword = s:CCTreeGlobals.Window.hiKeyword
- silent! wincmd P
- if !&previewwindow
- wincmd p
- endif
- try
- exec "ptag ". hiKeyword
- catch
- call s:CCTreeUtils.mWarningMsg('Tag '.hiKeyword. ' not found')
- endtry
-endfunction
-
-" }}}
-" {{{ Define commands
-command! -nargs=? -complete=file CCTreeLoadXRefDBFromDisk
- \ call s:CCTreeCmdLine.mLoadDBFromDisk(<q-args>)
-command! -nargs=? -complete=file CCTreeLoadDB call s:CCTreeCmdLine.mLoadDB(<q-args>, s:DBClasses.cscopeid)
-command! -nargs=? -complete=file CCTreeLoadXRefDB call s:CCTreeCmdLine.mLoadDB(<q-args>, s:DBClasses.cctreexref)
-command! -nargs=? -complete=file CCTreeSaveXRefDB call s:CCTreeCmdLine.mSaveDB(<q-args>, s:DBClasses.cctreexref)
-command! -nargs=? -complete=file CCTreeAppendDB call s:CCTreeCmdLine.mMergeDB(<q-args>, s:DBClasses.cscopeid)
-command! -nargs=0 CCTreeUnLoadDB call s:CCTreeGlobals.mUnLoadDBs()
-command! -nargs=0 CCTreeShowLoadedDBs call s:CCTreeGlobals.mShowLoadedDBs()
-command! -nargs=? -complete=customlist,s:CCTreeCompleteKwd
- \ CCTreeTraceForward call s:CCTreeTraceTreeForSymbol(<q-args>, 'c')
-command! -nargs=? -complete=customlist,s:CCTreeCompleteKwd CCTreeTraceReverse
- \ call s:CCTreeTraceTreeForSymbol(<q-args>, 'p')
-command! -nargs=0 CCTreeLoadBufferUsingTag call s:CCTreeGlobals.mLoadBufferFromKeyword()
-command! -nargs=0 CCTreePreviewBufferUsingTag call s:CCTreeGlobals.mPreviewBufferFromKeyword()
-command! -nargs=0 CCTreeRecurseDepthPlus call s:CCTreeGlobals.mRecursiveDepthIncrease()
-command! -nargs=0 CCTreeRecurseDepthMinus call s:CCTreeGlobals.mRecursiveDepthDecrease()
-" Preview Window
-command! -nargs=0 CCTreeWindowToggle call s:CCTreeGlobals.mDisplayToggle()
-command! -nargs=0 CCTreeWindowSaveCopy call s:CCTreeGlobals.mPreviewSave()
-" Run-time dynamic options
-command! -nargs=1 -complete=customlist,s:CCTreeOptionsList CCTreeOptsEnable call s:CCTreeGlobals.mEnable(<q-args>)
-command! -nargs=1 -complete=customlist,s:CCTreeOptionsList CCTreeOptsDisable call s:CCTreeGlobals.mDisable(<q-args>)
-command! -nargs=1 -complete=customlist,s:CCTreeOptionsList CCTreeOptsToggle call s:CCTreeGlobals.mToggle(<q-args>)
-"}}}
-" {{{ finish (and init)
-call s:CCTreeGlobals.mInit()
-" restore 'cpo'
-let &cpoptions = s:cpo_save
-unlet s:cpo_save
-" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
-" }}}
+++ /dev/null
-"==============================================================================
-" Plugin: CScope Loader
-"
-" Description: This plugin attempts to find a cscope database corresponding to
-" the current buffer and connect to it until the buffer is changed. The plugin
-" searches from the containing folder up to the file system root looking for a
-" cscope.out file. If a database is found it uses the cscope command to open a
-" connection until the user changes to a different buffer.
-"==============================================================================
-
-"==============================================================================
-" Global Variables
-"==============================================================================
-let s:RootPath = 'C:\'
-let s:DirSeparator = '\'
-let s:DBFileName = 'cscope.out'
-let s:CScopeBin = 'cscope'
-let s:CScopeOptions = '-Rb'
-
-"==============================================================================
-" Functions
-"==============================================================================
-function! GetCScopeDir()
- let searching = 1
- let buf_path = '%:p'
- let cscope_dir = ''
-
- while searching
- let buf_path = buf_path . ':h'
- let search_path = expand(buf_path)
- let cscope_path = search_path . s:DirSeparator . s:DBFileName
-
- if tolower(search_path) == tolower(s:RootPath)
- let searching = 0
- endif
-
- if filereadable(cscope_path)
- let cscope_dir = search_path
- let searching = 0
- endif
- endwhile
- return cscope_dir
-endfunction
-
-function! SetCScopeDB()
- let cscope_dir = GetCScopeDir()
- let cscope_file = cscope_dir . s:DirSeparator . s:DBFileName
- execute('cscope kill -1')
- if strlen(cscope_file)
- let cscope_file = escape( cscope_file, ' ')
- execute('cscope add ' . cscope_file . ' ' . cscope_dir . ' -C')
- endif
-endfunction
-
-function! RebuildCScopeDB()
- let prev_dir = getcwd()
- let cscope_dir = GetCScopeDir()
- echo cscope_dir
- if strlen(cscope_dir)
- execute('cscope kill -1')
- execute('cd ' . cscope_dir)
- execute('silent !' . s:CScopeBin . " " . s:CScopeOptions)
- call SetCScopeDB()
- execute('cd ' . prev_dir)
- endif
-endfunction
-
-"==============================================================================
-" Commands
-"==============================================================================
-" Find all references to token
-command! CSFindS :cs find s <cword><CR>
-
-" Find global definitions of token
-command! CSFindG :cs find g <cword><CR>
-
-" Find all calls to function
-command! CSFindD :cs find d <cword><CR>
-
-" Find all instances of text
-command! CSFindC :cs find c <cword><CR>
-
-" egrep search for token
-command! CSFindT :cs find t <cword><CR>
-
-" Open filename
-command! CSFindE :cs find e <cword><CR>
-
-" Find files including filename
-command! CSFindF :cs find f <cword><CR>
-
-" Find functions that function calls
-command! CSFindI :cs find i <cword><CR>
-
-"==============================================================================
-" Auto Commands
-"==============================================================================
-augroup cscopeloader
-autocmd!
-autocmd cscopeloader BufEnter * :call SetCScopeDB()
-
+++ /dev/null
-"here is a more exotic version of my original Kwbd script
-"delete the buffer; keep windows; create a scratch buffer if no buffers left
-function s:Kwbd(kwbdStage)
- if(a:kwbdStage == 1)
- if(!buflisted(winbufnr(0)))
- bd!
- return
- endif
- let s:kwbdBufNum = bufnr("%")
- let s:kwbdWinNum = winnr()
- windo call s:Kwbd(2)
- execute s:kwbdWinNum . 'wincmd w'
- let s:buflistedLeft = 0
- let s:bufFinalJump = 0
- let l:nBufs = bufnr("$")
- let l:i = 1
- while(l:i <= l:nBufs)
- if(l:i != s:kwbdBufNum)
- if(buflisted(l:i))
- let s:buflistedLeft = s:buflistedLeft + 1
- else
- if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump)
- let s:bufFinalJump = l:i
- endif
- endif
- endif
- let l:i = l:i + 1
- endwhile
- if(!s:buflistedLeft)
- if(s:bufFinalJump)
- windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif
- else
- enew
- let l:newBuf = bufnr("%")
- windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
- endif
- execute s:kwbdWinNum . 'wincmd w'
- endif
- if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%"))
- execute "bd! " . s:kwbdBufNum
- endif
- if(!s:buflistedLeft)
- set buflisted
- set bufhidden=delete
- set buftype=nofile
- setlocal noswapfile
- endif
- else
- if(bufnr("%") == s:kwbdBufNum)
- let prevbufvar = bufnr("#")
- if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum)
- b #
- else
- bn
- endif
- endif
- endif
-endfunction
-
-command! Kwbd call <SID>Kwbd(1)
-nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR>
-
-" Create a mapping (e.g. in your .vimrc) like this:
-"nmap <C-W>! <Plug>Kwbd
+++ /dev/null
-" File: snipMate.vim
-" Author: Michael Sanders
-" Last Updated: July 13, 2009
-" Version: 0.83
-" Description: snipMate.vim implements some of TextMate's snippets features in
-" Vim. A snippet is a piece of often-typed text that you can
-" insert into your document using a trigger word followed by a "<tab>".
-"
-" For more help see snipMate.txt; you can do this by using:
-" :helptags ~/.vim/doc
-" :h snipMate.txt
-
-if exists('loaded_snips') || &cp || version < 700
- finish
-endif
-let loaded_snips = 1
-if !exists('snips_author') | let snips_author = 'Me' | endif
-
-au BufRead,BufNewFile *.snippets\= set ft=snippet
-au FileType snippet setl noet fdm=indent
-
-let s:snippets = {} | let s:multi_snips = {}
-
-if !exists('snippets_dir')
- let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
-endif
-
-fun! MakeSnip(scope, trigger, content, ...)
- let multisnip = a:0 && a:1 != ''
- let var = multisnip ? 's:multi_snips' : 's:snippets'
- if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
- if !has_key({var}[a:scope], a:trigger)
- let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content
- elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]]
- else
- echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.'
- \ .' See :h multi_snip for help on snippets with multiple matches.'
- endif
-endf
-
-fun! ExtractSnips(dir, ft)
- for path in split(globpath(a:dir, '*'), "\n")
- if isdirectory(path)
- let pathname = fnamemodify(path, ':t')
- for snipFile in split(globpath(path, '*.snippet'), "\n")
- call s:ProcessFile(snipFile, a:ft, pathname)
- endfor
- elseif fnamemodify(path, ':e') == 'snippet'
- call s:ProcessFile(path, a:ft)
- endif
- endfor
-endf
-
-" Processes a single-snippet file; optionally add the name of the parent
-" directory for a snippet with multiple matches.
-fun s:ProcessFile(file, ft, ...)
- let keyword = fnamemodify(a:file, ':t:r')
- if keyword == '' | return | endif
- try
- let text = join(readfile(a:file), "\n")
- catch /E484/
- echom "Error in snipMate.vim: couldn't read file: ".a:file
- endtry
- return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
- \ : MakeSnip(a:ft, keyword, text)
-endf
-
-fun! ExtractSnipsFile(file, ft)
- if !filereadable(a:file) | return | endif
- let text = readfile(a:file)
- let inSnip = 0
- for line in text + ["\n"]
- if inSnip && (line[0] == "\t" || line == '')
- let content .= strpart(line, 1)."\n"
- continue
- elseif inSnip
- call MakeSnip(a:ft, trigger, content[:-2], name)
- let inSnip = 0
- endif
-
- if line[:6] == 'snippet'
- let inSnip = 1
- let trigger = strpart(line, 8)
- let name = ''
- let space = stridx(trigger, ' ') + 1
- if space " Process multi snip
- let name = strpart(trigger, space)
- let trigger = strpart(trigger, 0, space - 1)
- endif
- let content = ''
- endif
- endfor
-endf
-
-fun! ResetSnippets()
- let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
-endf
-
-let g:did_ft = {}
-fun! GetSnippets(dir, filetypes)
- for ft in split(a:filetypes, '\.')
- if has_key(g:did_ft, ft) | continue | endif
- call s:DefineSnips(a:dir, ft, ft)
- if ft == 'objc' || ft == 'cpp' || ft == 'cs'
- call s:DefineSnips(a:dir, 'c', ft)
- elseif ft == 'xhtml'
- call s:DefineSnips(a:dir, 'html', 'xhtml')
- endif
- let g:did_ft[ft] = 1
- endfor
-endf
-
-" Define "aliasft" snippets for the filetype "realft".
-fun s:DefineSnips(dir, aliasft, realft)
- for path in split(globpath(a:dir, a:aliasft.'/')."\n".
- \ globpath(a:dir, a:aliasft.'-*/'), "\n")
- call ExtractSnips(path, a:realft)
- endfor
- for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n".
- \ globpath(a:dir, a:aliasft.'-*.snippets'), "\n")
- call ExtractSnipsFile(path, a:realft)
- endfor
-endf
-
-fun! TriggerSnippet()
- if exists('g:SuperTabMappingForward')
- if g:SuperTabMappingForward == "<tab>"
- let SuperTabKey = "\<c-n>"
- elseif g:SuperTabMappingBackward == "<tab>"
- let SuperTabKey = "\<c-p>"
- endif
- endif
-
- if pumvisible() " Update snippet if completion is used, or deal with supertab
- if exists('SuperTabKey')
- call feedkeys(SuperTabKey) | return ''
- endif
- call feedkeys("\<esc>a", 'n') " Close completion menu
- call feedkeys("\<tab>") | return ''
- endif
-
- if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif
-
- let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')
- for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
- let [trigger, snippet] = s:GetSnippet(word, scope)
- " If word is a trigger for a snippet, delete the trigger & expand
- " the snippet.
- if snippet != ''
- let col = col('.') - len(trigger)
- sil exe 's/\V'.escape(trigger, '/.').'\%#//'
- return snipMate#expandSnip(snippet, col)
- endif
- endfor
-
- if exists('SuperTabKey')
- call feedkeys(SuperTabKey)
- return ''
- endif
- return "\<tab>"
-endf
-
-fun! BackwardsSnippet()
- if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif
-
- if exists('g:SuperTabMappingForward')
- if g:SuperTabMappingBackward == "<s-tab>"
- let SuperTabKey = "\<c-p>"
- elseif g:SuperTabMappingForward == "<s-tab>"
- let SuperTabKey = "\<c-n>"
- endif
- endif
- if exists('SuperTabKey')
- call feedkeys(SuperTabKey)
- return ''
- endif
- return "\<s-tab>"
-endf
-
-" Check if word under cursor is snippet trigger; if it isn't, try checking if
-" the text after non-word characters is (e.g. check for "foo" in "bar.foo")
-fun s:GetSnippet(word, scope)
- let word = a:word | let snippet = ''
- while snippet == ''
- if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]')
- let snippet = s:snippets[a:scope][word]
- elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]')
- let snippet = s:ChooseSnippet(a:scope, word)
- if snippet == '' | break | endif
- else
- if match(word, '\W') == -1 | break | endif
- let word = substitute(word, '.\{-}\W', '', '')
- endif
- endw
- if word == '' && a:word != '.' && stridx(a:word, '.') != -1
- let [word, snippet] = s:GetSnippet('.', a:scope)
- endif
- return [word, snippet]
-endf
-
-fun s:ChooseSnippet(scope, trigger)
- let snippet = []
- let i = 1
- for snip in s:multi_snips[a:scope][a:trigger]
- let snippet += [i.'. '.snip[0]]
- let i += 1
- endfor
- if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif
- let num = inputlist(snippet) - 1
- return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
-endf
-
-fun! ShowAvailableSnips()
- let line = getline('.')
- let col = col('.')
- let word = matchstr(getline('.'), '\S\+\%'.col.'c')
- let words = [word]
- if stridx(word, '.')
- let words += split(word, '\.', 1)
- endif
- let matchlen = 0
- let matches = []
- for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
- let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : []
- if has_key(s:multi_snips, scope)
- let triggers += keys(s:multi_snips[scope])
- endif
- for trigger in triggers
- for word in words
- if word == ''
- let matches += [trigger] " Show all matches if word is empty
- elseif trigger =~ '^'.word
- let matches += [trigger]
- let len = len(word)
- if len > matchlen | let matchlen = len | endif
- endif
- endfor
- endfor
- endfor
-
- " This is to avoid a bug with Vim when using complete(col - matchlen, matches)
- " (Issue#46 on the Google Code snipMate issue tracker).
- call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', ''))
- call complete(col, matches)
- return ''
-endf
-" vim:noet:sw=4:ts=4:ft=vim
+++ /dev/null
-"==============================================================================
-" Plugin: Tag Loader
-"
-" Description: This plugin will search for a tags file in every directory from
-" the containing directory of the file in the current buffer, up to the
-" filesystem root. When a tags file is found the tags option is set to the
-" directory containing the tag file. If a tags file is not found, the tags
-" option is set to the current directory.
-"==============================================================================
-
-"==============================================================================
-" Global Variables
-"==============================================================================
-let s:RootPath = 'C:\'
-let s:DirSeparator = '\'
-let s:TagsFileName = 'tags'
-let s:CTagsBin = 'ctags'
-let s:CTagsOptions = '-R'
-
-"==============================================================================
-" Functions
-"==============================================================================
-function! s:GetTagsFileDir()
- let searching = 1
- let buf_path = '%:p'
- let tags_dir = ''
-
- while searching
- let buf_path = buf_path . ':h'
- let search_path = expand(buf_path)
- let tag_path = search_path . s:DirSeparator . s:TagsFileName
-
- if tolower(search_path) == tolower(s:RootPath)
- let searching = 0
- endif
-
- if filereadable(tag_path)
- let tags_dir = search_path
- let searching = 0
- endif
- endwhile
- return tags_dir
-endfunction
-
-function! SetTagsFile()
- let tags_file = s:GetTagsFileDir()
- if strlen(tags_file)
- let tags_file = tags_file . s:DirSeparator . s:TagsFileName
- endif
- let tags_file = escape( tags_file, ' ')
- execute('set tags='.tags_file)
-endfunction
-
-function! RebuildTagsFile()
- let prev_dir = getcwd()
- let tags_dir = s:GetTagsFileDir()
- if strlen(tags_dir)
- execute("cd ".tags_dir)
- execute('silent !' . s:CTagsBin . " " . s:CTagsOptions)
- let tags_file = tags_dir . s:DirSeparator . s:TagsFileName
- let tags_file = escape(tags_file , ' ')
- execute('set tags=' . tags_file)
- execute('cd '.prev_dir)
- endif
-endfunction
-
-"==============================================================================
-" Auto Commands
-"==============================================================================
-augroup tagsloader
-autocmd!
-autocmd tagsloader BufEnter * :call SetTagsFile()
-
+++ /dev/null
-# Global snippets
-
-# (c) holds no legal value ;)
-snippet c)
- `&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
-snippet date
- `strftime("%Y-%m-%d")`
+++ /dev/null
-# main()
-snippet main
- int main(int argc, const char** argv)
- {
- ${1}
- return 0;
- }
-# GNU Copyright Header
-snippet gnu
- /******************************************************************************
- * Copyright (C) 2011 ${1}
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *****************************************************************************/
-# Separator
-snippet sep
- //-----------------------------------------------------------------------------
-# Section Header
-snippet head
- /******************************************************************************
- * ${1}
- *****************************************************************************/
-# Documentation flower box
-snippet doc
- /**
- * @brief ${1}
- **/
-# #include <...>
-snippet Inc
- #include <${1:stdio}.h>${2}
-# #include "..."
-snippet inc
- #include "${1:`Filename("$1.h")`}"${2}
-# #ifndef ... #define ... #endif
-snippet ifndef
- #ifndef $1
- #define ${1:SYMBOL} ${2:value}
- #endif${3}
-snippet def
- #define
-snippet ifdef
- #ifdef ${1:FOO}
- ${2:#define }
- #endif
-snippet #if
- #if ${1:FOO}
- ${2}
- #endif
-# If Condition
-snippet if
- if (${1:/* condition */})
- {
- ${2:/* code */}
- }
-snippet el
- else
- {
- ${1}
- }
-# Gentex If Condition
-snippet gif
- if (${1:/* condition */})
- {
- ${2:/* code */}
- }
-snippet gel
- else
- {
- ${1}
- }
-# Tertiary conditional
-snippet t
- ${1:/* condition */} ? ${2:a} : ${3:b}
-# Do While Loop
-snippet do
- do
- {
- ${2:/* code */}
- }
- while (${1:/* condition */});
-# Gentex Do While Loop
-snippet gdo
- do
- {
- ${2:/* code */}
- }
- while (${1:/* condition */});
-# While Loop
-snippet wh
- while (${1:/* condition */})
- {
- ${2:/* code */}
- }
-# Gentex While Loop
-snippet gwh
- while (${1:/* condition */})
- {
- ${2:/* code */}
- }
-# Custom For Loop
-snippet for
- for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++})
- {
- ${5:/* code */}
- }
-# Gentex Custom For Loop
-snippet gfor
- for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++})
- {
- ${5:/* code */}
- }
-# Function
-snippet fun
- ${1:void} ${2:function_name}(${3})
- {
- ${4:/* code */}
- }
-# Function Declaration
-snippet fund
- ${1:void} ${2:function_name}(${3});${4}
-# Typedef
-snippet td
- typedef ${1:int} ${2:MyCustomType};${3}
-# Struct
-snippet st
- struct ${1:`Filename('$1_t', 'name')`}
- {
- ${2:/* data */}
- }${3: /* optional variable list */};${4}
-# Typedef struct
-snippet tds
- typedef struct ${2:_$1 }
- {
- ${3:/* data */}
- } ${1:`Filename('$1_t', 'name')`};
-# Typdef enum
-snippet tde
- typedef enum
- {
- ${1:/* data */}
- } ${2:foo};
-# printf
-# unfortunately version this isn't as nice as TextMates's, given the lack of a
-# dynamic `...`
-snippet pr
- printf("${1:%s}\n"${2});${3}
-# Test File Definition
-snippet tests
- #include "unity.h"
-
- // File to Test
- #include "${1}.h"
-
- // Real Includes
- ${2}
-
- // Mock Includes
- ${3}
-
- void setUp()
- {
- }
-
- void tearDown()
- {
- }
-
- //-----------------------------------------------------------------------------
-
- ${4}
-# Mock Include
-snippet mock
- #include "mock_${1}.h"
-# Test Definition
-snippet test
- void test_${1}(void) // Implementation
- {
- // Setup
-
- // Expected Function Calls
-
- // Function to Test
-
- // Asserts
-
- }
-# Doxygen Flower Box
-snippet doxy
- /**
- * @brief ${1}
- **/
-# Test Assert Equal
-snippet assert
- TEST_ASSERT_EQUAL( ${1:TRUE}, ${2} );
-# Requirement Tag: Corner
-snippet cor
- // Corner
-# Requirement Tag: Implementation
-snippet imp
- // Implementation
-# Requirement Tag: Requirements
-snippet req
- // Requirements: ${1}
+++ /dev/null
-# snippets for making snippets :)
-snippet snip
- snippet ${1:trigger}
- ${2}
-snippet msnip
- snippet ${1:trigger} ${2:description}
- ${3}
+++ /dev/null
-" Vim syntax file
-" Language: Clojure
-" Last Change: 2008-05-14
-" Maintainer: Toralf Wittner <toralf.wittner@gmail.com>
-
-if version < 600
- syntax clear
-elseif exists("b:current_syntax")
- finish
-endif
-
-syn match cljError "]\|}\|)"
-
-syn keyword cljConstant nil true false
-
-syn keyword cljConditional if cond condp case
-syn keyword cljConditional if-not if-let when when-not when-let when-first
-
-syn keyword cljException try catch finally throw
-
-syn keyword cljRepeat recur map mapcat reduce filter for doseq dorun
-syn keyword cljRepeat doall dotimes map-indexed keep keep-indexed
-
-syn keyword cljSpecial . def do fn if let new quote var loop
-
-syn keyword cljVariable *warn-on-reflection* this *assert*
-syn keyword cljVariable *agent* *ns* *in* *out* *err* *command-line-args*
-syn keyword cljVariable *print-meta* *print-readably* *print-length*
-syn keyword cljVariable *allow-unresolved-args* *compile-files*
-syn keyword cljVariable *compile-path* *file* *flush-on-newline*
-syn keyword cljVariable *math-context* *unchecked-math* *print-dup*
-syn keyword cljVariable *print-level* *use-context-classloader*
-syn keyword cljVariable *source-path* *clojure-version* *read-eval*
-syn keyword cljVariable *1 *2 *3 *e
-
-syn keyword cljDefine def- defn defn- defmacro defmulti defmethod
-syn keyword cljDefine defstruct defonce declare definline definterface
-syn keyword cljDefine defprotocol defrecord deftype
-
-syn keyword cljMacro and or -> assert with-out-str with-in-str with-open
-syn keyword cljMacro locking destructure ns dosync binding delay
-syn keyword cljMacro lazy-cons lazy-cat time assert doc with-precision
-syn keyword cljMacro with-local-vars .. doto memfn proxy amap areduce
-syn keyword cljMacro refer-clojure future lazy-seq letfn
-syn keyword cljMacro with-loading-context bound-fn extend extend-protocol
-syn keyword cljMacro extend-type reify with-bindings ->>
-
-syn keyword cljFunc = not= not nil? false? true? complement identical?
-syn keyword cljFunc string? symbol? map? seq? vector? keyword? var?
-syn keyword cljFunc special-symbol? apply partial comp constantly
-syn keyword cljFunc identity comparator fn? re-matcher re-find re-matches
-syn keyword cljFunc re-groups re-seq re-pattern str pr prn print
-syn keyword cljFunc println pr-str prn-str print-str println-str newline
-syn keyword cljFunc macroexpand macroexpand-1 monitor-enter monitor-exit
-syn keyword cljFunc eval find-doc file-seq flush hash load load-file
-syn keyword cljFunc print-doc read read-line scan slurp subs sync test
-syn keyword cljFunc format printf loaded-libs use require load-reader
-syn keyword cljFunc load-string + - * / < <= == >= > dec inc min max neg?
-syn keyword cljFunc pos? quot rem zero? rand rand-int decimal? even? odd?
-syn keyword cljFunc float? integer? number? ratio? rational?
-syn keyword cljFunc bit-and bit-or bit-xor bit-not bit-shift-left
-syn keyword cljFunc bit-shift-right symbol keyword gensym count conj seq
-syn keyword cljFunc first rest ffirst fnext nfirst nnext second every?
-syn keyword cljFunc not-every? some not-any? concat reverse cycle
-syn keyword cljFunc interleave interpose split-at split-with take
-syn keyword cljFunc take-nth take-while drop drop-while repeat replicate
-syn keyword cljFunc iterate range into distinct sort sort-by zipmap
-syn keyword cljFunc line-seq butlast last nth nthnext next
-syn keyword cljFunc repeatedly tree-seq enumeration-seq iterator-seq
-syn keyword cljFunc coll? associative? empty? list? reversible?
-syn keyword cljFunc sequential? sorted? list list* cons peek pop vec
-syn keyword cljFunc vector peek pop rseq subvec array-map hash-map
-syn keyword cljFunc sorted-map sorted-map-by assoc assoc-in dissoc get
-syn keyword cljFunc get-in contains? find select-keys update-in key val
-syn keyword cljFunc keys vals merge merge-with max-key min-key
-syn keyword cljFunc create-struct struct-map struct accessor
-syn keyword cljFunc remove-method meta with-meta in-ns refer create-ns
-syn keyword cljFunc find-ns all-ns remove-ns import ns-name ns-map
-syn keyword cljFunc ns-interns ns-publics ns-imports ns-refers ns-resolve
-syn keyword cljFunc resolve ns-unmap name namespace require use
-syn keyword cljFunc set! find-var var-get var-set ref deref
-syn keyword cljFunc ensure alter ref-set commute agent send send-off
-syn keyword cljFunc agent-errors clear-agent-errors await await-for
-syn keyword cljFunc instance? bean alength aget aset aset-boolean
-syn keyword cljFunc aset-byte aset-char aset-double aset-float
-syn keyword cljFunc aset-int aset-long aset-short make-array
-syn keyword cljFunc to-array to-array-2d into-array int long float
-syn keyword cljFunc double char boolean short byte parse add-classpath
-syn keyword cljFunc cast class get-proxy-class proxy-mappings
-syn keyword cljFunc update-proxy hash-set sorted-set set disj set?
-syn keyword cljFunc aclone add-watch alias alter-var-root
-syn keyword cljFunc ancestors await1 bases bigdec bigint bit-and-not
-syn keyword cljFunc bit-clear bit-flip bit-set bit-test counted?
-syn keyword cljFunc char-escape-string char-name-string class?
-syn keyword cljFunc compare compile construct-proxy delay?
-syn keyword cljFunc derive descendants distinct? double-array
-syn keyword cljFunc doubles drop-last empty float-array floats
-syn keyword cljFunc force gen-class get-validator int-array ints
-syn keyword cljFunc isa? long-array longs make-hierarchy method-sig
-syn keyword cljFunc not-empty ns-aliases ns-unalias num partition
-syn keyword cljFunc parents pmap prefer-method primitives-classnames
-syn keyword cljFunc print-ctor print-dup print-method print-simple
-syn keyword cljFunc print-special-doc proxy-call-with-super
-syn keyword cljFunc proxy-super rationalize read-string remove
-syn keyword cljFunc remove-watch replace resultset-seq rsubseq
-syn keyword cljFunc seque set-validator! shutdown-agents subseq
-syn keyword cljFunc special-form-anchor syntax-symbol-anchor supers
-syn keyword cljFunc unchecked-add unchecked-dec unchecked-divide
-syn keyword cljFunc unchecked-inc unchecked-multiply unchecked-negate
-syn keyword cljFunc unchecked-subtract underive xml-seq trampoline
-syn keyword cljFunc atom compare-and-set! ifn? gen-interface
-syn keyword cljFunc intern init-proxy io! memoize proxy-name swap!
-syn keyword cljFunc release-pending-sends the-ns unquote while
-syn keyword cljFunc unchecked-remainder alter-meta!
-syn keyword cljFunc future-call methods mod pcalls prefers pvalues
-syn keyword cljFunc print-namespace-doc reset!
-syn keyword cljFunc reset-meta! type vary-meta unquote-splicing
-syn keyword cljFunc sequence clojure-version counted?
-syn keyword cljFunc chunk-buffer chunk-append chunk chunk-first
-syn keyword cljFunc chunk-rest chunk-next chunk-cons chunked-seq?
-syn keyword cljFunc deliver future? future-done? future-cancel
-syn keyword cljFunc future-cancelled? get-method promise
-syn keyword cljFunc ref-history-count ref-min-history ref-max-history
-syn keyword cljFunc agent-error assoc! boolean-array booleans bound-fn*
-syn keyword cljFunc bound? byte-array bytes char-array char? chars
-syn keyword cljFunc conj! denominator disj! dissoc! error-handler
-syn keyword cljFunc error-mode extenders extends? find-protocol-impl
-syn keyword cljFunc find-protocol-method flatten frequencies
-syn keyword cljFunc get-thread-bindings group-by hash-combine juxt
-syn keyword cljFunc munge namespace-munge numerator object-array
-syn keyword cljFunc partition-all partition-by persistent! pop!
-syn keyword cljFunc pop-thread-bindings push-thread-bindings rand-nth
-syn keyword cljFunc reductions remove-all-methods restart-agent
-syn keyword cljFunc satisfies? set-error-handler! set-error-mode!
-syn keyword cljFunc short-array shorts shuffle sorted-set-by take-last
-syn keyword cljFunc thread-bound? transient vector-of with-bindings* fnil
-syn keyword cljFunc spit
-
-syn cluster cljAtomCluster contains=cljError,cljFunc,cljMacro,cljConditional,cljDefine,cljRepeat,cljException,cljConstant,cljVariable,cljSpecial,cljKeyword,cljString,cljCharacter,cljNumber,cljBoolean,cljQuote,cljUnquote,cljDispatch,cljPattern
-syn cluster cljTopCluster contains=@cljAtomCluster,cljComment,cljSexp,cljAnonFn,cljVector,cljMap,cljSet
-
-syn keyword cljTodo contained FIXME XXX TODO FIXME: XXX: TODO:
-syn match cljComment contains=cljTodo ";.*$"
-
-syn match cljKeyword "\c:\{1,2}[a-z?!\-_+*./=<>#$][a-z0-9?!\-_+*\./=<>#$]*"
-
-syn region cljString start=/L\="/ skip=/\\\\\|\\"/ end=/"/
-
-syn match cljCharacter "\\."
-syn match cljCharacter "\\[0-7]\{3\}"
-syn match cljCharacter "\\u[0-9]\{4\}"
-syn match cljCharacter "\\space"
-syn match cljCharacter "\\tab"
-syn match cljCharacter "\\newline"
-syn match cljCharacter "\\return"
-syn match cljCharacter "\\backspace"
-syn match cljCharacter "\\formfeed"
-
-let radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
-for radix in range(2, 36)
- execute 'syn match cljNumber "\c\<-\?' . radix . 'r['
- \ . strpart(radixChars, 0, radix)
- \ . ']\+\>"'
-endfor
-
-syn match cljNumber "\<-\=[0-9]\+\(\.[0-9]*\)\=\(M\|\([eE][-+]\?[0-9]\+\)\)\?\>"
-syn match cljNumber "\<-\=0x[0-9a-fA-F]\+\>"
-syn match cljNumber "\<-\=[0-9]\+/[0-9]\+\>"
-
-syn match cljQuote "\('\|`\)"
-syn match cljUnquote "\(\~@\|\~\)"
-syn match cljDispatch "\(#^\|#'\)"
-
-syn match cljAnonArg contained "%\(\d\|&\)\?"
-syn match cljVarArg contained "&"
-
-syn region cljSexpLevel0 matchgroup=cljParen0 start="(" matchgroup=cljParen0 end=")" contains=@cljTopCluster,cljSexpLevel1
-syn region cljSexpLevel1 matchgroup=cljParen1 start="(" matchgroup=cljParen1 end=")" contained contains=@cljTopCluster,cljSexpLevel2
-syn region cljSexpLevel2 matchgroup=cljParen2 start="(" matchgroup=cljParen2 end=")" contained contains=@cljTopCluster,cljSexpLevel3
-syn region cljSexpLevel3 matchgroup=cljParen3 start="(" matchgroup=cljParen3 end=")" contained contains=@cljTopCluster,cljSexpLevel4
-syn region cljSexpLevel4 matchgroup=cljParen4 start="(" matchgroup=cljParen4 end=")" contained contains=@cljTopCluster,cljSexpLevel5
-syn region cljSexpLevel5 matchgroup=cljParen5 start="(" matchgroup=cljParen5 end=")" contained contains=@cljTopCluster,cljSexpLevel6
-syn region cljSexpLevel6 matchgroup=cljParen6 start="(" matchgroup=cljParen6 end=")" contained contains=@cljTopCluster,cljSexpLevel7
-syn region cljSexpLevel7 matchgroup=cljParen7 start="(" matchgroup=cljParen7 end=")" contained contains=@cljTopCluster,cljSexpLevel8
-syn region cljSexpLevel8 matchgroup=cljParen8 start="(" matchgroup=cljParen8 end=")" contained contains=@cljTopCluster,cljSexpLevel9
-syn region cljSexpLevel9 matchgroup=cljParen9 start="(" matchgroup=cljParen9 end=")" contained contains=@cljTopCluster,cljSexpLevel0
-
-syn region cljAnonFn matchgroup=cljParen0 start="#(" matchgroup=cljParen0 end=")" contains=@cljTopCluster,cljAnonArg,cljSexpLevel0
-syn region cljVector matchgroup=cljParen0 start="\[" matchgroup=cljParen0 end="\]" contains=@cljTopCluster,cljVarArg,cljSexpLevel0
-syn region cljMap matchgroup=cljParen0 start="{" matchgroup=cljParen0 end="}" contains=@cljTopCluster,cljSexpLevel0
-syn region cljSet matchgroup=cljParen0 start="#{" matchgroup=cljParen0 end="}" contains=@cljTopCluster,cljSexpLevel0
-
-syn region cljPattern start=/L\=\#"/ skip=/\\\\\|\\"/ end=/"/
-
-syn region cljCommentSexp start="(" end=")" transparent contained contains=cljCommentSexp
-syn region cljComment matchgroup=cljParen0 start="(comment"rs=s+1 matchgroup=cljParen0 end=")" contains=cljCommentSexp
-syn region cljComment start="#!" end="\n"
-syn match cljComment "#_"
-
-syn sync fromstart
-
-" Create a convenience higlighting command
-if version >= 600
- command -nargs=+ HiLink highlight default link <args>
-else
- command -nargs=+ HiLink highlight link <args>
-endif
-
-HiLink cljConstant Constant
-HiLink cljBoolean Boolean
-HiLink cljCharacter Character
-HiLink cljKeyword Operator
-HiLink cljNumber Number
-HiLink cljString String
-HiLink cljPattern Constant
-
-HiLink cljVariable Identifier
-HiLink cljCond Conditional
-HiLink cljDefine Define
-HiLink cljException Exception
-HiLink cljFunc Function
-HiLink cljMacro Macro
-HiLink cljRepeat Repeat
-
-HiLink cljQuote Special
-HiLink cljUnquote Special
-HiLink cljDispatch Special
-HiLink cljAnonArg Special
-HiLink cljVarArg Special
-HiLink cljSpecial Special
-
-HiLink cljComment Comment
-HiLink cljTodo Todo
-
-HiLink cljError Error
-
-if &background == "dark"
- highlight default cljParen1 ctermfg=yellow guifg=orange1
- highlight default cljParen2 ctermfg=green guifg=yellow1
- highlight default cljParen3 ctermfg=cyan guifg=greenyellow
- highlight default cljParen4 ctermfg=magenta guifg=green1
- highlight default cljParen5 ctermfg=red guifg=springgreen1
- highlight default cljParen6 ctermfg=yellow guifg=cyan1
- highlight default cljParen7 ctermfg=green guifg=slateblue1
- highlight default cljParen8 ctermfg=cyan guifg=magenta1
- highlight default cljParen9 ctermfg=magenta guifg=purple1
-else
- highlight default cljParen1 ctermfg=darkyellow guifg=orangered3
- highlight default cljParen2 ctermfg=darkgreen guifg=orange2
- highlight default cljParen3 ctermfg=blue guifg=yellow3
- highlight default cljParen4 ctermfg=darkmagenta guifg=olivedrab4
- highlight default cljParen5 ctermfg=red guifg=green4
- highlight default cljParen6 ctermfg=darkyellow guifg=paleturquoise3
- highlight default cljParen7 ctermfg=darkgreen guifg=deepskyblue4
- highlight default cljParen8 ctermfg=blue guifg=darkslateblue
- highlight default cljParen9 ctermfg=darkmagenta guifg=darkviolet
-endif
-
-" delete our temporary command
-delcommand HiLink
-
--- /dev/null
+let s:tree_up_dir_line = '.. (up a dir)'
+"NERDTreeFlags are syntax items that should be invisible, but give clues as to
+"how things should be highlighted
+syn match NERDTreeFlag #\~#
+syn match NERDTreeFlag #\[RO\]#
+
+"highlighting for the .. (up dir) line at the top of the tree
+execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
+
+"highlighting for the ~/+ symbols for the directory nodes
+syn match NERDTreeClosable #\~\<#
+syn match NERDTreeClosable #\~\.#
+syn match NERDTreeOpenable #+\<#
+syn match NERDTreeOpenable #+\.#he=e-1
+
+"highlighting for the tree structural parts
+syn match NERDTreePart #|#
+syn match NERDTreePart #`#
+syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
+
+"quickhelp syntax elements
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
+syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
+syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
+syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
+syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
+syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
+
+"highlighting for readonly files
+syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
+
+"highlighting for sym links
+syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
+
+"highlighing for directory nodes and file nodes
+syn match NERDTreeDirSlash #/#
+syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
+syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
+syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
+syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
+syn match NERDTreeCWD #^[</].*$#
+
+"highlighting for bookmarks
+syn match NERDTreeBookmark # {.*}#hs=s+1
+
+"highlighting for the bookmarks table
+syn match NERDTreeBookmarksLeader #^>#
+syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
+syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
+syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
+
+if exists("g:NERDChristmasTree") && g:NERDChristmasTree
+ hi def link NERDTreePart Special
+ hi def link NERDTreePartFile Type
+ hi def link NERDTreeFile Normal
+ hi def link NERDTreeExecFile Title
+ hi def link NERDTreeDirSlash Identifier
+ hi def link NERDTreeClosable Type
+else
+ hi def link NERDTreePart Normal
+ hi def link NERDTreePartFile Normal
+ hi def link NERDTreeFile Normal
+ hi def link NERDTreeClosable Title
+endif
+
+hi def link NERDTreeBookmarksHeader statement
+hi def link NERDTreeBookmarksLeader ignore
+hi def link NERDTreeBookmarkName Identifier
+hi def link NERDTreeBookmark normal
+
+hi def link NERDTreeHelp String
+hi def link NERDTreeHelpKey Identifier
+hi def link NERDTreeHelpCommand Identifier
+hi def link NERDTreeHelpTitle Macro
+hi def link NERDTreeToggleOn Question
+hi def link NERDTreeToggleOff WarningMsg
+
+hi def link NERDTreeDir Directory
+hi def link NERDTreeUp Directory
+hi def link NERDTreeCWD Statement
+hi def link NERDTreeLink Macro
+hi def link NERDTreeOpenable Title
+hi def link NERDTreeFlag ignore
+hi def link NERDTreeRO WarningMsg
+hi def link NERDTreeBookmark Statement
+
+hi def link NERDTreeCurrentNode Search
+++ /dev/null
-" Syntax highlighting for snippet files (used for snipMate.vim)
-" Hopefully this should make snippets a bit nicer to write!
-syn match snipComment '^#.*'
-syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
-syn match tabStop '\$\d\+'
-syn match snipCommand '`.\{-}`'
-syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
-syn match multiSnipText '\S\+ \zs.*' contained
-syn match snipKeyword '^snippet'me=s+8 contained
-syn match snipError "^[^#s\t].*$"
-
-hi link snipComment Comment
-hi link multiSnipText String
-hi link snipKeyword Keyword
-hi link snipComment Comment
-hi link placeHolder Special
-hi link tabStop Special
-hi link snipCommand String
-hi link snipError Error
-"==============================================================================
-" Wish List
-"==============================================================================
-" Less buggy session restore
-" Default window setup
-
"==============================================================================
" General Settings
"==============================================================================
set nocompatible " Disable VI compatibility
set backspace=indent,eol,start " Makes backspace work as expected
set whichwrap+=<,>,[,],h,l " Make cursor keys wrap lines
-set autoindent " Indent follows previous line
+set autoindent " turn on auto indent
+set copyindent " Indent follows previous line
set tabstop=4 " Tabs equivalent to 4 spaces
-set shiftwidth=4 " Sets the size used for vims reindent operator ( Shift-> and Shift-< )
+set shiftwidth=4 " Sets the size used for Vim's re-indent operator ( Shift-> and Shift-< )
+set expandtab " Expand tabs to spaces
+set softtabstop=4 " Backspace over expanded tabs
set number " Turn on line numbering
set colorcolumn=80 " Draw right margin at 80 chars
set nowrap " Turn off line wrapping so long lines extend off screen
set foldmethod=syntax " Enable folds defined by syntax (i.e. functions)
set foldlevelstart=100 " Open all folds by default
-set so=7 " scrolling activates at 7 lines from the top or bottom of screen
+set so=5 " scrolling activates at 7 lines from the top or bottom of screen
+set nobackup " Do not create backup files before editing
+set nowritebackup " Do not create backup files before writing
+set noswapfile " Do not create a swap file for files before editing
set ruler " Always show current cursor position
set showmatch " Highlight matching braces
-set vb t_vb= " Turn off visual and error bells
-set cursorline " Highlights current line
+set mat=2 " How long to blink matching braces for
+set visualbell t_vb= " Turn off visual and error bells
+set noerrorbells " Turn off auditory bells
set hid " Change buffer without saving
set clipboard=unnamed " Yank and Put commands use the system clipboard
-set hlsearch " Turn on search higlighting
-set laststatus=2 " Turn on status line all the time
+set laststatus=0 " Turn off the status line
+set undodir=~/vimfiles/undo " Set directory for storing undo files
+set undofile " Turn on persistent undo
+set cscopetag " Search both cscope dbs and ctags files for tags
+set csto=0 " Search cscope dbs before ctags files
+set history=20 " Save 20 lines of command history
+set hlsearch " Turn on search highlighting
set ignorecase " Ignore case in searches
+set smartcase " Don't ignore case when search term contains capitals
+set incsearch " Highlight search string as you type
+set tags=tags;/ " Search from current directory to root for ctags db
+set fileformats=unix,dos,mac " support all three, in this order
+set list " Show control and whitespace characters (tabs, spaces, etc.)
+set listchars=tab:>-,trail:- " Show only trailing spaces and tabs
+setlocal spell spelllang=en_us " Turn on spell checking
+set lazyredraw " Don't redraw unless we need to
+"set cursorline " Highlights current line
+"set textwidth=79 " Wrap to next line if the next character is at the margin
"==============================================================================
-" More Complicated Settings
+" Function and Command Definitions
"==============================================================================
-"---- Turn off backup and swap files ----
-set nobackup
-set nowb
-set noswapfile
-
-"---- OmniComplete ----
-filetype plugin on
-set ofu=syntaxcomplete#Complete
-set completeopt=longest,menuone
-highlight Pmenu guibg=blue gui=bold
-
-"---- Wild Mode ----
-set wildmenu " Turns on auto complete for vim command line
-set wildmode=full
-
-"---- Persistent Undo ----
-set undodir=~/vimfiles/undo " Set directory for storing undo files
-set undofile " Turn on persistent undo
-
-"---- CScope ----
-set cscopetag " Search both cscope dbs and ctags files for tags
-set csto=0 " Search cscope dbs before ctags files
-
-"---- Make the Home and End keys smarter ----
-noremap <expr> <Home> (col('.') == matchend(getline('.'), '^\s*')+1 ? '0' : '^')
-noremap <expr> <End> (col('.') == match(getline('.'), '\s*$') ? '$' : 'g_')
-vnoremap <expr> <End> (col('.') == match(getline('.'), '\s*$') ? '$h' : 'g_')
-imap <Home> <C-o><Home>
-imap <End> <C-o><End>
-
-"---- Save Session on Exit ----
-augroup autosession
-autocmd autosession BufRead,VimLeave * mksession! ~/.vimsession
-function! RestoreSession()
- autocmd! autosession
- source ~/.vimsession
- autocmd autosession BufRead,VimLeave * mksession! ~/.vimsession
+function! LoadCscope()
+ let db = findfile("cscope.out", ".;")
+ if (!empty(db))
+ let path = strpart(db, 0, match(db, "[\\\/]cscope.out$"))
+ set nocscopeverbose " suppress 'duplicate connection' error
+ exe "cs add " . db . " " . path
+ set cscopeverbose
+ endif
endfunction
-"---- Status Line ----
-set statusline=\ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L\ \ Column:\ %c\ \ %F%m%r%h\ %w
-
-"---- Change to Src dir when opened without a file ----
-au VimEnter * if expand('%') == '' | cd C:\Src | endif
-
-"==============================================================================
-" Functions
-"==============================================================================
-function! LoadCCTreeDB()
- CCTreeUnLoadDB
- let dir = GetCScopeDir() . "/cscope.out"
- execute("CCTreeLoadDB " . dir)
-endfunction
-
-function! CurDir()
- let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
- return curdir
+function! SwitchToProjectDir()
+ let db = findfile("rakefile.rb", ".;")
+ if (!empty(db))
+ let path = strpart(db, 0, match(db, "[\\\/]rakefile.rb$"))
+ exec "cd " . path
+ endif
endfunction
-"==============================================================================
-" Commands
-"==============================================================================
-" ---- Vimrc - Edit vimrc file ----
-command! Vimrc :e ~/.vimrc
-
-" ---- Print - Print the current file ----
-command! Print :hardcopy
-
-" ---- Split - Splits the selection into multiple lines based on whitespace ----
-command! -range=% -nargs=0 Split execute "<line1>,<line2>s/\\s\\+/\r/g"
-
-" ---- Trim - Trims trailing white space from the end of every line ----
-command! -range=% -nargs=0 Trim execute "<line1>,<line2>s/\\s\\+$//"
-
-" ---- ToSpaces - Converts leading tabs to spaces ----
-command! -range=% -nargs=0 ToSpaces execute "<line1>,<line2>s/^\\t\\+/\\=substitute(submatch(0), '\\t', repeat(' ', ".&ts."), 'g')"
-
-" ---- ToTabs - Converts leading spaces to tabs ----
-command! -range=% -nargs=0 ToTabs execute "<line1>,<line2>s/^\\( \\{".&ts."\\}\\)\\+/\\=substitute(submatch(0), ' \\{".&ts."\\}', '\\t', 'g')"
-
-" ---- Trim - Trims trailing white space from the end of every line ----
-command! -range=% -nargs=0 NoCR execute "<line1>,<line2>s/\\r//"
-
-" ---- Snippets - Opens a file browser in the snippets directory ----
-command! Snippets :Ex $HOME/vimfiles/snippets
-
-" ---- ToFns - Converts a group of C function prototypes to definitions ----
+" ---- ToFn - Converts a group of C function prototypes to definitions ----
command! -range=% -nargs=0 ToFn execute "<line1>,<line2>s/;/\r{\r\r}\r/"
"==============================================================================
" Keyboard Mappings
"==============================================================================
-" ---- Previous Buffer ----
-map <C-S-tab> :bp<CR>
-imap <C-S-tab> <ESC>:bp<CR>
-
-" ---- Next Buffer ----
-map <C-tab> :bn<CR>
-imap <C-tab> <ESC>:bn<CR>
-
-" ---- Delete Buffer (Keep Windows) ----
-map ;d :Kwbd<CR>
-
-" ---- Directory Listing ----
-map ;o :Ex<CR>
-
-" ---- List Buffers ----
-map ;bl :buffers<CR>:buffer
-
-" ---- Restore Buffer ----
-map ;br :call BufferRestore()<CR>
-
-" ---- Block Comment ----
-map ;cc <plug>NERDCommenterComment
-
-" ---- Block Uncomment ----
-map ;cu <plug>NERDCommenterUncomment
-
-" ---- Restore Previous Session ----
-map ;sr :call RestoreSession()<CR>
+" ---- Define Map Leader ----
+let mapleader = ";"
+let g:mapleader = ";"
" ---- Toggle Fold ----
map zz <ESC>za
-" ---- Unindent Visual Block ----
+" ---- Indenting Visual Blocks ----
vnoremap < <gv
-
-" ---- Indent Visual Block ----
vnoremap > >gv
-" ---- Swap current line with line below ----
+" ---- Tab Triggers Omni Complete ----
+inoremap <tab> <C-n>
+inoremap <S-tab> <C-p>
+
+" ---- Buffer Management ----
+map <C-S-tab> :bp<CR>
+imap <C-S-tab> <ESC>:bp<CR>
+map <C-tab> :bn<CR>
+imap <C-tab> <ESC>:bn<CR>
+map <Leader>d :bd<CR>
+imap <Leader>d <ESC>:bd<CR>
+
+" ---- Working With Windows ----
+map <M-h> <C-w>h
+map <M-j> <C-w>j
+map <M-k> <C-w>k
+map <M-l> <C-w>l
+map <M-c> <C-w>c
+map <M-v> :vs<CR>
+map <M-h> :split<CR>
+
+" ---- Moving Lines Around ----
nmap <C-j> ddp
imap <C-j> <ESC>ddpi
-
-" ---- Swap current line with line above ----
nmap <C-k> ddkP
imap <C-k> <ESC>ddkPi
-" ---- Update CTags file ----
-map <F2> <ESC>:call RebuildTagsFile()<CR>
-
-" ---- Update CScope Database ----
-map <F3> <ESC>:call RebuildCScopeDB()<CR>
-
-" ---- Open new file for editing ----
-map <F4> <ESC>:enew<CR>i
-
-" ---- Switch between header and C file ----
-map <F5> <ESC>:e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
-
-" ---- Fast File Open using CScope ----
-map ;f <ESC>:execute('cs find f ' . input('Filename: '))<CR>
+" ---- CScope Mappings ----
+map <Leader>fs :cs find s <cword><CR>
+map <Leader>fg :cs find g <cword><CR>
+map <Leader>fd :cs find d <cword><CR>
+map <Leader>fc :cs find c <cword><CR>
+map <Leader>ft :cs find t <cword><CR>
+map <Leader>fe :cs find e <cword><CR>
+map <Leader>ff :cs find f <cword><CR>
+map <Leader>fi :cs find i <cword><CR>
-" ---- Clear higlighting from last search ----
-map ;h <ESC>:nohl<CR>
-
-" ---- Toggle NERD Tree side bar ----
-map ;t <ESC>:NERDTreeToggle<CR>
-
-" ---- CScope Loader Mappings ----
-" Find all references to token under cursor
-map \fs <ESC>:CSFindS<CR>
-
-" Find global definitions of token under cursor
-map \fg <ESC>:CSFindG<CR>
-
-" Find functions called by function under cursor
-map \fd <ESC>:CSFindD<CR>
+"==============================================================================
+" Abbreviations
+"==============================================================================
+abbreviate inc #include
+abbreviate def #define
+abbreviate ifndef #ifndef<CR>#endif<up><END>
+abbreviate prf printf("");<left><left><left>
-" Find functions calling function under cursor
-map \fc <ESC>:CSFindC<CR>
-" Find text under cursor
-map \ft <ESC>:CSFindT<CR>
+cnoreabbrev trim %s/\s\+$//
+cnoreabbrev print hardcopy
+cnoreabbrev tofn ToFn
+cnoreabbrev fn ToFn
+cnoreabbrev <expr> ff
+ \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs f f' : 'ff')
-" Egrep for text under cursor
-map \fe <ESC>:CSFindE<CR>
+"==============================================================================
+" Auto Commands
+"==============================================================================
+" Auto locate and connect to cscope db.
+au BufEnter * call SwitchToProjectDir()
-" Find file under cursor
-map \ff <ESC>:CSFindF<CR>
+" Auto locate and connect to cscope db.
+au BufEnter * call LoadCscope()
-" Find files including filename under cursor
-map \fi <ESC>:CSFindI<CR>
+" Replace all tabs with spaces
+au BufEnter * retab
-" Load CScope database with CCTree plugin (for call tree generation)
-map <C-\>l <ESC>:call LoadCCTreeDB()<CR>
+" Trim any trailing whitespace
+au BufEnter * silent! exec("%s/\\s\\+$//")
"==============================================================================
" GVim
"==============================================================================
if has('gui_running')
- set guioptions-=T " no toolbar
- set guioptions-=m " no menubar
- set guioptions+=b " enable horizontal tabbar
- set guifont=Monaco:h10 " use 10 point monaco font in gui mode
+ set guioptions-=T " no toolbar
+ set guioptions-=m " no menubar
+ set guifont=Monaco:h10 " use 10 point Monaco font in gui mode
- " GVim resets this for some stupid reason so disable visual bell ... again
- autocmd GUIEnter * set visualbell t_vb=
-
- " GVim specific commands
- command! Menu :set guioptions+=m
- command! NoMenu :set guioptions-=m
+ " GVim resets this for some stupid reason so disable visual bell ... again
+ autocmd GUIEnter * set visualbell t_vb=
endif
-