first commit
This commit is contained in:
commit
5cce2032be
12
.vim/.netrwhist
Normal file
12
.vim/.netrwhist
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
let g:netrw_dirhistmax =10
|
||||||
|
let g:netrw_dirhistcnt =9
|
||||||
|
let g:netrw_dirhist_9='/home/sk4nz/SKANZ-INC/thesaucerecordings.co.uk'
|
||||||
|
let g:netrw_dirhist_8='/home/sk4nz/SKANZ-INC/www/src/templates'
|
||||||
|
let g:netrw_dirhist_7='/home/sk4nz/perso/skzbsd-src/sys/arch/amd64/compile/SKZ-VIRT'
|
||||||
|
let g:netrw_dirhist_6='/home/sk4nz/perso/sixpointcinq-www/app/templates'
|
||||||
|
let g:netrw_dirhist_5='/home/sk4nz/perso/MO'
|
||||||
|
let g:netrw_dirhist_4='/home/sk4nz/phd/magma-src/sys/arch/amd64/conf'
|
||||||
|
let g:netrw_dirhist_3='/home/sk4nz/perso/skz-opack/build/buildsrc'
|
||||||
|
let g:netrw_dirhist_2='/home/sk4nz/perso/skz-opack/build/buildsrc/reboot'
|
||||||
|
let g:netrw_dirhist_1='/home/sk4nz/perso/skz-opack/build/buildsrc'
|
||||||
|
let g:netrw_dirhist_0='/home/sk4nz/perso/skz-opack/build/buildsrc/reboot'
|
475
.vim/autoload/acp.vim
Executable file
475
.vim/autoload/acp.vim
Executable file
@ -0,0 +1,475 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" 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 * nested 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#meetsForPhpOmni(context)
|
||||||
|
if g:acp_behaviorPhpOmniLength < 1
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
if a:context =~ '[^a-zA-Z0-9_:>\$]$'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
if a:context =~ 'new \k\{' .
|
||||||
|
\ g:acp_behaviorPhpOmniLength . ',}$'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
if a:context =~ '\$\{' .
|
||||||
|
\ g:acp_behaviorPhpOmniLength . ',}$'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
if a:context =~ '[^.]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function acp#meetsForXmlOmni(context)
|
||||||
|
return g:acp_behaviorXmlOmniLength >= 0 &&
|
||||||
|
\ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
|
||||||
|
\ g:acp_behaviorXmlOmniLength . ',}$'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function acp#meetsForHtmlOmni(context)
|
||||||
|
if g:acp_behaviorHtmlOmniLength >= 0
|
||||||
|
if a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .g:acp_behaviorHtmlOmniLength . ',}$'
|
||||||
|
return 1
|
||||||
|
elseif a:context =~ '\(\<\k\{1,}\(=\"\)\{0,1}\|\" \)$'
|
||||||
|
let cur = line('.')-1
|
||||||
|
while cur > 0
|
||||||
|
let lstr = getline(cur)
|
||||||
|
if lstr =~ '>[^>]*$'
|
||||||
|
return 0
|
||||||
|
elseif lstr =~ '<[^<]*$'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
let cur = cur-1
|
||||||
|
endwhile
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
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#meetsForJavaScriptOmni(context)
|
||||||
|
let matches = matchlist(a:context, '\(\k\{1}\)$')
|
||||||
|
if empty(matches)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
return 1
|
||||||
|
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 = snipMate#GetSnippetsForWordBelowCursor(a:base, 0)
|
||||||
|
call filter(items, 'strpart(v:val[0], 0, len(a:base)) ==? a:base')
|
||||||
|
return map(sort(items), 's:makeSnipmateItem(v:val[0], values(v:val[1])[0])')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function acp#onPopupCloseSnipmate()
|
||||||
|
let word = s:getCurrentText()[s:posSnipmateCompletion :]
|
||||||
|
if len(snipMate#GetSnippetsForWordBelowCursor(word, 0))
|
||||||
|
call feedkeys("\<C-r>=snipMate#TriggerSnippet()\<CR>", "n")
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function acp#onPopupPost()
|
||||||
|
" to clear <C-r>= expression on command-line
|
||||||
|
echo ''
|
||||||
|
if pumvisible() && exists('s:behavsCurrent[s:iBehavs]')
|
||||||
|
inoremap <silent> <expr> <C-h> acp#onBs()
|
||||||
|
inoremap <silent> <expr> <BS> acp#onBs()
|
||||||
|
if exists('g:AutoComplPopDontSelectFirst') ? g:AutoComplPopDontSelectFirst : 0
|
||||||
|
return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>" ? "\<C-n>"
|
||||||
|
\ : "\<C-p>")
|
||||||
|
else
|
||||||
|
" 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
|
||||||
|
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 = a:snip[0]
|
||||||
|
let snipFormatted = descriptions
|
||||||
|
elseif type(a:snip) == type({})
|
||||||
|
let descriptions = values(a:snip)[0][0]
|
||||||
|
let snipFormatted = substitute(descriptions, '\(\n\|\s\)\+', ' ', 'g')
|
||||||
|
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] = snipMate#GetSnippetsForWordBelowCursor(tolower(a:base), 0)
|
||||||
|
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:
|
570
.vim/autoload/l9.vim
Executable file
570
.vim/autoload/l9.vim
Executable file
@ -0,0 +1,570 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (c) 2009-2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if exists('g:loaded_autoload_l9')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:loaded_autoload_l9 = 1
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" COMPATIBILITY TEST {{{1
|
||||||
|
|
||||||
|
"
|
||||||
|
let s:L9_VERSION_CURRENT = 101
|
||||||
|
let s:L9_VERSION_PASSABLE = 101
|
||||||
|
|
||||||
|
" returns true if given version is compatible.
|
||||||
|
function l9#isCompatible(ver)
|
||||||
|
return
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:VERSION_FACTOR = str2float('0.01')
|
||||||
|
|
||||||
|
" returns false if the caller script should finish.
|
||||||
|
" a:vimVersion: if 0, don't check vim version
|
||||||
|
" a:l9Version: same rule as v:version
|
||||||
|
function l9#guardScriptLoading(path, vimVersion, l9Version, exprs)
|
||||||
|
let loadedVarName = 'g:loaded_' . substitute(a:path, '\W', '_', 'g')
|
||||||
|
if exists(loadedVarName)
|
||||||
|
return 0
|
||||||
|
elseif a:vimVersion > 0 && a:vimVersion > v:version
|
||||||
|
echoerr a:path . ' requires Vim version ' . string(a:vimVersion * s:VERSION_FACTOR)
|
||||||
|
return 0
|
||||||
|
elseif a:l9Version > 0 && (a:l9Version > s:L9_VERSION_CURRENT ||
|
||||||
|
\ a:l9Version < s:L9_VERSION_PASSABLE)
|
||||||
|
echoerr a:path . ' requires L9 library version ' . string(a:l9Version * s:VERSION_FACTOR)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
for expr in a:exprs
|
||||||
|
if !eval(expr)
|
||||||
|
echoerr a:path . ' requires: ' . expr
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
let {loadedVarName} = 1
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#getVersion()
|
||||||
|
return s:L9_VERSION_CURRENT
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" LIST {{{1
|
||||||
|
|
||||||
|
" Removes duplicates (unstable)
|
||||||
|
" This function doesn't change the list of argument.
|
||||||
|
function l9#unique(items)
|
||||||
|
let sorted = sort(a:items)
|
||||||
|
if len(sorted) < 2
|
||||||
|
return sorted
|
||||||
|
endif
|
||||||
|
let last = remove(sorted, 0)
|
||||||
|
let result = [last]
|
||||||
|
for item in sorted
|
||||||
|
if item != last
|
||||||
|
call add(result, item)
|
||||||
|
let last = item
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Removes duplicates (stable)
|
||||||
|
" This function doesn't change the list of argument.
|
||||||
|
function l9#uniqueStably(items)
|
||||||
|
let result = []
|
||||||
|
for item in a:items
|
||||||
|
if count(result, item, &ignorecase) == 0
|
||||||
|
call add(result, item)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" [ [0], [1,2], [3] ] -> [ 0, 1, 2, 3 ]
|
||||||
|
" This function doesn't change the list of argument.
|
||||||
|
function l9#concat(items)
|
||||||
|
let result = []
|
||||||
|
for l in a:items
|
||||||
|
let result += l
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" [ [0,1,2], [3,4], [5,6,7,8] ] -> [ [0,3,5],[1,4,6] ]
|
||||||
|
" This function doesn't change the list of argument.
|
||||||
|
function l9#zip(items)
|
||||||
|
let result = []
|
||||||
|
for i in range(min(map(copy(a:items), 'len(v:val)')))
|
||||||
|
call add(result, map(copy(a:items), 'v:val[i]'))
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" filter() with the maximum number of items
|
||||||
|
" This function doesn't change the list of argument.
|
||||||
|
function l9#filterWithLimit(items, expr, limit)
|
||||||
|
if a:limit <= 0
|
||||||
|
return filter(copy(a:items), a:expr)
|
||||||
|
endif
|
||||||
|
let result = []
|
||||||
|
let stride = a:limit * 3 / 2 " x1.5
|
||||||
|
for i in range(0, len(a:items) - 1, stride)
|
||||||
|
let result += filter(a:items[i : i + stride - 1], a:expr)
|
||||||
|
if len(result) >= a:limit
|
||||||
|
return remove(result, 0, a:limit - 1)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Removes if a:expr is evaluated as non-zero and returns removed items.
|
||||||
|
" This function change the list of argument.
|
||||||
|
function l9#removeIf(items, expr)
|
||||||
|
let removed = filter(copy(a:items), a:expr)
|
||||||
|
call filter(a:items, '!( ' . a:expr . ')')
|
||||||
|
return removed
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" NUMERIC {{{1
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" STRING {{{1
|
||||||
|
|
||||||
|
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||||
|
function l9#snipHead(str, len, mask)
|
||||||
|
if a:len >= len(a:str)
|
||||||
|
return a:str
|
||||||
|
elseif a:len <= len(a:mask)
|
||||||
|
return a:mask
|
||||||
|
endif
|
||||||
|
return a:mask . a:str[-a:len + len(a:mask):]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||||
|
function l9#snipTail(str, len, mask)
|
||||||
|
if a:len >= len(a:str)
|
||||||
|
return a:str
|
||||||
|
elseif a:len <= len(a:mask)
|
||||||
|
return a:mask
|
||||||
|
endif
|
||||||
|
return a:str[:a:len - 1 - len(a:mask)] . a:mask
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||||
|
function l9#snipMid(str, len, mask)
|
||||||
|
if a:len >= len(a:str)
|
||||||
|
return a:str
|
||||||
|
elseif a:len <= len(a:mask)
|
||||||
|
return a:mask
|
||||||
|
endif
|
||||||
|
let len_head = (a:len - len(a:mask)) / 2
|
||||||
|
let len_tail = a:len - len(a:mask) - len_head
|
||||||
|
return (len_head > 0 ? a:str[: len_head - 1] : '') . a:mask .
|
||||||
|
\ (len_tail > 0 ? a:str[-len_tail :] : '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#hash224(str)
|
||||||
|
let a = 0x00000800 " shift 11 bit (if unsigned)
|
||||||
|
let b = 0x001fffff " extract 11 bit (if unsigned)
|
||||||
|
let nHash = 7
|
||||||
|
let hashes = repeat([0], nHash)
|
||||||
|
for i in range(len(a:str))
|
||||||
|
let iHash = i % nHash
|
||||||
|
let hashes[iHash] = hashes[iHash] * a + hashes[iHash] / b
|
||||||
|
let hashes[iHash] += char2nr(a:str[i])
|
||||||
|
endfor
|
||||||
|
return join(map(hashes, 'printf("%08x", v:val)'), '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" wildcard -> regexp
|
||||||
|
function l9#convertWildcardToRegexp(expr)
|
||||||
|
let re = escape(a:expr, '\')
|
||||||
|
for [pat, sub] in [ [ '*', '\\.\\*' ], [ '?', '\\.' ], [ '[', '\\[' ], ]
|
||||||
|
let re = substitute(re, pat, sub, 'g')
|
||||||
|
endfor
|
||||||
|
return '\V' . re
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" LINES {{{1
|
||||||
|
|
||||||
|
" Removes from the line matching with a:begin first to the line matching with
|
||||||
|
" a:end next and returns removed lines.
|
||||||
|
" If matching range is not found, returns []
|
||||||
|
function l9#removeLinesBetween(lines, begin, end)
|
||||||
|
for i in range(len(a:lines) - 1)
|
||||||
|
if a:lines[i] =~ a:begin
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
for j in range(i + 1, len(a:lines) - 1)
|
||||||
|
if a:lines[j] =~ a:end
|
||||||
|
let g:l0 += [a:lines[i : j]]
|
||||||
|
return remove(a:lines, i, j)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return []
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" PATH {{{1
|
||||||
|
|
||||||
|
" returns the path separator charactor.
|
||||||
|
function l9#getPathSeparator()
|
||||||
|
return (!&shellslash && (has('win32') || has('win64')) ? '\' : '/')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" [ 'a', 'b/', '/c' ] -> 'a/b/c'
|
||||||
|
function l9#concatPaths(paths)
|
||||||
|
let result = ''
|
||||||
|
for p in a:paths
|
||||||
|
if empty(p)
|
||||||
|
continue
|
||||||
|
elseif empty(result)
|
||||||
|
let result = p
|
||||||
|
else
|
||||||
|
let result = substitute(result, '[/\\]$', '', '') . l9#getPathSeparator()
|
||||||
|
\ . substitute(p, '^[/\\]', '', '')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" path: '/a/b/c/d', dir: '/a/b' => 'c/d'
|
||||||
|
function l9#modifyPathRelativeToDir(path, dir)
|
||||||
|
let pathFull = fnamemodify(a:path, ':p')
|
||||||
|
let dirFull = fnamemodify(a:dir, ':p')
|
||||||
|
if len(pathFull) < len(dirFull) || pathFull[:len(dirFull) - 1] !=# dirFull
|
||||||
|
return pathFull
|
||||||
|
endif
|
||||||
|
return pathFull[len(dirFull):]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" FILE {{{1
|
||||||
|
|
||||||
|
" Almost same as readfile().
|
||||||
|
function l9#readFile(...)
|
||||||
|
let args = copy(a:000)
|
||||||
|
let args[0] = expand(args[0])
|
||||||
|
try
|
||||||
|
return call('readfile', args)
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
return []
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Almost same as writefile().
|
||||||
|
function l9#writeFile(...)
|
||||||
|
let args = copy(a:000)
|
||||||
|
let args[1] = expand(args[1])
|
||||||
|
let dir = fnamemodify(args[1], ':h')
|
||||||
|
try
|
||||||
|
if !isdirectory(dir)
|
||||||
|
call mkdir(dir, 'p')
|
||||||
|
endif
|
||||||
|
return call('writefile', args)
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
return -1 " -1 is error code.
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" BUFFER {{{1
|
||||||
|
|
||||||
|
" :wall/:wall! wrapper. Useful for writing readonly buffers.
|
||||||
|
function l9#writeAll()
|
||||||
|
try
|
||||||
|
silent update " NOTE: avoiding a problem with a buftype=acwrite buffer.
|
||||||
|
silent wall
|
||||||
|
catch /^Vim/ " E45, E505
|
||||||
|
if l9#inputHl('Question', v:exception . "\nWrite readonly files? (Y/N) : ", 'Y') ==? 'y'
|
||||||
|
redraw
|
||||||
|
:wall!
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Loads given files with :edit command
|
||||||
|
function l9#loadFilesToBuffers(files)
|
||||||
|
for file in filter(copy(a:files), '!bufloaded(v:val)')
|
||||||
|
execute 'edit ' . fnameescape(file)
|
||||||
|
if !exists('bufNrFirst')
|
||||||
|
let bufNrFirst = bufnr('%')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
if exists('bufNrFirst')
|
||||||
|
execute bufNrFirst . 'buffer'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Deletes all buffers except given files with :bdelete command
|
||||||
|
function l9#deleteAllBuffersExcept(files)
|
||||||
|
let bufNrExcepts = map(copy(a:files), 'bufnr("^" . v:val . "$")')
|
||||||
|
for bufNr in filter(range(1, bufnr('$')), 'bufloaded(v:val)')
|
||||||
|
if count(bufNrExcepts, bufNr) == 0
|
||||||
|
execute bufNr . 'bdelete'
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" WINDOW {{{1
|
||||||
|
|
||||||
|
" move current window to next tabpage.
|
||||||
|
function l9#shiftWinNextTabpage()
|
||||||
|
if tabpagenr('$') < 2
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let bufnr = bufnr('%')
|
||||||
|
tabnext
|
||||||
|
execute bufnr . 'sbuffer'
|
||||||
|
tabprevious
|
||||||
|
if winnr('$') > 1
|
||||||
|
close
|
||||||
|
tabnext
|
||||||
|
else
|
||||||
|
close " if tabpage is closed, next tabpage will become current
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" move current window to previous tabpage.
|
||||||
|
function l9#shiftWinPrevTabpage()
|
||||||
|
if tabpagenr('$') < 2
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let bufnr = bufnr('%')
|
||||||
|
tabprevious
|
||||||
|
execute bufnr . 'sbuffer'
|
||||||
|
tabnext
|
||||||
|
close
|
||||||
|
tabprevious
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" move to a window containing specified buffer.
|
||||||
|
" returns 0 if the buffer is not found.
|
||||||
|
function l9#moveToBufferWindowInCurrentTabpage(bufNr)
|
||||||
|
if bufnr('%') == a:bufNr
|
||||||
|
return 1
|
||||||
|
elseif count(tabpagebuflist(), a:bufNr) == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
execute bufwinnr(a:bufNr) . 'wincmd w'
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" returns 0 if the buffer is not found.
|
||||||
|
function s:moveToOtherTabpageOpeningBuffer(bufNr)
|
||||||
|
for tabNr in range(1, tabpagenr('$'))
|
||||||
|
if tabNr != tabpagenr() && count(tabpagebuflist(tabNr), a:bufNr) > 0
|
||||||
|
execute 'tabnext ' . tabNr
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" move to a window containing specified buffer.
|
||||||
|
" returns 0 if the buffer is not found.
|
||||||
|
function l9#moveToBufferWindowInOtherTabpage(bufNr)
|
||||||
|
if !s:moveToOtherTabpageOpeningBuffer(a:bufNr)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
return l9#moveToBufferWindowInCurrentTabpage(a:bufNr)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" COMMAND LINE {{{1
|
||||||
|
|
||||||
|
" echo/echomsg with highlighting.
|
||||||
|
function l9#echoHl(hl, msg, prefix, addingHistory)
|
||||||
|
let echoCmd = (a:addingHistory ? 'echomsg' : 'echo')
|
||||||
|
execute "echohl " . a:hl
|
||||||
|
try
|
||||||
|
for l in (type(a:msg) == type([]) ? a:msg : split(a:msg, "\n"))
|
||||||
|
execute echoCmd . ' a:prefix . l'
|
||||||
|
endfor
|
||||||
|
finally
|
||||||
|
echohl None
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" input() with highlighting.
|
||||||
|
" This function can take list as {completion} argument.
|
||||||
|
function l9#inputHl(hl, ...)
|
||||||
|
execute "echohl " . a:hl
|
||||||
|
try
|
||||||
|
let args = copy(a:000)
|
||||||
|
if len(args) > 2 && type(args[2]) == type([])
|
||||||
|
let s:candidatesForInputHl = args[2]
|
||||||
|
let args[2] = 'custom,l9#completeForInputHl'
|
||||||
|
endif
|
||||||
|
let s = call('input', args)
|
||||||
|
unlet! s:candidatesForInputHl
|
||||||
|
finally
|
||||||
|
echohl None
|
||||||
|
endtry
|
||||||
|
redraw " needed to show following echo to next line.
|
||||||
|
return s
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" only called by l9#inputHl() for completion.
|
||||||
|
function l9#completeForInputHl(lead, line, pos)
|
||||||
|
return join(s:candidatesForInputHl, "\n")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" VISUAL MODE {{{1
|
||||||
|
|
||||||
|
" returns last selected text in Visual mode.
|
||||||
|
function l9#getSelectedText()
|
||||||
|
let reg_ = [@", getregtype('"')]
|
||||||
|
let regA = [@a, getregtype('a')]
|
||||||
|
if mode() =~# "[vV\<C-v>]"
|
||||||
|
silent normal! "aygv
|
||||||
|
else
|
||||||
|
let pos = getpos('.')
|
||||||
|
silent normal! gv"ay
|
||||||
|
call setpos('.', pos)
|
||||||
|
endif
|
||||||
|
let text = @a
|
||||||
|
call setreg('"', reg_[0], reg_[1])
|
||||||
|
call setreg('a', regA[0], regA[1])
|
||||||
|
return text
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" EVAL {{{1
|
||||||
|
|
||||||
|
" loads given text as Vim script with :source command
|
||||||
|
function l9#loadScript(text)
|
||||||
|
let lines = (type(a:text) == type([]) ? a:text : split(a:text, "\n"))
|
||||||
|
let fname = tempname()
|
||||||
|
call writefile(lines, fname)
|
||||||
|
source `=fname`
|
||||||
|
call delete(fname)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" VARIABLES {{{1
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#defineVariableDefault(name, default)
|
||||||
|
if !exists(a:name)
|
||||||
|
let {a:name} = a:default
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" GREP {{{1
|
||||||
|
|
||||||
|
" Execute :vimgrep and opens the quickfix window if matches are found.
|
||||||
|
"
|
||||||
|
" a:pattern: search pattern. If ommitted, last search pattern (@/) is used.
|
||||||
|
" a:files: List of files
|
||||||
|
function l9#grepFiles(pattern, files)
|
||||||
|
let target = join(map(a:files, 'escape(v:val, " ")'), ' ')
|
||||||
|
let pattern = (a:pattern[0] ==# '/' ? a:pattern[1:] : a:pattern)
|
||||||
|
let pattern = (empty(pattern) ? @/ : pattern)
|
||||||
|
try
|
||||||
|
execute printf('vimgrep/%s/j %s', pattern, target)
|
||||||
|
catch /^Vim/
|
||||||
|
call setqflist([])
|
||||||
|
endtry
|
||||||
|
call l9#quickfix#sort()
|
||||||
|
call l9#quickfix#openIfNotEmpty(1, 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Execute :vimgrep for buffers using l9#grepFiles()
|
||||||
|
" See also: :L9GrepBuffer :L9GrepBufferAll
|
||||||
|
function l9#grepBuffers(pattern, bufNrs)
|
||||||
|
let files = map(filter(a:bufNrs, 'bufloaded(v:val)'), 'bufname(v:val)')
|
||||||
|
call l9#grepFiles(a:pattern, files)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" SIGN {{{1
|
||||||
|
|
||||||
|
" Highlights lines using :sign define and :sign place.
|
||||||
|
"
|
||||||
|
" a:linehl, a:text, a:texthl: See |signs|. Ignored if empty string.
|
||||||
|
" a:locations: List of [{buffer number}, {line number}] for highlighting
|
||||||
|
function l9#placeSign(linehl, text, texthl, locations)
|
||||||
|
let argLinehl = (empty(a:linehl) ? '' : 'linehl=' . a:linehl)
|
||||||
|
let argText = (empty(a:text) ? '' : 'text=' . a:text)
|
||||||
|
let argTexthl = (empty(a:texthl) ? '' : 'texthl=' . a:texthl)
|
||||||
|
let name = 'l9--' . a:linehl . '--' . a:text . '--' . a:texthl
|
||||||
|
execute printf('sign define %s linehl=%s text=%s texthl=%s',
|
||||||
|
\ name, a:linehl, a:text, a:texthl)
|
||||||
|
for [bufNr, lnum] in a:locations
|
||||||
|
execute printf('sign place 1 line=%d name=%s buffer=%d', lnum, name, bufNr)
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" NOTIFY EXTERNALLY {{{1
|
||||||
|
|
||||||
|
" Notify a message using an external program.
|
||||||
|
" Currently supports Balloonly, Screen, and Tmux.
|
||||||
|
function l9#notifyExternally(msg)
|
||||||
|
return l9#notifyBalloonly(a:msg)
|
||||||
|
\ || l9#notifyScreen(a:msg)
|
||||||
|
\ || l9#notifyTmux(a:msg)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#notifyBalloonly(msg)
|
||||||
|
if !(has('win32') || has('win64')) || !executable(g:l9_balloonly)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
execute 'silent !start ' . shellescape(g:l9_balloonly) . ' 4000 "l9" ' . shellescape(a:msg)
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#notifyScreen(msg)
|
||||||
|
if !has('unix') || has('gui_running') || $WINDOW !~ '\d' || !executable('screen')
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
call system('screen -X wall ' . shellescape('l9: ' . a:msg))
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#notifyTmux(msg)
|
||||||
|
if !has('unix') || has('gui_running') || empty($TMUX) || !executable('tmux')
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
call system('tmux display-message ' . shellescape('l9: ' . a:msg))
|
||||||
|
return 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
92
.vim/autoload/l9/async.py
Executable file
92
.vim/autoload/l9/async.py
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
|
import vim
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import threading
|
||||||
|
import Queue
|
||||||
|
|
||||||
|
|
||||||
|
class Asyncer:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._workers = {}
|
||||||
|
|
||||||
|
def execute(self, var_key, var_command, var_cwd, var_input, var_appends):
|
||||||
|
key = vim.eval(var_key)
|
||||||
|
command = vim.eval(var_command)
|
||||||
|
cwd = vim.eval(var_cwd)
|
||||||
|
input = vim.eval(var_input)
|
||||||
|
appends = vim.eval(var_appends)
|
||||||
|
if key not in self._workers:
|
||||||
|
self._workers[key] = Worker()
|
||||||
|
self._workers[key].start()
|
||||||
|
self._workers[key].put(Executor(command, cwd, input, appends))
|
||||||
|
|
||||||
|
def print_output(self, var_key):
|
||||||
|
key = vim.eval(var_key)
|
||||||
|
if key not in self._workers:
|
||||||
|
return
|
||||||
|
for l in self._workers[key].copy_outputs():
|
||||||
|
print l,
|
||||||
|
|
||||||
|
def print_worker_keys(self):
|
||||||
|
for k in self._workers.keys():
|
||||||
|
print k
|
||||||
|
|
||||||
|
def print_active_worker_keys(self):
|
||||||
|
for k in self._workers.keys():
|
||||||
|
print k
|
||||||
|
|
||||||
|
|
||||||
|
class Worker(threading.Thread):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self._queue = Queue.Queue()
|
||||||
|
self._lines = []
|
||||||
|
self._lock = threading.Lock()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
self._queue.get().execute(self)
|
||||||
|
self._queue.task_done()
|
||||||
|
|
||||||
|
def put(self, executor):
|
||||||
|
self._queue.put(executor)
|
||||||
|
|
||||||
|
def clear_outputs(self):
|
||||||
|
with self._lock:
|
||||||
|
self._lines = []
|
||||||
|
|
||||||
|
def record_output(self, line):
|
||||||
|
with self._lock:
|
||||||
|
self._lines.append(line)
|
||||||
|
|
||||||
|
def copy_outputs(self):
|
||||||
|
with self._lock:
|
||||||
|
return self._lines[:]
|
||||||
|
|
||||||
|
|
||||||
|
class Executor:
|
||||||
|
|
||||||
|
def __init__(self, command, cwd, input, appends):
|
||||||
|
self._command = command
|
||||||
|
self._cwd = cwd
|
||||||
|
self._input = input
|
||||||
|
self._appends = appends
|
||||||
|
|
||||||
|
def execute(self, worker):
|
||||||
|
if not self._appends:
|
||||||
|
worker.clear_outputs()
|
||||||
|
os.chdir(self._cwd)
|
||||||
|
p = subprocess.Popen(self._command, shell=True, stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
p.stdin.write(self._input)
|
||||||
|
line = p.stdout.readline()
|
||||||
|
while line:
|
||||||
|
worker.record_output(line)
|
||||||
|
line = p.stdout.readline()
|
||||||
|
|
||||||
|
|
67
.vim/autoload/l9/async.vim
Executable file
67
.vim/autoload/l9/async.vim
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, ['has("python")'])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" ASYNC EXECUTE {{{1
|
||||||
|
|
||||||
|
"
|
||||||
|
function s:checkKey(key)
|
||||||
|
if a:key =~ '\n' || a:key !~ '\S'
|
||||||
|
throw "Asyncer: Invalid key: " . a:key
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#async#execute(key, cmd, cwd, input, appends)
|
||||||
|
call s:checkKey(a:key)
|
||||||
|
python asyncer.execute('a:key', 'a:cmd', 'a:cwd', 'a:input', 'a:appends')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#async#read(key)
|
||||||
|
call s:checkKey(a:key)
|
||||||
|
redir => result
|
||||||
|
silent python asyncer.print_output('a:key')
|
||||||
|
redir END
|
||||||
|
" NOTE: "\n" is somehow inserted by redir.
|
||||||
|
return (result[0] ==# "\n" ? result[1:] : result)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#async#listWorkers()
|
||||||
|
redir => result
|
||||||
|
silent python asyncer.print_worker_keys()
|
||||||
|
redir END
|
||||||
|
return split(result, "\n")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#async#listActiveWorkers()
|
||||||
|
redir => result
|
||||||
|
silent python asyncer.print_active_worker_keys()
|
||||||
|
redir END
|
||||||
|
return split(result, "\n")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" INITIALIZATION {{{1
|
||||||
|
|
||||||
|
let s:ASYNC_PY_PATH = fnamemodify(expand('<sfile>:p:h'), ':p') . 'async.py'
|
||||||
|
|
||||||
|
pyfile `=s:ASYNC_PY_PATH`
|
||||||
|
python asyncer = Asyncer()
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
||||||
|
|
||||||
|
|
107
.vim/autoload/l9/quickfix.vim
Executable file
107
.vim/autoload/l9/quickfix.vim
Executable file
@ -0,0 +1,107 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" QUICKFIX {{{1
|
||||||
|
|
||||||
|
" Returns non-zero if quickfix window is opened.
|
||||||
|
function l9#quickfix#isWindowOpened()
|
||||||
|
return count(map(range(1, winnr('$')), 'getwinvar(v:val, "&buftype")'), 'quickfix') > 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Opens quickfix window if quickfix is not empty, and echo the number of errors.
|
||||||
|
"
|
||||||
|
" a:onlyRecognized: if non-zero, opens only if quickfix has recognized errors.
|
||||||
|
" a:holdCursor: if non-zero, the cursor won't move to quickfix window.
|
||||||
|
function l9#quickfix#openIfNotEmpty(onlyRecognized, holdCursor)
|
||||||
|
let numErrors = len(filter(getqflist(), 'v:val.valid'))
|
||||||
|
let numOthers = len(getqflist()) - numErrors
|
||||||
|
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
|
||||||
|
copen
|
||||||
|
if a:holdCursor
|
||||||
|
wincmd p
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
cclose
|
||||||
|
endif
|
||||||
|
redraw
|
||||||
|
if numOthers > 0
|
||||||
|
echo printf('Quickfix: %d(+%d)', numErrors, numOthers)
|
||||||
|
else
|
||||||
|
echo printf('Quickfix: %d', numErrors)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Toggles Quickfix window
|
||||||
|
function l9#quickfix#toggleWindow()
|
||||||
|
if l9#quickfix#isWindowOpened()
|
||||||
|
cclose
|
||||||
|
else
|
||||||
|
call l9#quickfix#openIfNotEmpty(0, 0)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Creates quickfix list form given lines and opens the quickfix window if
|
||||||
|
" errors exists.
|
||||||
|
"
|
||||||
|
" a:lines:
|
||||||
|
" a:jump: if non-zero, jump to the first error.
|
||||||
|
function l9#quickfix#setMakeResult(lines)
|
||||||
|
cexpr a:lines
|
||||||
|
call l9#quickfix#openIfNotEmpty(0, 1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Compares quickfix entries for sorting.
|
||||||
|
function l9#quickfix#compareEntries(e0, e1)
|
||||||
|
if a:e0.bufnr != a:e1.bufnr
|
||||||
|
let i0 = bufname(a:e0.bufnr)
|
||||||
|
let i1 = bufname(a:e1.bufnr)
|
||||||
|
elseif a:e0.lnum != a:e1.lnum
|
||||||
|
let i0 = a:e0.lnum
|
||||||
|
let i1 = a:e1.lnum
|
||||||
|
elseif a:e0.col != a:e1.col
|
||||||
|
let i0 = a:e0.col
|
||||||
|
let i1 = a:e1.col
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
return (i0 > i1 ? +1 : -1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Sorts quickfix
|
||||||
|
function l9#quickfix#sort()
|
||||||
|
call setqflist(sort(getqflist(), 'l9#quickfix#compareEntries'), 'r')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Highlights Quickfix lines by :sign.
|
||||||
|
" Inspired by errormarker plugin.
|
||||||
|
"
|
||||||
|
" You can customize the highlighting via L9ErrorLine and L9WarningLine
|
||||||
|
" highlight groups.
|
||||||
|
function l9#quickfix#placeSign()
|
||||||
|
let warnings = []
|
||||||
|
let errors = []
|
||||||
|
for e in filter(getqflist(), 'v:val.valid')
|
||||||
|
let warning = (e.type ==? 'w' || e.text =~? '^\s*warning:')
|
||||||
|
call add((warning ? warnings : errors), [e.bufnr, e.lnum])
|
||||||
|
endfor
|
||||||
|
sign unplace *
|
||||||
|
call l9#placeSign('L9WarningLine', '>>', '', warnings)
|
||||||
|
call l9#placeSign('L9ErrorLine', '>>', '', errors)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
highlight default L9ErrorLine ctermfg=white ctermbg=52 guibg=#5F0000
|
||||||
|
highlight default L9WarningLine ctermfg=white ctermbg=17 guibg=#00005F
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
||||||
|
|
112
.vim/autoload/l9/tempbuffer.vim
Executable file
112
.vim/autoload/l9/tempbuffer.vim
Executable file
@ -0,0 +1,112 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" TEMPORARY BUFFER {{{1
|
||||||
|
|
||||||
|
" each key is a buffer name.
|
||||||
|
let s:dataMap = {}
|
||||||
|
|
||||||
|
"
|
||||||
|
function s:onBufDelete(bufname)
|
||||||
|
if exists('s:dataMap[a:bufname].listener.onClose')
|
||||||
|
call s:dataMap[a:bufname].listener.onClose(s:dataMap[a:bufname].written)
|
||||||
|
endif
|
||||||
|
if bufnr('%') == s:dataMap[a:bufname].bufNr && winnr('#') != 0
|
||||||
|
" if winnr('#') returns 0, "wincmd p" causes ringing the bell.
|
||||||
|
wincmd p
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function s:onBufWriteCmd(bufname)
|
||||||
|
if !exists('s:dataMap[a:bufname].listener.onWrite') ||
|
||||||
|
\ s:dataMap[a:bufname].listener.onWrite(getline(1, '$'))
|
||||||
|
setlocal nomodified
|
||||||
|
let s:dataMap[a:bufname].written = 1
|
||||||
|
call l9#tempbuffer#close(a:bufname)
|
||||||
|
else
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" a:bufname:
|
||||||
|
" a:height: Window height. If 0, default height is used.
|
||||||
|
" If less than 0, the window becomes full-screen.
|
||||||
|
" a:listener:
|
||||||
|
" a:listener.onClose(written)
|
||||||
|
function l9#tempbuffer#openScratch(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||||
|
let openCmdPrefix = (a:topleft ? 'topleft ' : '')
|
||||||
|
\ . (a:vertical ? 'vertical ' : '')
|
||||||
|
\ . (a:height > 0 ? a:height : '')
|
||||||
|
if !exists('s:dataMap[a:bufname]') || !bufexists(s:dataMap[a:bufname].bufNr)
|
||||||
|
execute openCmdPrefix . 'new'
|
||||||
|
else
|
||||||
|
call l9#tempbuffer#close(a:bufname)
|
||||||
|
execute openCmdPrefix . 'split'
|
||||||
|
execute 'silent ' . s:dataMap[a:bufname].bufNr . 'buffer'
|
||||||
|
endif
|
||||||
|
if a:height < 0
|
||||||
|
only
|
||||||
|
endif
|
||||||
|
setlocal buflisted noswapfile bufhidden=delete modifiable noreadonly buftype=nofile
|
||||||
|
let &l:filetype = a:filetype
|
||||||
|
silent file `=a:bufname`
|
||||||
|
call setline(1, a:lines)
|
||||||
|
setlocal nomodified
|
||||||
|
augroup L9TempBuffer
|
||||||
|
autocmd! * <buffer>
|
||||||
|
execute printf('autocmd BufDelete <buffer> call s:onBufDelete (%s)', string(a:bufname))
|
||||||
|
execute printf('autocmd BufWriteCmd <buffer> nested call s:onBufWriteCmd(%s)', string(a:bufname))
|
||||||
|
augroup END
|
||||||
|
let s:dataMap[a:bufname] = {
|
||||||
|
\ 'bufNr': bufnr('%'),
|
||||||
|
\ 'written': 0,
|
||||||
|
\ 'listener': a:listener,
|
||||||
|
\ }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#tempbuffer#openReadOnly(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||||
|
call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
|
||||||
|
setlocal nomodifiable readonly
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" a:listener:
|
||||||
|
" a:listener.onClose(written)
|
||||||
|
" a:listener.onWrite(lines)
|
||||||
|
function l9#tempbuffer#openWritable(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||||
|
call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
|
||||||
|
setlocal buftype=acwrite
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" makes specified temp buffer current.
|
||||||
|
function l9#tempbuffer#moveTo(bufname)
|
||||||
|
return l9#moveToBufferWindowInCurrentTabpage(s:dataMap[a:bufname].bufNr) ||
|
||||||
|
\ l9#moveToBufferWindowInOtherTabpage(s:dataMap[a:bufname].bufNr)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#tempbuffer#close(bufname)
|
||||||
|
if !l9#tempbuffer#isOpen(a:bufname)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
execute printf('%dbdelete!', s:dataMap[a:bufname].bufNr)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
function l9#tempbuffer#isOpen(bufname)
|
||||||
|
return exists('s:dataMap[a:bufname]') && bufloaded(s:dataMap[a:bufname].bufNr)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
||||||
|
|
60
.vim/autoload/l9/tempvariables.vim
Executable file
60
.vim/autoload/l9/tempvariables.vim
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (C) 2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" TEMPORARY VARIABLES {{{1
|
||||||
|
|
||||||
|
"
|
||||||
|
let s:origMap = {}
|
||||||
|
|
||||||
|
" set temporary variables
|
||||||
|
function l9#tempvariables#set(group, name, value)
|
||||||
|
if !exists('s:origMap[a:group]')
|
||||||
|
let s:origMap[a:group] = {}
|
||||||
|
endif
|
||||||
|
if !exists('s:origMap[a:group][a:name]')
|
||||||
|
let s:origMap[a:group][a:name] = eval(a:name)
|
||||||
|
endif
|
||||||
|
execute 'let ' . a:name . ' = a:value'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" set temporary variables
|
||||||
|
function l9#tempvariables#setList(group, variables)
|
||||||
|
for [name, value] in a:variables
|
||||||
|
call l9#tempvariables#set(a:group, name, value)
|
||||||
|
unlet value " to avoid E706
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" get temporary variables
|
||||||
|
function l9#tempvariables#getList(group)
|
||||||
|
if !exists('s:origMap[a:group]')
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
return map(keys(s:origMap[a:group]), '[v:val, eval(v:val)]')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" restore original variables and clean up.
|
||||||
|
function l9#tempvariables#end(group)
|
||||||
|
if !exists('s:origMap[a:group]')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
for [name, value] in items(s:origMap[a:group])
|
||||||
|
execute 'let ' . name . ' = value'
|
||||||
|
unlet value " to avoid E706
|
||||||
|
endfor
|
||||||
|
unlet s:origMap[a:group]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
||||||
|
|
1
.vim/bundle/Vundle.vim
Submodule
1
.vim/bundle/Vundle.vim
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b255382d6242d7ea3877bf059d2934125e0c4d95
|
1
.vim/bundle/syntastic
Submodule
1
.vim/bundle/syntastic
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit f3766538720116f099a8b1517f76ae2f094afd20
|
1
.vim/bundle/vim-airline
Submodule
1
.vim/bundle/vim-airline
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4e2546a2098954b74cbc612f573826f13d6fb88e
|
1
.vim/bundle/vim-surround
Submodule
1
.vim/bundle/vim-surround
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit f51a26d3710629d031806305b6c8727189cd1935
|
52
.vim/colors/mustang.vim
Normal file
52
.vim/colors/mustang.vim
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
set background=dark
|
||||||
|
|
||||||
|
hi clear
|
||||||
|
|
||||||
|
if exists("syntax_on")
|
||||||
|
syntax reset
|
||||||
|
endif
|
||||||
|
|
||||||
|
let colors_name = "mustang"
|
||||||
|
|
||||||
|
" Vim >= 7.0 specific colors
|
||||||
|
if version >= 700
|
||||||
|
hi CursorLine guibg=#2d2d2d ctermbg=236
|
||||||
|
hi CursorColumn guibg=#2d2d2d ctermbg=236
|
||||||
|
hi ColorColumn guibg=#000000 ctermbg=235
|
||||||
|
hi MatchParen guifg=#d0ffc0 guibg=#2f2f2f gui=bold ctermfg=157 ctermbg=237 cterm=bold
|
||||||
|
hi Pmenu guifg=#ffffff guibg=#444444 ctermfg=255 ctermbg=238
|
||||||
|
hi PmenuSel guifg=#000000 guibg=#b1d631 ctermfg=0 ctermbg=148
|
||||||
|
endif
|
||||||
|
|
||||||
|
" General colors
|
||||||
|
hi Cursor guifg=NONE guibg=#626262 gui=none ctermbg=241
|
||||||
|
hi Normal guifg=#e2e2e5 guibg=#202020 gui=none ctermfg=253 ctermbg=none
|
||||||
|
hi NonText guifg=#808080 guibg=#303030 gui=none ctermfg=244 ctermbg=none
|
||||||
|
hi LineNr guifg=#808080 guibg=#000000 gui=none ctermfg=244 ctermbg=232
|
||||||
|
hi StatusLine guifg=#d3d3d5 guibg=#444444 gui=italic ctermfg=253 ctermbg=238 cterm=italic
|
||||||
|
hi StatusLineNC guifg=#939395 guibg=#444444 gui=none ctermfg=246 ctermbg=238
|
||||||
|
hi VertSplit guifg=#444444 guibg=#444444 gui=none ctermfg=238 ctermbg=238
|
||||||
|
hi Folded guibg=#384048 guifg=#a0a8b0 gui=none ctermbg=4 ctermfg=248
|
||||||
|
hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=254 cterm=bold
|
||||||
|
hi Visual guifg=#faf4c6 guibg=#3c414c gui=none ctermfg=254 ctermbg=4
|
||||||
|
hi SpecialKey guifg=#808080 guibg=#343434 gui=none ctermfg=244 ctermbg=236
|
||||||
|
|
||||||
|
" Syntax highlighting
|
||||||
|
hi Comment guifg=#808080 gui=italic ctermfg=244
|
||||||
|
hi Todo guifg=#8f8f8f gui=italic ctermfg=245
|
||||||
|
hi Boolean guifg=#b1d631 gui=none ctermfg=148
|
||||||
|
hi String guifg=#b1d631 gui=italic ctermfg=148
|
||||||
|
hi Identifier guifg=#b1d631 gui=none ctermfg=148
|
||||||
|
hi Function guifg=#ffffff gui=bold ctermfg=255
|
||||||
|
hi Type guifg=#7e8aa2 gui=none ctermfg=103
|
||||||
|
hi Statement guifg=#7e8aa2 gui=none ctermfg=103
|
||||||
|
hi Keyword guifg=#ff9800 gui=none ctermfg=208
|
||||||
|
hi Constant guifg=#ff9800 gui=none ctermfg=208
|
||||||
|
hi Number guifg=#ff9800 gui=none ctermfg=208
|
||||||
|
hi Special guifg=#ff9800 gui=none ctermfg=208
|
||||||
|
hi PreProc guifg=#faf4c6 gui=none ctermfg=230
|
||||||
|
hi Todo guifg=#000000 guibg=#e6ea50 gui=italic
|
||||||
|
|
||||||
|
" Code-specific colors
|
||||||
|
hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103
|
||||||
|
hi Search cterm=NONE ctermbg=yellow
|
206
.vim/plugin/acp.vim
Executable file
206
.vim/plugin/acp.vim
Executable file
@ -0,0 +1,206 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
" GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
try
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 702, 101, [])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
catch /E117/
|
||||||
|
echoerr '***** L9 library must be installed! *****'
|
||||||
|
finish
|
||||||
|
endtry
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" FUNCTION: {{{1
|
||||||
|
|
||||||
|
"
|
||||||
|
function s:makeDefaultBehavior()
|
||||||
|
let behavs = {
|
||||||
|
\ '*' : [],
|
||||||
|
\ 'ruby' : [],
|
||||||
|
\ 'python' : [],
|
||||||
|
\ 'perl' : [],
|
||||||
|
\ 'php' : [],
|
||||||
|
\ 'xml' : [],
|
||||||
|
\ 'html' : [],
|
||||||
|
\ 'xhtml' : [],
|
||||||
|
\ 'css' : [],
|
||||||
|
\ 'scss' : [],
|
||||||
|
\ 'javascript': [],
|
||||||
|
\ 'coffee' : [],
|
||||||
|
\ 'ls' : [],
|
||||||
|
\ }
|
||||||
|
"---------------------------------------------------------------------------
|
||||||
|
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.php, {
|
||||||
|
\ 'command' : "\<C-x>\<C-o>",
|
||||||
|
\ 'meets' : 'acp#meetsForPhpOmni',
|
||||||
|
\ '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,
|
||||||
|
\ })
|
||||||
|
"---------------------------------------------------------------------------
|
||||||
|
call add(behavs.scss, {
|
||||||
|
\ 'command' : "\<C-x>\<C-f>",
|
||||||
|
\ 'meets' : 'acp#meetsForFile',
|
||||||
|
\ 'repeat' : 1,
|
||||||
|
\ })
|
||||||
|
call add(behavs.scss, {
|
||||||
|
\ 'command' : "\<C-x>\<C-o>",
|
||||||
|
\ 'meets' : 'acp#meetsForCssOmni',
|
||||||
|
\ 'repeat' : 0,
|
||||||
|
\ })
|
||||||
|
"---------------------------------------------------------------------------
|
||||||
|
call add(behavs.javascript, {
|
||||||
|
\ 'command' : "\<C-x>\<C-o>",
|
||||||
|
\ 'meets' : 'acp#meetsForJavaScriptOmni',
|
||||||
|
\ 'repeat' : 0,
|
||||||
|
\})
|
||||||
|
call add(behavs.coffee, {
|
||||||
|
\ 'command' : "\<C-x>\<C-o>",
|
||||||
|
\ 'meets' : 'acp#meetsForJavaScriptOmni',
|
||||||
|
\ 'repeat' : 0,
|
||||||
|
\})
|
||||||
|
call add(behavs.ls, {
|
||||||
|
\ 'command' : "\<C-x>\<C-o>",
|
||||||
|
\ 'meets' : 'acp#meetsForJavaScriptOmni',
|
||||||
|
\ 'repeat' : 0,
|
||||||
|
\})
|
||||||
|
return behavs
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1a
|
||||||
|
"=============================================================================
|
||||||
|
" INITIALIZATION {{{1
|
||||||
|
|
||||||
|
"-----------------------------------------------------------------------------
|
||||||
|
call l9#defineVariableDefault('g:acp_enableAtStartup', 1)
|
||||||
|
call l9#defineVariableDefault('g:acp_mappingDriven', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_ignorecaseOption', 1)
|
||||||
|
call l9#defineVariableDefault('g:acp_completeOption', '.,w,b,k')
|
||||||
|
call l9#defineVariableDefault('g:acp_completeoptPreview', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorUserDefinedFunction', '')
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorUserDefinedMeets', '')
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorSnipmateLength', -1)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorKeywordCommand', "\<C-n>")
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorKeywordLength', 2)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorKeywordIgnores', [])
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorFileLength', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorRubyOmniMethodLength', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorRubyOmniSymbolLength', 1)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorPythonOmniLength', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorPerlOmniLength', -1)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorPhpOmniLength', 1)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorXmlOmniLength', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorHtmlOmniLength', 0)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorCssOmniPropertyLength', 1)
|
||||||
|
call l9#defineVariableDefault('g:acp_behaviorCssOmniValueLength', 0)
|
||||||
|
call l9#defineVariableDefault('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
|
||||||
|
" Disable ACP when in nvim terminal emulator
|
||||||
|
if has("nvim")
|
||||||
|
au BufEnter,TermOpen term://* AcpDisable
|
||||||
|
au BufLeave term://* AcpEnable
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
108
.vim/plugin/l9.vim
Executable file
108
.vim/plugin/l9.vim
Executable file
@ -0,0 +1,108 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||||
|
"
|
||||||
|
" GetLatestVimScripts: 3252 1 :AutoInstall: L9
|
||||||
|
"=============================================================================
|
||||||
|
" LOAD GUARD {{{1
|
||||||
|
|
||||||
|
if !l9#guardScriptLoading(expand('<sfile>:p'), 702, 0, [])
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" OPTIONS: {{{1
|
||||||
|
|
||||||
|
call l9#defineVariableDefault('g:l9_balloonly', 'balloonly.exe')
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" ASSERTION: {{{1
|
||||||
|
|
||||||
|
" This command has effect only if $L9_DEBUG is non-zero.
|
||||||
|
" Used as follows:
|
||||||
|
" L9Assert a:i > 0
|
||||||
|
" This command can't interpret script-local variables directly.
|
||||||
|
" NG: L9Assert s:a == 1
|
||||||
|
" OK: execute 'L9Assert ' . s:a . ' == 1'
|
||||||
|
"
|
||||||
|
if $L9_DEBUG
|
||||||
|
command -nargs=* L9Assert call eval((<args>) ? 0 : s:handleFailedAssersion(<q-args>))
|
||||||
|
|
||||||
|
function s:handleFailedAssersion(expr)
|
||||||
|
echoerr '[L9Assert] Assersion failure: ' . a:expr
|
||||||
|
if input('[L9Assert] Continue? (Y/N) ', 'Y') !=? 'Y'
|
||||||
|
throw 'L9Assert ' . a:expr
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
else
|
||||||
|
command -nargs=* L9Assert :
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" TIMER: {{{1
|
||||||
|
|
||||||
|
" These commands have effect only if $L9_TIMER is non-zero.
|
||||||
|
" Used as follows:
|
||||||
|
" L9Timer foo
|
||||||
|
" ... (1)
|
||||||
|
" L9Timer bar
|
||||||
|
" ... (2)
|
||||||
|
" L9TimerStop
|
||||||
|
" ...
|
||||||
|
" L9TimerDump <- shows each elapsed time of (1) and (2)
|
||||||
|
"
|
||||||
|
if $L9_TIMER
|
||||||
|
command -nargs=1 L9Timer call s:timerBegin(<q-args>)
|
||||||
|
command -nargs=0 L9TimerStop call s:timerStop()
|
||||||
|
command -nargs=0 L9TimerDump call s:timerDump()
|
||||||
|
|
||||||
|
let s:timerData = []
|
||||||
|
let s:timerTagMaxLen = 0
|
||||||
|
|
||||||
|
function s:timerBegin(tag)
|
||||||
|
L9TimerStop
|
||||||
|
let s:timerCurrent = {'tag': strftime('%c ') . a:tag . ' ', 'time': reltime()}
|
||||||
|
let s:timerTagMaxLen = max([len(s:timerCurrent.tag), s:timerTagMaxLen])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:timerStop()
|
||||||
|
if !exists('s:timerCurrent')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let s:timerCurrent.time = reltimestr(reltime(s:timerCurrent.time))
|
||||||
|
call add(s:timerData, s:timerCurrent)
|
||||||
|
unlet s:timerCurrent
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:timerDump()
|
||||||
|
L9TimerStop
|
||||||
|
let lines = map(s:timerData, 'v:val.tag . repeat(" ", s:timerTagMaxLen - len(v:val.tag)) . v:val.time')
|
||||||
|
call l9#tempbuffer#openReadOnly('[l9-timer]', '', lines, 0, 0, 0, {})
|
||||||
|
let s:timerData = []
|
||||||
|
let s:timerTagMaxLen = 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
else
|
||||||
|
command -nargs=1 L9Timer :
|
||||||
|
command -nargs=0 L9TimerStop :
|
||||||
|
command -nargs=0 L9TimerDump :
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" GREP BUFFER: {{{1
|
||||||
|
|
||||||
|
" Grep for current buffer by l9#grepBuffers()
|
||||||
|
" Used as :L9GrepBuffer/pattern
|
||||||
|
command -nargs=? L9GrepBuffer call l9#grepBuffers(<q-args>, [bufnr('%')])
|
||||||
|
|
||||||
|
" Grep for all buffers by l9#grepBuffers()
|
||||||
|
" Used as :L9GrepBufferAll/pattern
|
||||||
|
command -nargs=? L9GrepBufferAll call l9#grepBuffers(<q-args>, range(1, bufnr('$')))
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
"=============================================================================
|
||||||
|
" vim: set fdm=marker:
|
BIN
.vim/spell/fr.utf-8.spl
Normal file
BIN
.vim/spell/fr.utf-8.spl
Normal file
Binary file not shown.
BIN
.vim/spell/fr.utf-8.sug
Normal file
BIN
.vim/spell/fr.utf-8.sug
Normal file
Binary file not shown.
97
.vimrc
Normal file
97
.vimrc
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
set nocompatible
|
||||||
|
filetype off
|
||||||
|
set rtp+=~/.vim/bundle/Vundle.vim
|
||||||
|
call vundle#begin()
|
||||||
|
|
||||||
|
Plugin 'scrooloose/syntastic'
|
||||||
|
"Plugin 'tpope/vim-fugitive'
|
||||||
|
Plugin 'tpope/vim-surround'
|
||||||
|
Plugin 'vim-airline/vim-airline'
|
||||||
|
|
||||||
|
call vundle#end()
|
||||||
|
|
||||||
|
"Syntastic
|
||||||
|
set statusline+=%#warningmsg#
|
||||||
|
set statusline+=%{SyntasticStatuslineFlag()}
|
||||||
|
set statusline+=%*
|
||||||
|
let g:syntastic_always_populate_loc_list = 1
|
||||||
|
let g:syntastic_auto_loc_list = 1
|
||||||
|
let g:syntastic_check_on_open = 1
|
||||||
|
let g:syntastic_check_on_wq = 0
|
||||||
|
let g:syntastic_c_compiler = "clang"
|
||||||
|
function! SyntasticCheckHook(errors)
|
||||||
|
if !empty(a:errors)
|
||||||
|
let g:syntastic_loc_list_height = min([len(a:errors), 6])
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"Airline
|
||||||
|
let g:airline_powerline_fonts = 0
|
||||||
|
let g:airline#extensions#whitespace#checks = [ ]
|
||||||
|
let g:airline#extensions#whitespace#mixed_indent_algo = 0
|
||||||
|
set noshowmode " to get rid of thing like --INSERT--
|
||||||
|
set noshowcmd " to get rid of display of last command
|
||||||
|
set shortmess+=F " to get rid of the file name displayed in the command line bar
|
||||||
|
|
||||||
|
|
||||||
|
"Global options
|
||||||
|
set backspace=indent,eol,start "allow backspacing over everything in insert mode
|
||||||
|
set history=500 "keep 50 lines of command line history
|
||||||
|
set ruler "show the cursor position all the time
|
||||||
|
set showcmd "display incomplete commands
|
||||||
|
set incsearch "do incremental searching
|
||||||
|
set nu "show line numbers
|
||||||
|
"set expandtab "use spaces instead of tabs
|
||||||
|
"set tabstop=4 "insert 4 spaces whenever the tab key is pressed
|
||||||
|
"set shiftwidth=4 "set indentation to 4 spaces
|
||||||
|
set hlsearch "highlight search terms
|
||||||
|
set ic "Ignore Case during searches
|
||||||
|
set autoindent "start new line at the same indentation level
|
||||||
|
syntax enable "syntax highlighting
|
||||||
|
set cmdheight=1 "The commandbar height
|
||||||
|
set showmatch "Show matching bracets when text indicator is over them
|
||||||
|
set nobackup " do not keep backup files, it's 70's style cluttering
|
||||||
|
set noswapfile " do not write annoying intermediate swap files,
|
||||||
|
set ttimeoutlen=50 "Solves: there is a pause when leaving insert mode
|
||||||
|
set splitbelow " Horizontal splits open below current file
|
||||||
|
set splitright " Vertical splits open to the right of the current file
|
||||||
|
set wildmode=longest,list " Pressing <Tab> shows command suggestions similar
|
||||||
|
set t_Co=256
|
||||||
|
colorscheme mustang
|
||||||
|
set encoding=utf-8 " The encoding displayed.
|
||||||
|
set fileencoding=utf-8 " The encoding written to file
|
||||||
|
"hi ColorColumn ctermbg=235
|
||||||
|
"let &colorcolumn=join(range(81,999),",")
|
||||||
|
autocmd FileType latex,tex,md,markdown setlocal spell spelllang=en,fr
|
||||||
|
hi clear SpellBad
|
||||||
|
hi SpellBad cterm=underline
|
||||||
|
|
||||||
|
highlight clear SpellBad
|
||||||
|
highlight clear SpellCap
|
||||||
|
highlight clear SpellLocal
|
||||||
|
highlight clear SpellRare
|
||||||
|
|
||||||
|
highlight SpellBad cterm=underline,bold
|
||||||
|
highlight SpellCap cterm=underline
|
||||||
|
highlight SpellLocal cterm=underline
|
||||||
|
highlight SpellRare cterm=underline
|
||||||
|
|
||||||
|
au BufNewFile,BufRead *.py
|
||||||
|
\ set tabstop=4 |
|
||||||
|
\ set softtabstop=4 |
|
||||||
|
\ set shiftwidth=4 |
|
||||||
|
\ set expandtab |
|
||||||
|
\ set autoindent |
|
||||||
|
\ set fileformat=unix
|
||||||
|
|
||||||
|
au BufNewFile,BufRead *.c,*.h
|
||||||
|
\ set autoindent |
|
||||||
|
\ set fileformat=unix
|
||||||
|
|
||||||
|
inoremap { {}<Esc>ha
|
||||||
|
inoremap ( ()<Esc>ha
|
||||||
|
inoremap [ []<Esc>ha
|
||||||
|
inoremap " ""<Esc>ha
|
||||||
|
inoremap ' ''<Esc>ha
|
||||||
|
inoremap ` ``<Esc>ha
|
||||||
|
|
Loading…
Reference in New Issue
Block a user