422
homedir/.vim/autoload/acp.vim
Normal file
422
homedir/.vim/autoload/acp.vim
Normal file
@@ -0,0 +1,422 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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: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 l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
|
||||
\ '&spell', 0)
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
|
||||
\ '&completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
|
||||
\ '&complete', g:acp_completeOption)
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_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 l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
|
||||
\ '&lazyredraw', !g:acp_mappingDriven)
|
||||
" NOTE: 'textwidth' must be restored after <C-e>.
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_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 l9#tempvariables#end(s:TEMP_VARIABLES_GROUP0)
|
||||
if a:fGroup1
|
||||
call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:setCompletefunc()
|
||||
if exists('s:behavsCurrent[s:iBehavs].completefunc')
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
|
||||
\ '&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:TEMP_VARIABLES_GROUP0 = "AutoComplPop0"
|
||||
let s:TEMP_VARIABLES_GROUP1 = "AutoComplPop1"
|
||||
let s:lockCount = 0
|
||||
let s:behavsCurrent = []
|
||||
let s:iBehavs = 0
|
||||
let s:snipItems = {}
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
244
homedir/.vim/colors/apprentice.vim
Normal file
244
homedir/.vim/colors/apprentice.vim
Normal file
@@ -0,0 +1,244 @@
|
||||
" 'apprentice.vim' -- Vim color scheme.
|
||||
" Maintainer: Romain Lafourcade (romainlafourcade@gmail.com)
|
||||
" Essentially a streamlining and conversion to xterm colors of
|
||||
" 'sorcerer' by Jeet Sukumaran (jeetsukumaran@gmailcom)
|
||||
|
||||
" MADE-UP NAME HEX RGB XTERM ANSI
|
||||
" ========================================================================
|
||||
" almost black #1c1c1c rgb(28, 28, 28) 234 0
|
||||
" darker grey #262626 rgb(38, 38, 38) 235 background color
|
||||
" dark grey #303030 rgb(48, 48, 48) 236 8
|
||||
" grey #444444 rgb(68, 68, 68) 238 8
|
||||
" medium grey #585858 rgb(88, 88, 88) 240 8
|
||||
" light grey #6c6c6c rgb(108, 108, 108) 242 7
|
||||
" lighter grey #bcbcbc rgb(188, 188, 188) 250 foreground color
|
||||
" white #ffffff rgb(255, 255, 255) 231 15
|
||||
" purple #5f5f87 rgb(95, 95, 135) 60 5
|
||||
" light purple #8787af rgb(135, 135, 175) 103 13
|
||||
" green #5f875f rgb(95, 135, 95) 65 2
|
||||
" light green #87af87 rgb(135, 175, 135) 108 10
|
||||
" aqua #5f8787 rgb(95, 135, 135) 66 6
|
||||
" light aqua #5fafaf rgb(95, 175, 175) 73 14
|
||||
" blue #5f87af rgb(95, 135, 175) 67 4
|
||||
" light blue #8fafd7 rgb(143, 175, 215) 110 12
|
||||
" red #af5f5f rgb(175, 95, 95) 131 1
|
||||
" orange #ff8700 rgb(255, 135, 0) 208 9
|
||||
" ocre #87875f rgb(135, 135, 95) 101 3
|
||||
" yellow #ffffaf rgb(255, 255, 175) 229 11
|
||||
|
||||
hi clear
|
||||
|
||||
if exists('syntax_on')
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
set background=dark
|
||||
|
||||
let colors_name = 'apprentice'
|
||||
|
||||
if &t_Co >= 256 || has('gui_running')
|
||||
hi Normal ctermbg=235 ctermfg=250 guibg=#262626 guifg=#bcbcbc cterm=NONE gui=NONE
|
||||
|
||||
set background=dark
|
||||
|
||||
hi Comment ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
|
||||
hi Constant ctermbg=NONE ctermfg=208 guibg=NONE guifg=#ff8700 cterm=NONE gui=NONE
|
||||
hi Error ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=reverse gui=reverse
|
||||
hi Identifier ctermbg=NONE ctermfg=67 guibg=NONE guifg=#5f87af cterm=NONE gui=NONE
|
||||
hi Ignore ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
|
||||
hi PreProc ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE
|
||||
hi Special ctermbg=NONE ctermfg=65 guibg=NONE guifg=#5f875f cterm=NONE gui=NONE
|
||||
hi Statement ctermbg=NONE ctermfg=110 guibg=NONE guifg=#8fafd7 cterm=NONE gui=NONE
|
||||
hi String ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE
|
||||
hi Todo ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=reverse gui=reverse
|
||||
hi Type ctermbg=NONE ctermfg=103 guibg=NONE guifg=#8787af cterm=NONE gui=NONE
|
||||
hi Underlined ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=underline gui=underline
|
||||
|
||||
hi LineNr ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
|
||||
hi NonText ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
|
||||
|
||||
hi Pmenu ctermbg=238 ctermfg=250 guibg=#444444 guifg=#bcbcbc cterm=NONE gui=NONE
|
||||
hi PmenuSbar ctermbg=240 ctermfg=NONE guibg=#585858 guifg=NONE cterm=NONE gui=NONE
|
||||
hi PmenuSel ctermbg=66 ctermfg=235 guibg=#5f8787 guifg=#262626 cterm=NONE gui=NONE
|
||||
hi PmenuThumb ctermbg=66 ctermfg=66 guibg=#5f8787 guifg=#5f8787 cterm=NONE gui=NONE
|
||||
|
||||
hi ErrorMsg ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
|
||||
hi ModeMsg ctermbg=108 ctermfg=235 guibg=#87af87 guifg=#262626 cterm=NONE gui=NONE
|
||||
hi MoreMsg ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE
|
||||
hi Question ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE
|
||||
hi WarningMsg ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=NONE gui=NONE
|
||||
|
||||
hi TabLine ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=NONE
|
||||
hi TabLineFill ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE
|
||||
hi TabLineSel ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE
|
||||
|
||||
hi Cursor ctermbg=242 ctermfg=NONE guibg=#6c6c6c guifg=NONE cterm=NONE gui=NONE
|
||||
hi CursorColumn ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE
|
||||
hi CursorLine ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE
|
||||
hi CursorLineNr ctermbg=236 ctermfg=73 guibg=#303030 guifg=#5fafaf cterm=NONE gui=NONE
|
||||
|
||||
hi helpLeadBlank ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
|
||||
hi helpNormal ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
|
||||
|
||||
hi StatusLine ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE
|
||||
hi StatusLineNC ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=italic
|
||||
|
||||
hi Visual ctermbg=110 ctermfg=235 guibg=#8fafd7 guifg=#262626 cterm=NONE gui=NONE
|
||||
hi VisualNOS ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=underline gui=underline
|
||||
|
||||
hi FoldColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
|
||||
hi Folded ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
|
||||
|
||||
hi VertSplit ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE
|
||||
hi WildMenu ctermbg=110 ctermfg=235 guibg=#8fafd7 guifg=#262626 cterm=NONE gui=NONE
|
||||
|
||||
hi Function ctermbg=NONE ctermfg=229 guibg=NONE guifg=#ffffaf cterm=NONE gui=NONE
|
||||
hi SpecialKey ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
|
||||
hi Title ctermbg=NONE ctermfg=231 guibg=NONE guifg=#ffffff cterm=NONE gui=NONE
|
||||
|
||||
hi DiffAdd ctermbg=108 ctermfg=235 guibg=#87af87 guifg=#262626 cterm=NONE gui=NONE
|
||||
hi DiffChange ctermbg=60 ctermfg=235 guibg=#5f5f87 guifg=#262626 cterm=NONE gui=NONE
|
||||
hi DiffDelete ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
|
||||
hi DiffText ctermbg=103 ctermfg=235 guibg=#8787af guifg=#262626 cterm=NONE gui=NONE
|
||||
|
||||
hi IncSearch ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
|
||||
hi Search ctermbg=229 ctermfg=235 guibg=#ffffaf guifg=#262626 cterm=NONE gui=NONE
|
||||
|
||||
hi Directory ctermbg=NONE ctermfg=73 guibg=NONE guifg=#5fafaf cterm=NONE gui=NONE
|
||||
hi MatchParen ctermbg=234 ctermfg=229 guibg=#1c1c1c guifg=#ffffaf cterm=NONE gui=NONE
|
||||
|
||||
hi SpellBad ctermbg=NONE ctermfg=131 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#af5f5f
|
||||
hi SpellCap ctermbg=NONE ctermfg=73 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5fafaf
|
||||
hi SpellLocal ctermbg=NONE ctermfg=65 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5f875f
|
||||
hi SpellRare ctermbg=NONE ctermfg=208 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#ff8700
|
||||
|
||||
hi ColorColumn ctermbg=131 ctermfg=NONE guibg=#af5f5f guifg=NONE cterm=NONE gui=NONE
|
||||
hi signColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
|
||||
elseif &t_Co == 8 || $TERM !~# '^linux' || &t_Co == 16
|
||||
set t_Co=16
|
||||
|
||||
hi Normal ctermbg=NONE ctermfg=15 cterm=NONE
|
||||
|
||||
set background=dark
|
||||
|
||||
hi Comment ctermbg=NONE ctermfg=8 cterm=NONE
|
||||
hi Constant ctermbg=NONE ctermfg=9 cterm=NONE
|
||||
hi Function ctermbg=NONE ctermfg=11 cterm=NONE
|
||||
hi Identifier ctermbg=NONE ctermfg=4 cterm=NONE
|
||||
hi PreProc ctermbg=NONE ctermfg=6 cterm=NONE
|
||||
hi Special ctermbg=NONE ctermfg=2 cterm=NONE
|
||||
hi Statement ctermbg=NONE ctermfg=12 cterm=NONE
|
||||
hi String ctermbg=NONE ctermfg=10 cterm=NONE
|
||||
hi Todo ctermbg=NONE ctermfg=NONE cterm=reverse
|
||||
hi Type ctermbg=NONE ctermfg=13 cterm=NONE
|
||||
|
||||
hi Error ctermbg=NONE ctermfg=1 cterm=reverse
|
||||
hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE
|
||||
hi Underlined ctermbg=NONE ctermfg=6 cterm=underline
|
||||
|
||||
hi LineNr ctermbg=0 ctermfg=7 cterm=NONE
|
||||
hi NonText ctermbg=NONE ctermfg=8 cterm=NONE
|
||||
|
||||
hi Pmenu ctermbg=8 ctermfg=15 cterm=NONE
|
||||
hi PmenuSbar ctermbg=7 ctermfg=NONE cterm=NONE
|
||||
hi PmenuSel ctermbg=6 ctermfg=0 cterm=NONE
|
||||
hi PmenuThumb ctermbg=6 ctermfg=NONE cterm=NONE
|
||||
|
||||
hi ErrorMsg ctermbg=1 ctermfg=0 cterm=NONE
|
||||
hi ModeMsg ctermbg=2 ctermfg=0 cterm=NONE
|
||||
hi MoreMsg ctermbg=NONE ctermfg=6 cterm=NONE
|
||||
hi Question ctermbg=NONE ctermfg=10 cterm=NONE
|
||||
hi WarningMsg ctermbg=NONE ctermfg=1 cterm=NONE
|
||||
|
||||
hi TabLine ctermbg=8 ctermfg=3 cterm=NONE
|
||||
hi TabLineFill ctermbg=8 ctermfg=0 cterm=NONE
|
||||
hi TabLineSel ctermbg=3 ctermfg=0 cterm=NONE
|
||||
|
||||
hi Cursor ctermbg=NONE ctermfg=NONE cterm=NONE
|
||||
hi CursorColumn ctermbg=8 ctermfg=NONE cterm=NONE
|
||||
hi CursorLine ctermbg=NONE ctermfg=NONE cterm=underline
|
||||
hi CursorLineNr ctermbg=0 ctermfg=14 cterm=NONE
|
||||
|
||||
hi helpLeadBlank ctermbg=NONE ctermfg=NONE cterm=NONE
|
||||
hi helpNormal ctermbg=NONE ctermfg=NONE cterm=NONE
|
||||
|
||||
hi StatusLine ctermbg=3 ctermfg=0 cterm=NONE
|
||||
hi StatusLineNC ctermbg=8 ctermfg=0 cterm=NONE
|
||||
|
||||
hi Visual ctermbg=12 ctermfg=0 cterm=NONE
|
||||
hi VisualNOS ctermbg=NONE ctermfg=NONE cterm=underline
|
||||
|
||||
hi FoldColumn ctermbg=0 ctermfg=8 cterm=NONE
|
||||
hi Folded ctermbg=0 ctermfg=8 cterm=NONE
|
||||
|
||||
hi VertSplit ctermbg=8 ctermfg=8 cterm=NONE
|
||||
hi WildMenu ctermbg=12 ctermfg=0 cterm=NONE
|
||||
|
||||
hi SpecialKey ctermbg=NONE ctermfg=8 cterm=NONE
|
||||
hi Title ctermbg=NONE ctermfg=15 cterm=NONE
|
||||
|
||||
hi DiffAdd ctermbg=2 ctermfg=0 cterm=NONE
|
||||
hi DiffChange ctermbg=6 ctermfg=0 cterm=NONE
|
||||
hi DiffDelete ctermbg=1 ctermfg=0 cterm=NONE
|
||||
hi DiffText ctermbg=11 ctermfg=0 cterm=NONE
|
||||
|
||||
hi IncSearch ctermbg=1 ctermfg=0 cterm=NONE
|
||||
hi Search ctermbg=11 ctermfg=0 cterm=NONE
|
||||
|
||||
hi Directory ctermbg=NONE ctermfg=14 cterm=NONE
|
||||
hi MatchParen ctermbg=0 ctermfg=11 cterm=NONE
|
||||
|
||||
hi SpellBad ctermbg=NONE ctermfg=1 cterm=undercurl
|
||||
hi SpellCap ctermbg=NONE ctermfg=3 cterm=undercurl
|
||||
hi SpellLocal ctermbg=NONE ctermfg=2 cterm=undercurl
|
||||
hi SpellRare ctermbg=NONE ctermfg=5 cterm=undercurl
|
||||
|
||||
hi ColorColumn ctermbg=1 ctermfg=NONE cterm=NONE
|
||||
hi SignColumn ctermbg=0 ctermfg=8 cterm=NONE
|
||||
endif
|
||||
|
||||
hi link Boolean Constant
|
||||
hi link Character Constant
|
||||
hi link Conceal Normal
|
||||
hi link Conditional Statement
|
||||
hi link Debug Special
|
||||
hi link Define PreProc
|
||||
hi link Delimiter Special
|
||||
hi link Exception Statement
|
||||
hi link Float Number
|
||||
hi link HelpCommand Statement
|
||||
hi link HelpExample Statement
|
||||
hi link Include PreProc
|
||||
hi link Keyword Statement
|
||||
hi link Label Statement
|
||||
hi link Macro PreProc
|
||||
hi link Number Constant
|
||||
hi link Operator Statement
|
||||
hi link PreCondit PreProc
|
||||
hi link Repeat Statement
|
||||
hi link SpecialChar Special
|
||||
hi link SpecialComment Special
|
||||
hi link StorageClass Type
|
||||
hi link Structure Type
|
||||
hi link Tag Special
|
||||
hi link Typedef Type
|
||||
|
||||
hi link htmlEndTag htmlTagName
|
||||
hi link htmlLink Function
|
||||
hi link htmlSpecialTagName htmlTagName
|
||||
hi link htmlTag htmlTagName
|
||||
hi link xmlTag Statement
|
||||
hi link xmlTagName Statement
|
||||
hi link xmlEndTag Statement
|
||||
|
||||
hi link markdownItalic Preproc
|
||||
|
||||
hi link diffBDiffer WarningMsg
|
||||
hi link diffCommon WarningMsg
|
||||
hi link diffDiffer WarningMsg
|
||||
hi link diffIdentical WarningMsg
|
||||
hi link diffIsA WarningMsg
|
||||
hi link diffNoEOL WarningMsg
|
||||
hi link diffOnly WarningMsg
|
||||
hi link diffRemoved WarningMsg
|
||||
hi link diffAdded String
|
519
homedir/.vim/doc/acp.txt
Normal file
519
homedir/.vim/doc/acp.txt
Normal file
@@ -0,0 +1,519 @@
|
||||
*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 are disgusted to make your runtime directory confused with a lot of
|
||||
plugins, put each of the plugins into a directory individually and just add
|
||||
the directory path to 'runtimepath'. It's easy to uninstall plugins.
|
||||
|
||||
Then update your help tags files to enable help for this plugin. See
|
||||
|add-local-help| for details.
|
||||
|
||||
Requirements: ~
|
||||
|
||||
- L9 library (vimscript #3252)
|
||||
|
||||
|
||||
==============================================================================
|
||||
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*
|
||||
|
||||
3.0: [TODO]
|
||||
- From this version, L9 library (vimscript #3252) is required.
|
||||
|
||||
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:
|
||||
|
1
homedir/.vim/init.vim
Symbolic link
1
homedir/.vim/init.vim
Symbolic link
@@ -0,0 +1 @@
|
||||
/home/fbt/.vimrc
|
542
homedir/.vim/plugin/AutoClose.vim
Normal file
542
homedir/.vim/plugin/AutoClose.vim
Normal file
@@ -0,0 +1,542 @@
|
||||
scriptencoding utf-8
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" AutoClose.vim - Automatically close pair of characters: ( with ), [ with ], { with }, etc.
|
||||
" Version: 2.0
|
||||
" Author: Thiago Alves <talk@thiagoalves.com.br>
|
||||
" Maintainer: Thiago Alves <talk@thiagoalves.com.br>
|
||||
" URL: http://thiagoalves.com.br
|
||||
" Licence: This script is released under the Vim License.
|
||||
" Last modified: 02/02/2011
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
" check if script is already loaded
|
||||
if !exists("g:debug_AutoClose") && exists("g:loaded_AutoClose")
|
||||
finish "stop loading the script"
|
||||
endif
|
||||
let g:loaded_AutoClose = 1
|
||||
|
||||
let s:global_cpo = &cpo " store compatible-mode in local variable
|
||||
set cpo&vim " go into nocompatible-mode
|
||||
|
||||
if !exists('g:AutoClosePreserveDotReg')
|
||||
let g:AutoClosePreserveDotReg = 1
|
||||
endif
|
||||
|
||||
if g:AutoClosePreserveDotReg
|
||||
" Because dot register preservation code remaps escape we have to remap
|
||||
" some terminal specific escape sequences first
|
||||
if &term =~ 'xterm' || &term =~ 'rxvt' || &term =~ 'screen' || &term =~ 'linux' || &term =~ 'gnome'
|
||||
imap <silent> <Esc>OA <Up>
|
||||
imap <silent> <Esc>OB <Down>
|
||||
imap <silent> <Esc>OC <Right>
|
||||
imap <silent> <Esc>OD <Left>
|
||||
imap <silent> <Esc>OH <Home>
|
||||
imap <silent> <Esc>OF <End>
|
||||
imap <silent> <Esc>[5~ <PageUp>
|
||||
imap <silent> <Esc>[6~ <PageDown>
|
||||
endif
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Functions
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
function! s:GetCharAhead(len)
|
||||
if col('$') == col('.')
|
||||
return "\0"
|
||||
endif
|
||||
return strpart(getline('.'), col('.')-2 + a:len, 1)
|
||||
endfunction
|
||||
|
||||
function! s:GetCharBehind(len)
|
||||
if col('.') == 1
|
||||
return "\0"
|
||||
endif
|
||||
return strpart(getline('.'), col('.') - (1 + a:len), 1)
|
||||
endfunction
|
||||
|
||||
function! s:GetNextChar()
|
||||
return s:GetCharAhead(1)
|
||||
endfunction
|
||||
|
||||
function! s:GetPrevChar()
|
||||
return s:GetCharBehind(1)
|
||||
endfunction
|
||||
|
||||
" used to implement automatic deletion of closing character when opening
|
||||
" counterpart is deleted and by space expansion
|
||||
function! s:IsEmptyPair()
|
||||
let l:prev = s:GetPrevChar()
|
||||
let l:next = s:GetNextChar()
|
||||
return (l:next != "\0") && (get(b:AutoClosePairs, l:prev, "\0") == l:next)
|
||||
endfunction
|
||||
|
||||
function! s:GetCurrentSyntaxRegion()
|
||||
return synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
|
||||
endfunction
|
||||
|
||||
function! s:GetCurrentSyntaxRegionIf(char)
|
||||
let l:origin_line = getline('.')
|
||||
let l:changed_line = strpart(l:origin_line, 0, col('.')-1) . a:char . strpart(l:origin_line, col('.')-1)
|
||||
call setline('.', l:changed_line)
|
||||
let l:region = synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
|
||||
call setline('.', l:origin_line)
|
||||
return l:region
|
||||
endfunction
|
||||
|
||||
function! s:IsForbidden(char)
|
||||
let l:result = index(b:AutoCloseProtectedRegions, s:GetCurrentSyntaxRegion()) >= 0
|
||||
if l:result
|
||||
return l:result
|
||||
endif
|
||||
let l:region = s:GetCurrentSyntaxRegionIf(a:char)
|
||||
let l:result = index(b:AutoCloseProtectedRegions, l:region) >= 0
|
||||
return l:result || l:region == 'Comment'
|
||||
endfunction
|
||||
|
||||
function! s:AllowQuote(char, isBS)
|
||||
let l:result = 1
|
||||
if b:AutoCloseSmartQuote
|
||||
let l:initPos = 1 + (a:isBS ? 1 : 0)
|
||||
let l:charBehind = s:GetCharBehind(l:initPos)
|
||||
let l:prev = l:charBehind
|
||||
let l:backSlashCount = 0
|
||||
while l:charBehind == '\'
|
||||
let l:backSlashCount = l:backSlashCount + 1
|
||||
let l:charBehind = s:GetCharBehind(l:initPos + l:backSlashCount)
|
||||
endwhile
|
||||
|
||||
if l:backSlashCount % 2
|
||||
let l:result = 0
|
||||
else
|
||||
if a:char == "'" && l:prev =~ '[a-zA-Z0-9]'
|
||||
let l:result = 0
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
function! s:CountQuotes(char)
|
||||
let l:currPos = col('.')-1
|
||||
let l:line = strpart(getline('.'), 0, l:currPos)
|
||||
let l:result = 0
|
||||
|
||||
if l:currPos >= 0
|
||||
for [q,closer] in items(b:AutoClosePairs)
|
||||
" only consider twin pairs
|
||||
if q != closer | continue | endif
|
||||
|
||||
if b:AutoCloseSmartQuote != 0
|
||||
let l:regex = q . '[ˆ\\' . q . ']*(\\.[ˆ\\' . q . ']*)*' . q
|
||||
else
|
||||
let l:regex = q . '[ˆ' . q . ']*' . q
|
||||
endif
|
||||
|
||||
let l:closedQuoteIdx = match(l:line, l:regex)
|
||||
while l:closedQuoteIdx >= 0
|
||||
let l:matchedStr = matchstr(l:line, l:regex, l:closedQuoteIdx)
|
||||
let l:line = strpart(l:line, 0, l:closedQuoteIdx) . strpart(l:line, l:closedQuoteIdx + strlen(l:matchedStr))
|
||||
let l:closedQuoteIdx = match(l:line, l:regex)
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
for c in split(l:line, '\zs')
|
||||
if c == a:char
|
||||
let l:result = l:result + 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
" The auto-close buffer is used in a fix of the redo functionality.
|
||||
" As we insert characters after cursor, we remember them and at the moment
|
||||
" that vim would normally collect the last entered string into dot register
|
||||
" (:help ".) - i.e. when esc or a motion key is typed in insert mode - we
|
||||
" erase the inserted symbols and pretend that we have just now typed them.
|
||||
" This way vim picks them up into dot register as well and user can repeat the
|
||||
" typed bit with . command.
|
||||
function! s:PushBuffer(char)
|
||||
if !exists("b:AutoCloseBuffer")
|
||||
let b:AutoCloseBuffer = []
|
||||
endif
|
||||
call insert(b:AutoCloseBuffer, a:char)
|
||||
endfunction
|
||||
|
||||
function! s:PopBuffer()
|
||||
if exists("b:AutoCloseBuffer") && len(b:AutoCloseBuffer) > 0
|
||||
call remove(b:AutoCloseBuffer, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:EmptyBuffer()
|
||||
if exists("b:AutoCloseBuffer")
|
||||
let b:AutoCloseBuffer = []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:FlushBuffer()
|
||||
let l:result = ''
|
||||
if exists("b:AutoCloseBuffer")
|
||||
let l:len = len(b:AutoCloseBuffer)
|
||||
if l:len > 0
|
||||
let l:result = join(b:AutoCloseBuffer, '') . repeat("\<Left>", l:len)
|
||||
let b:AutoCloseBuffer = []
|
||||
call s:EraseNCharsAtCursor(l:len)
|
||||
endif
|
||||
endif
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
function! s:InsertStringAtCursor(str)
|
||||
let l:line = getline('.')
|
||||
let l:column = col('.')-2
|
||||
|
||||
if l:column < 0
|
||||
call setline('.', a:str . l:line)
|
||||
else
|
||||
call setline('.', l:line[:l:column] . a:str . l:line[l:column+1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:EraseNCharsAtCursor(len)
|
||||
let l:line = getline('.')
|
||||
let l:column = col('.')-2
|
||||
|
||||
if l:column < 0
|
||||
call setline('.', l:line[a:len + 1:])
|
||||
else
|
||||
call setline('.', l:line[:l:column] . l:line[l:column + a:len + 1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" returns the opener, after having inserted its closer if necessary
|
||||
function! s:InsertPair(opener)
|
||||
if ! b:AutoCloseOn || ! has_key(b:AutoClosePairs, a:opener) || s:IsForbidden(a:opener)
|
||||
return a:opener
|
||||
endif
|
||||
|
||||
let l:save_ve = &ve
|
||||
set ve=all
|
||||
|
||||
let l:next = s:GetNextChar()
|
||||
" only add closing pair before space or any of the closepair chars
|
||||
let close_before = '\s\|\V\[,.;' . escape(join(keys(b:AutoClosePairs) + values(b:AutoClosePairs), ''), ']').']'
|
||||
if (l:next == "\0" || l:next =~ close_before) && s:AllowQuote(a:opener, 0)
|
||||
call s:InsertStringAtCursor(b:AutoClosePairs[a:opener])
|
||||
call s:PushBuffer(b:AutoClosePairs[a:opener])
|
||||
endif
|
||||
|
||||
exec "set ve=" . l:save_ve
|
||||
return a:opener
|
||||
endfunction
|
||||
|
||||
" returns the closer, after having eaten identical one if necessary
|
||||
function! s:ClosePair(closer)
|
||||
let l:save_ve = &ve
|
||||
set ve=all
|
||||
|
||||
if b:AutoCloseOn && s:GetNextChar() == a:closer
|
||||
call s:EraseNCharsAtCursor(1)
|
||||
call s:PopBuffer()
|
||||
endif
|
||||
|
||||
exec "set ve=" . l:save_ve
|
||||
return a:closer
|
||||
endfunction
|
||||
|
||||
" in case closer is identical with its opener - heuristically decide which one
|
||||
" is being typed and act accordingly
|
||||
function! s:OpenOrCloseTwinPair(char)
|
||||
if s:CountQuotes(a:char) % 2 == 0
|
||||
" act as opening char
|
||||
return s:InsertPair(a:char)
|
||||
else
|
||||
" act as closing char
|
||||
return s:ClosePair(a:char)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" maintain auto-close buffer when delete key is pressed
|
||||
function! s:Delete()
|
||||
let l:save_ve = &ve
|
||||
set ve=all
|
||||
|
||||
if exists("b:AutoCloseBuffer") && len(b:AutoCloseBuffer) > 0 && b:AutoCloseBuffer[0] == s:GetNextChar()
|
||||
call s:PopBuffer()
|
||||
endif
|
||||
|
||||
exec "set ve=" . l:save_ve
|
||||
return "\<Del>"
|
||||
endfunction
|
||||
|
||||
" when backspace is pressed:
|
||||
" - erase an empty pair if backspacing from inside one
|
||||
" - maintain auto-close buffer
|
||||
function! s:Backspace()
|
||||
let l:save_ve = &ve
|
||||
let l:prev = s:GetPrevChar()
|
||||
let l:next = s:GetNextChar()
|
||||
set ve=all
|
||||
|
||||
if b:AutoCloseOn && s:IsEmptyPair() && (l:prev != l:next || s:AllowQuote(l:prev, 1))
|
||||
call s:EraseNCharsAtCursor(1)
|
||||
call s:PopBuffer()
|
||||
endif
|
||||
|
||||
exec "set ve=" . l:save_ve
|
||||
return "\<BS>"
|
||||
endfunction
|
||||
|
||||
function! s:Space()
|
||||
if b:AutoCloseOn && s:IsEmptyPair()
|
||||
call s:PushBuffer("\<Space>")
|
||||
return "\<Space>\<Space>\<Left>"
|
||||
else
|
||||
return "\<Space>"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:Enter()
|
||||
if has_key(b:AutoClosePumvisible, 'ENTER') && pumvisible()
|
||||
let b:snippet_chosen = 1
|
||||
return b:AutoClosePumvisible['ENTER']
|
||||
elseif b:AutoCloseOn && s:IsEmptyPair() && stridx( b:AutoCloseExpandEnterOn, s:GetPrevChar() ) >= 0
|
||||
return "\<CR>\<Esc>O"
|
||||
endif
|
||||
return "\<CR>"
|
||||
endfunction
|
||||
|
||||
function! s:ToggleAutoClose()
|
||||
let b:AutoCloseOn = !b:AutoCloseOn
|
||||
if b:AutoCloseOn
|
||||
echo "AutoClose ON"
|
||||
else
|
||||
echo "AutoClose OFF"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Parse a whitespace separated line of pairs
|
||||
" single characters are assumed to be twin pairs (closer identical to
|
||||
" opener)
|
||||
function! AutoClose#ParsePairs(string)
|
||||
if type(a:string) == type({})
|
||||
return a:string
|
||||
elseif type(a:string) != type("")
|
||||
echoerr "AutoClose#ParsePairs(): Argument not a dictionary or a string"
|
||||
return {}
|
||||
endif
|
||||
|
||||
let l:dict = {}
|
||||
for pair in split(a:string)
|
||||
" strlen is length in bytes, we want in (wide) characters
|
||||
let l:pairLen = strlen(substitute(pair,'.','x','g'))
|
||||
if l:pairLen == 1
|
||||
" assume a twin pair
|
||||
let l:dict[pair] = pair
|
||||
elseif l:pairLen == 2
|
||||
let l:dict[pair[0]] = pair[1]
|
||||
else
|
||||
echoerr "AutoClose: Bad pair string - a pair longer then two character"
|
||||
echoerr " `- String: " . a:sring
|
||||
echoerr " `- Pair: " . pair . " Pair len: " . l:pairLen
|
||||
endif
|
||||
endfor
|
||||
return l:dict
|
||||
endfunction
|
||||
|
||||
" this function is made visible for the sake of users
|
||||
function! AutoClose#DefaultPairs()
|
||||
return AutoClose#ParsePairs(g:AutoClosePairs)
|
||||
endfunction
|
||||
|
||||
function! s:ModifyPairsList(list, pairsToAdd, openersToRemove)
|
||||
return filter(
|
||||
\ extend(a:list, AutoClose#ParsePairs(a:pairsToAdd), "force"),
|
||||
\ "stridx(a:openersToRemove,v:key)<0")
|
||||
endfunction
|
||||
|
||||
function! AutoClose#DefaultPairsModified(pairsToAdd,openersToRemove)
|
||||
return s:ModifyPairsList(AutoClose#DefaultPairs(), a:pairsToAdd, a:openersToRemove)
|
||||
endfunction
|
||||
|
||||
" Define variables (in the buffer namespace).
|
||||
function! s:DefineVariables()
|
||||
" All the following variables can be set per buffer or global.
|
||||
" The buffer namespace is used internally
|
||||
let defaults = {
|
||||
\ 'AutoClosePairs': AutoClose#DefaultPairs(),
|
||||
\ 'AutoCloseProtectedRegions': ["Comment", "String", "Character"],
|
||||
\ 'AutoCloseSmartQuote': 1,
|
||||
\ 'AutoCloseOn': 1,
|
||||
\ 'AutoCloseSelectionWrapPrefix': '<LEADER>a',
|
||||
\ 'AutoClosePumvisible': {"ENTER": "\<C-Y>", "ESC": "\<C-E>"},
|
||||
\ 'AutoCloseExpandEnterOn': "",
|
||||
\ 'AutoCloseExpandSpace': 1,
|
||||
\ }
|
||||
|
||||
" Let the user define if he/she wants the plugin to do special actions when the
|
||||
" popup menu is visible and a movement key is pressed.
|
||||
" Movement keys used in the menu get mapped to themselves
|
||||
" (Up/Down/PageUp/PageDown).
|
||||
for key in s:movementKeys
|
||||
if key == 'ENTER' || key == 'ESC'
|
||||
continue
|
||||
endif
|
||||
let defaults['AutoClosePumvisible'][key] = ''
|
||||
endfor
|
||||
for key in s:pumMovementKeys
|
||||
if key == 'ENTER' || key == 'ESC'
|
||||
continue
|
||||
endif
|
||||
let defaults['AutoClosePumvisible'][key] = '<'.key.'>'
|
||||
endfor
|
||||
|
||||
if exists ('b:AutoClosePairs') && type('b:AutoClosePairs') == type("")
|
||||
let tmp = AutoClose#ParsePairs(b:AutoClosePairs)
|
||||
unlet b:AutoClosePairs
|
||||
let b:AutoClosePairs = tmp
|
||||
endif
|
||||
|
||||
" Now handle/assign values
|
||||
for key in keys(defaults)
|
||||
if key == 'AutoClosePumvisible'
|
||||
let tempVisible = defaults['AutoClosePumvisible']
|
||||
if exists('g:AutoClosePumvisible') && type(eval('g:AutoClosePumvisible')) == type(defaults['AutoClosePumvisible'])
|
||||
for childKey in keys(g:AutoClosePumvisible)
|
||||
let tempVisible[toupper(childKey)] = g:AutoClosePumvisible[childKey]
|
||||
endfor
|
||||
endif
|
||||
if exists('b:AutoClosePumvisible') && type(eval('b:AutoClosePumvisible')) == type(defaults['AutoClosePumvisible'])
|
||||
for childKey in keys(b:AutoClosePumvisible)
|
||||
let tempVisible[toupper(childKey)] = b:AutoClosePumvisible[childKey]
|
||||
endfor
|
||||
endif
|
||||
let b:AutoClosePumvisible = tempVisible
|
||||
else
|
||||
if exists('b:'.key) && type(eval('b:'.key)) == type(defaults[key])
|
||||
continue
|
||||
elseif exists('g:'.key) && type(eval('g:'.key)) == type(defaults[key])
|
||||
exec 'let b:' . key . ' = g:' . key
|
||||
else
|
||||
exec 'let b:' . key . ' = ' . string(defaults[key])
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:CreatePairsMaps()
|
||||
" create appropriate maps to defined open/close characters
|
||||
for key in keys(b:AutoClosePairs)
|
||||
let opener = s:keyName(key)
|
||||
let closer = s:keyName(b:AutoClosePairs[key])
|
||||
let quoted_opener = s:quoteAndEscape(opener)
|
||||
let quoted_closer = s:quoteAndEscape(closer)
|
||||
|
||||
exec "xnoremap <buffer> <silent> ". b:AutoCloseSelectionWrapPrefix
|
||||
\ . opener . " <Esc>`>a" . closer . "<Esc>`<i" . opener . "<Esc>"
|
||||
exec "xnoremap <buffer> <silent> ". b:AutoCloseSelectionWrapPrefix
|
||||
\ . closer . " <Esc>`>a" . closer . "<Esc>`<i" . opener . "<Esc>"
|
||||
if key == b:AutoClosePairs[key]
|
||||
exec "inoremap <buffer> <silent> " . opener
|
||||
\ . " <C-R>=<SID>OpenOrCloseTwinPair(" . quoted_opener . ")<CR>"
|
||||
else
|
||||
exec "inoremap <buffer> <silent> " . opener
|
||||
\ . " <C-R>=<SID>InsertPair(" . quoted_opener . ")<CR>"
|
||||
exec "inoremap <buffer> <silent> " . closer
|
||||
\ . " <C-R>=<SID>ClosePair(" . quoted_closer . ")<CR>"
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:CreateExtraMaps()
|
||||
" Extra mapping
|
||||
inoremap <buffer> <silent> <BS> <C-R>=<SID>Backspace()<CR>
|
||||
inoremap <buffer> <silent> <Del> <C-R>=<SID>Delete()<CR>
|
||||
if b:AutoCloseExpandSpace
|
||||
inoremap <buffer> <silent> <Space> <C-R>=<SID>Space()<CR>
|
||||
endif
|
||||
if len(b:AutoCloseExpandEnterOn) > 0
|
||||
inoremap <buffer> <silent> <CR> <C-R>=<SID>Enter()<CR>
|
||||
endif
|
||||
|
||||
if g:AutoClosePreserveDotReg
|
||||
" Fix the re-do feature by flushing the char buffer on key movements (including Escape):
|
||||
for key in s:movementKeys
|
||||
let l:pvisiblemap = b:AutoClosePumvisible[key]
|
||||
let key = "<".key.">"
|
||||
let l:currentmap = maparg(key,"i")
|
||||
if (l:currentmap=="")|let l:currentmap=key|endif
|
||||
if len(l:pvisiblemap)
|
||||
exec "inoremap <buffer> <silent> <expr> " . key . " pumvisible() ? '" . l:pvisiblemap . "' : '<C-R>=<SID>FlushBuffer()<CR>" . l:currentmap . "'"
|
||||
else
|
||||
exec "inoremap <buffer> <silent> " . key . " <C-R>=<SID>FlushBuffer()<CR>" . l:currentmap
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Flush the char buffer on mouse click:
|
||||
inoremap <buffer> <silent> <LeftMouse> <C-R>=<SID>FlushBuffer()<CR><LeftMouse>
|
||||
inoremap <buffer> <silent> <RightMouse> <C-R>=<SID>FlushBuffer()<CR><RightMouse>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:CreateMaps()
|
||||
silent doautocmd FileType
|
||||
call s:DefineVariables()
|
||||
call s:CreatePairsMaps()
|
||||
call s:CreateExtraMaps()
|
||||
|
||||
let b:loaded_AutoClose = 1
|
||||
endfunction
|
||||
|
||||
function! s:IsLoadedOnBuffer()
|
||||
return (exists("b:loaded_AutoClose") && b:loaded_AutoClose)
|
||||
endfunction
|
||||
|
||||
" map some characters to their key names
|
||||
function! s:keyName(char)
|
||||
let s:keyNames = {'|': '<Bar>', ' ': '<Space>'}
|
||||
return get(s:keyNames,a:char,a:char)
|
||||
endfunction
|
||||
|
||||
" escape some characters for use in strings
|
||||
function! s:quoteAndEscape(char)
|
||||
let s:escapedChars = {'"': '\"'}
|
||||
return '"' . get(s:escapedChars,a:char,a:char) . '"'
|
||||
endfunction
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Configuration
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let s:AutoClosePairs_FactoryDefaults = AutoClose#ParsePairs("() {} [] ` \" '")
|
||||
if !exists("g:AutoClosePairs_add") | let g:AutoClosePairs_add = "" | endif
|
||||
if !exists("g:AutoClosePairs_del") | let g:AutoClosePairs_del = "" | endif
|
||||
if !exists("g:AutoClosePairs")
|
||||
let g:AutoClosePairs = s:ModifyPairsList(
|
||||
\ s:AutoClosePairs_FactoryDefaults,
|
||||
\ g:AutoClosePairs_add,
|
||||
\ g:AutoClosePairs_del )
|
||||
endif
|
||||
|
||||
let s:movementKeys = split('ESC UP DOWN LEFT RIGHT HOME END PAGEUP PAGEDOWN')
|
||||
" list of keys that get mapped to themselves for pumvisible()
|
||||
let s:pumMovementKeys = split('UP DOWN PAGEUP PAGEDOWN')
|
||||
|
||||
|
||||
if has("gui_macvim")
|
||||
call extend(s:movementKeys, split("D-LEFT D-RIGHT D-UP D-DOWN M-LEFT M-RIGHT M-UP M-DOWN"))
|
||||
endif
|
||||
|
||||
augroup <Plug>(autoclose)
|
||||
autocmd!
|
||||
autocmd BufNewFile,BufRead,BufEnter * if !<SID>IsLoadedOnBuffer() | call <SID>CreateMaps() | endif
|
||||
autocmd InsertEnter * call <SID>EmptyBuffer()
|
||||
autocmd BufEnter * if mode() == 'i' | call <SID>EmptyBuffer() | endif
|
||||
augroup END
|
||||
|
||||
" Define convenient commands
|
||||
command! AutoCloseOn :let b:AutoCloseOn = 1
|
||||
command! AutoCloseOff :let b:AutoCloseOn = 0
|
||||
command! AutoCloseToggle :call s:ToggleAutoClose()
|
||||
" vim:sw=4:sts=4:
|
Reference in New Issue
Block a user