258 changed files with 58460 additions and 0 deletions
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
# Improved AnsiEsc.vim |
||||
|
||||
This is a [Vim script №302: AnsiEsc.vim](http://www.vim.org/scripts/script.php?script_id=302) |
||||
updated to [latest author's version](http://www.drchip.org/astronaut/vim/index.html#ANSIESC) |
||||
with several fixes/improvements. |
||||
|
||||
Download .zip/.vmb from http://www.vim.org/scripts/script.php?script_id=4979 |
||||
|
||||
## Changes |
||||
|
||||
* updated to latest author's version: **13e** (Dec 06, 2012) |
||||
* add support for simple ANSI sequences like "bold" (without defining color) |
||||
* add support for 16-color 'light' escape sequences (by Andy Berdan, merged from https://github.com/berdandy/AnsiEsc.vim) |
||||
* disable `\swp` and `\rwp` maps if `g:no_plugin_maps` or `g:no_cecutil_maps` exists |
||||
* disable DrChip/AnsiEsc menu if `g:no_drchip_menu` or `g:no_ansiesc_menu` exists |
||||
* add support for simple ANSI sequences like disable bold/italic/etc. |
||||
|
||||
## Original README |
||||
|
||||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=302 |
||||
|
||||
Files with ANSI escape sequences look good when dumped onto a terminal that accepts them, but have been a distracting clutter when edited via vim. The AnsiEsc.vim file, when sourced, will conceal Ansi escape sequences but will cause subsequent text to be colored as the escape sequence specifies when used with Vince Negri's conceal patch. AnsiEsc.vim v3 or later uses the conceal patch to accomplish this. |
||||
|
||||
Without that conceal patch, the best that can be done is to suppress Ansi escape sequences with "Ignore" highlighting. AnsiEsc.vim v2 does that. |
||||
|
||||
### VIM Developer's Corner: |
||||
|
||||
Vince Negri's "conceal" patch to vim6.3 and vim7.0 allows one to suppress strings within a line; ie. in-line folding! This feature is ideal for Ansi escape sequence handling. Starting with AnsiEsc's version 3 the <AnsiEsc.vim> script makes use of that new capability to display Ansi-sequence containing files. The Ansi escape sequences themselves are concealed (except for the line where the cursor is), but they have their desired colorizing effect. Note that you must have Vim7.0 with the +conceal option for the latest <AnsiEsc.vim> (v8) to work. Apply Vince Negri's patch to the Vim 7.0 source code and compile Vim for "huge" features. Once you've done that, simply source the <AnsiEsc.vim> file in when you want to see Ansi-escape sequenced text in Vim. |
||||
|
||||
### Typical Compiling Directions: |
||||
|
||||
To use the AnsiEsc v2, just source it in when you wish to; your vim version needs +syntax, which is fairly common. |
||||
|
||||
To use the conceal-mode AnsiEsc (those with versions >= 3), you'll need to have a Vim that has been patched with Vince Negri's concealownsyntax patch; the version will show both +syntax and +conceal. |
||||
|
||||
Typical compiling directions: |
||||
|
||||
* cd ..wherever../vim70/ |
||||
* browse http://sites.google.com/site/vincenegri/ for the conceal/ownsyntax patch |
||||
* patch -p0 < conceal-ownsyntax.diff |
||||
* make distclean |
||||
* configure --with-features=huge |
||||
* make |
||||
* make install |
||||
|
||||
|
||||
(also see: vimtip#1308) |
||||
(alpha/beta version available at http://mysite.verizon.net/astronaut/vim/index.html#ANSIESC) |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
" AnsiEscPlugin.vim |
||||
" Author: Charles E. Campbell |
||||
" Date: Apr 07, 2010 |
||||
" Version: 13e |
||||
" --------------------------------------------------------------------- |
||||
" Load Once: {{{1 |
||||
if &cp || exists("g:loaded_AnsiEscPlugin") |
||||
finish |
||||
endif |
||||
let g:loaded_AnsiEscPlugin = "v13e" |
||||
let s:keepcpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Public Interface: {{{1 |
||||
com! -bang -nargs=0 AnsiEsc :call AnsiEsc#AnsiEsc(<bang>0) |
||||
|
||||
" DrChip Menu Support: {{{2 |
||||
if !exists('g:no_drchip_menu') && !exists('g:no_ansiesc_menu') |
||||
if has("gui_running") && has("menu") && &go =~ 'm' |
||||
if !exists("g:DrChipTopLvlMenu") |
||||
let g:DrChipTopLvlMenu= "DrChip." |
||||
endif |
||||
exe 'menu '.g:DrChipTopLvlMenu.'AnsiEsc.Start<tab>:AnsiEsc :AnsiEsc<cr>' |
||||
endif |
||||
endif |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Restore: {{{1 |
||||
let &cpo= s:keepcpo |
||||
unlet s:keepcpo |
||||
" vim: ts=4 fdm=marker |
@ -0,0 +1,538 @@
@@ -0,0 +1,538 @@
|
||||
" cecutil.vim : save/restore window position |
||||
" save/restore mark position |
||||
" save/restore selected user maps |
||||
" Author: Charles E. Campbell |
||||
" Version: 18i ASTRO-ONLY |
||||
" Date: Oct 21, 2013 |
||||
" |
||||
" Saving Restoring Destroying Marks: {{{1 |
||||
" call SaveMark(markname) let savemark= SaveMark(markname) |
||||
" call RestoreMark(markname) call RestoreMark(savemark) |
||||
" call DestroyMark(markname) |
||||
" commands: SM RM DM |
||||
" |
||||
" Saving Restoring Destroying Window Position: {{{1 |
||||
" call SaveWinPosn() let winposn= SaveWinPosn() |
||||
" call RestoreWinPosn() call RestoreWinPosn(winposn) |
||||
" \swp : save current window/buffer's position |
||||
" \rwp : restore current window/buffer's previous position |
||||
" commands: SWP RWP |
||||
" |
||||
" Saving And Restoring User Maps: {{{1 |
||||
" call SaveUserMaps(mapmode,maplead,mapchx,suffix) |
||||
" call RestoreUserMaps(suffix) |
||||
" |
||||
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim |
||||
" |
||||
" You believe that God is one. You do well. The demons also {{{1 |
||||
" believe, and shudder. But do you want to know, vain man, that |
||||
" faith apart from works is dead? (James 2:19,20 WEB) |
||||
"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore() |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Load Once: {{{1 |
||||
if &cp || exists("g:loaded_cecutil") |
||||
finish |
||||
endif |
||||
let g:loaded_cecutil = "v18i" |
||||
let s:keepcpo = &cpo |
||||
set cpo&vim |
||||
"DechoRemOn |
||||
|
||||
" ======================= |
||||
" Public Interface: {{{1 |
||||
" ======================= |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Map Interface: {{{2 |
||||
if !exists('g:no_plugin_maps') && !exists('g:no_cecutil_maps') |
||||
if !hasmapto('<Plug>SaveWinPosn') |
||||
map <unique> <Leader>swp <Plug>SaveWinPosn |
||||
endif |
||||
if !hasmapto('<Plug>RestoreWinPosn') |
||||
map <unique> <Leader>rwp <Plug>RestoreWinPosn |
||||
endif |
||||
endif |
||||
nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR> |
||||
nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR> |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Command Interface: {{{2 |
||||
com! -bar -nargs=0 SWP call SaveWinPosn() |
||||
com! -bar -nargs=? RWP call RestoreWinPosn(<args>) |
||||
com! -bar -nargs=1 SM call SaveMark(<q-args>) |
||||
com! -bar -nargs=1 RM call RestoreMark(<q-args>) |
||||
com! -bar -nargs=1 DM call DestroyMark(<q-args>) |
||||
|
||||
com! -bar -nargs=1 WLR call s:WinLineRestore(<q-args>) |
||||
|
||||
if v:version < 630 |
||||
let s:modifier= "sil! " |
||||
else |
||||
let s:modifier= "sil! keepj " |
||||
endif |
||||
|
||||
" =============== |
||||
" Functions: {{{1 |
||||
" =============== |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" SaveWinPosn: {{{2 |
||||
" let winposn= SaveWinPosn() will save window position in winposn variable |
||||
" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn} |
||||
" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done) |
||||
fun! SaveWinPosn(...) |
||||
" echomsg "Decho: SaveWinPosn() a:0=".a:0 |
||||
if line("$") == 1 && getline(1) == "" |
||||
" echomsg "Decho: SaveWinPosn : empty buffer" |
||||
return "" |
||||
endif |
||||
let so_keep = &l:so |
||||
let siso_keep = &siso |
||||
let ss_keep = &l:ss |
||||
setlocal so=0 siso=0 ss=0 |
||||
|
||||
let swline = line(".") " save-window line in file |
||||
let swcol = col(".") " save-window column in file |
||||
if swcol >= col("$") |
||||
let swcol= swcol + virtcol(".") - virtcol("$") " adjust for virtual edit (cursor past end-of-line) |
||||
endif |
||||
let swwline = winline() - 1 " save-window window line |
||||
let swwcol = virtcol(".") - wincol() " save-window window column |
||||
let savedposn = "" |
||||
" echomsg "Decho: sw[".swline.",".swcol."] sww[".swwline.",".swwcol."]" |
||||
let savedposn = "call GoWinbufnr(".winbufnr(0).")" |
||||
let savedposn = savedposn."|".s:modifier.swline |
||||
let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>" |
||||
if swwline > 0 |
||||
let savedposn= savedposn.":".s:modifier."call s:WinLineRestore(".(swwline+1).")\<cr>" |
||||
endif |
||||
if swwcol > 0 |
||||
let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>" |
||||
endif |
||||
let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>" |
||||
|
||||
" save window position in |
||||
" b:cecutil_winposn_{iwinposn} (stack) |
||||
" only when SaveWinPosn() is used |
||||
if a:0 == 0 |
||||
if !exists("b:cecutil_iwinposn") |
||||
let b:cecutil_iwinposn= 1 |
||||
else |
||||
let b:cecutil_iwinposn= b:cecutil_iwinposn + 1 |
||||
endif |
||||
" echomsg "Decho: saving posn to SWP stack" |
||||
let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn |
||||
endif |
||||
|
||||
let &l:so = so_keep |
||||
let &siso = siso_keep |
||||
let &l:ss = ss_keep |
||||
|
||||
" if exists("b:cecutil_iwinposn") " Decho |
||||
" echomsg "Decho: b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]" |
||||
" else " Decho |
||||
" echomsg "Decho: b:cecutil_iwinposn doesn't exist" |
||||
" endif " Decho |
||||
" echomsg "Decho: SaveWinPosn [".savedposn."]" |
||||
return savedposn |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" RestoreWinPosn: {{{2 |
||||
" call RestoreWinPosn() |
||||
" call RestoreWinPosn(winposn) |
||||
fun! RestoreWinPosn(...) |
||||
" echomsg "Decho: RestoreWinPosn() a:0=".a:0 |
||||
" echomsg "Decho: getline(1)<".getline(1).">" |
||||
" echomsg "Decho: line(.)=".line(".") |
||||
if line("$") == 1 && getline(1) == "" |
||||
" echomsg "Decho: RestoreWinPosn : empty buffer" |
||||
return "" |
||||
endif |
||||
let so_keep = &l:so |
||||
let siso_keep = &l:siso |
||||
let ss_keep = &l:ss |
||||
setlocal so=0 siso=0 ss=0 |
||||
|
||||
if a:0 == 0 || a:1 == "" |
||||
" use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists |
||||
if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}") |
||||
" echomsg "Decho: using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">" |
||||
try |
||||
exe s:modifier.b:cecutil_winposn{b:cecutil_iwinposn} |
||||
catch /^Vim\%((\a\+)\)\=:E749/ |
||||
" ignore empty buffer error messages |
||||
endtry |
||||
" normally drop top-of-stack by one |
||||
" but while new top-of-stack doesn't exist |
||||
" drop top-of-stack index by one again |
||||
if b:cecutil_iwinposn >= 1 |
||||
unlet b:cecutil_winposn{b:cecutil_iwinposn} |
||||
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 |
||||
while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}") |
||||
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 |
||||
endwhile |
||||
if b:cecutil_iwinposn < 1 |
||||
unlet b:cecutil_iwinposn |
||||
endif |
||||
endif |
||||
else |
||||
echohl WarningMsg |
||||
echomsg "***warning*** need to SaveWinPosn first!" |
||||
echohl None |
||||
endif |
||||
|
||||
else " handle input argument |
||||
" echomsg "Decho: using input a:1<".a:1.">" |
||||
" use window position passed to this function |
||||
exe a:1 |
||||
" remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack |
||||
if exists("b:cecutil_iwinposn") |
||||
let jwinposn= b:cecutil_iwinposn |
||||
while jwinposn >= 1 " search for a:1 in iwinposn..1 |
||||
if exists("b:cecutil_winposn{jwinposn}") " if it exists |
||||
if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches |
||||
unlet b:cecutil_winposn{jwinposn} " unlet it |
||||
if jwinposn == b:cecutil_iwinposn " if at top-of-stack |
||||
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one |
||||
endif |
||||
endif |
||||
endif |
||||
let jwinposn= jwinposn - 1 |
||||
endwhile |
||||
endif |
||||
endif |
||||
|
||||
" Seems to be something odd: vertical motions after RWP |
||||
" cause jump to first column. The following fixes that. |
||||
" Note: was using wincol()>1, but with signs, a cursor |
||||
" at column 1 yields wincol()==3. Beeping ensued. |
||||
let vekeep= &ve |
||||
set ve=all |
||||
if virtcol('.') > 1 |
||||
exe s:modifier."norm! hl" |
||||
elseif virtcol(".") < virtcol("$") |
||||
exe s:modifier."norm! lh" |
||||
endif |
||||
let &ve= vekeep |
||||
|
||||
let &l:so = so_keep |
||||
let &l:siso = siso_keep |
||||
let &l:ss = ss_keep |
||||
|
||||
" echomsg "Decho: RestoreWinPosn" |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" s:WinLineRestore: {{{2 |
||||
fun! s:WinLineRestore(swwline) |
||||
" echomsg "Decho: s:WinLineRestore(swwline=".a:swwline.")" |
||||
while winline() < a:swwline |
||||
let curwinline= winline() |
||||
exe s:modifier."norm! \<c-y>" |
||||
if curwinline == winline() |
||||
break |
||||
endif |
||||
endwhile |
||||
" echomsg "Decho: s:WinLineRestore" |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" GoWinbufnr: go to window holding given buffer (by number) {{{2 |
||||
" Prefers current window; if its buffer number doesn't match, |
||||
" then will try from topleft to bottom right |
||||
fun! GoWinbufnr(bufnum) |
||||
" call Dfunc("GoWinbufnr(".a:bufnum.")") |
||||
if winbufnr(0) == a:bufnum |
||||
" call Dret("GoWinbufnr : winbufnr(0)==a:bufnum") |
||||
return |
||||
endif |
||||
winc t |
||||
let first=1 |
||||
while winbufnr(0) != a:bufnum && (first || winnr() != 1) |
||||
winc w |
||||
let first= 0 |
||||
endwhile |
||||
" call Dret("GoWinbufnr") |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" SaveMark: sets up a string saving a mark position. {{{2 |
||||
" For example, SaveMark("a") |
||||
" Also sets up a global variable, g:savemark_{markname} |
||||
fun! SaveMark(markname) |
||||
" call Dfunc("SaveMark(markname<".a:markname.">)") |
||||
let markname= a:markname |
||||
if strpart(markname,0,1) !~ '\a' |
||||
let markname= strpart(markname,1,1) |
||||
endif |
||||
" call Decho("markname=".markname) |
||||
|
||||
let lzkeep = &lz |
||||
set lz |
||||
|
||||
if 1 <= line("'".markname) && line("'".markname) <= line("$") |
||||
let winposn = SaveWinPosn(0) |
||||
exe s:modifier."norm! `".markname |
||||
let savemark = SaveWinPosn(0) |
||||
let g:savemark_{markname} = savemark |
||||
let savemark = markname.savemark |
||||
call RestoreWinPosn(winposn) |
||||
else |
||||
let g:savemark_{markname} = "" |
||||
let savemark = "" |
||||
endif |
||||
|
||||
let &lz= lzkeep |
||||
|
||||
" call Dret("SaveMark : savemark<".savemark.">") |
||||
return savemark |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" RestoreMark: {{{2 |
||||
" call RestoreMark("a") -or- call RestoreMark(savemark) |
||||
fun! RestoreMark(markname) |
||||
" call Dfunc("RestoreMark(markname<".a:markname.">)") |
||||
|
||||
if strlen(a:markname) <= 0 |
||||
" call Dret("RestoreMark : no such mark") |
||||
return |
||||
endif |
||||
let markname= strpart(a:markname,0,1) |
||||
if markname !~ '\a' |
||||
" handles 'a -> a styles |
||||
let markname= strpart(a:markname,1,1) |
||||
endif |
||||
" call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname)) |
||||
|
||||
let lzkeep = &lz |
||||
set lz |
||||
let winposn = SaveWinPosn(0) |
||||
|
||||
if strlen(a:markname) <= 2 |
||||
if exists("g:savemark_{markname}") && strlen(g:savemark_{markname}) != 0 |
||||
" use global variable g:savemark_{markname} |
||||
" call Decho("use savemark list") |
||||
call RestoreWinPosn(g:savemark_{markname}) |
||||
exe "norm! m".markname |
||||
endif |
||||
else |
||||
" markname is a savemark command (string) |
||||
" call Decho("use savemark command") |
||||
let markcmd= strpart(a:markname,1) |
||||
call RestoreWinPosn(markcmd) |
||||
exe "norm! m".markname |
||||
endif |
||||
|
||||
call RestoreWinPosn(winposn) |
||||
let &lz = lzkeep |
||||
|
||||
" call Dret("RestoreMark") |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" DestroyMark: {{{2 |
||||
" call DestroyMark("a") -- destroys mark |
||||
fun! DestroyMark(markname) |
||||
" call Dfunc("DestroyMark(markname<".a:markname.">)") |
||||
|
||||
" save options and set to standard values |
||||
let reportkeep= &report |
||||
let lzkeep = &lz |
||||
set lz report=10000 |
||||
|
||||
let markname= strpart(a:markname,0,1) |
||||
if markname !~ '\a' |
||||
" handles 'a -> a styles |
||||
let markname= strpart(a:markname,1,1) |
||||
endif |
||||
" call Decho("markname=".markname) |
||||
|
||||
let curmod = &mod |
||||
let winposn = SaveWinPosn(0) |
||||
1 |
||||
let lineone = getline(".") |
||||
exe "k".markname |
||||
d |
||||
put! =lineone |
||||
let &mod = curmod |
||||
call RestoreWinPosn(winposn) |
||||
|
||||
" restore options to user settings |
||||
let &report = reportkeep |
||||
let &lz = lzkeep |
||||
|
||||
" call Dret("DestroyMark") |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{2 |
||||
" However, <q-args> doesn't split at all, so this one returns a list |
||||
" with splits at all whitespace (only!), plus a leading length-of-list. |
||||
" The resulting list: qarglist[0] corresponds to a:0 |
||||
" qarglist[i] corresponds to a:{i} |
||||
fun! QArgSplitter(qarg) |
||||
" call Dfunc("QArgSplitter(qarg<".a:qarg.">)") |
||||
let qarglist = split(a:qarg) |
||||
let qarglistlen = len(qarglist) |
||||
let qarglist = insert(qarglist,qarglistlen) |
||||
" call Dret("QArgSplitter ".string(qarglist)) |
||||
return qarglist |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" ListWinPosn: {{{2 |
||||
"fun! ListWinPosn() " Decho |
||||
" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho |
||||
" call Decho("nothing on SWP stack") " Decho |
||||
" else " Decho |
||||
" let jwinposn= b:cecutil_iwinposn " Decho |
||||
" while jwinposn >= 1 " Decho |
||||
" if exists("b:cecutil_winposn{jwinposn}") " Decho |
||||
" call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho |
||||
" else " Decho |
||||
" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho |
||||
" endif " Decho |
||||
" let jwinposn= jwinposn - 1 " Decho |
||||
" endwhile " Decho |
||||
" endif " Decho |
||||
"endfun " Decho |
||||
"com! -nargs=0 LWP call ListWinPosn() " Decho |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{2 |
||||
" which can be used to restore user maps later with |
||||
" call RestoreUserMaps() |
||||
" |
||||
" mapmode - see :help maparg for details (n v o i c l "") |
||||
" ex. "n" = Normal |
||||
" The letters "b" and "u" are optional prefixes; |
||||
" The "u" means that the map will also be unmapped |
||||
" The "b" means that the map has a <buffer> qualifier |
||||
" ex. "un" = Normal + unmapping |
||||
" ex. "bn" = Normal + <buffer> |
||||
" ex. "bun" = Normal + <buffer> + unmapping |
||||
" ex. "ubn" = Normal + <buffer> + unmapping |
||||
" maplead - see mapchx |
||||
" mapchx - "<something>" handled as a single map item. |
||||
" ex. "<left>" |
||||
" - "string" a string of single letters which are actually |
||||
" multiple two-letter maps (using the maplead: |
||||
" maplead . each_character_in_string) |
||||
" ex. maplead="\" and mapchx="abc" saves user mappings for |
||||
" \a, \b, and \c |
||||
" Of course, if maplead is "", then for mapchx="abc", |
||||
" mappings for a, b, and c are saved. |
||||
" - :something handled as a single map item, w/o the ":" |
||||
" ex. mapchx= ":abc" will save a mapping for "abc" |
||||
" suffix - a string unique to your plugin |
||||
" ex. suffix= "DrawIt" |
||||
fun! SaveUserMaps(mapmode,maplead,mapchx,suffix) |
||||
" call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)") |
||||
|
||||
if !exists("s:restoremap_{a:suffix}") |
||||
" initialize restoremap_suffix to null string |
||||
let s:restoremap_{a:suffix}= "" |
||||
endif |
||||
|
||||
" set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u") |
||||
" if 0, save only |
||||
let mapmode = a:mapmode |
||||
let dounmap = 0 |
||||
let dobuffer = "" |
||||
while mapmode =~ '^[bu]' |
||||
if mapmode =~ '^u' |
||||
let dounmap = 1 |
||||
let mapmode = strpart(a:mapmode,1) |
||||
elseif mapmode =~ '^b' |
||||
let dobuffer = "<buffer> " |
||||
let mapmode = strpart(a:mapmode,1) |
||||
endif |
||||
endwhile |
||||
" call Decho("dounmap=".dounmap." dobuffer<".dobuffer.">") |
||||
|
||||
" save single map :...something... |
||||
if strpart(a:mapchx,0,1) == ':' |
||||
" call Decho("save single map :...something...") |
||||
let amap= strpart(a:mapchx,1) |
||||
if amap == "|" || amap == "\<c-v>" |
||||
let amap= "\<c-v>".amap |
||||
endif |
||||
let amap = a:maplead.amap |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:sil! ".mapmode."unmap ".dobuffer.amap |
||||
if maparg(amap,mapmode) != "" |
||||
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".dobuffer.amap." ".maprhs |
||||
endif |
||||
if dounmap |
||||
exe "sil! ".mapmode."unmap ".dobuffer.amap |
||||
endif |
||||
|
||||
" save single map <something> |
||||
elseif strpart(a:mapchx,0,1) == '<' |
||||
" call Decho("save single map <something>") |
||||
let amap = a:mapchx |
||||
if amap == "|" || amap == "\<c-v>" |
||||
let amap= "\<c-v>".amap |
||||
" call Decho("amap[[".amap."]]") |
||||
endif |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap |
||||
if maparg(a:mapchx,mapmode) != "" |
||||
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs |
||||
endif |
||||
if dounmap |
||||
exe "sil! ".mapmode."unmap ".dobuffer.amap |
||||
endif |
||||
|
||||
" save multiple maps |
||||
else |
||||
" call Decho("save multiple maps") |
||||
let i= 1 |
||||
while i <= strlen(a:mapchx) |
||||
let amap= a:maplead.strpart(a:mapchx,i-1,1) |
||||
if amap == "|" || amap == "\<c-v>" |
||||
let amap= "\<c-v>".amap |
||||
endif |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap |
||||
if maparg(amap,mapmode) != "" |
||||
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') |
||||
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs |
||||
endif |
||||
if dounmap |
||||
exe "sil! ".mapmode."unmap ".dobuffer.amap |
||||
endif |
||||
let i= i + 1 |
||||
endwhile |
||||
endif |
||||
" call Dret("SaveUserMaps : restoremap_".a:suffix.": ".s:restoremap_{a:suffix}) |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" RestoreUserMaps: {{{2 |
||||
" Used to restore user maps saved by SaveUserMaps() |
||||
fun! RestoreUserMaps(suffix) |
||||
" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)") |
||||
if exists("s:restoremap_{a:suffix}") |
||||
let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e') |
||||
if s:restoremap_{a:suffix} != "" |
||||
" call Decho("exe ".s:restoremap_{a:suffix}) |
||||
exe "sil! ".s:restoremap_{a:suffix} |
||||
endif |
||||
unlet s:restoremap_{a:suffix} |
||||
endif |
||||
" call Dret("RestoreUserMaps") |
||||
endfun |
||||
|
||||
" ============== |
||||
" Restore: {{{1 |
||||
" ============== |
||||
let &cpo= s:keepcpo |
||||
unlet s:keepcpo |
||||
|
||||
" ================ |
||||
" Modelines: {{{1 |
||||
" ================ |
||||
" vim: ts=4 fdm=marker |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
**Join** README file |
||||
|
||||
__ _ __ |
||||
/ /___ (_)___ / / |
||||
__ / / __ \/ / __ \ / / |
||||
/ /_/ / /_/ / / / / / /_/ |
||||
\____/\____/_/_/ /_/ (_) |
||||
|
||||
-Do better Join in vim |
||||
|
||||
##Join |
||||
|
||||
**Join** provides more powerful line join features than the build-in `:join`. |
||||
|
||||
##Features |
||||
|
||||
Except for all features provided by the build-in `:join` command, **Join** can: |
||||
|
||||
- **Join** lines with separator (string) |
||||
- **Join** lines with or without trimming the leading whitespaces |
||||
- **Join** lines with negative count (backwards join) |
||||
- **Join** lines in reverse |
||||
- **Join** lines and keep joined lines (without removing) |
||||
- **Join** lines with any combinations of above options |
||||
|
||||
##Usage |
||||
|
||||
>If you are impatient, move your eyes down to the **Examples and Screenshots** section. :) |
||||
|
||||
**Join** plugin defines only one command: `:Join`. If there is no other customer command (by other plugins maybe) starts with `J`, `:J` is also available for `:Join`. |
||||
|
||||
The command format is: |
||||
|
||||
:[range]Join[!] [separator] [count] [flags] |
||||
|
||||
Short explanation: (detailed command description please check `:h Join`) |
||||
|
||||
- all arguments are optional. If one argument was not given, the default value will be used: |
||||
|
||||
arg | Default value |
||||
======================== |
||||
range | current line |
||||
count | 1 |
||||
bang | "" |
||||
separator| " " |
||||
flags | "" |
||||
------------------------ |
||||
|
||||
- all given arguments must be separated by space |
||||
- `range` follows Vim's range definition |
||||
- `separator` must be the 1st argument, and could be any string. It must be quoted by `"` or `'`, depends on if an escaped special character is required. |
||||
- the order of last two argument: count and flags are free. e.g `:Join 5 rk` and `:Join rk 5`, both are valid. |
||||
- `count` could be negative number. In this case **Join** will do backwards join. |
||||
- `flags` : |
||||
|
||||
r : (reverse) join lines in reverse |
||||
k : (keep) don't remove joined line after join |
||||
|
||||
- If you don't give `[separator]` and `[flags]` also give only positive `[count]`, the `:Join` works as same as build-in `:join` |
||||
|
||||
##Examples & Screenshots |
||||
|
||||
**For detailed explainations, please check `:h Join`** |
||||
|
||||
Before |command & description |After |
||||
--- |--- |--- |
||||
![][before]|`:J ', ' 3`<br/>Join with:<br/>`sep`<br/>`count` |![][after01] |
||||
![][before]|`:J '-' 3 r`<br/>Join with:<br/>`sep`<br/>`count`<br/>`reverse` |![][after02] |
||||
![][before]|`:J '-' 3 k`<br/>Join with:<br/>`sep`<br/>`count`<br/>`keep` |![][after03] |
||||
![][before]|`:J '-' 3 kr`<br/>Join with:<br/>`sep`<br/>`count`<br/>`keep`<br/>`reverse` |![][after04] |
||||
![][before]|`:J -3`<br/>Join with:<br/>negative `count` |![][after05] |
||||
![][before]|`:J -3 r`<br/>Join with:<br/>negative `count`<br/>`reverse` |![][after06] |
||||
![][before]|`:J -3 kr`<br/>Join with:<br/>negative `count`<br/>`reverse`<br/>`keep` |![][after07] |
||||
![][before]|`:2,5J "'\"\t" k`<br/>Join with:<br/>`range`<br/>special `sep`<br/>`keep` |![][after08] |
||||
![][before]|`:2,5J "# " rk`<br/>Join with:<br/>`range`<br/>`sep`<br/>`keep`<br/>`reverse`|![][after09] |
||||
![][before]|`:5,7J 3`<br/>Join with:<br/>`range`<br/>`count` |![][after10] |
||||
![][before]|`:5,7J -3`<br/>Join with:<br/>`range`<br/>negative `count` |![][after11] |
||||
|
||||
|
||||
[before]: https://lh3.googleusercontent.com/-IXqp1V2h_HA/UWQCFc4bRAI/AAAAAAAAGxs/mqcm1khN1gU/s352/Join_before.png |
||||
[after01]: https://lh4.googleusercontent.com/-DqvfdX6MCiU/UWQCDsP5E7I/AAAAAAAAGxs/2WnuKdgC80M/s352/Join_01after.png |
||||
[after02]: https://lh4.googleusercontent.com/-hw8IC-YmIhE/UWQCDgj5wjI/AAAAAAAAGxs/ezX_2JTfIi4/s352/Join_02after.png |
||||
[after03]: https://lh3.googleusercontent.com/-7guzDaZG0w8/UWQCDnx04PI/AAAAAAAAGxs/2gf4vfUlgNo/s352/Join_03after.png |
||||
[after04]: https://lh4.googleusercontent.com/-1IJjBlWyESs/UWQCDy7cYQI/AAAAAAAAGxs/eySzhoe58SA/s352/Join_04after.png |
||||
[after05]: https://lh6.googleusercontent.com/-2Cf0bxmAQTo/UWQCECkBcXI/AAAAAAAAGxs/KtJW73eSvCs/s352/Join_05after.png |
||||
[after06]: https://lh4.googleusercontent.com/-x7oZd6beZzw/UWQCELjXSwI/AAAAAAAAGxs/dG7zZmXEUb0/s352/Join_06after.png |
||||
[after07]: https://lh3.googleusercontent.com/-72riJu4013M/UWQCErpQAII/AAAAAAAAGxs/TdVE93p6m4I/s352/Join_07after.png |
||||
[after08]: https://lh5.googleusercontent.com/-5G5cqY0uOp0/UWQCEmXmtTI/AAAAAAAAGxs/z7bE07FkhcU/s352/Join_08after.png |
||||
[after09]: https://lh6.googleusercontent.com/-LLHPh8cdWAI/UWQCEjf_34I/AAAAAAAAGxs/9obzpaHeS7c/s352/Join_09after.png |
||||
[after10]: https://lh3.googleusercontent.com/-NVj0xyquocE/UWQCFDTidPI/AAAAAAAAGxs/yesHmMVAfrk/s363/Join_10after.png |
||||
[after11]: https://lh4.googleusercontent.com/-xORvSXkcDl4/UWQCFTdqpYI/AAAAAAAAGxs/E_X6z9Ij7O4/s363/Join_11after.png |
||||
|
||||
vim:ft=markdown:sw=2:ts=2:fdm=marker:expandtab |
@ -0,0 +1,248 @@
@@ -0,0 +1,248 @@
|
||||
*Join.txt* A more powerful line join command in vim |
||||
|
||||
__ _ __ |
||||
/ /___ (_)___ / / |
||||
__ / / __ \/ / __ \ / / |
||||
/ /_/ / /_/ / / / / / /_/ |
||||
\____/\____/_/_/ /_/ (_) |
||||
|
||||
-Do better Join in vim |
||||
|
||||
Author: Kai Yuan (kent.yuan at gmail dot com) |
||||
|
||||
This plugin requires Vim 7.3 or later. |
||||
|
||||
============================================================================== |
||||
Help on using Join |
||||
|
||||
1. Introduction .......................... |Join-intro| |
||||
2. Usage ................................. |Join-usage| |
||||
3. Examples .............................. |Join-examples| |
||||
|
||||
============================================================================== |
||||
1. INTRODUCTION *Join-intro* |
||||
|
||||
|Join| provides more powerful line join features than the build-in |:join|. |
||||
|
||||
Features: |
||||
|
||||
Except for all features provided by the build-in |:join| command, |Join| can: |
||||
|
||||
- |Join| lines with separator (any string) |
||||
- |Join| lines with or without trimming the leading whitespaces |
||||
- |Join| lines with negative count (backwards join) |
||||
- |Join| lines in reverse |
||||
- |Join| lines and keep joined lines (without removing) |
||||
- |Join| lines with any combinations of above options |
||||
|
||||
============================================================================== |
||||
2. USAGE *:J* *:Join* *Join-usage* |
||||
|
||||
This plugin has defined only one command: |:Join||. If there is no other |
||||
customer command (by other plugins maybe) starting with "J", |:J| is also |
||||
available for |:Join|. |
||||
|
||||
The command format is: |
||||
|
||||
:[range]Join[!] [separator] [count] [flags] |
||||
|
||||
Arguments description: |
||||
|
||||
- [range] follows the rule of |cmdline-ranges| |
||||
- [!](bang) if with "!" all leading and trailing whitespaces of joined |
||||
lines will be kept |
||||
- [count] Join [count] lines starting with [range]. If [count] is negative |
||||
number, join [count] lines backwards. Check |Join-range-count| or |
||||
|Join-negative-count| |
||||
- [flags] Two flags are available: |
||||
r : (reverse) join lines in reverse |
||||
k : (keep) don't remove joined line after join |
||||
|
||||
Argument rules: |
||||
|
||||
- Arguments should be separated by space |
||||
- If [separator] occurence, it must be the first argument also must be |
||||
quoted by '(single quote) or "(double quote) |
||||
- The order of [count] and [flags] is free. For example the following two |
||||
commands have exactly same meaning: > |
||||
:J 5 kr |
||||
:J kr 5 |
||||
< |
||||
- all arguments are optional. If an argument was not given by user, the default |
||||
value will be used: |
||||
|
||||
======================== |
||||
arg | Default value |
||||
======================== |
||||
range | current line |
||||
count | 1 |
||||
!(bang) | "" |
||||
separator| " " |
||||
flags | "" |
||||
------------------------ |
||||
|
||||
*Join-negative-count* *Join-range-count* |
||||
|
||||
If [count] is negative. |Join| will join lines backwards. For example: |
||||
|
||||
before: > |
||||
|
||||
aa |
||||
bb |
||||
cc |
||||
dd* (* indicates cursor) |
||||
ee |
||||
|
||||
After executing command > |
||||
:J -3 |
||||
|
||||
aa |
||||
bb cc dd |
||||
ee* |
||||
|
||||
If [range] is crossing multiple lines, with [count] together, |Join| will do in |
||||
this way: |
||||
|
||||
if [count] > 0, the largest line number in [range] will be the base, and join |
||||
[count] lines |
||||
|
||||
if [count] < 0, the smallest line number in [range] will be the base, and |
||||
join abs([count]) lines backwards |
||||
|
||||
check |Join-examples| for detail. |
||||
|
||||
============================================================================== |
||||
3. Examples *Join-examples* |
||||
|
||||
More examples with screenshots can be found at https://github.com/sk1418/Join |
||||
|
||||
(* indicates cursor in example) |
||||
|
||||
Original file: > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
5* |
||||
6 |
||||
7 |
||||
8 |
||||
9 |
||||
10 |
||||
|
||||
- with [separator] and [count] > |
||||
|
||||
:J ', ' 3 |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
5, 6, 7 |
||||
8* |
||||
9 |
||||
10 |
||||
|
||||
|
||||
- with [separator], [count] and [flag] r > |
||||
|
||||
:J '-' 3 r |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
7-6-5 |
||||
8* |
||||
9 |
||||
10 |
||||
|
||||
- with [separator], [count] and [flag] k > |
||||
|
||||
:J '-' 3 k |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
*5-6-7 |
||||
6 |
||||
7 |
||||
8 |
||||
9 |
||||
10 |
||||
|
||||
|
||||
- with negative [count] > |
||||
|
||||
:J -3 |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 4 5 |
||||
6* |
||||
7 |
||||
8 |
||||
9 |
||||
10 |
||||
|
||||
|
||||
- with special [separator], negative [count] and [flag] kr > |
||||
|
||||
:J "'\"\t" -3 kr |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
5'" 4'" 3 |
||||
6* |
||||
7 |
||||
8 |
||||
9 |
||||
10 |
||||
|
||||
|
||||
- with [range] and [count] > |
||||
|
||||
:2,5J 3 |
||||
|
||||
result > |
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
5 6 7 |
||||
8* |
||||
9 |
||||
10 |
||||
|
||||
- with [range], negative [count] and [flag] k > |
||||
|
||||
:5,7J -3 k |
||||
|
||||
result > |
||||
|
||||
1 |
||||
2 |
||||
3 |
||||
4 |
||||
*3 4 5 |
||||
6 |
||||
7 |
||||
8 |
||||
9 |
||||
10 |
||||
|
||||
vim:ft=help:ts=2:tw=78:shiftwidth=2:tabstop=2:fdm=marker:expandtab |
@ -0,0 +1,208 @@
@@ -0,0 +1,208 @@
|
||||
" Join : a better (hopefully) :Join command in Vim |
||||
" Author : Kai Yuan <kent.yuan@gmail.com> |
||||
" Version : 1.0.0 |
||||
" License: {{{ |
||||
"Copyright (c) 2013 Kai Yuan |
||||
"Permission is hereby granted, free of charge, to any person obtaining a copy of |
||||
"this software and associated documentation files (the "Software"), to deal in |
||||
"the Software without restriction, including without limitation the rights to |
||||
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
||||
"the Software, and to permit persons to whom the Software is furnished to do so, |
||||
"subject to the following conditions: |
||||
" |
||||
"The above copyright notice and this permission notice shall be included in all |
||||
"copies or substantial portions of the Software. |
||||
" |
||||
"THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
||||
"FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
||||
"COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
||||
"IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||
"CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
if exists("g:loaded_Join") || &cp |
||||
finish |
||||
endif |
||||
|
||||
let g:loaded_Join = 1 |
||||
let s:FLAGS = ['k','r'] "available flags |
||||
let g:Join_debug = 0 |
||||
|
||||
"message dictionary |
||||
let s:errMsgsDict = {'err_arg_sep': '[JoinErr:ARG] Invalid Separator'} |
||||
let s:errMsgsDict['err_arg_num'] = '[JoinErr:ARG] Invalid number of arguments' |
||||
let s:errMsgsDict['err_arg_cf'] = '[JoinErr:ARG] Argument Count or Flags is invalid' |
||||
|
||||
"------------------------------------ |
||||
" Do the join logic here |
||||
"------------------------------------ |
||||
fun! <SID>DoJoin(sep, bang, count, flag, first, last) |
||||
if g:Join_debug"{{{ |
||||
echom '---------------------' |
||||
echom 'parsed sep:' . a:sep |
||||
echom 'bang:' . a:bang |
||||
echom 'input count:' . a:count |
||||
echom 'input flags' . a:flag |
||||
echom '---------------------' |
||||
endif"}}} |
||||
let cnt = a:count |
||||
|
||||
"flags |
||||
let joinRev = stridx(a:flag, 'r') >= 0 |
||||
let joinKeep = stridx(a:flag, 'k') >= 0 |
||||
|
||||
if a:first == a:last |
||||
let cnt = cnt == 0 ? 1 : cnt |
||||
"a:first and a:last are same |
||||
let jbegin = cnt > 0 ? a:first : a:first + ((cnt + 1)<0?cnt+1:cnt) |
||||
let jend = cnt > 0 ? (cnt > 1 ? a:first + cnt - 1:a:first + cnt): a:first |
||||
else " user inputed a range > 1 line |
||||
if cnt == 0 "without count |
||||
let jbegin = a:first |
||||
let jend = a:last |
||||
elseif cnt > 0 "with positive count |
||||
let jbegin = a:last |
||||
let jend = jbegin + (cnt==1?1:cnt -1) |
||||
else " negative count !! could be confusing, need explain in doc |
||||
let jend = a:first |
||||
let jbegin = (a:first + ((cnt+1)<0?cnt+1:cnt) ) |
||||
endif |
||||
endif |
||||
" |
||||
if g:Join_debug"{{{ |
||||
echom '---------------------' |
||||
echom 'calculated firstline:'.jbegin |
||||
echom 'calculated lastline:' . jend |
||||
echom 'join keep :' . joinKeep |
||||
echom 'join rev :' . joinRev |
||||
echom '---------------------' |
||||
endif"}}} |
||||
|
||||
|
||||
let jbegin = jbegin < 0 ? 0 : jbegin |
||||
let jend = jend >= line('$') ? line('$') : jend |
||||
|
||||
"now load lines |
||||
let lines = getline(jbegin, jend) |
||||
|
||||
if !a:bang "without bang, trim lines |
||||
call map(lines, "substitute(v:val, '^\\s\\+\\|\\s\\$','','g')") |
||||
endif |
||||
|
||||
if !joinKeep |
||||
"remove lines |
||||
execute jbegin . ',' . jend . 'd' |
||||
call append(jbegin>0 ? jbegin-1 : 0, join(joinRev?reverse(lines):lines, a:sep)) |
||||
else |
||||
if cnt>=0 |
||||
call setline(jbegin, join(joinRev?reverse(lines):lines, a:sep)) |
||||
else |
||||
call setline(jend, join(joinRev?reverse(lines):lines, a:sep)) |
||||
endif |
||||
|
||||
endif |
||||
|
||||
endf |
||||
|
||||
"------------------------------------ |
||||
"check if an input is Count argument |
||||
"------------------------------------ |
||||
fun! <SID>IsCount(inputCount) |
||||
return a:inputCount =~ '^-\?[1-9]\d*$' |
||||
endf |
||||
|
||||
"------------------------------------ |
||||
"check if an input string is flags argument |
||||
"------------------------------------ |
||||
fun! <SID>IsFlag(inputFlags) |
||||
let flagReg = '['. join(s:FLAGS,'') .']' |
||||
if empty(a:inputFlags) || len(a:inputFlags) > len(s:FLAGS) |
||||
return 0 |
||||
else |
||||
return empty(substitute(a:inputFlags,flagReg, '','g')) |
||||
endif |
||||
endf |
||||
|
||||
|
||||
|
||||
"------------------------------------ |
||||
" this function is responsible to parse user inputs, and return parted |
||||
" arguments in a dictionary. If parsing error occured, exception will be thrown |
||||
" argstr should follow format [sep] [count] [flags] |
||||
" for example 'I am sep' 20 kr |
||||
"------------------------------------ |
||||
fun! <SID>ParseArgs(argstr) |
||||
let rest = a:argstr |
||||
let c = 0 |
||||
let sep = " " |
||||
let flags = "" |
||||
|
||||
"first check sep |
||||
if a:argstr[0] =~ "['\"]" |
||||
let sepRegex = "\\v^(['\"]).*(\\\\)@<!\\1( |$)@=" |
||||
try |
||||
let sepInput = matchstr(a:argstr,sepRegex,0) |
||||
catch /.*/ |
||||
throw 'err_arg-sep' |
||||
endtry |
||||
|
||||
if empty(sepInput) |
||||
throw 'err_arg_sep' |
||||
else |
||||
let rest = strpart(rest, len(sepInput)) |
||||
let sep = eval(sepInput) |
||||
endif |
||||
endif |
||||
|
||||
let rest = substitute(rest,' \+', " ","g") |
||||
let cfList = split(rest, " ") "count flag list |
||||
let ln = len(cfList) |
||||
if ln > 2 |
||||
throw 'err_arg_num' |
||||
elseif ln == 1 |
||||
if s:IsCount(cfList[0]) |
||||
let c = cfList[0] |
||||
elseif s:IsFlag(cfList[0]) |
||||
let flags = cfList[0] |
||||
else |
||||
throw 'err_arg_cf' |
||||
endif |
||||
elseif ln == 2 |
||||
if s:IsCount(cfList[0]) && s:IsFlag(cfList[1]) |
||||
let c = cfList[0] |
||||
let flags = cfList[1] |
||||
elseif s:IsCount(cfList[1]) && s:IsFlag(cfList[0]) |
||||
let c = cfList[1] |
||||
let flags = cfList[0] |
||||
else |
||||
throw 'err_arg_cf' |
||||
endif |
||||
endif |
||||
|
||||
return {'sep':sep, 'count':c, 'flags':flags} |
||||
endf |
||||
|
||||
|
||||
fun! <SID>Join(argstr, bang) range |
||||
try |
||||
let args = s:ParseArgs(a:argstr) |
||||
catch /^err/ |
||||
call s:ShowErrMsg(v:exception) |
||||
return |
||||
endtry |
||||
|
||||
let args['first'] = a:firstline |
||||
let args['last'] = a:lastline |
||||
let args['bang'] = a:bang |
||||
call s:DoJoin( args['sep'], args['bang'], args['count'], args['flags'], args['first'], args['last']) |
||||
endf |
||||
|
||||
|
||||
fun! <SID>ShowErrMsg(errKey) |
||||
echohl Error |
||||
echon s:errMsgsDict[a:errKey] |
||||
echohl None |
||||
endf |
||||
command! -nargs=* -range -bang -bar Join <line1>,<line2>call <SID>Join(<q-args>, <bang>0) |
||||
|
||||
" vim: ts=4:sw=4:ft=vim:expandtab:fdm=marker |
@ -0,0 +1,977 @@
@@ -0,0 +1,977 @@
|
||||
" File: mru.vim |
||||
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) |
||||
" Version: 3.5 |
||||
" Last Modified: May 8, 2013 |
||||
" Copyright: Copyright (C) 2003-2013 Yegappan Lakshmanan |
||||
" Permission is hereby granted to use and distribute this code, |
||||
" with or without modifications, provided that this copyright |
||||
" notice is copied with it. Like anything else that's free, |
||||
" mru.vim is provided *as is* and comes with no warranty of any |
||||
" kind, either expressed or implied. In no event will the copyright |
||||
" holder be liable for any damamges resulting from the use of this |
||||
" software. |
||||
" |
||||
" Overview |
||||
" -------- |
||||
" The Most Recently Used (MRU) plugin provides an easy access to a list of |
||||
" recently opened/edited files in Vim. This plugin automatically stores the |
||||
" file names as you open/edit them in Vim. |
||||
" |
||||
" This plugin will work on all the platforms where Vim is supported. This |
||||
" plugin will work in both console and GUI Vim. This version of the MRU |
||||
" plugin needs Vim 7.0 and above. If you are using an earlier version of |
||||
" Vim, then you should use an older version of the MRU plugin. |
||||
" |
||||
" The recently used filenames are stored in a file specified by the Vim |
||||
" MRU_File variable. |
||||
" |
||||
" Installation |
||||
" ------------ |
||||
" 1. Copy the mru.vim file to one of the following directories: |
||||
" |
||||
" $HOME/.vim/plugin - Unix like systems |
||||
" $HOME/vimfiles/plugin - MS-Windows |
||||
" $VIM:vimfiles:plugin - Macintosh |
||||
" $VIM/vimfiles/plugin - All |
||||
" |
||||
" Refer to the following Vim help topics for more information about Vim |
||||
" plugins: |
||||
" |
||||
" :help add-plugin |
||||
" :help add-global-plugin |
||||
" :help runtimepath |
||||
" |
||||
" 2. Set the MRU_File Vim variable in the .vimrc file to the location of a |
||||
" file to store the most recently edited file names. This step is needed |
||||
" only if you want to change the default MRU filename. |
||||
" 3. Restart Vim. |
||||
" 4. You can use the ":MRU" command to list and edit the recently used files. |
||||
" In GUI Vim, you can use the 'File->Recent Files' menu to access the |
||||
" recently used files. |
||||
" |
||||
" To uninstall this plugin, remove this file (mru.vim) from the |
||||
" $HOME/.vim/plugin or $HOME/vimfiles/plugin or the $VIM/vimfile/plugin |
||||
" directory. |
||||
" |
||||
" Usage |
||||
" ----- |
||||
" To list and edit files from the MRU list, you can use the ":MRU" command. |
||||
" The ":MRU" command displays the MRU file list in a temporary Vim window. If |
||||
" the MRU window is already opened, then the MRU list displayed in the window |
||||
" is refreshed. |
||||
" |
||||
" If you are using GUI Vim, then the names of the recently edited files are |
||||
" added to the "File->Recent Files" menu. You can select the name of a file |
||||
" from this sub-menu to edit the file. |
||||
" |
||||
" You can use the normal Vim commands to move around in the MRU window. You |
||||
" cannot make changes in the MRU window. |
||||
" |
||||
" You can select a file name to edit by pressing the <Enter> key or by double |
||||
" clicking the left mouse button on a file name. The selected file will be |
||||
" opened. If the file is already opened in a window, the cursor will be moved |
||||
" to that window. Otherwise, the file is opened in the previous window. If the |
||||
" previous window has a modified buffer or is the preview window or is used by |
||||
" some other plugin, then the file is opened in a new window. |
||||
" |
||||
" You can press the 'o' key to open the file name under the cursor in the |
||||
" MRU window in a new window. |
||||
" |
||||
" To open a file from the MRU window in read-only mode (view), press the 'v' |
||||
" key. |
||||
" |
||||
" To open a file from the MRU window in a new tab, press the 't' key. If the |
||||
" file is already opened in a window in the current or in another tab, then |
||||
" the cursor is moved to that tab. Otherwise, a new tab is opened. |
||||
" |
||||
" You can open multiple files from the MRU window by specifying a count before |
||||
" pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually select |
||||
" multiple filenames and invoke the commands to open the files. Each selected |
||||
" file will be opened in a separate window or tab. |
||||
" |
||||
" You can press the 'u' key in the MRU window to update the file list. This is |
||||
" useful if you keep the MRU window open always. |
||||
" |
||||
" You can close the MRU window by pressing the 'q' key or using one of the Vim |
||||
" window commands. |
||||
" |
||||
" To display only files matching a pattern from the MRU list in the MRU |
||||
" window, you can specify a pattern to the ":MRU" command. For example, to |
||||
" display only file names matching "vim" in them, you can use the following |
||||
" command ":MRU vim". When you specify a partial file name and only one |
||||
" matching filename is found, then the ":MRU" command will edit that file. |
||||
" |
||||
" The ":MRU" command supports command-line completion of file names from |
||||
" the MRU list. You can enter a partial file name and then press <Tab> |
||||
" or <Ctrl-D> to complete or list all the matching file names. Note that |
||||
" after typing the ":MRU" command, you have to enter a space before completing |
||||
" the file names with <Tab>. |
||||
" |
||||
" When a file supplied to the ":MRU" command is not present in the MRU list, |
||||
" but it is a readable file, then the file will be opened (even though it is |
||||
" not present in the MRU list). This is useful if you want to open a file |
||||
" present in the same directory as a file in the MRU list. You can use the |
||||
" command-line completion of the ":MRU" command to complete the full path of a |
||||
" file and then modify the path to open another file present in the same path. |
||||
" |
||||
" Whenever the MRU list changes, the MRU file is updated with the latest MRU |
||||
" list. When you have multiple instances of Vim running at the same time, the |
||||
" latest MRU list will show up in all the instances of Vim. |
||||
" |
||||
" Configuration |
||||
" ------------- |
||||
" By changing the following variables you can configure the behavior of this |
||||
" plugin. Set the following variables in your .vimrc file using the 'let' |
||||
" command. |
||||
" |
||||
" The list of recently edited file names is stored in the file specified by the |
||||
" MRU_File variable. The default setting for this variable is |
||||
" $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files |
||||
" for MS-Windows systems. You can change this variable to point to a file by |
||||
" adding the following line to the .vimrc file: |
||||
" |
||||
" let MRU_File = 'd:\myhome\_vim_mru_files' |
||||
" |
||||
" By default, the plugin will remember the names of the last 100 used files. |
||||
" As you edit more files, old file names will be removed from the MRU list. |
||||
" You can set the 'MRU_Max_Entries' variable to remember more file names. For |
||||
" example, to remember 1000 most recently used file names, you can use |
||||
" |
||||
" let MRU_Max_Entries = 1000 |
||||
" |
||||
" By default, all the edited file names will be added to the MRU list. If you |
||||
" want to exclude file names matching a list of patterns, you can set the |
||||
" MRU_Exclude_Files variable to a list of Vim regular expressions. By default, |
||||
" this variable is set to an empty string. For example, to not include files |
||||
" in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the |
||||
" MRU_Exclude_Files variable to |
||||
" |
||||
" let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix |
||||
" let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows |
||||
" |
||||
" The specified pattern should be a Vim regular expression pattern. |
||||
" |
||||
" If you want to add only file names matching a set of patterns to the MRU |
||||
" list, then you can set the MRU_Include_Files variable. This variable should |
||||
" be set to a Vim regular expression pattern. For example, to add only .c and |
||||
" .h files to the MRU list, you can set this variable as below: |
||||
" |
||||
" let MRU_Include_Files = '\.c$\|\.h$' |
||||
" |
||||
" By default, MRU_Include_Files is set to an empty string and all the edited |
||||
" filenames are added to the MRU list. |
||||
" |
||||
" The default height of the MRU window is 8. You can set the MRU_Window_Height |
||||
" variable to change the window height. |
||||
" |
||||
" let MRU_Window_Height = 15 |
||||
" |
||||
" By default, when the :MRU command is invoked, the MRU list will be displayed |
||||
" in a new window. Instead, if you want the MRU plugin to reuse the current |
||||
" window, then you can set the 'MRU_Use_Current_Window' variable to one. |
||||
" |
||||
" let MRU_Use_Current_Window = 1 |
||||
" |
||||
" The MRU plugin will reuse the current window. When a file name is selected, |
||||
" the file is also opened in the current window. |
||||
" |
||||
" When you select a file from the MRU window, the MRU window will be |
||||
" automatically closed and the selected file will be opened in the previous |
||||
" window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU |
||||
" window open. |
||||
" |
||||
" let MRU_Auto_Close = 0 |
||||
" |
||||
" If you don't use the "File->Recent Files" menu and want to disable it, |
||||
" then you can set the 'MRU_Add_Menu' variable to zero. By default, the |
||||
" menu is enabled. |
||||
" |
||||
" let MRU_Add_Menu = 0 |
||||
" |
||||
" If too many file names are present in the MRU list, then updating the MRU |
||||
" menu to list all the file names makes Vim slow. To avoid this, the |
||||
" MRU_Max_Menu_Entries variable controls the number of file names to show in |
||||
" the MRU menu. By default, this is set to 10. You can change this to show |
||||
" more entries in the menu. |
||||
" |
||||
" let MRU_Max_Menu_Entries = 20 |
||||
" |
||||
" If many file names are present in the MRU list, then the MRU menu is split |
||||
" into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names. |
||||
" The default setting for this is 10. You can change this to increase the |
||||
" number of file names displayed in a single sub-menu: |
||||
" |
||||
" let MRU_Max_Submenu_Entries = 15 |
||||
" |
||||
" ****************** Do not modify after this line ************************ |
||||
if exists('loaded_mru') |
||||
finish |
||||
endif |
||||
let loaded_mru=1 |
||||
|
||||
if v:version < 700 |
||||
finish |
||||
endif |
||||
|
||||
" Line continuation used here |
||||
let s:cpo_save = &cpo |
||||
set cpo&vim |
||||
|
||||
" MRU configuration variables {{{1 |
||||
" Maximum number of entries allowed in the MRU list |
||||
if !exists('MRU_Max_Entries') |
||||
let MRU_Max_Entries = 100 |
||||
endif |
||||
|
||||
" Files to exclude from the MRU list |
||||
if !exists('MRU_Exclude_Files') |
||||
let MRU_Exclude_Files = '' |
||||
endif |
||||
|
||||
" Files to include in the MRU list |
||||
if !exists('MRU_Include_Files') |
||||
let MRU_Include_Files = '' |
||||
endif |
||||
|
||||
" Height of the MRU window |
||||
" Default height is 8 |
||||
if !exists('MRU_Window_Height') |
||||
let MRU_Window_Height = 8 |
||||
endif |
||||
|
||||
if !exists('MRU_Use_Current_Window') |
||||
let MRU_Use_Current_Window = 0 |
||||
endif |
||||
|
||||
if !exists('MRU_Auto_Close') |
||||
let MRU_Auto_Close = 1 |
||||
endif |
||||
|
||||
if !exists('MRU_File') |
||||
if has('unix') || has('macunix') |
||||
let MRU_File = $HOME . '/.vim_mru_files' |
||||
else |
||||
let MRU_File = $VIM . '/_vim_mru_files' |
||||
if has('win32') |
||||
" MS-Windows |
||||
if $USERPROFILE != '' |
||||
let MRU_File = $USERPROFILE . '\_vim_mru_files' |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
|
||||
" Option for enabling or disabling the MRU menu |
||||
if !exists('MRU_Add_Menu') |
||||
let MRU_Add_Menu = 1 |
||||
endif |
||||
|
||||
" Maximum number of file names to show in the MRU menu. If too many files are |
||||
" listed in the menu, then Vim becomes slow when updating the menu. So set |
||||
" this to a low value. |
||||
if !exists('MRU_Max_Menu_Entries') |
||||
let MRU_Max_Menu_Entries = 10 |
||||
endif |
||||
|
||||
" Maximum number of file names to show in a MRU sub-menu. If the MRU list |
||||
" contains more file names than this setting, then the MRU menu is split into |
||||
" one or more sub-menus. |
||||
if !exists('MRU_Max_Submenu_Entries') |
||||
let MRU_Max_Submenu_Entries = 10 |
||||
endif |
||||
|
||||
" When only a single matching filename is found in the MRU list, the following |
||||
" option controls whether the file name is displayed in the MRU window or the |
||||
" file is directly opened. When this variable is set to 0 and a single |
||||
" matching file name is found, then the file is directly opened. |
||||
if !exists('MRU_Window_Open_Always') |
||||
let MRU_Window_Open_Always = 0 |
||||
endif |
||||
|
||||
" When opening a file from the MRU list, the file is opened in the current |
||||
" tab. If the selected file has to be opened in a tab always, then set the |
||||
" following variable to 1. If the file is already opened in a tab, then the |
||||
" cursor will be moved to that tab. |
||||
if !exists('MRU_Open_File_Use_Tabs') |
||||
let MRU_Open_File_Use_Tabs = 0 |
||||
endif |
||||
|
||||
" Control to temporarily lock the MRU list. Used to prevent files from |
||||
" getting added to the MRU list when the ':vimgrep' command is executed. |
||||
let s:mru_list_locked = 0 |
||||
|
||||
" MRU_LoadList {{{1 |
||||
" Loads the latest list of file names from the MRU file |
||||
function! s:MRU_LoadList() |
||||
" If the MRU file is present, then load the list of filenames. Otherwise |
||||
" start with an empty list. |
||||
if filereadable(g:MRU_File) |
||||
let s:MRU_files = readfile(g:MRU_File) |
||||
if s:MRU_files[0] =~# '^\s*" Most recently edited files in Vim' |
||||
" Generated by the previous version of the MRU plugin. |
||||
" Discard the list. |
||||
let s:MRU_files = [] |
||||
elseif s:MRU_files[0] =~# '^#' |
||||
" Remove the comment line |
||||
call remove(s:MRU_files, 0) |
||||
else |
||||
" Unsupported format |
||||
let s:MRU_files = [] |
||||
endif |
||||
else |
||||
let s:MRU_files = [] |
||||
endif |
||||
|
||||
" Refresh the MRU menu with the latest list of filenames |
||||
call s:MRU_Refresh_Menu() |
||||
endfunction |
||||
|
||||
" MRU_SaveList {{{1 |
||||
" Saves the MRU file names to the MRU file |
||||
function! s:MRU_SaveList() |
||||
let l = [] |
||||
call add(l, '# Most recently edited files in Vim (version 3.0)') |
||||
call extend(l, s:MRU_files) |
||||
call writefile(l, g:MRU_File) |
||||
endfunction |
||||
|
||||
" MRU_AddFile {{{1 |
||||
" Adds a file to the MRU file list |
||||
" acmd_bufnr - Buffer number of the file to add |
||||
function! s:MRU_AddFile(acmd_bufnr) |
||||
if s:mru_list_locked |
||||
" MRU list is currently locked |
||||
return |
||||
endif |
||||
|
||||
" Get the full path to the filename |
||||
let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':p') |
||||
if fname == '' |
||||
return |
||||
endif |
||||
|
||||
" Skip temporary buffers with buftype set. The buftype is set for buffers |
||||
" used by plugins. |
||||
if &buftype != '' |
||||
return |
||||
endif |
||||
|
||||
if g:MRU_Include_Files != '' |
||||
" If MRU_Include_Files is set, include only files matching the |
||||
" specified pattern |
||||
if fname !~# g:MRU_Include_Files |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
if g:MRU_Exclude_Files != '' |
||||
" Do not add files matching the pattern specified in the |
||||
" MRU_Exclude_Files to the MRU list |
||||
if fname =~# g:MRU_Exclude_Files |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
" If the filename is not already present in the MRU list and is not |
||||
" readable then ignore it |
||||
let idx = index(s:MRU_files, fname) |
||||
if idx == -1 |
||||
if !filereadable(fname) |
||||
" File is not readable and is not in the MRU list |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
" Load the latest MRU file list |
||||
call s:MRU_LoadList() |
||||
|
||||
" Remove the new file name from the existing MRU list (if already present) |
||||
call filter(s:MRU_files, 'v:val !=# fname') |
||||
|
||||
" Add the new file list to the beginning of the updated old file list |
||||
call insert(s:MRU_files, fname, 0) |
||||
|
||||
" Trim the list |
||||
if len(s:MRU_files) > g:MRU_Max_Entries |
||||
call remove(s:MRU_files, g:MRU_Max_Entries, -1) |
||||
endif |
||||
|
||||
" Save the updated MRU list |
||||
call s:MRU_SaveList() |
||||
|
||||
" Refresh the MRU menu |
||||
call s:MRU_Refresh_Menu() |
||||
|
||||
" If the MRU window is open, update the displayed MRU list |
||||
let bname = '__MRU_Files__' |
||||
let winnum = bufwinnr(bname) |
||||
if winnum != -1 |
||||
let cur_winnr = winnr() |
||||
call s:MRU_Open_Window() |
||||
if winnr() != cur_winnr |
||||
exe cur_winnr . 'wincmd w' |
||||
endif |
||||
endif |
||||
endfunction |
||||
|
||||
" MRU_escape_filename {{{1 |
||||
" Escape special characters in a filename. Special characters in file names |
||||
" that should be escaped (for security reasons) |
||||
let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n" |
||||
function! s:MRU_escape_filename(fname) |
||||
return escape(a:fname, s:esc_filename_chars) |
||||
endfunction |
||||
|
||||
" MRU_Edit_File {{{1 |
||||
" Edit the specified file |
||||
" filename - Name of the file to edit |
||||
" sanitized - Specifies whether the filename is already escaped for special |
||||
" characters or not. |
||||
function! s:MRU_Edit_File(filename, sanitized) |
||||
if !a:sanitized |
||||
let esc_fname = s:MRU_escape_filename(a:filename) |
||||
else |
||||
let esc_fname = a:filename |
||||
endif |
||||
|
||||
" If the user wants to always open the file in a tab, then open the file |
||||
" in a tab. If it is already opened in a tab, then the cursor will be |
||||
" moved to that tab. |
||||
if g:MRU_Open_File_Use_Tabs |
||||
call s:MRU_Open_File_In_Tab(a:filename, esc_fname) |
||||
return |
||||
endif |
||||
|
||||
" If the file is already open in one of the windows, jump to it |
||||
let winnum = bufwinnr('^' . a:filename . '$') |
||||
if winnum != -1 |
||||
if winnum != winnr() |
||||
exe winnum . 'wincmd w' |
||||
endif |
||||
else |
||||
if &modified || &buftype != '' || &previewwindow |
||||
" Current buffer has unsaved changes or is a special buffer or is |
||||
" the preview window. So open the file in a new window |
||||
exe 'split ' . esc_fname |
||||
else |
||||
exe 'edit ' . esc_fname |
||||
endif |
||||
endif |
||||
endfunction |
||||
|
||||
" MRU_Open_File_In_Tab |
||||
" Open a file in a tab. If the file is already opened in a tab, jump to the |
||||
" tab. Otherwise, create a new tab and open the file. |
||||
" fname : Name of the file to open |
||||
" esc_fname : File name with special characters escaped |
||||
function! s:MRU_Open_File_In_Tab(fname, esc_fname) |
||||
" If the selected file is already open in the current tab or in |
||||
" another tab, jump to it. Otherwise open it in a new tab |
||||
if bufwinnr('^' . a:fname . '$') == -1 |
||||
let tabnum = -1 |
||||
let i = 1 |
||||
let bnum = bufnr('^' . a:fname . '$') |
||||
while i <= tabpagenr('$') |
||||
if index(tabpagebuflist(i), bnum) != -1 |
||||
let tabnum = i |
||||
break |
||||
endif |
||||
let i += 1 |
||||
endwhile |
||||
|
||||
if tabnum != -1 |
||||
" Goto the tab containing the file |
||||
exe 'tabnext ' . i |
||||
else |
||||
" Open a new tab as the last tab page |
||||
exe '999tabnew ' . a:esc_fname |
||||
endif |
||||
endif |
||||
|
||||
" Jump to the window containing the file |
||||
let winnum = bufwinnr('^' . a:fname . '$') |
||||
if winnum != winnr() |
||||
exe winnum . 'wincmd w' |
||||
endif |
||||
endfunction |
||||
|
||||
" MRU_Window_Edit_File {{{1 |
||||
" fname : Name of the file to edit. May specify single or multiple |
||||
" files. |
||||
" edit_type : Specifies how to edit the file. Can be one of 'edit' or 'view'. |
||||
" 'view' - Open the file as a read-only file |
||||
" 'edit' - Edit the file as a regular file |
||||
" multi : Specifies whether a single file or multiple files need to be |
||||
" opened. |
||||
" open_type : Specifies where to open the file. Can be one of 'useopen' or |
||||
" 'newwin' or 'newtab'. |
||||
" useopen - If the file is already present in a window, then |
||||
" jump to that window. Otherwise, open the file in |
||||
" the previous window. |
||||
" newwin_horiz - Open the file in a new horizontal window. |
||||
" newwin_vert - Open the file in a new vertical window. |
||||
" newtab - Open the file in a new tab. If the file is already |
||||
" opened in a tab, then jump to that tab. |
||||
function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type) |
||||
let esc_fname = s:MRU_escape_filename(a:fname) |
||||
|
||||
if a:open_type == 'newwin_horiz' |
||||
" Edit the file in a new horizontally split window above the previous |
||||
" window |
||||
wincmd p |
||||
exe 'belowright new ' . esc_fname |
||||
elseif a:open_type == 'newwin_vert' |
||||
" Edit the file in a new vertically split window above the previous |
||||
" window |
||||
wincmd p |
||||
exe 'belowright vnew ' . esc_fname |
||||
elseif a:open_type == 'newtab' || g:MRU_Open_File_Use_Tabs |
||||
call s:MRU_Open_File_In_Tab(a:fname, esc_fname) |
||||
else |
||||
" If the selected file is already open in one of the windows, |
||||
" jump to it |
||||
let winnum = bufwinnr('^' . a:fname . '$') |
||||
if winnum != -1 |
||||
exe winnum . 'wincmd w' |
||||
else |
||||
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 |
||||
" Jump to the window from which the MRU window was opened |
||||
if exists('s:MRU_last_buffer') |
||||
let last_winnr = bufwinnr(s:MRU_last_buffer) |
||||
if last_winnr != -1 && last_winnr != winnr() |
||||
exe last_winnr . 'wincmd w' |
||||
endif |
||||
endif |
||||
else |
||||
if g:MRU_Use_Current_Window == 0 |
||||
" Goto the previous window |
||||
" If MRU_Use_Current_Window is set to one, then the |
||||
" current window is used to open the file |
||||
wincmd p |
||||
endif |
||||
endif |
||||
|
||||
let split_window = 0 |
||||
|
||||
if &modified || &previewwindow || a:multi |
||||
" Current buffer has unsaved changes or is the preview window |
||||
" or the user is opening multiple files |
||||
" So open the file in a new window |
||||
let split_window = 1 |
||||
endif |
||||
|
||||
if &buftype != '' |
||||
" Current buffer is a special buffer (maybe used by a plugin) |
||||
if g:MRU_Use_Current_Window == 0 || |
||||
\ bufnr('%') != bufnr('__MRU_Files__') |
||||
let split_window = 1 |
||||
endif |
||||
endif |
||||
|
||||
" Edit the file |
||||
if split_window |
||||
" Current buffer has unsaved changes or is a special buffer or |
||||
" is the preview window. So open the file in a new window |
||||
if a:edit_type == 'edit' |
||||
exe 'split ' . esc_fname |
||||
else |
||||
exe 'sview ' . esc_fname |
||||
endif |
||||
else |
||||
if a:edit_type == 'edit' |
||||
exe 'edit ' . esc_fname |
||||
else |
||||
exe 'view ' . esc_fname |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
endfunction |
||||
|
||||
" MRU_Select_File_Cmd {{{1 |
||||
" Open a file selected from the MRU window |
||||
" |
||||
" 'opt' has two values separated by comma. The first value specifies how to |
||||
" edit the file and can be either 'edit' or 'view'. The second value |
||||
" specifies where to open the file. It can take one of the following values: |
||||
" 'useopen' to open file in the previous window |
||||
" 'newwin_horiz' to open the file in a new horizontal split window |
||||
" 'newwin_vert' to open the file in a new vertical split window. |
||||
" 'newtab' to open the file in a new tab. |
||||
" If multiple file names are selected using visual mode, then open multiple |
||||
" files (either in split windows or tabs) |
||||
function! s:MRU_Select_File_Cmd(opt) range |
||||
let [edit_type, open_type] = split(a:opt, ',') |
||||
|
||||
let fnames = getline(a:firstline, a:lastline) |
||||
|
||||
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 |
||||
" Automatically close the window if the file window is |
||||
" not used to display the MRU list. |
||||
silent! close |
||||
endif |
||||
|
||||
let multi = 0 |
||||
|
||||
for f in fnames |
||||
if f == '' |
||||
continue |
||||
endif |
||||
|
||||
" The text in the MRU window contains the filename in parenthesis |
||||
let file = matchstr(f, '(\zs.*\ze)') |
||||
|
||||
call s:MRU_Window_Edit_File(file, multi, edit_type, open_type) |
||||
|
||||
if a:firstline != a:lastline |
||||
" Opening multiple files |
||||
let multi = 1 |
||||
endif |
||||
endfor |
||||
endfunction |
||||
|
||||
" MRU_Warn_Msg {{{1 |
||||
" Display a warning message |
||||
function! s:MRU_Warn_Msg(msg) |
||||
echohl WarningMsg |
||||
echo a:msg |
||||
echohl None |
||||
endfunction |
||||
|
||||
" MRU_Open_Window {{{1 |
||||
" Display the Most Recently Used file list in a temporary window. |
||||
" If the optional argument is supplied, then it specifies the pattern of files |
||||
" to selectively display in the MRU window. |
||||
function! s:MRU_Open_Window(...) |
||||
|
||||
" Load the latest MRU file list |
||||
call s:MRU_LoadList() |
||||
|
||||
" Check for empty MRU list |
||||
if empty(s:MRU_files) |
||||
call s:MRU_Warn_Msg('MRU file list is empty') |
||||
return |
||||
endif |
||||
|
||||
" Save the current buffer number. This is used later to open a file when a |
||||
" entry is selected from the MRU window. The window number is not saved, |
||||
" as the window number will change when new windows are opened. |
||||
let s:MRU_last_buffer = bufnr('%') |
||||
|
||||
let bname = '__MRU_Files__' |
||||
|
||||
" If the window is already open, jump to it |
||||
let winnum = bufwinnr(bname) |
||||
if winnum != -1 |
||||
if winnr() != winnum |
||||
" If not already in the window, jump to it |
||||
exe winnum . 'wincmd w' |
||||
endif |
||||
|
||||
setlocal modifiable |
||||
|
||||
" Delete the contents of the buffer to the black-hole register |
||||
silent! %delete _ |
||||
else |
||||
if g:MRU_Use_Current_Window |
||||
" Reuse the current window |
||||
" |
||||
" If the __MRU_Files__ buffer exists, then reuse it. Otherwise open |
||||
" a new buffer |
||||
let bufnum = bufnr(bname) |
||||
if bufnum == -1 |
||||
let cmd = 'edit ' . bname |
||||
else |
||||
let cmd = 'buffer ' . bufnum |
||||
endif |
||||
|
||||
exe cmd |
||||
|
||||
if bufnr('%') != bufnr(bname) |
||||
" Failed to edit the MRU buffer |
||||
return |
||||
endif |
||||
else |
||||
" Open a new window at the bottom |
||||
|
||||
" If the __MRU_Files__ buffer exists, then reuse it. Otherwise open |
||||
" a new buffer |
||||
let bufnum = bufnr(bname) |
||||
if bufnum == -1 |
||||
let wcmd = bname |
||||
else |
||||
let wcmd = '+buffer' . bufnum |
||||
endif |
||||
|
||||
exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd |
||||
endif |
||||
endif |
||||
|
||||
" Mark the buffer as scratch |
||||
setlocal buftype=nofile |
||||
setlocal bufhidden=delete |
||||
setlocal noswapfile |
||||
setlocal nowrap |
||||
setlocal nobuflisted |
||||
" Use fixed height for the MRU window |
||||
setlocal winfixheight |
||||
|
||||
" Setup the cpoptions properly for the maps to work |
||||
let old_cpoptions = &cpoptions |
||||
set cpoptions&vim |
||||
|
||||
" Create mappings to select and edit a file from the MRU list |
||||
nnoremap <buffer> <silent> <CR> |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR> |
||||
vnoremap <buffer> <silent> <CR> |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR> |
||||
nnoremap <buffer> <silent> o |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR> |
||||
vnoremap <buffer> <silent> o |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR> |
||||
nnoremap <buffer> <silent> O |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_vert')<CR> |
||||
vnoremap <buffer> <silent> O |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_vert')<CR> |
||||
nnoremap <buffer> <silent> t |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newtab')<CR> |
||||
vnoremap <buffer> <silent> t |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,newtab')<CR> |
||||
nnoremap <buffer> <silent> v |
||||
\ :call <SID>MRU_Select_File_Cmd('view,useopen')<CR> |
||||
nnoremap <buffer> <silent> u :MRU<CR> |
||||
nnoremap <buffer> <silent> <2-LeftMouse> |
||||
\ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR> |
||||
nnoremap <buffer> <silent> q :close<CR> |
||||
|
||||
" Restore the previous cpoptions settings |
||||
let &cpoptions = old_cpoptions |
||||
|
||||
" Display the MRU list |
||||
if a:0 == 0 |
||||
" No search pattern specified. Display the complete list |
||||
let m = copy(s:MRU_files) |
||||
else |
||||
" Display only the entries matching the specified pattern |
||||
" First try using it as a literal pattern |
||||
let m = filter(copy(s:MRU_files), 'stridx(v:val, a:1) != -1') |
||||
if len(m) == 0 |
||||
" No match. Try using it as a regular expression |
||||
let m = filter(copy(s:MRU_files), 'v:val =~# a:1') |
||||
endif |
||||
endif |
||||
|
||||
" Get the tail part of the file name (without the directory) and display |
||||
" it along with the full path |
||||
let output = map(m, 'fnamemodify(v:val, ":t") . " (" . v:val . ")"') |
||||
silent! 0put =output |
||||
|
||||
" Delete the empty line at the end of the buffer |
||||
$delete |
||||
|
||||
" Move the cursor to the beginning of the file |
||||
normal! gg |
||||
|
||||
setlocal nomodifiable |
||||
endfunction |
||||
|
||||
" MRU_Complete {{{1 |
||||
" Command-line completion function used by :MRU command |
||||
function! s:MRU_Complete(ArgLead, CmdLine, CursorPos) |
||||
if a:ArgLead == '' |
||||
" Return the complete list of MRU files |
||||
return s:MRU_files |
||||
else |
||||
" Return only the files matching the specified pattern |
||||
return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead') |
||||
endif |
||||
endfunction |
||||
|
||||
" MRU_Cmd {{{1 |
||||
" Function to handle the MRU command |
||||
" pat - File name pattern passed to the MRU command |
||||
function! s:MRU_Cmd(pat) |
||||
if a:pat == '' |
||||
" No arguments specified. Open the MRU window |
||||
call s:MRU_Open_Window() |
||||
return |
||||
endif |
||||
|
||||
" Load the latest MRU file |
||||
call s:MRU_LoadList() |
||||
|
||||
" Empty MRU list |
||||
if empty(s:MRU_files) |
||||
call s:MRU_Warn_Msg('MRU file list is empty') |
||||
return |
||||
endif |
||||
|
||||
" First use the specified string as a literal string and search for |
||||
" filenames containing the string. If only one filename is found, |
||||
" then edit it (unless the user wants to open the MRU window always) |
||||
let m = filter(copy(s:MRU_files), 'stridx(v:val, a:pat) != -1') |
||||
if len(m) > 0 |
||||
if len(m) == 1 && !g:MRU_Window_Open_Always |
||||
call s:MRU_Edit_File(m[0], 0) |
||||
return |
||||
endif |
||||
|
||||
" More than one file matches. Try find an accurate match |
||||
let new_m = filter(m, 'v:val ==# a:pat') |
||||
if len(new_m) == 1 && !g:MRU_Window_Open_Always |
||||
call s:MRU_Edit_File(new_m[0], 0) |
||||
return |
||||
endif |
||||
|
||||
" Couldn't find an exact match, open the MRU window with all the |
||||
" files matching the pattern. |
||||
call s:MRU_Open_Window(a:pat) |
||||
return |
||||
endif |
||||
|
||||
" Use the specified string as a regular expression pattern and search |
||||
" for filenames matching the pattern |
||||
let m = filter(copy(s:MRU_files), 'v:val =~? a:pat') |
||||
|
||||
if len(m) == 0 |
||||
" If an existing file (not present in the MRU list) is specified, |
||||
" then open the file. |
||||
if filereadable(a:pat) |
||||
call s:MRU_Edit_File(a:pat, 0) |
||||
return |
||||
endif |
||||
|
||||
" No filenames matching the specified pattern are found |
||||
call s:MRU_Warn_Msg("MRU file list doesn't contain " . |
||||
\ "files matching " . a:pat) |
||||
return |
||||
endif |
||||
|
||||
if len(m) == 1 && !g:MRU_Window_Open_Always |
||||
call s:MRU_Edit_File(m[0], 0) |
||||
return |
||||
endif |
||||
|
||||
call s:MRU_Open_Window(a:pat) |
||||
endfunction |
||||
|
||||
" MRU_add_files_to_menu {{{1 |
||||
" Adds a list of files to the "Recent Files" sub menu under the "File" menu. |
||||
" prefix - Prefix to use for each of the menu entries |
||||
" file_list - List of file names to add to the menu |
||||
function! s:MRU_add_files_to_menu(prefix, file_list) |
||||
for fname in a:file_list |
||||
" Escape special characters in the filename |
||||
let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" . |
||||
\ s:esc_filename_chars) |
||||
let esc_fname = substitute(esc_fname, '&', '&&', 'g') |
||||
|
||||
" Truncate the directory name if it is long |
||||
let dir_name = fnamemodify(fname, ':h') |
||||
let len = strlen(dir_name) |
||||
" Shorten long file names by adding only few characters from |
||||
" the beginning and end. |
||||
if len > 30 |
||||
let dir_name = strpart(dir_name, 0, 10) . |
||||
\ '...' . |
||||
\ strpart(dir_name, len - 20) |
||||
endif |
||||
let esc_dir_name = escape(dir_name, ".\\" . s:esc_filename_chars) |
||||
let esc_dir_name = substitute(esc_dir_name, '&', '&&', 'g') |
||||
|
||||
let menu_path = '&File.&Recent\ Files.' . a:prefix . esc_fname . |
||||
\ '\ (' . esc_dir_name . ')' |
||||
let esc_mfname = s:MRU_escape_filename(fname) |
||||
exe 'anoremenu <silent> ' . menu_path . |
||||
\ " :call <SID>MRU_Edit_File('" . esc_mfname . "', 1)<CR>" |
||||
exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname |
||||
endfor |
||||
endfunction |
||||
|
||||
" MRU_Refresh_Menu {{{1 |
||||
" Refresh the MRU menu |
||||
function! s:MRU_Refresh_Menu() |
||||
if !has('menu') || !g:MRU_Add_Menu |
||||
" No support for menus |
||||
return |
||||
endif |
||||
|
||||
" Setup the cpoptions properly for the maps to work |
||||
let old_cpoptions = &cpoptions |
||||
set cpoptions&vim |
||||
|
||||
" Remove the MRU menu |
||||
" To retain the teared-off MRU menu, we need to add a dummy entry |
||||
silent! unmenu &File.&Recent\ Files |
||||
" The menu priority of the File menu is 10. If the MRU plugin runs |
||||
" first before menu.vim, the File menu order may not be correct. |
||||
" So specify the priority of the File menu here. |
||||
10noremenu &File.&Recent\ Files.Dummy <Nop> |
||||
silent! unmenu! &File.&Recent\ Files |
||||
|
||||
anoremenu <silent> &File.&Recent\ Files.Refresh\ list |
||||
\ :call <SID>MRU_LoadList()<CR> |
||||
exe 'tmenu File.&Recent\ Files.Refresh\ list Reload the MRU file list from ' |
||||
\ . s:MRU_escape_filename(g:MRU_File) |
||||
anoremenu File.&Recent\ Files.-SEP1- : |
||||
|
||||
" Add the filenames in the MRU list to the menu |
||||
let entry_cnt = len(s:MRU_files) |
||||
if entry_cnt > g:MRU_Max_Menu_Entries |
||||
" Show only MRU_Max_Menu_Entries file names in the menu |
||||
let mru_list = s:MRU_files[0 : g:MRU_Max_Menu_Entries - 1] |
||||
let entry_cnt = g:MRU_Max_Menu_Entries |
||||
else |
||||
let mru_list = s:MRU_files |
||||
endif |
||||
if entry_cnt > g:MRU_Max_Submenu_Entries |
||||
" Split the MRU menu into sub-menus |
||||
for start_idx in range(0, entry_cnt, g:MRU_Max_Submenu_Entries) |
||||
let last_idx = start_idx + g:MRU_Max_Submenu_Entries - 1 |
||||
if last_idx >= entry_cnt |
||||
let last_idx = entry_cnt - 1 |
||||
endif |
||||
let prefix = 'Files\ (' . (start_idx + 1) . '\.\.\.' . |
||||
\ (last_idx + 1) . ').' |
||||
call s:MRU_add_files_to_menu(prefix, |
||||
\ mru_list[start_idx : last_idx]) |
||||
endfor |
||||
else |
||||
call s:MRU_add_files_to_menu('', mru_list) |
||||
endif |
||||
|
||||
" Remove the dummy menu entry |
||||
unmenu &File.&Recent\ Files.Dummy |
||||
|
||||
" Restore the previous cpoptions settings |
||||
let &cpoptions = old_cpoptions |
||||
endfunction |
||||
|
||||
" Load the MRU list on plugin startup |
||||
call s:MRU_LoadList() |
||||
|
||||
" MRU autocommands {{{1 |
||||
" Autocommands to detect the most recently used files |
||||
autocmd BufRead * call s:MRU_AddFile(expand('<abuf>')) |
||||
autocmd BufNewFile * call s:MRU_AddFile(expand('<abuf>')) |
||||
autocmd BufWritePost * call s:MRU_AddFile(expand('<abuf>')) |
||||
|
||||
" The ':vimgrep' command adds all the files searched to the buffer list. |
||||
" This also modifies the MRU list, even though the user didn't edit the |
||||
" files. Use the following autocmds to prevent this. |
||||
autocmd QuickFixCmdPre *vimgrep* let s:mru_list_locked = 1 |
||||
autocmd QuickFixCmdPost *vimgrep* let s:mru_list_locked = 0 |
||||
|
||||
" Command to open the MRU window |
||||
command! -nargs=? -complete=customlist,s:MRU_Complete MRU |
||||
\ call s:MRU_Cmd(<q-args>) |
||||
command! -nargs=? -complete=customlist,s:MRU_Complete Mru |
||||
\ call s:MRU_Cmd(<q-args>) |
||||
|
||||
" }}} |
||||
|
||||
" restore 'cpo' |
||||
let &cpo = s:cpo_save |
||||
unlet s:cpo_save |
||||
|
||||
" vim:set foldenable foldmethod=marker: |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
" {{{1 Documentation |
||||
" Version: $Id: autoloadTemplate.vim,v 1.2 2007/02/06 05:22:55 alanc Exp $ |
||||
" File: autoloadTemplate.vim |
||||
" Maintainer: Alan Che <alan.che@hotmail.com> |
||||
" Last Change:2007/02/06 |
||||
" |
||||
" {{{2 Decription: |
||||
" |
||||
" Load template file from a specific directory according their filetype while |
||||
" starting to edit a new file. if the file does not exist, skip it! |
||||
" |
||||
" |
||||
" {{{2 INSTALL: |
||||
" Here is the way to install this script to your site: |
||||
" 1. extract this file to ~/.vim/plugin |
||||
" 2. create a directory ~/.vim/template |
||||
" 3. create your template files in that directory, where the file name follow |
||||
" th rule: |
||||
" <filetype>.vim |
||||
" where <filetype> is the filetype of this template will apply to, such |
||||
" as: verilog.vim, tcl.vim and so on. |
||||
" |
||||
" |
||||
" {{{1 Source code |
||||
|
||||
|
||||
|
||||
let g:TemplatePath="~/.vim/template" |
||||
|
||||
augroup loadTemplate |
||||
autocmd! |
||||
au FileType * call Template() |
||||
|
||||
function! Template() |
||||
if ! exists("b:IsNewFile") |
||||
return |
||||
endif |
||||
|
||||
if exists("b:Template_loaded") |
||||
return |
||||
endif |
||||
let b:Template_loaded=1 |
||||
|
||||
let b:ThisFileType=expand("<amatch>") |
||||
let b:TemplatePath=g:TemplatePath ."/". b:ThisFileType . ".vim" |
||||
let TemplateFullName = expand(b:TemplatePath) |
||||
|
||||
if filereadable(TemplateFullName) |
||||
let $TemplateFullName=TemplateFullName |
||||
0r $TemplateFullName |
||||
unlet TemplateFullName |
||||
normal G |
||||
endif |
||||
endfunction |
||||
|
||||
augroup END |
||||
|
||||
au BufNewFile * execute "let b:IsNewFile=1" |
||||
au BufNewFile * execute "doau loadTemplate FileType" |
||||
|
||||
|
||||
" vim: set ft=vim foldmethod=marker sw=4 ts=8: |
@ -0,0 +1,988 @@
@@ -0,0 +1,988 @@
|
||||
if !exists("g:calendar_action") |
||||
let g:calendar_action = "calendar#diary" |
||||
endif |
||||
if !exists("g:calendar_sign") |
||||
let g:calendar_sign = "calendar#sign" |
||||
endif |
||||
if !exists("g:calendar_mark") |
||||
\|| (g:calendar_mark != 'left' |
||||
\&& g:calendar_mark != 'left-fit' |
||||
\&& g:calendar_mark != 'right') |
||||
let g:calendar_mark = 'left' |
||||
endif |
||||
if !exists("g:calendar_navi") |
||||
\|| (g:calendar_navi != 'top' |
||||
\&& g:calendar_navi != 'bottom' |
||||
\&& g:calendar_navi != 'both' |
||||
\&& g:calendar_navi != '') |
||||
let g:calendar_navi = 'top' |
||||
endif |
||||
if !exists("g:calendar_navi_label") |
||||
let g:calendar_navi_label = "Prev,Today,Next" |
||||
endif |
||||
if !exists("g:calendar_diary") |
||||
let g:calendar_diary = "~/diary" |
||||
endif |
||||
if !exists("g:calendar_focus_today") |
||||
let g:calendar_focus_today = 0 |
||||
endif |
||||
if !exists("g:calendar_datetime") |
||||
\|| (g:calendar_datetime != '' |
||||
\&& g:calendar_datetime != 'title' |
||||
\&& g:calendar_datetime != 'statusline') |
||||
let g:calendar_datetime = 'title' |
||||
endif |
||||
if !exists("g:calendar_options") |
||||
let g:calendar_options = "fdc=0 nonu" |
||||
if has("+relativenumber") |
||||
let g:calendar_options .= " nornu" |
||||
endif |
||||
endif |
||||
|
||||
"***************************************************************** |
||||
"* Default Calendar key bindings |
||||
"***************************************************************** |
||||
let s:calendar_keys = { |
||||
\ 'close' : 'q', |
||||
\ 'do_action' : '<CR>', |
||||
\ 'goto_today' : 't', |
||||
\ 'show_help' : '?', |
||||
\ 'redisplay' : 'r', |
||||
\ 'goto_next_month' : '<RIGHT>', |
||||
\ 'goto_prev_month' : '<LEFT>', |
||||
\ 'goto_next_year' : '<UP>', |
||||
\ 'goto_prev_year' : '<DOWN>', |
||||
\} |
||||
|
||||
if exists("g:calendar_keys") && type(g:calendar_keys) == 4 |
||||
let s:calendar_keys = extend(s:calendar_keys, g:calendar_keys) |
||||
end |
||||
|
||||
"***************************************************************** |
||||
"* CalendarDoAction : call the action handler function |
||||
"*---------------------------------------------------------------- |
||||
"***************************************************************** |
||||
function! calendar#action(...) |
||||
" for navi |
||||
if exists('g:calendar_navi') |
||||
let navi = (a:0 > 0)? a:1 : expand("<cWORD>") |
||||
let curl = line(".") |
||||
if navi == '<' . get(split(g:calendar_navi_label, ','), 0, '') |
||||
if b:CalendarMonth > 1 |
||||
call calendar#show(b:CalendarDir, b:CalendarYear, b:CalendarMonth-1) |
||||
else |
||||
call calendar#show(b:CalendarDir, b:CalendarYear-1, 12) |
||||
endif |
||||
elseif navi == get(split(g:calendar_navi_label, ','), 2, '') . '>' |
||||
if b:CalendarMonth < 12 |
||||
call calendar#show(b:CalendarDir, b:CalendarYear, b:CalendarMonth+1) |
||||
else |
||||
call calendar#show(b:CalendarDir, b:CalendarYear+1, 1) |
||||
endif |
||||
elseif navi == get(split(g:calendar_navi_label, ','), 1, '') |
||||
call calendar#show(b:CalendarDir) |
||||
if exists('g:calendar_today') |
||||
exe "call " . g:calendar_today . "()" |
||||
endif |
||||
else |
||||
let navi = '' |
||||
endif |
||||
if navi != '' |
||||
if g:calendar_focus_today == 1 && search("\*","w") > 0 |
||||
silent execute "normal! gg/\*\<cr>" |
||||
return |
||||
else |
||||
if curl < line('$')/2 |
||||
silent execute "normal! gg0/".navi."\<cr>" |
||||
else |
||||
silent execute "normal! G$?".navi."\<cr>" |
||||
endif |
||||
return |
||||
endif |
||||
endif |
||||
endif |
||||
|
||||
" if no action defined return |
||||
if !exists("g:calendar_action") || g:calendar_action == "" |
||||
return |
||||
endif |
||||
|
||||
if b:CalendarDir |
||||
let dir = 'H' |
||||
if exists('g:calendar_weeknm') |
||||
let cnr = col('.') - (col('.')%(24+5)) + 1 |
||||
else |
||||
let cnr = col('.') - (col('.')%(24)) + 1 |
||||
endif |
||||
let week = ((col(".") - cnr - 1 + cnr/49) / 3) |
||||
else |
||||
let dir = 'V' |
||||
let cnr = 1 |
||||
let week = ((col(".")+1) / 3) - 1 |
||||
endif |
||||
let lnr = 1 |
||||
let hdr = 1 |
||||
while 1 |
||||
if lnr > line('.') |
||||
break |
||||
endif |
||||
let sline = getline(lnr) |
||||
if sline =~ '^\s*$' |
||||
let hdr = lnr + 1 |
||||
endif |
||||
let lnr = lnr + 1 |
||||
endwhile |
||||
let lnr = line('.') |
||||
if(exists('g:calendar_monday')) |
||||
let week = week + 1 |
||||
elseif(week == 0) |
||||
let week = 7 |
||||
endif |
||||
if lnr-hdr < 2 |
||||
return |
||||
endif |
||||
let sline = substitute(strpart(getline(hdr),cnr,21),'\s*\(.*\)\s*','\1','') |
||||
if (col(".")-cnr) > 21 |
||||
return |
||||
endif |
||||
|
||||
" extract day |
||||
if g:calendar_mark == 'right' && col('.') > 1 |
||||
normal! h |
||||
let day = matchstr(expand("<cword>"), '[^0].*') |
||||
normal! l |
||||
else |
||||
let day = matchstr(expand("<cword>"), '[^0].*') |
||||
endif |
||||
if day == 0 |
||||
return |
||||
endif |
||||
" extract year and month |
||||
if exists('g:calendar_erafmt') && g:calendar_erafmt !~ "^\s*$" |
||||
let year = matchstr(substitute(sline, '/.*', '', ''), '\d\+') |
||||
let month = matchstr(substitute(sline, '.*/\(\d\d\=\).*', '\1', ""), '[^0].*') |
||||
if g:calendar_erafmt =~ '.*,[+-]*\d\+' |
||||
let veranum = substitute(g:calendar_erafmt,'.*,\([+-]*\d\+\)','\1','') |
||||
if year-veranum > 0 |
||||
let year = year-veranum |
||||
endif |
||||
endif |
||||
else |
||||
let year = matchstr(substitute(sline, '/.*', '', ''), '[^0].*') |
||||
let month = matchstr(substitute(sline, '\d*/\(\d\d\=\).*', '\1', ""), '[^0].*') |
||||
endif |
||||
" call the action function |
||||
exe "call " . g:calendar_action . "(day, month, year, week, dir)" |
||||
endfunc |
||||
|
||||
"***************************************************************** |
||||
"* Calendar : build calendar |
||||
"*---------------------------------------------------------------- |
||||
"* a1 : direction |
||||
"* a2 : month(if given a3, it's year) |
||||
"* a3 : if given, it's month |
||||
"***************************************************************** |
||||
function! calendar#show(...) |
||||
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
"+++ ready for build |
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
" remember today |
||||
" divide strftime('%d') by 1 so as to get "1,2,3 .. 9" instead of "01, 02, 03 .. 09" |
||||
let vtoday = strftime('%Y').strftime('%m').strftime('%d') |
||||
|
||||
" get arguments |
||||
if a:0 == 0 |
||||
let dir = 0 |
||||
let vyear = strftime('%Y') |
||||
let vmnth = matchstr(strftime('%m'), '[^0].*') |
||||
elseif a:0 == 1 |
||||
let dir = a:1 |
||||
let vyear = strftime('%Y') |
||||
let vmnth = matchstr(strftime('%m'), '[^0].*') |
||||
elseif a:0 == 2 |
||||
let dir = a:1 |
||||
let vyear = strftime('%Y') |
||||
let vmnth = matchstr(a:2, '^[^0].*') |
||||
else |
||||
let dir = a:1 |
||||
let vyear = a:2 |
||||
let vmnth = matchstr(a:3, '^[^0].*') |
||||
endif |
||||
|
||||
" remember constant |
||||
let vmnth_org = vmnth |
||||
let vyear_org = vyear |
||||
|
||||
" start with last month |
||||
let vmnth = vmnth - 1 |
||||
if vmnth < 1 |
||||
let vmnth = 12 |
||||
let vyear = vyear - 1 |
||||
endif |
||||
|
||||
" reset display variables |
||||
let vdisplay1 = '' |
||||
let vheight = 1 |
||||
let vmcnt = 0 |
||||
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
"+++ build display |
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
if exists("g:calendar_begin") |
||||
exe "call " . g:calendar_begin . "()" |
||||
endif |
||||
while vmcnt < 3 |
||||
let vcolumn = 22 |
||||
let vnweek = -1 |
||||
"-------------------------------------------------------------- |
||||
"--- calculating |
||||
"-------------------------------------------------------------- |
||||
" set boundary of the month |
||||
if vmnth == 1 |
||||
let vmdays = 31 |
||||
let vparam = 1 |
||||
let vsmnth = 'Jan' |
||||
elseif vmnth == 2 |
||||
let vmdays = 28 |
||||
let vparam = 32 |
||||
let vsmnth = 'Feb' |
||||
elseif vmnth == 3 |
||||
let vmdays = 31 |
||||
let vparam = 60 |
||||
let vsmnth = 'Mar' |
||||
elseif vmnth == 4 |
||||
let vmdays = 30 |
||||
let vparam = 91 |
||||
let vsmnth = 'Apr' |
||||
elseif vmnth == 5 |
||||
let vmdays = 31 |
||||
let vparam = 121 |
||||
let vsmnth = 'May' |
||||
elseif vmnth == 6 |
||||
let vmdays = 30 |
||||
let vparam = 152 |
||||
let vsmnth = 'Jun' |
||||
elseif vmnth == 7 |
||||
let vmdays = 31 |
||||
let vparam = 182 |
||||
let vsmnth = 'Jul' |
||||
elseif vmnth == 8 |
||||
let vmdays = 31 |
||||
let vparam = 213 |
||||
let vsmnth = 'Aug' |
||||
elseif vmnth == 9 |
||||
let vmdays = 30 |
||||
let vparam = 244 |
||||
let vsmnth = 'Sep' |
||||
elseif vmnth == 10 |
||||
let vmdays = 31 |
||||
let vparam = 274 |
||||
let vsmnth = 'Oct' |
||||
elseif vmnth == 11 |
||||
let vmdays = 30 |
||||
let vparam = 305 |
||||
let vsmnth = 'Nov' |
||||
elseif vmnth == 12 |
||||
let vmdays = 31 |
||||
let vparam = 335 |
||||
let vsmnth = 'Dec' |
||||
else |
||||
echo 'Invalid Year or Month' |
||||
return |
||||
endif |
||||
if vyear % 400 == 0 |
||||
if vmnth == 2 |
||||
let vmdays = 29 |
||||
elseif vmnth >= 3 |
||||
let vparam = vparam + 1 |
||||
endif |
||||
elseif vyear % 100 == 0 |
||||
if vmnth == 2 |
||||
let vmdays = 28 |
||||
endif |
||||
elseif vyear % 4 == 0 |
||||
if vmnth == 2 |
||||
let vmdays = 29 |
||||
elseif vmnth >= 3 |
||||
let vparam = vparam + 1 |
||||
endif |
||||
endif |
||||
|
||||
" calc vnweek of the day |
||||
if vnweek == -1 |
||||
let vnweek = ( vyear * 365 ) + vparam |
||||
let vnweek = vnweek + ( vyear/4 ) - ( vyear/100 ) + ( vyear/400 ) |
||||
if vyear % 4 == 0 |
||||
if vyear % 100 != 0 || vyear % 400 == 0 |
||||
let vnweek = vnweek - 1 |
||||
endif |
||||
endif |
||||
let vnweek = vnweek - 1 |
||||
endif |
||||
|
||||
" fix Gregorian |
||||
if vyear <= 1752 |
||||
let vnweek = vnweek - 3 |
||||
endif |
||||
|
||||
let vnweek = vnweek % 7 |
||||
|
||||
if exists('g:calendar_monday') |
||||
" if given g:calendar_monday, the week start with monday |
||||
if vnweek == 0 |
||||
let vnweek = 7 |
||||
endif |
||||
let vnweek = vnweek - 1 |
||||
endif |
||||
|
||||
if exists('g:calendar_weeknm') |
||||
" if given g:calendar_weeknm, show week number(ref:ISO8601) |
||||
|
||||
"vparam <= 1. day of month |
||||
"vnweek <= 1. weekday of month (0-6) |
||||
"viweek <= number of week |
||||
"vfweek <= 1. day of year |
||||
|
||||
" mo di mi do fr sa so |
||||
" 6 5 4 3 2 1 0 vfweek |
||||
" 0 1 2 3 4 5 6 vnweek |
||||
|
||||
let vfweek =((vparam % 7) -vnweek+ 14-2) % 7 |
||||
let viweek = (vparam - vfweek-2+7 ) / 7 +1 |
||||
|
||||
if vfweek < 3 |
||||
let viweek = viweek - 1 |
||||
endif |
||||
|
||||
"vfweekl <=year length |
||||
let vfweekl = 52 |
||||
if (vfweek == 3) |
||||
let vfweekl = 53 |
||||
endif |
||||
|
||||
if viweek == 0 |
||||
let viweek = 52 |
||||
if ((vfweek == 2) && (((vyear-1) % 4) != 0)) |
||||
\ || ((vfweek == 1) && (((vyear-1) % 4) == 0)) |
||||
let viweek = 53 |
||||
endif |
||||
endif |
||||
|
||||
let vcolumn = vcolumn + 5 |
||||
if g:calendar_weeknm == 5 |
||||
let vcolumn = vcolumn - 2 |
||||
endif |
||||
endif |
||||
|
||||
"-------------------------------------------------------------- |
||||
"--- displaying |
||||
"-------------------------------------------------------------- |
||||
" build header |
||||
if exists('g:calendar_erafmt') && g:calendar_erafmt !~ "^\s*$" |
||||
if g:calendar_erafmt =~ '.*,[+-]*\d\+' |
||||
let veranum = substitute(g:calendar_erafmt,'.*,\([+-]*\d\+\)','\1','') |
||||
if vyear+veranum > 0 |
||||
let vdisplay2 = substitute(g:calendar_erafmt,'\(.*\),.*','\1','') |
||||
let vdisplay2 = vdisplay2.(vyear+veranum).'/'.vmnth.'(' |
||||
else |
||||
let vdisplay2 = vyear.'/'.vmnth.'(' |
||||
endif |
||||
else |
||||
let vdisplay2 = vyear.'/'.vmnth.'(' |
||||
endif |
||||
let vdisplay2 = strpart(" ", |
||||
\ 1,(vcolumn-strlen(vdisplay2))/2-2).vdisplay2 |
||||
else |
||||
let vdisplay2 = vyear.'/'.vmnth.'(' |
||||
let vdisplay2 = strpart(" ", |
||||
\ 1,(vcolumn-strlen(vdisplay2))/2-2).vdisplay2 |
||||
endif |
||||
if exists('g:calendar_mruler') && g:calendar_mruler !~ "^\s*$" |
||||
let vdisplay2 = vdisplay2 . get(split(g:calendar_mruler, ','), vmnth-1, '').')'."\n" |
||||
else |
||||
let vdisplay2 = vdisplay2 . vsmnth.')'."\n" |
||||
endif |
||||
let vwruler = "Su Mo Tu We Th Fr Sa" |
||||
if exists('g:calendar_wruler') && g:calendar_wruler !~ "^\s*$" |
||||
let vwruler = g:calendar_wruler |
||||
endif |
||||
if exists('g:calendar_monday') |
||||
let vwruler = strpart(vwruler,stridx(vwruler, ' ') + 1).' '.strpart(vwruler,0,stridx(vwruler, ' ')) |
||||
endif |
||||
let vdisplay2 = vdisplay2.' '.vwruler."\n" |
||||
if g:calendar_mark == 'right' |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
|
||||
" build calendar |
||||
let vinpcur = 0 |
||||
while (vinpcur < vnweek) |
||||
let vdisplay2 = vdisplay2.' ' |
||||
let vinpcur = vinpcur + 1 |
||||
endwhile |
||||
let vdaycur = 1 |
||||
while (vdaycur <= vmdays) |
||||
if vmnth < 10 |
||||
let vtarget = vyear."0".vmnth |
||||
else |
||||
let vtarget = vyear.vmnth |
||||
endif |
||||
if vdaycur < 10 |
||||
let vtarget = vtarget."0".vdaycur |
||||
else |
||||
let vtarget = vtarget.vdaycur |
||||
endif |
||||
if exists("g:calendar_sign") && g:calendar_sign != "" |
||||
exe "let vsign = " . g:calendar_sign . "(vdaycur, vmnth, vyear)" |
||||
if vsign != "" |
||||
let vsign = vsign[0] |
||||
if vsign !~ "[+!#$%&@?]" |
||||
let vsign = "+" |
||||
endif |
||||
endif |
||||
else |
||||
let vsign = '' |
||||
endif |
||||
|
||||
" show mark |
||||
if g:calendar_mark == 'right' |
||||
if vdaycur < 10 |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
let vdisplay2 = vdisplay2.vdaycur |
||||
elseif g:calendar_mark == 'left-fit' |
||||
if vdaycur < 10 |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
endif |
||||
if vtarget == vtoday |
||||
let vdisplay2 = vdisplay2.'*' |
||||
elseif vsign != '' |
||||
let vdisplay2 = vdisplay2.vsign |
||||
else |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
if g:calendar_mark == 'left' |
||||
if vdaycur < 10 |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
let vdisplay2 = vdisplay2.vdaycur |
||||
endif |
||||
if g:calendar_mark == 'left-fit' |
||||
let vdisplay2 = vdisplay2.vdaycur |
||||
endif |
||||
let vdaycur = vdaycur + 1 |
||||
|
||||
" fix Gregorian |
||||
if vyear == 1752 && vmnth == 9 && vdaycur == 3 |
||||
let vdaycur = 14 |
||||
endif |
||||
|
||||
let vinpcur = vinpcur + 1 |
||||
if vinpcur % 7 == 0 |
||||
if exists('g:calendar_weeknm') |
||||
if g:calendar_mark != 'right' |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
" if given g:calendar_weeknm, show week number |
||||
if viweek < 10 |
||||
if g:calendar_weeknm == 1 |
||||
let vdisplay2 = vdisplay2.'WK0'.viweek |
||||
elseif g:calendar_weeknm == 2 |
||||
let vdisplay2 = vdisplay2.'WK '.viweek |
||||
elseif g:calendar_weeknm == 3 |
||||
let vdisplay2 = vdisplay2.'KW0'.viweek |
||||
elseif g:calendar_weeknm == 4 |
||||
let vdisplay2 = vdisplay2.'KW '.viweek |
||||
elseif g:calendar_weeknm == 5 |
||||
let vdisplay2 = vdisplay2.' '.viweek |
||||
endif |
||||
else |
||||
if g:calendar_weeknm <= 2 |
||||
let vdisplay2 = vdisplay2.'WK'.viweek |
||||
elseif g:calendar_weeknm == 3 || g:calendar_weeknm == 4 |
||||
let vdisplay2 = vdisplay2.'KW'.viweek |
||||
elseif g:calendar_weeknm == 5 |
||||
let vdisplay2 = vdisplay2.viweek |
||||
endif |
||||
endif |
||||
let viweek = viweek + 1 |
||||
|
||||
if viweek > vfweekl |
||||
let viweek = 1 |
||||
endif |
||||
|
||||
endif |
||||
let vdisplay2 = vdisplay2."\n" |
||||
if g:calendar_mark == 'right' |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
endif |
||||
endwhile |
||||
|
||||
" if it is needed, fill with space |
||||
if vinpcur % 7 |
||||
while (vinpcur % 7 != 0) |
||||
let vdisplay2 = vdisplay2.' ' |
||||
let vinpcur = vinpcur + 1 |
||||
endwhile |
||||
if exists('g:calendar_weeknm') |
||||
if g:calendar_mark != 'right' |
||||
let vdisplay2 = vdisplay2.' ' |
||||
endif |
||||
if viweek < 10 |
||||
if g:calendar_weeknm == 1 |
||||
let vdisplay2 = vdisplay2.'WK0'.viweek |
||||
elseif g:calendar_weeknm == 2 |
||||
let vdisplay2 = vdisplay2.'WK '.viweek |
||||
elseif g:calendar_weeknm == 3 |
||||
let vdisplay2 = vdisplay2.'KW0'.viweek |
||||
elseif g:calendar_weeknm == 4 |
||||
let vdisplay2 = vdisplay2.'KW '.viweek |
||||
elseif g:calendar_weeknm == 5 |
||||
let vdisplay2 = vdisplay2.' '.viweek |
||||
endif |
||||
else |
||||
if g:calendar_weeknm <= 2 |
||||
let vdisplay2 = vdisplay2.'WK'.viweek |
||||
elseif g:calendar_weeknm == 3 || g:calendar_weeknm == 4 |
||||
let vdisplay2 = vdisplay2.'KW'.viweek |
||||
elseif g:calendar_weeknm == 5 |
||||
let vdisplay2 = vdisplay2.viweek |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
|
||||
" build display |
||||
let vstrline = '' |
||||
if dir |
||||
" for horizontal |
||||
"-------------------------------------------------------------- |
||||
" +---+ +---+ +------+ |
||||
" | | | | | | |
||||
" | 1 | + | 2 | = | 1' | |
||||
" | | | | | | |
||||
" +---+ +---+ +------+ |
||||
"-------------------------------------------------------------- |
||||
let vtokline = 1 |
||||
while 1 |
||||
let vtoken1 = get(split(vdisplay1, "\n"), vtokline-1, '') |
||||
let vtoken2 = get(split(vdisplay2, "\n"), vtokline-1, '') |
||||
if vtoken1 == '' && vtoken2 == '' |
||||
break |
||||
endif |
||||
while strlen(vtoken1) < (vcolumn+1)*vmcnt |
||||
if strlen(vtoken1) % (vcolumn+1) == 0 |
||||
let vtoken1 = vtoken1.'|' |
||||
else |
||||
let vtoken1 = vtoken1.' ' |
||||
endif |
||||
endwhile |
||||
let vstrline = vstrline.vtoken1.'|'.vtoken2.' '."\n" |
||||
let vtokline = vtokline + 1 |
||||
endwhile |
||||
let vdisplay1 = vstrline |
||||
let vheight = vtokline-1 |
||||
else |
||||
" for virtical |
||||
"-------------------------------------------------------------- |
||||
" +---+ +---+ +---+ |
||||
" | 1 | + | 2 | = | | |
||||
" +---+ +---+ | 1'| |
||||
" | | |
||||
" +---+ |
||||
"-------------------------------------------------------------- |
||||
let vtokline = 1 |
||||
while 1 |
||||
let vtoken1 = get(split(vdisplay1, "\n"), vtokline-1, '') |
||||
if vtoken1 == '' |
||||
break |
||||
endif |
||||
let vstrline = vstrline.vtoken1."\n" |
||||
let vtokline = vtokline + 1 |
||||
let vheight = vheight + 1 |
||||
endwhile |
||||
if vstrline != '' |
||||
let vstrline = vstrline.' '."\n" |
||||
let vheight = vheight + 1 |
||||
endif |
||||
let vtokline = 1 |
||||
while 1 |
||||
let vtoken2 = get(split(vdisplay2, "\n"), vtokline-1, '') |
||||
if vtoken2 == '' |
||||
break |
||||
endif |
||||
while strlen(vtoken2) < vcolumn |
||||
let vtoken2 = vtoken2.' ' |
||||
endwhile |
||||
let vstrline = vstrline.vtoken2."\n" |
||||
let vtokline = vtokline + 1 |
||||
let vheight = vtokline + 1 |
||||
endwhile |
||||
let vdisplay1 = vstrline |
||||
endif |
||||
let vmnth = vmnth + 1 |
||||
let vmcnt = vmcnt + 1 |
||||
if vmnth > 12 |
||||
let vmnth = 1 |
||||
let vyear = vyear + 1 |
||||
endif |
||||
endwhile |
||||
if exists("g:calendar_end") |
||||
exe "call " . g:calendar_end . "()" |
||||
endif |
||||
if a:0 == 0 |
||||
return vdisplay1 |
||||
endif |
||||
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
"+++ build window |
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
" make window |
||||
let vwinnum = bufnr('__Calendar') |
||||
if getbufvar(vwinnum, 'Calendar') == 'Calendar' |
||||
let vwinnum = bufwinnr(vwinnum) |
||||
else |
||||
let vwinnum = -1 |
||||
endif |
||||
|
||||
if vwinnum >= 0 |
||||
" if already exist |
||||
if vwinnum != bufwinnr('%') |
||||
exe vwinnum . 'wincmd w' |
||||
endif |
||||
setlocal modifiable |
||||
silent %d _ |
||||
else |
||||
" make title |
||||
if g:calendar_datetime == "title" && (!exists('s:bufautocommandsset')) |
||||
auto BufEnter *Calendar let b:sav_titlestring = &titlestring | let &titlestring = '%{strftime("%c")}' |
||||
auto BufLeave *Calendar let &titlestring = b:sav_titlestring |
||||
let s:bufautocommandsset = 1 |
||||
endif |
||||
|
||||
if exists('g:calendar_navi') && dir |
||||
if g:calendar_navi == 'both' |
||||
let vheight = vheight + 4 |
||||
else |
||||
let vheight = vheight + 2 |
||||
endif |
||||
endif |
||||
|
||||
" or not |
||||
if dir |
||||
silent execute 'bo '.vheight.'split __Calendar' |
||||
setlocal winfixheight |
||||
else |
||||
silent execute 'to '.vcolumn.'vsplit __Calendar' |
||||
setlocal winfixwidth |
||||
endif |
||||
call s:CalendarBuildKeymap(dir, vyear, vmnth) |
||||
setlocal noswapfile |
||||
setlocal buftype=nofile |
||||
setlocal bufhidden=delete |
||||
silent! exe "setlocal " . g:calendar_options |
||||
let nontext_columns = &foldcolumn + &nu * &numberwidth |
||||
if has("+relativenumber") |
||||
let nontext_columns += &rnu * &numberwidth |
||||
endif |
||||
" Without this, the 'sidescrolloff' setting may cause the left side of the |
||||
" calendar to disappear if the last inserted element is near the right |
||||
" window border. |
||||
setlocal nowrap |
||||
setlocal norightleft |
||||
setlocal modifiable |
||||
setlocal nolist |
||||
let b:Calendar = 'Calendar' |
||||
setlocal filetype=calendar |
||||
" is this a vertical (0) or a horizontal (1) split? |
||||
exe vcolumn + nontext_columns . "wincmd |" |
||||
endif |
||||
if g:calendar_datetime == "statusline" |
||||
setlocal statusline=%{strftime('%c')} |
||||
endif |
||||
let b:CalendarDir = dir |
||||
let b:CalendarYear = vyear_org |
||||
let b:CalendarMonth = vmnth_org |
||||
|
||||
" navi |
||||
if exists('g:calendar_navi') |
||||
let navi_label = '<' |
||||
\.get(split(g:calendar_navi_label, ','), 0, '').' ' |
||||
\.get(split(g:calendar_navi_label, ','), 1, '').' ' |
||||
\.get(split(g:calendar_navi_label, ','), 2, '').'>' |
||||
if dir |
||||
let navcol = vcolumn + (vcolumn-strlen(navi_label)+2)/2 |
||||
else |
||||
let navcol = (vcolumn-strlen(navi_label)+2)/2 |
||||
endif |
||||
if navcol < 3 |
||||
let navcol = 3 |
||||
endif |
||||
|
||||
if g:calendar_navi == 'top' |
||||
execute "normal gg".navcol."i " |
||||
silent exec "normal! a".navi_label."\<cr>\<cr>" |
||||
silent put! =vdisplay1 |
||||
endif |
||||
if g:calendar_navi == 'bottom' |
||||
silent put! =vdisplay1 |
||||
silent exec "normal! Gi\<cr>" |
||||
execute "normal ".navcol."i " |
||||
silent exec "normal! a".navi_label |
||||
endif |
||||
if g:calendar_navi == 'both' |
||||
execute "normal gg".navcol."i " |
||||
silent exec "normal! a".navi_label."\<cr>\<cr>" |
||||
silent put! =vdisplay1 |
||||
silent exec "normal! Gi\<cr>" |
||||
execute "normal ".navcol."i " |
||||
silent exec "normal! a".navi_label |
||||
endif |
||||
else |
||||
silent put! =vdisplay1 |
||||
endif |
||||
|
||||
setlocal nomodifiable |
||||
" In case we've gotten here from insert mode (via <C-O>:Calendar<CR>)... |
||||
stopinsert |
||||
|
||||
let vyear = vyear_org |
||||
let vmnth = vmnth_org |
||||
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
"+++ build highlight |
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||
" today |
||||
syn clear |
||||
if g:calendar_mark =~ 'left-fit' |
||||
syn match CalToday display "\s*\*\d*" |
||||
syn match CalMemo display "\s*[+!#$%&@?]\d*" |
||||
elseif g:calendar_mark =~ 'right' |
||||
syn match CalToday display "\d*\*\s*" |
||||
syn match CalMemo display "\d*[+!#$%&@?]\s*" |
||||
else |
||||
syn match CalToday display "\*\s*\d*" |
||||
syn match CalMemo display "[+!#$%&@?]\s*\d*" |
||||
endif |
||||
" header |
||||
syn match CalHeader display "[^ ]*\d\+\/\d\+([^)]*)" |
||||
|
||||
" navi |
||||
if exists('g:calendar_navi') |
||||
exec "silent! syn match CalNavi display \"\\(<" |
||||
\.get(split(g:calendar_navi_label, ','), 0, '')."\\|" |
||||
\.get(split(g:calendar_navi_label, ','), 2, '').">\\)\"" |
||||
exec "silent! syn match CalNavi display \"\\s" |
||||
\.get(split(g:calendar_navi_label, ','), 1, '')."\\s\"hs=s+1,he=e-1" |
||||
endif |
||||
|
||||
" saturday, sunday |
||||
|
||||
if exists('g:calendar_monday') |
||||
if dir |
||||
syn match CalSaturday display /|.\{15}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
syn match CalSunday display /|.\{18}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
else |
||||
syn match CalSaturday display /^.\{15}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
syn match CalSunday display /^.\{18}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
endif |
||||
else |
||||
if dir |
||||
syn match CalSaturday display /|.\{18}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
syn match CalSunday display /|\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
else |
||||
syn match CalSaturday display /^.\{18}\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
syn match CalSunday display /^\s\([0-9\ ]\d\)/hs=e-1 contains=ALL |
||||
endif |
||||
endif |
||||
|
||||
" week number |
||||
if !exists('g:calendar_weeknm') || g:calendar_weeknm <= 2 |
||||
syn match CalWeeknm display "WK[0-9\ ]\d" |
||||
else |
||||
syn match CalWeeknm display "KW[0-9\ ]\d" |
||||
endif |
||||
|
||||
" ruler |
||||
execute 'syn match CalRuler "'.vwruler.'"' |
||||
|
||||
if search("\*","w") > 0 |
||||
silent execute "normal! gg/\*\<cr>" |
||||
endif |
||||
|
||||
return '' |
||||
endfunction |
||||
|
||||
"***************************************************************** |
||||
"* make_dir : make directory |
||||
"*---------------------------------------------------------------- |
||||
"* dir : directory |
||||
"***************************************************************** |
||||
function! s:make_dir(dir) |
||||
if(has("unix")) |
||||
call system("mkdir " . a:dir) |
||||
let rc = v:shell_error |
||||
elseif(has("win16") || has("win32") || has("win95") || |
||||
\has("dos16") || has("dos32") || has("os2")) |
||||
call system("mkdir \"" . a:dir . "\"") |
||||
let rc = v:shell_error |
||||
else |
||||
let rc = 1 |
||||
endif |
||||
if rc != 0 |
||||
call confirm("can't create directory : " . a:dir, "&OK") |
||||
endif |
||||
return rc |
||||
endfunc |
||||
|
||||
"***************************************************************** |
||||
"* diary : calendar hook function |
||||
"*---------------------------------------------------------------- |
||||
"* day : day you actioned |
||||
"* month : month you actioned |
||||
"* year : year you actioned |
||||
"***************************************************************** |
||||
function! calendar#diary(day, month, year, week, dir) |
||||
" build the file name and create directories as needed |
||||
if !isdirectory(expand(g:calendar_diary)) |
||||
call confirm("please create diary directory : ".g:calendar_diary, 'OK') |
||||
return |
||||
endif |
||||
let sfile = expand(g:calendar_diary) . "/" . a:year |
||||
if isdirectory(sfile) == 0 |
||||
if s:make_dir(sfile) != 0 |
||||
return |
||||
endif |
||||
endif |
||||
let sfile = sfile . "/" . a:month |
||||
if isdirectory(sfile) == 0 |
||||
if s:make_dir(sfile) != 0 |
||||
return |
||||
endif |
||||
endif |
||||
let sfile = expand(sfile) . "/" . a:day . ".md" |
||||
let sfile = substitute(sfile, ' ', '\\ ', 'g') |
||||
let vbufnr = bufnr('__Calendar') |
||||
|
||||
" load the file |
||||
exe "wincmd w" |
||||
exe "edit " . sfile |
||||
let dir = getbufvar(vbufnr, "CalendarDir") |
||||
let vyear = getbufvar(vbufnr, "CalendarYear") |
||||
let vmnth = getbufvar(vbufnr, "CalendarMonth") |
||||
exe "auto BufDelete ".escape(sfile, ' \\')." call calendar#show(" . dir . "," . vyear . "," . vmnth . ")" |
||||
endfunc |
||||
|
||||
"***************************************************************** |
||||
"* sign : calendar sign function |
||||
"*---------------------------------------------------------------- |
||||
"* day : day of sign |
||||
"* month : month of sign |
||||
"* year : year of sign |
||||
"***************************************************************** |
||||
function! calendar#sign(day, month, year) |
||||
let sfile = g:calendar_diary."/".a:year."/".a:month."/".a:day.".md" |
||||
return filereadable(expand(sfile)) |
||||
endfunction |
||||
|
||||
"***************************************************************** |
||||
"* CalendarVar : get variable |
||||
"*---------------------------------------------------------------- |
||||
"***************************************************************** |
||||
function! s:CalendarVar(var) |
||||
if !exists(a:var) |
||||
return '' |
||||
endif |
||||
exec 'return ' . a:var |
||||
endfunction |
||||
|
||||
"***************************************************************** |
||||
"* CalendarBuildKeymap : build keymap |
||||
"*---------------------------------------------------------------- |
||||
"***************************************************************** |
||||
function! s:CalendarBuildKeymap(dir, vyear, vmnth) |
||||
" make keymap |
||||
nnoremap <silent> <buffer> <Plug>CalendarDoAction :call calendar#action()<cr> |
||||
nnoremap <silent> <buffer> <Plug>CalendarDoAction :call calendar#action()<cr> |
||||
nnoremap <silent> <buffer> <Plug>CalendarGotoToday :call calendar#show(b:CalendarDir)<cr> |
||||
nnoremap <silent> <buffer> <Plug>CalendarShowHelp :call <SID>CalendarHelp()<cr> |
||||
execute 'nnoremap <silent> <buffer> <Plug>CalendarReDisplay :call calendar#show(' . a:dir . ',' . a:vyear . ',' . a:vmnth . ')<cr>' |
||||
let pnav = get(split(g:calendar_navi_label, ','), 0, '') |
||||
let nnav = get(split(g:calendar_navi_label, ','), 2, '') |
||||
execute 'nnoremap <silent> <buffer> <Plug>CalendarGotoPrevMonth :call calendar#action("<' . pnav . '")<cr>' |
||||
execute 'nnoremap <silent> <buffer> <Plug>CalendarGotoNextMonth :call calendar#action("' . nnav . '>")<cr>' |
||||
execute 'nnoremap <silent> <buffer> <Plug>CalendarGotoPrevYear :call calendar#show('.a:dir.','.(a:vyear-1).','.a:vmnth.')<cr>' |
||||
execute 'nnoremap <silent> <buffer> <Plug>CalendarGotoNextYear :call calendar#show('.a:dir.','.(a:vyear+1).','.a:vmnth.')<cr>' |
||||
|
||||
nmap <buffer> <2-LeftMouse> <Plug>CalendarDoAction |
||||
|
||||
execute 'nmap <buffer> ' . s:calendar_keys['close'] . ' <C-w>c' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['do_action'] . ' <Plug>CalendarDoAction' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['goto_today'] . ' <Plug>CalendarGotoToday' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['show_help'] . ' <Plug>CalendarShowHelp' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['redisplay'] . ' <Plug>CalendarRedisplay' |
||||
|
||||
execute 'nmap <buffer> ' . s:calendar_keys['goto_next_month'] . ' <Plug>CalendarGotoNextMonth' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['goto_prev_month'] . ' <Plug>CalendarGotoPrevMonth' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['goto_next_year'] . ' <Plug>CalendarGotoNextYear' |
||||
execute 'nmap <buffer> ' . s:calendar_keys['goto_prev_year'] . ' <Plug>CalendarGotoPrevYear' |
||||
endfunction |
||||
|
||||
"***************************************************************** |
||||
"* CalendarHelp : show help for Calendar |
||||
"*---------------------------------------------------------------- |
||||
"***************************************************************** |
||||
function! s:CalendarHelp() |
||||
let ck = s:calendar_keys |
||||
let max_width = max(map(values(ck), 'len(v:val)')) |
||||
let offsets = map(copy(ck), '1 + max_width - len(v:val)') |
||||
|
||||
echohl SpecialKey |
||||
echo ck['goto_prev_month'] . repeat(' ', offsets['goto_prev_month']) . ': goto prev month' |
||||
echo ck['goto_next_month'] . repeat(' ', offsets['goto_next_month']) . ': goto next month' |
||||
echo ck['goto_prev_year'] . repeat(' ', offsets['goto_prev_year']) . ': goto prev year' |
||||
echo ck['goto_next_year'] . repeat(' ', offsets['goto_next_year']) . ': goto next year' |
||||
echo ck['goto_today'] . repeat(' ', offsets['goto_today']) . ': goto today' |
||||
echo ck['close'] . repeat(' ', offsets['close']) . ': close window' |
||||
echo ck['redisplay'] . repeat(' ', offsets['redisplay']) . ': re-display window' |
||||
echo ck['show_help'] . repeat(' ', offsets['show_help']) . ': show this help' |
||||
if g:calendar_action == "calendar#diary" |
||||
echo ck['do_action'] . repeat(' ', offsets['do_action']) . ': show diary' |
||||
endif |
||||
echo '' |
||||
echohl Question |
||||
|
||||
let vk = [ |
||||
\ 'calendar_erafmt', |
||||
\ 'calendar_mruler', |
||||
\ 'calendar_wruler', |
||||
\ 'calendar_weeknm', |
||||
\ 'calendar_navi_label', |
||||
\ 'calendar_diary', |
||||
\ 'calendar_mark', |
||||
\ 'calendar_navi', |
||||
\] |
||||
let max_width = max(map(copy(vk), 'len(v:val)')) |
||||
|
||||
for _ in vk |
||||
let v = get(g:, _, '') |
||||
echo _ . repeat(' ', max_width - len(_)) . ' = ' . v |
||||
endfor |
||||
echohl MoreMsg |
||||
echo "[Hit any key]" |
||||
echohl None |
||||
call getchar() |
||||
redraw! |
||||
endfunction |
||||
|
||||
hi def link CalNavi Search |
||||
hi def link CalSaturday Statement |
||||
hi def link CalSunday Type |
||||
hi def link CalRuler StatusLine |
||||
hi def link CalWeeknm Comment |
||||
hi def link CalToday Directory |
||||
hi def link CalHeader Special |
||||
hi def link CalMemo Identifier |
@ -0,0 +1,195 @@
@@ -0,0 +1,195 @@
|
||||
*calendar.txt* Calendar utility for vim |
||||
|
||||
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> |
||||
|
||||
INTRODUCTION *calendar* |
||||
|
||||
This script creates a calendar window in vim. It does not rely on any |
||||
external program, such as cal, etc. |
||||
|
||||
COMMANDS *calendar-commands* |
||||
|
||||
calendar.vim makes the following commands available: |
||||
|
||||
*calendar-:Calendar* |
||||
:Calendar [[year] month] Show calendar at this year and this month in a |
||||
vertical split. When [year] is omitted, the |
||||
calendar will show the given month in the current |
||||
year. When both [year] and [month] are omitted, the |
||||
calendar will show the current month. |
||||
|
||||
*calendar-:CalendarH* |
||||
:CalendarH [[year] month] Show calendar at this year and this month in a |
||||
horizontal split. When [year] is omitted, the |
||||
calendar will show the given month in the current |
||||
year. When both [year] and [month] are omitted, the |
||||
calendar will show the current month. |
||||
|
||||
MAPPINGS *calendar-mappings* |
||||
|
||||
calendar.vim makes the following normal mode mappings available: |
||||
|
||||
*calendar-cal* |
||||
<LocalLeader>cal Brings up the calendar in a vertical split. |
||||
Equivalent to calling |:Calendar|. |
||||
|
||||
*calendar-caL* |
||||
<LocalLeader>caL Brings up the calendar in a horizontal split. |
||||
Equivalent to calling |:CalendarH|. |
||||
|
||||
SETTINGS *calendar-settings* |
||||
|
||||
calendar.vim can be configured using the following settings: |
||||
|
||||
*g:calendar_focus_today* |
||||
Keeps focus when moving to next or previous calendar: > |
||||
let g:calendar_focus_today = 1 |
||||
< |
||||
|
||||
*g:calendar_keys* |
||||
To change the key bindings in the calendar window, add entries to this |
||||
dictionary. Possible keys, the action bound to the keycode given in the |
||||
respective value for this key and the default binding are listed below. |
||||
'close' Closes calendar window. 'q' |
||||
'do_action' Executes |calendar_action|. '<CR>' |
||||
'goto_today' Executes |calendar_today|. 't' |
||||
'show_help' Displays a short help message. '?' |
||||
'redisplay' Redraws calendar window. 'r' |
||||
'goto_next_month' Jumps to the next month. '<Right>' |
||||
'goto_prev_month' Jumps to the previous month. '<Left>' |
||||
'goto_next_year' Jumps to the next month. '<Up>' |
||||
'goto_prev_year' Jumps to the previous month. '<Down>' |
||||
An example in your .vimrc might look like this: > |
||||
let g:calendar_keys = { 'goto_next_month':'<C-Right>, 'goto_prev_month':'<C-Left>'} |
||||
< |
||||
|
||||
*g:calendar_mark* |
||||
Place a '*' or '+' mark after the day. Acceptable values are 'left', |
||||
'left-fit', and 'right': > |
||||
let g:calendar_mark = 'right' |
||||
< |
||||
|
||||
*g:calendar_navi* |
||||
To control the calendar navigator, set this variable. Acceptable values are |
||||
'top', 'bottom', or 'both'. > |
||||
let g:calendar_navi = '' |
||||
< |
||||
|
||||
*g:calendar_navi_label* |
||||
To set the labels for the calendar navigator, for example to change the |
||||
language, use this variable. Entries should be comma separated. > |
||||
let g:calendar_navi_label = 'Prev,Today,Next' |
||||
< |
||||
|
||||
*g:calendar_erafmt* |
||||
To change the dating system, set the following variable. Include the name of |
||||
the dating system and its offset from the Georgian calendar (A.D.). For |
||||
example, to use the current Japanese era (Heisei), you would set: > |
||||
let g:calendar_erafmt = 'Heisei,-1988' |
||||
< |
||||
|
||||
*g:calendar_mruler* |
||||
To change the month names for the calendar headings, set this variable. The |
||||
value is expected to be a comma-separated list of twelve values, starting with |
||||
Janurary: > |
||||
let g:calendar_mruler = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec' |
||||
< |
||||
|
||||
*g:calendar_wruler* |
||||
To change the week names for the calendar headings, set this variable. The |
||||
value is expected to be a space-separated list of seven values, starting with |
||||
Sunday: > |
||||
let g:calendar_wruler = 'Su Mo Tu We Th Fr Sa' |
||||
< |
||||
|
||||
*g:calendar_monday* |
||||
To make the week start on Monday rather than Sunday, set this variable. Note |
||||
that the value of |g:calendar_wruler| is not affected by this; it should |
||||
always begin with Sunday: > |
||||
let g:calendar_monday = 1 |
||||
< |
||||
|
||||
*g:calendar_weeknm* |
||||
To show the week number, set this variable. There are four valid settings: > |
||||
let g:calendar_weeknm = 1 " WK01 |
||||
let g:calendar_weeknm = 2 " WK 1 |
||||
let g:calendar_weeknm = 3 " KW01 |
||||
let g:calendar_weeknm = 4 " KW 1 |
||||
let g:calendar_weeknm = 5 " 1 |
||||
< |
||||
|
||||
*g:calendar_datetime* |
||||
To control display of the current date and time, set this variable. |
||||
Acceptable values are 'title', 'statusline', and '': > |
||||
let g:calendar_datetime = 'title' |
||||
< |
||||
|
||||
HOOKS *calendar-hooks* |
||||
|
||||
calendar.vim provides a number of hooks which allow you to run custom code on |
||||
certain events. These are documented below. |
||||
|
||||
*calendar_action* |
||||
The function declared in the calendar_action variable is run when the user |
||||
presses enter on a date. Implement and set your function as follows: > |
||||
function MyCalAction(day,month,year,week,dir) |
||||
" day : day you actioned |
||||
" month : month you actioned |
||||
" year : year you actioned |
||||
" week : day of week (Mo=1 ... Su=7) |
||||
" dir : direction of calendar |
||||
endfunction |
||||
let calendar_action = 'MyCalAction' |
||||
< |
||||
|
||||
*calendar_begin* |
||||
The function declared in the calendar_begin variable is run just before the |
||||
calendar is displayed. Implement and set your function as follows: > |
||||
function MyCalActionBegin() |
||||
endfunction |
||||
let calendar_begin = 'MyCalActionBegin' |
||||
< |
||||
|
||||
*calendar_end* |
||||
The function declared in the calendar_end variable is run just after the |
||||
calendar is displayed. Implement and set your function as follows: > |
||||
function MyCalActionEnd() |
||||
endfunction |
||||
let calendar_end = 'MyCalActionEnd' |
||||
< |
||||
|
||||
*calendar_sign* |
||||
The function declared in the calendar_sign variable can be used to set a mark |
||||
next to certain dates. Implement and set your function as follows: > |
||||
function MyCalSign(day,month,year) |
||||
" day : day you actioned |
||||
" month : month you actioned |
||||
" year : year you actioned |
||||
if a:day == 1 && a:month == 1 |
||||
return 1 " happy new year |
||||
else |
||||
return 0 " or not |
||||
endif |
||||
endfunction |
||||
let calendar_sign = 'MyCalSign' |
||||
< |
||||
|
||||
*calendar_today* |
||||
The function declared in the calendar_today variable is run when the user |
||||
presses 'today'. Implement and set your function as follows: > |
||||
function MyCalToday() |
||||
endfunction |
||||
let calendar_today = 'MyCalToday' |
||||
< |
||||
|
||||
ABOUT *calendar-about* |
||||
|
||||
calendar.vim is available on GitHub: |
||||
|
||||
http://github.com/mattn/calendar.vim |
||||
|
||||
and also on VimScripts: |
||||
|
||||
http://www.vim.org/scripts/script.php?script_id=52 |
||||
|
||||
vim:tw=78:et:ft=help:norl: |
@ -0,0 +1,229 @@
@@ -0,0 +1,229 @@
|
||||
"============================================================================= |
||||
" What Is This: Calendar |
||||
" File: calendar.vim |
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> |
||||
" Last Change: 2013 Mar 19 |
||||
" Version: 2.9 |
||||
" Thanks: |
||||
" Tobias Columbus : customizable key bindings |
||||
" Daniel P. Wright : doc/calendar.txt |
||||
" SethMilliken : gave a hint for 2.4 |
||||
" bw1 : bug fix, new weeknm format |
||||
" Ingo Karkat : bug fix |
||||
" Thinca : bug report, bug fix |
||||
" Yu Pei : bug report |
||||
" Per Winkvist : bug fix |
||||
" Serge (gentoosiast) Koksharov : bug fix |
||||
" Vitor Antunes : bug fix |
||||
" Olivier Mengue : bug fix |
||||
" Noel Henson : today action |
||||
" Per Winkvist : bug report |
||||
" Peter Findeisen : bug fix |
||||
" Chip Campbell : gave a hint for 1.3z |
||||
" PAN Shizhu : gave a hint for 1.3y |
||||
" Eric Wald : bug fix |
||||
" Sascha Wuestemann : advise |
||||
" Linas Vasiliauskas : bug report |
||||
" Per Winkvist : bug report |
||||
" Ronald Hoelwarth : gave a hint for 1.3s |
||||
" Vikas Agnihotri : bug report |
||||
" Steve Hall : gave a hint for 1.3q |
||||
" James Devenish : bug fix |
||||
" Carl Mueller : gave a hint for 1.3o |
||||
" Klaus Fabritius : bug fix |
||||
" Stucki : gave a hint for 1.3m |
||||
" Rosta : bug report |
||||
" Richard Bair : bug report |
||||
" Yin Hao Liew : bug report |
||||
" Bill McCarthy : bug fix and gave a hint |
||||
" Srinath Avadhanula : bug fix |
||||
" Ronald Hoellwarth : few advices |
||||
" Juan Orlandini : added higlighting of days with data |
||||
" Ray : bug fix |
||||
" Ralf.Schandl : gave a hint for 1.3 |
||||
" Bhaskar Karambelkar : bug fix |
||||
" Suresh Govindachar : gave a hint for 1.2, bug fix |
||||
" Michael Geddes : bug fix |
||||
" Leif Wickland : bug fix |
||||
" ChangeLog: |
||||
" 2.8 : bug fix |
||||
" 2.7 : vim7ish, customizable key bindings |
||||
" 2.6 : new week number format |
||||
" 2.5 : bug fix, 7.2 don't have relativenumber. |
||||
" 2.4 : added g:calendar_options. |
||||
" 2.3 : week number like ISO8601 |
||||
" g:calendar_monday and g:calendar_weeknm work together |
||||
" 2.2 : http://gist.github.com/355513#file_customizable_keymap.diff |
||||
" http://gist.github.com/355513#file_winfixwidth.diff |
||||
" 2.1 : bug fix, set filetype 'calendar'. |
||||
" 2.0 : bug fix, many bug fix and enhancements. |
||||
" 1.9 : bug fix, use nnoremap. |
||||
" 1.8 : bug fix, E382 when close diary. |
||||
" 1.7 : bug fix, week number was broken on 2008. |
||||
" 1.6 : added calendar_begin action. |
||||
" added calendar_end action. |
||||
" 1.5 : bug fix, fixed ruler formating with strpart. |
||||
" bug fix, using winfixheight. |
||||
" 1.4a : bug fix, week number was broken on 2005. |
||||
" added calendar_today action. |
||||
" bug fix, about wrapscan. |
||||
" bug fix, about today mark. |
||||
" bug fix, about today navigation. |
||||
" 1.4 : bug fix, and one improvement. |
||||
" bug 1: |
||||
" when marking the current date, there is not distinguished e.g. between |
||||
" 20041103 and 20040113, both dates are marked as today |
||||
" bug 2: |
||||
" the navigation mark "today" doesn't work |
||||
" improvement: |
||||
" the mapping t worked only when today was displayed, now it works always |
||||
" and redisplays the cuurent month and today |
||||
" 1.3z : few changes |
||||
" asign <Left>, <Right> for navigation. |
||||
" set ws for search navigation. |
||||
" add tag for GetLatestVimScripts(AutoInstall) |
||||
" 1.3y : bug fix, few changes |
||||
" changed color syntax name. (ex. CalNavi, see bottom of this) |
||||
" changed a map CalendarV for <Leader>cal |
||||
" changed a map CalendarH for <Leader>caL |
||||
" (competitive map for cvscommand.vim) |
||||
" the date on the right-hand side didn't work correctoly. |
||||
" make a map to rebuild Calendar window(r). |
||||
" 1.3x : bug fix |
||||
" viweek can't refer when not set calendar_weeknm. |
||||
" 1.3w : bug fix |
||||
" on leap year, week number decreases. |
||||
" 1.3v : bug fix |
||||
" add nowrapscan |
||||
" use s:bufautocommandsset for making title |
||||
" don't focus to navi when doubleclick bottom next>. |
||||
" 1.3u : bug fix |
||||
" when enter diary first time, |
||||
" it don't warn that you don't have diary directory. |
||||
" 1.3t : bug fix |
||||
" make sure the variables for help |
||||
" 1.3s : bug fix |
||||
" make a map CalendarV for <Leader>ca |
||||
" add option calendar_navi_label |
||||
" see Additional: |
||||
" add option calendar_focus_today |
||||
" see Additional: |
||||
" add map ? for help |
||||
" 1.3r : bug fix |
||||
" if clicked navigator, cursor go to strange position. |
||||
" 1.3q : bug fix |
||||
" coundn't set calendar_navi |
||||
" in its horizontal direction |
||||
" 1.3p : bug fix |
||||
" coundn't edit diary when the calendar is |
||||
" in its horizontal direction |
||||
" 1.3o : add option calendar_mark, and delete calendar_rmark |
||||
" see Additional: |
||||
" add option calendar_navi |
||||
" see Additional: |
||||
" 1.3n : bug fix |
||||
" s:CalendarSign() should use filereadable(expand(sfile)). |
||||
" 1.3m : tuning |
||||
" using topleft or botright for opening Calendar. |
||||
" use filereadable for s:CalendarSign(). |
||||
" 1.3l : bug fix |
||||
" if set calendar_monday, it can see that Sep 1st is Sat |
||||
" as well as Aug 31st. |
||||
" 1.3k : bug fix |
||||
" it didn't escape the file name on calendar. |
||||
" 1.3j : support for fixed Gregorian |
||||
" added the part of Sep 1752. |
||||
" 1.3i : bug fix |
||||
" Calculation mistake for week number. |
||||
" 1.3h : add option for position of displaying '*' or '+'. |
||||
" see Additional: |
||||
" 1.3g : centering header |
||||
" add option for show name of era. |
||||
" see Additional: |
||||
" bug fix |
||||
" <Leader>ca didn't show current month. |
||||
" 1.3f : bug fix |
||||
" there was yet another bug of today's sign. |
||||
" 1.3e : added usage for <Leader> |
||||
" support handler for sign. |
||||
" see Additional: |
||||
" 1.3d : added higlighting of days that have calendar data associated |
||||
" with it. |
||||
" bug fix for calculates date. |
||||
" 1.3c : bug fix for MakeDir() |
||||
" if CalendarMakeDir(sfile) != 0 |
||||
" v |
||||
" if s:CalendarMakeDir(sfile) != 0 |
||||
" 1.3b : bug fix for calendar_monday. |
||||
" it didn't work g:calendar_monday correctly. |
||||
" add g:calendar_version. |
||||
" add argument on action handler. |
||||
" see Additional: |
||||
" 1.3a : bug fix for MakeDir(). |
||||
" it was not able to make directory. |
||||
" 1.3 : support handler for action. |
||||
" see Additional: |
||||
" 1.2g : bug fix for today's sign. |
||||
" it could not display today's sign correctly. |
||||
" 1.2f : bug fix for current Date. |
||||
" vtoday variable calculates date as 'YYYYMMDD' |
||||
" while the loop calculates date as 'YYYYMMD' i.e just 1 digit |
||||
" for date if < 10 so if current date is < 10 , the if condiction |
||||
" to check for current date fails and current date is not |
||||
" highlighted. |
||||
" simple solution changed vtoday calculation line divide the |
||||
" current-date by 1 so as to get 1 digit date. |
||||
" 1.2e : change the way for setting title. |
||||
" auto configuration for g:calendar_wruler with g:calendar_monday |
||||
" 1.2d : add option for show week number. |
||||
" let g:calendar_weeknm = 1 |
||||
" add separator if horizontal. |
||||
" change all option's name |
||||
" g:calendar_mnth -> g:calendar_mruler |
||||
" g:calendar_week -> g:calendar_wruler |
||||
" g:calendar_smnd -> g:calendar_monday |
||||
" 1.2c : add option for that the week starts with monday. |
||||
" let g:calendar_smnd = 1 |
||||
" 1.2b : bug fix for modifiable. |
||||
" setlocal nomodifiable (was set) |
||||
" 1.2a : add default options. |
||||
" nonumber,foldcolumn=0,nowrap... as making gap |
||||
" 1.2 : support wide display. |
||||
" add a command CalendarH |
||||
" add map <s-left> <s-right> |
||||
" 1.1c : extra. |
||||
" add a titlestring for today. |
||||
" 1.1b : bug fix by Michael Geddes. |
||||
" it happend when do ':Calender' twice |
||||
" 1.1a : fix misspell. |
||||
" Calender -> Calendar |
||||
" 1.1 : bug fix. |
||||
" it"s about strftime("%m") |
||||
" 1.0a : bug fix by Leif Wickland. |
||||
" it"s about strftime("%w") |
||||
" 1.0 : first release. |
||||
" TODO: |
||||
" add the option for diary which is separate or single file. |
||||
" GetLatestVimScripts: 52 1 :AutoInstall: calendar.vim |
||||
|
||||
if &compatible |
||||
finish |
||||
endif |
||||
"***************************************************************** |
||||
"* Calendar commands |
||||
"***************************************************************** |
||||
command! -nargs=* Calendar call calendar#show(0,<f-args>) |
||||
command! -nargs=* CalendarH call calendar#show(1,<f-args>) |
||||
|
||||
if !get(g:, 'calendar_no_mappings', 0) |
||||
if !hasmapto('<Plug>CalendarV') |
||||
nmap <unique> <Leader>cal <Plug>CalendarV |
||||
endif |
||||
if !hasmapto('<Plug>CalendarH') |
||||
nmap <unique> <Leader>caL <Plug>CalendarH |
||||
endif |
||||
endif |
||||
nnoremap <silent> <Plug>CalendarV :cal calendar#show(0)<CR> |
||||
nnoremap <silent> <Plug>CalendarH :cal calendar#show(1)<CR> |
||||
|
||||
" vi: et sw=2 ts=2 |
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
scriptencoding utf-8 |
||||
if &cp || exists('g:loaded_cmdline_increment') |
||||
finish |
||||
endif |
||||
let g:loaded_cmdline_increment = 1 |
||||
|
||||
" escape user configuration |
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" mapping |
||||
if !hasmapto('<Plug>IncrementCommandLineNumber', 'c') |
||||
cmap <c-a> <Plug>IncrementCommandLineNumber |
||||
endif |
||||
cnoremap <Plug>IncrementCommandLineNumber <c-b>"<cr>:call g:IncrementCommandLineNumbering(1)<cr>:<c-r>=g:IncrementedCommandLine()<cr> |
||||
if !hasmapto('<Plug>DecrementCommandLineNumber', 'c') |
||||
cmap <c-x> <Plug>DecrementCommandLineNumber |
||||
endif |
||||
cnoremap <Plug>DecrementCommandLineNumber <c-b>"<cr>:call g:IncrementCommandLineNumbering(-1)<cr>:<c-r>=g:IncrementedCommandLine()<cr> |
||||
|
||||
" script sharing variables. |
||||
" updated command line will be stored in g:IncrementCommandLineNumbering(). |
||||
let s:updatedcommandline = '' |
||||
|
||||
" increment, or decrement last appearing number. |
||||
function! g:IncrementCommandLineNumbering(plus) |
||||
" when continuous increment is done, because @: is not updated, |
||||
" plugin can not increment correctly. |
||||
" so add one entry to command history, and use there flag. |
||||
" last command is start with '"' is first try, |
||||
" last command is not start with '"' is second try. |
||||
let l:lastcommand = histget(':', -1) |
||||
let l:firstcommandchar = strpart(l:lastcommand, 0, 1) |
||||
|
||||
" l:command is '"' starting text. |
||||
if l:firstcommandchar ==# '"' |
||||
let l:command = l:lastcommand |
||||
else |
||||
let l:command = '"' . l:lastcommand |
||||
endif |
||||
|
||||
" check input |
||||
let l:matchtest = match(l:command, '^".\{-\}-\?\d\+\D*$') |
||||
" command do not contain number |
||||
if l:matchtest < 0 |
||||
" remove first char '"' |
||||
let s:updatedcommandline = substitute(l:command, '^"\(.*\)$', '\1', '') |
||||
return |
||||
endif |
||||
|
||||
" update numbering |
||||
let l:numpattern = substitute(l:command, '^".\{-\}\(\d\+\)\D*$', '\1', '') |
||||
let l:updatednumberpattern = s:IncrementedText(l:numpattern, a:plus) |
||||
|
||||
" create new command line strings |
||||
let l:p1 = substitute(l:command, '^"\(.\{-\}\)\d\+\D*$', '\1', '') |
||||
let l:p2 = l:updatednumberpattern |
||||
let l:p3 = substitute(l:command, '^".\{-\}\d\+\(\D*\)$', '\1', '') |
||||
" set l register |
||||
let s:updatedcommandline = l:p1 . l:p2 . l:p3 |
||||
|
||||
" delete '"' command (dummy command) history |
||||
call histdel(':', -1) |
||||
" wrong command history is added. limitation. |
||||
call histadd(':', s:updatedcommandline) |
||||
endfunction |
||||
|
||||
" return incremented command line text. |
||||
function! g:IncrementedCommandLine() |
||||
return s:updatedcommandline |
||||
endfunction |
||||
|
||||
" return incremented pattern text. |
||||
" |
||||
" number + - |
||||
" 0 -> 1, 0 |
||||
" 0000 -> 0001, 0000 |
||||
" 127 -> 128, 126 |
||||
" 0127 -> 0128, 0126 |
||||
" 00127 -> 00128, 00126 |
||||
function! s:IncrementedText(pattern, plus) |
||||
" 0 |
||||
if match(a:pattern, '^0$') >= 0 |
||||
if a:plus > 0 |
||||
return a:pattern + a:plus |
||||
else |
||||
" not supported |
||||
return a:pattern |
||||
endif |
||||
endif |
||||
|
||||
" 123 |
||||
if match(a:pattern, '^[^0]\d*$') >= 0 |
||||
return a:pattern + a:plus |
||||
endif |
||||
|
||||
" 00000 |
||||
if match(a:pattern, '^0\+$') >= 0 |
||||
if a:plus > 0 |
||||
let l:numlength = strlen(a:pattern) |
||||
return printf('%0' .l:numlength. 'd', a:plus) |
||||
else |
||||
" not supported |
||||
return a:pattern |
||||
endif |
||||
endif |
||||
|
||||
" 00123 |
||||
if match(a:pattern, '^0\d*$') >= 0 |
||||
echo a:pattern + a:plus |
||||
let l:numlength = strlen(a:pattern) |
||||
let l:number = substitute(a:pattern, '^0\+\(\d\+\)$', '\1', '') |
||||
return printf('%0' .l:numlength. 'd', l:number + a:plus) |
||||
endif |
||||
|
||||
throw 'unknow numbering pattern is found.' |
||||
endfunction |
||||
|
||||
" recover user configuration |
||||
let &cpo = s:save_cpo |
||||
finish |
||||
|
||||
============================================================================== |
||||
cmdline-increment.vim : increment, decrement for commandline number. |
||||
------------------------------------------------------------------------------ |
||||
$VIMRUNTIMEPATH/plugin/cmdline-increment.vim |
||||
============================================================================== |
||||
author : OMI TAKU |
||||
url : http://nanasi.jp/ |
||||
email : mail@nanasi.jp |
||||
version : 2009/09/19 03:00:00 |
||||
============================================================================== |
||||
Increment last appearing number in commandline-mode command with Control-a , |
||||
and decrement with Control-x . |
||||
|
||||
<C-a> increment commandline last appearing number. |
||||
<C-x> decrement commandline last appearing number. |
||||
|
||||
|
||||
------------------------------------------------------------------------------ |
||||
[Usage] |
||||
|
||||
1. Enter commandline mode. |
||||
2. Enter next command. |
||||
|
||||
:edit workfile_1.txt |
||||
|
||||
3. And Press Control-a , or press Control-x . |
||||
|
||||
|
||||
------------------------------------------------------------------------------ |
||||
[Customized Mapping] |
||||
|
||||
If you will customize increment, decrement mapping, |
||||
add put these code to your vimrc . |
||||
|
||||
" (for example) |
||||
" increment with Shift-Up |
||||
cmap <S-Up> <Plug>IncrementCommandLineNumber |
||||
" decrement with Shift-Down |
||||
cmap <S-Down> <Plug>DecrementCommandLineNumber |
||||
|
||||
|
||||
------------------------------------------------------------------------------ |
||||
[history] |
||||
2009/09/17 |
||||
- initial version. |
||||
|
||||
2009/09/18 |
||||
- plugin is now not using 'l' register. |
||||
- below 0 number decrement is newly not supported. |
||||
minial value is 0. |
||||
- default mapping is switched to <c-a>, <c-x>. |
||||
- custom mapping is supported. |
||||
|
||||
|
||||
============================================================================== |
||||
" vim: set ff=unix et ft=vim nowrap : |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
--- ./commentToggle.vim 2010-10-30 17:29:40.000000000 +0600
|
||||
+++ /home/maks/.shellrc/config/soft/vim_old/vim/plugin/commentToggle.vim 2010-09-04 13:06:25.000000000 +0600
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
" all languages are defined as a list with the comment opening string in position 0 and the closing string in position 1
|
||||
" languages which support single line comments simply have an empty string in position 1
|
||||
-let s:commStrings = {"abap":['\*',''], "abc":['%',''], "ada":['--',''], "apache":['#',''], "asterisk":[';',''], "awk":['#',''], "basic":['rem',''], "bcpl":['//',''], "c":['//',''], "cecil":['--',''], "cfg":['#',''], "clean":['//',''], "cmake":['#',''], "cobol":['\*',''], "cpp":['//',''], "cs":['//',''], "css":['/\*','\*/'], "d":['//',''], "debcontrol":['#',''], "diff":['#',''], "dtml":['<!--','-->'], "dylan":['//',''], "e":['#',''], "eiffel":['--',''], "erlang":['%',''], "euphora":['--',''], "forth":['\',''], "fortan":['C ',''], "foxpro":['\*',''], "fs":['//',''], "groovy":['//',''], "grub":['#',''], "icon":['#',''], "io":['#',''], "j":['NB.',''], "java":['//',''], "javascript":['//',''], "haskell":['--',''], "html":['<!--','-->'], "htmldjango":['<!--','-->'], "htmlm4":['<!--','-->'], "lex":['//',''], "lhaskell":['%',''], "lilo":['#',''], "lisp":[';',''], "logo":[';',''], "lua":['--',''], "make":['#',''], "matlab":['%',''], "maple":['#',''], "merd":['#',''], "mma":['(\*','\*)'], "modula3":['(\*','\*)'], "mumps":[';',''], "natural":['\*',''], "nemerle":['//',''], "objc":['//',''], "objcpp":['//',''], "ocaml":['(\*','\*)'], "oz":['%',''], "pascal":['{','}'], "perl":['#',''], "php":['//',''], "pike":['//',''], "pliant":['#',''], "plsql":['--',''], "postscr":['%',''], "prolog":['%',''], "python":['#',''], "rebol":[';',''], "rexx":['/\*','\*/'], "ruby":['#',''], "sas":['/\*','\*/'], "sather":['--',''], "scala":['//',''], "scheme":[';',''], "sed":['#',''], "sgml":['<!--','-->'], "sh":['#',''], "sieve":['#',''], "simula":['--',''], "sql":['--',''], "st":['"','"'], "tcl":['#',''], "tex":['%',''], "vhdl":['--',''], "vim":['"',''], "xf86conf":['#',''], "xhtml":['<!--','-->'], "xml":['<!--','-->'], "xquery":['<!--','-->'], "xsd":['<!--','-->'], "yacc":['//',''], "yaml":['#',''], "ycp":['//',''], "yorick":['//','']}
|
||||
+let s:commStrings = {"alex":['--',''],"abap":['\*',''], "abc":['%',''], "ada":['--',''], "apache":['#',''], "asterisk":[';',''], "awk":['#',''], "basic":['rem',''], "bcpl":['//',''], "c":['//',''], "cecil":['--',''], "cfg":['#',''], "clean":['//',''], "cmake":['#',''], "cobol":['\*',''], "cpp":['//',''], "cs":['//',''], "css":['/\*','\*/'], "d":['//',''], "debcontrol":['#',''], "diff":['#',''], "dtml":['<!--','-->'], "dylan":['//',''], "e":['#',''], "eiffel":['--',''], "erlang":['%',''], "euphora":['--',''], "forth":['\',''], "fortan":['C ',''], "foxpro":['\*',''], "fs":['//',''], "groovy":['//',''], "grub":['#',''], "icon":['#',''], "io":['#',''], "j":['NB.',''], "java":['//',''], "javascript":['//',''], "haskell":['--',''], "html":['<!--','-->'], "htmldjango":['<!--','-->'], "htmlm4":['<!--','-->'], "lex":['//',''], "lhaskell":['%',''], "lilo":['#',''], "lisp":[';',''], "logo":[';',''], "lua":['--',''], "make":['#',''], "matlab":['%',''], "maple":['#',''], "merd":['#',''], "mma":['(\*','\*)'], "modula3":['(\*','\*)'], "mumps":[';',''], "natural":['\*',''], "nemerle":['//',''], "objc":['//',''], "objcpp":['//',''], "ocaml":['(\*','\*)'], "oz":['%',''], "pascal":['{','}'], "perl":['#',''], "php":['//',''], "pike":['//',''], "pliant":['#',''], "plsql":['--',''], "postscr":['%',''], "prolog":['%',''], "python":['#',''], "rebol":[';',''], "rexx":['/\*','\*/'], "ruby":['#',''], "sas":['/\*','\*/'], "sather":['--',''], "scala":['//',''], "scheme":[';',''], "sed":['#',''], "sgml":['<!--','-->'], "sh":['#',''], "sieve":['#',''], "simula":['--',''], "sql":['--',''], "st":['"','"'], "tcl":['#',''], "tex":['%',''], "vhdl":['--',''], "vim":['"',''], "xf86conf":['#',''], "xhtml":['<!--','-->'], "xml":['<!--','-->'], "xquery":['<!--','-->'], "xsd":['<!--','-->'], "yacc":['//',''], "yaml":['#',''], "ycp":['//',''], "yorick":['//',''], "mysql":['--','']}
|
||||
|
||||
" ===============================================================================================================================
|
||||
|
@ -0,0 +1,114 @@
@@ -0,0 +1,114 @@
|
||||
" description: a simple line-based commenting toggler |
||||
" maintainer: kamil.stachowski@gmail.com |
||||
" license: gpl 3+ |
||||
" version: 0.2 (2008.11.11) |
||||
|
||||
" changelog: |
||||
" 0.2: 2008.11.11 |
||||
" improved whitespace handling |
||||
" added languages: apache, asterisk, c, cfg, clean, cmake, css, d, debcontrol, diff, dtml, euphoria, foxpro, groovy, grub, htmldjango, htmlm4, lex, lhaskell, lilo, make, natural, nemerle, objc, objcpp, ,plsql, rexx, sas, scala, sed, sieve, sgml, xf86conf, xhtml, xquery, xsd, yacc, xhtml (total 93) |
||||
" 0.1: 2008.11.08 |
||||
" initial version |
||||
" |
||||
" TODO: do sth about block comments |
||||
" TODO: better guessing for undefined languages |
||||
" TODO: add support for scheme's multiple ;'s |
||||
|
||||
|
||||
|
||||
" =============================================================================================================================== |
||||
|
||||
" make sure the plugin hasn't been loaded yet and save something |
||||
if exists("g:loaded_commentToggle") || &cp |
||||
finish |
||||
endif |
||||
let g:loaded_commentToggle = "v0.2" |
||||
let s:cpoSave = &cpo |
||||
set cpo&vim |
||||
|
||||
" ------------------------------------------------------------------------------------------------------------------------------- |
||||
|
||||
" assign a shortcut |
||||
if !hasmapto('<Plug>CommentToggle') |
||||
map <unique> <Leader>; <Plug>CommentToggle |
||||
endif |
||||
noremap <silent> <unique> <script> <Plug>CommentToggle :call <SID>CommentToggle()<CR> |
||||
noremenu <script> Plugin.Add\ CommentToggle <SID>CommentToggle |
||||
|
||||
" and a command just in case |
||||
if !exists(":commentToggle") |
||||
command -nargs=1 CommentToggle :call s:CommentToggle() |
||||
endif |
||||
|
||||
" =============================================================================================================================== |
||||
|
||||
" all languages are defined as a list with the comment opening string in position 0 and the closing string in position 1 |
||||
" languages which support single line comments simply have an empty string in position 1 |
||||
let s:commStrings = {"alex":['--',''],"abap":['\*',''], "abc":['%',''], "ada":['--',''], "apache":['#',''], "asterisk":[';',''], "awk":['#',''], "basic":['rem',''], "bcpl":['//',''], "c":['//',''], "cecil":['--',''], "cfg":['#',''], "clean":['//',''], "cmake":['#',''], "cobol":['\*',''], "cpp":['//',''], "cs":['//',''], "css":['/\*','\*/'], "d":['//',''], "debcontrol":['#',''], "diff":['#',''], "dtml":['<!--','-->'], "dylan":['//',''], "e":['#',''], "eiffel":['--',''], "erlang":['%',''], "euphora":['--',''], "forth":['\',''], "fortan":['C ',''], "foxpro":['\*',''], "fs":['//',''], "groovy":['//',''], "grub":['#',''], "icon":['#',''], "io":['#',''], "j":['NB.',''], "java":['//',''], "javascript":['//',''], "haskell":['--',''], "html":['<!--','-->'], "htmldjango":['<!--','-->'], "htmlm4":['<!--','-->'], "lex":['//',''], "lhaskell":['%',''], "lilo":['#',''], "lisp":[';',''], "logo":[';',''], "lua":['--',''], "make":['#',''], "matlab":['%',''], "maple":['#',''], "merd":['#',''], "mma":['(\*','\*)'], "modula3":['(\*','\*)'], "mumps":[';',''], "natural":['\*',''], "nemerle":['//',''], "objc":['//',''], "objcpp":['//',''], "ocaml":['(\*','\*)'], "oz":['%',''], "pascal":['{','}'], "perl":['#',''], "php":['//',''], "pike":['//',''], "pliant":['#',''], "plsql":['--',''], "postscr":['%',''], "prolog":['%',''], "python":['#',''], "rebol":[';',''], "rexx":['/\*','\*/'], "ruby":['#',''], "sas":['/\*','\*/'], "sather":['--',''], "scala":['//',''], "scheme":[';',''], "sed":['#',''], "sgml":['<!--','-->'], "sh":['#',''], "sieve":['#',''], "simula":['--',''], "sql":['--',''], "st":['"','"'], "tcl":['#',''], "tex":['%',''], "vhdl":['--',''], "vim":['"',''], "xf86conf":['#',''], "xhtml":['<!--','-->'], "xml":['<!--','-->'], "xquery":['<!--','-->'], "xsd":['<!--','-->'], "yacc":['//',''], "yaml":['#',''], "ycp":['//',''], "yorick":['//',''], "mysql":['--','']} |
||||
|
||||
" =============================================================================================================================== |
||||
|
||||
" check if line aLineNr begins with string |
||||
function! s:CommentCheckCommented(aLineNr, aCommStr) |
||||
" check if the line begins with the comment opening string, ignoring whitespace |
||||
return match(getline(a:aLineNr), '^\s*' . a:aCommStr[0]) == "" |
||||
endfunction |
||||
|
||||
" ------------------------------------------------------------------------------------------------------------------------------- |
||||
|
||||
" find the comment string for syntax aSynCurr |
||||
function! s:CommentCheckString(aSynCurr) |
||||
if has_key(s:commStrings, a:aSynCurr) |
||||
" if we have the comment strings for the current syntax defined, take those |
||||
return s:commStrings[a:aSynCurr] |
||||
else |
||||
" TODO: doesn't work for all syntaxes |
||||
" i don't know how to properly extract the comment string for the current syntax; &comments is probably not the way |
||||
" check &comments and extract the one without any flags; alas, it's not always the string we're looking for |
||||
let s:result = "" |
||||
for s:tmp in split(&comments, ",") |
||||
if s:tmp[0] == ":" |
||||
let s:result = s:tmp[1:-1] |
||||
break |
||||
endif |
||||
endfor |
||||
return [s:result, ""] |
||||
endif |
||||
endfunction |
||||
|
||||
" ------------------------------------------------------------------------------------------------------------------------------- |
||||
|
||||
" the main part |
||||
" finds the comment string for the current syntax, and if the current line is already commented; |
||||
" if it is, it uncomments it; if it's not, it uncomments it |
||||
function! s:CommentToggle() |
||||
let s:commStr = s:CommentCheckString(&syntax) |
||||
let s:commed = s:CommentCheckCommented(line("."), s:commStr) |
||||
if match(getline(line(".")), '\S') != -1 " no point commenting empty lines |
||||
call s:CommentToggleHelper(line("."), s:commStr, s:commed) |
||||
endif |
||||
endfunction |
||||
|
||||
" ------------------------------------------------------------------------------------------------------------------------------- |
||||
|
||||
" toggles comment on line aLineNr with string aCommStr depending on whether the line is already commented (aCommed) |
||||
function! s:CommentToggleHelper(aLineNr, aCommStr, aCommed) |
||||
if a:aCommed |
||||
let s:tmpToBeSubsted = '\(\s*\)' . a:aCommStr[0] . '\(\s*\)\(.\{-}\)\(\s*\)' . a:aCommStr[1] |
||||
let s:tmpToSubst = '\1\3' " remove the comment string(s) and all superfluous whitespace (hence greedy match in \3) |
||||
else |
||||
let s:tmpToBeSubsted='\(\s*\)\(.*\)'" leave the whitespace in the beginning untouched |
||||
let s:tmpToSubst = '\1' . a:aCommStr[0] . ' \2' " add extra spaces inside the comment string |
||||
if a:aCommStr[1] != "" " but not after it in case the language supports single line comments |
||||
let s:tmpToSubst = s:tmpToSubst . ' ' . a:aCommStr[1] |
||||
endif |
||||
endif |
||||
call setline(a:aLineNr, substitute(getline(a:aLineNr), s:tmpToBeSubsted, s:tmpToSubst, "")) |
||||
endfunction |
||||
|
||||
|
||||
" =============================================================================================================================== |
||||
|
||||
|
||||
let &cpo = s:cpoSave |
||||
unlet s:cpoSave |
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
PLUGIN = $(wildcard plugin/*.vim)
|
||||
SOURCES = $(PLUGIN)
|
||||
LIB = $(wildcard autoload/*.vim)
|
||||
SOURCES += $(LIB)
|
||||
DOC = $(wildcard doc/*.txt)
|
||||
SOURCES += $(DOC)
|
||||
#NAME = $(shell basename "$$PWD")
|
||||
NAME = delimitMate
|
||||
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
|
||||
FILENAME = $(NAME)-$(VERSION)
|
||||
DESTDIR = $(HOME)/.vim
|
||||
VIM = vim
|
||||
SED = gsed
|
||||
PERL = perl
|
||||
comma := ,
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
.PHONY: version clean distclean undo release test install uninstall |
||||
|
||||
all: zip gzip |
||||
dist: version all |
||||
vimball: $(FILENAME).vmb |
||||
zip: $(FILENAME).zip $(FILENAME).vmb.zip |
||||
gzip: $(FILENAME).tar.gz $(FILENAME).vmb.gz |
||||
|
||||
clean: |
||||
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
|
||||
|
||||
distclean: clean |
||||
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile)'
|
||||
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile)*'
|
||||
|
||||
undo: |
||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||
|
||||
version: |
||||
$(PERL) -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(PLUGIN) $(LIB)
|
||||
$(PERL) -i.orig -pne \
|
||||
'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(PLUGIN)
|
||||
$(PERL) -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
|
||||
$(PERL) -i.orig -MPOSIX -pne \
|
||||
'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' \
|
||||
$(PLUGIN) $(LIB)
|
||||
$(PERL) -i.orig -MPOSIX -pne \
|
||||
'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' \
|
||||
$(DOC)
|
||||
|
||||
test: |
||||
runVimTests -0 test
|
||||
|
||||
install: $(SOURCES) |
||||
for dir in $(^D);\
|
||||
do install -d -m 0755 $(DESTDIR)$(PREFIX)/$$dir;\
|
||||
done;\ |
||||
for file in $^;\ |
||||
do install -m 0644 $$file $(DESTDIR)$(PREFIX)/$$file;\
|
||||
done; |
||||
|
||||
uninstall: |
||||
for file in $(SOURCES);\
|
||||
do rm -f $(DESTDIR)$(PREFIX)/$$file;\
|
||||
done; |
||||
|
||||
%.vmb: $(SOURCES) |
||||
$(VIM) -N -es -u NORC \
|
||||
-c 'call setline(1,["$(subst $(space),"$(comma)",$^)"])'\
|
||||
-c "%MkVimball! $(basename $@) ." -c 'q!'
|
||||
|
||||
%.vmb.zip: vimball |
||||
zip $@ $(basename $@)
|
||||
|
||||
%.zip: $(SOURCES) |
||||
zip $@ $^
|
||||
|
||||
%.vmb.gz: vimball |
||||
gzip -f $(basename $@)
|
||||
|
||||
%.tar.gz: $(SOURCES) |
||||
tar -cvzf $@ $^
|
||||
|
||||
# vim:ts=2:sw=2
|
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that |
||||
should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter |
||||
in comments and other configurable regions), <CR> and <Space> expansions (off by default), and some more. |
||||
|
||||
Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using |
||||
:autocmd. |
@ -0,0 +1,640 @@
@@ -0,0 +1,640 @@
|
||||
" File: autoload/delimitMate.vim |
||||
" Version: 2.7 |
||||
" Modified: 2013-07-15 |
||||
" Description: This plugin provides auto-completion for quotes, parens, etc. |
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com> |
||||
" Manual: Read ":help delimitMate". |
||||
" ============================================================================ |
||||
|
||||
" Utilities {{{ |
||||
|
||||
"let delimitMate_loaded = 1 |
||||
|
||||
if !exists('s:options') |
||||
let s:options = {} |
||||
endif |
||||
function! s:s(name, value, ...) "{{{ |
||||
let scope = a:0 ? a:1 : 's' |
||||
let bufnr = bufnr('%') |
||||
if !exists('s:options[bufnr]') |
||||
let s:options[bufnr] = {} |
||||
endif |
||||
if scope == 's' |
||||
let name = 'options.' . bufnr . '.' . a:name |
||||
else |
||||
let name = 'delimitMate_' . a:name |
||||
endif |
||||
exec 'let ' . scope . ':' . name . ' = a:value' |
||||
endfunction "}}} |
||||
|
||||
function! s:g(name, ...) "{{{ |
||||
let scope = a:0 ? a:1 : 's' |
||||
if scope == 's' |
||||
let bufnr = bufnr('%') |
||||
let name = 'options.' . bufnr . '.' . a:name |
||||
else |
||||
let name = 'delimitMate_' . a:name |
||||
endif |
||||
return eval(scope . ':' . name) |
||||
endfunction "}}} |
||||
|
||||
function! s:exists(name, ...) "{{{ |
||||
let scope = a:0 ? a:1 : 's' |
||||
if scope == 's' |
||||
let bufnr = bufnr('%') |
||||
let name = 'options.' . bufnr . '.' . a:name |
||||
else |
||||
let name = 'delimitMate_' . a:name |
||||
endif |
||||
return exists(scope . ':' . name) |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#Set(...) "{{{ |
||||
return call('s:s', a:000) |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#Get(...) "{{{ |
||||
return call('s:g', a:000) |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#ShouldJump(...) "{{{ |
||||
" Returns 1 if the next character is a closing delimiter. |
||||
let char = delimitMate#GetCharFromCursor(0) |
||||
let list = s:g('right_delims') + s:g('quotes_list') |
||||
|
||||
" Closing delimiter on the right. |
||||
if (!a:0 && index(list, char) > -1) |
||||
\ || (a:0 && char == a:1) |
||||
return 1 |
||||
endif |
||||
|
||||
" Closing delimiter with space expansion. |
||||
let nchar = delimitMate#GetCharFromCursor(1) |
||||
if !a:0 && s:g('expand_space') && char == " " |
||||
if index(list, nchar) > -1 |
||||
return 2 |
||||
endif |
||||
elseif a:0 && s:g('expand_space') && nchar == a:1 && char == ' ' |
||||
return 3 |
||||
endif |
||||
|
||||
if !s:g('jump_expansion') |
||||
return 0 |
||||
endif |
||||
|
||||
" Closing delimiter with CR expansion. |
||||
let uchar = matchstr(getline(line('.') + 1), '^\s*\zs\S') |
||||
if !a:0 && s:g('expand_cr') && char == "" |
||||
if index(list, uchar) > -1 |
||||
return 4 |
||||
endif |
||||
elseif a:0 && s:g('expand_cr') && uchar == a:1 |
||||
return 5 |
||||
endif |
||||
return 0 |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#IsEmptyPair(str) "{{{ |
||||
if strlen(substitute(a:str, ".", "x", "g")) != 2 |
||||
return 0 |
||||
endif |
||||
let idx = index(s:g('left_delims'), matchstr(a:str, '^.')) |
||||
if idx > -1 && |
||||
\ s:g('right_delims')[idx] == matchstr(a:str, '.$') |
||||
return 1 |
||||
endif |
||||
let idx = index(s:g('quotes_list'), matchstr(a:str, '^.')) |
||||
if idx > -1 && |
||||
\ s:g('quotes_list')[idx] == matchstr(a:str, '.$') |
||||
return 1 |
||||
endif |
||||
return 0 |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#RightQ(char) "{{{ |
||||
let i = 0 |
||||
while delimitMate#GetCharFromCursor(i) ==# a:char |
||||
let i += 1 |
||||
endwhile |
||||
return i |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#LeftQ(char) "{{{ |
||||
let i = 0 |
||||
while delimitMate#GetCharFromCursor(i - 1) ==# a:char |
||||
let i -= 1 |
||||
endwhile |
||||
return i * -1 |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#GetCharFromCursor(...) "{{{ |
||||
let idx = col('.') - 1 |
||||
if !a:0 || (a:0 && a:1 >= 0) |
||||
" Get char from cursor. |
||||
let line = getline('.')[idx :] |
||||
let pos = a:0 ? a:1 : 0 |
||||
return matchstr(line, '^'.repeat('.', pos).'\zs.') |
||||
endif |
||||
" Get char behind cursor. |
||||
let line = getline('.')[: idx - 1] |
||||
let pos = 0 - (1 + a:1) |
||||
return matchstr(line, '.\ze'.repeat('.', pos).'$') |
||||
endfunction "delimitMate#GetCharFromCursor }}} |
||||
|
||||
function! delimitMate#IsCRExpansion(...) " {{{ |
||||
let nchar = getline(line('.')-1)[-1:] |
||||
let schar = matchstr(getline(line('.')+1), '^\s*\zs\S') |
||||
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.')) |
||||
if index(s:g('left_delims'), nchar) > -1 |
||||
\ && index(s:g('left_delims'), nchar) |
||||
\ == index(s:g('right_delims'), schar) |
||||
\ && isEmpty |
||||
return 1 |
||||
elseif index(s:g('quotes_list'), nchar) > -1 |
||||
\ && index(s:g('quotes_list'), nchar) |
||||
\ == index(s:g('quotes_list'), schar) |
||||
\ && isEmpty |
||||
return 1 |
||||
else |
||||
return 0 |
||||
endif |
||||
endfunction " }}} delimitMate#IsCRExpansion() |
||||
|
||||
function! delimitMate#IsSpaceExpansion() " {{{ |
||||
if col('.') > 2 |
||||
let pchar = delimitMate#GetCharFromCursor(-2) |
||||
let nchar = delimitMate#GetCharFromCursor(1) |
||||
let isSpaces = |
||||
\ (delimitMate#GetCharFromCursor(-1) |
||||
\ == delimitMate#GetCharFromCursor(0) |
||||
\ && delimitMate#GetCharFromCursor(-1) == " ") |
||||
|
||||
if index(s:g('left_delims'), pchar) > -1 && |
||||
\ index(s:g('left_delims'), pchar) |
||||
\ == index(s:g('right_delims'), nchar) && |
||||
\ isSpaces |
||||
return 1 |
||||
elseif index(s:g('quotes_list'), pchar) > -1 && |
||||
\ index(s:g('quotes_list'), pchar) |
||||
\ == index(s:g('quotes_list'), nchar) && |
||||
\ isSpaces |
||||
return 1 |
||||
endif |
||||
endif |
||||
return 0 |
||||
endfunction " }}} IsSpaceExpansion() |
||||
|
||||
function! delimitMate#WithinEmptyPair() "{{{ |
||||
" get char before the cursor. |
||||
let char1 = delimitMate#GetCharFromCursor(-1) |
||||
" get char under the cursor. |
||||
let char2 = delimitMate#GetCharFromCursor(0) |
||||
return delimitMate#IsEmptyPair( char1.char2 ) |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#CursorIdx() "{{{ |
||||
let idx = len(split(getline('.')[: col('.') - 1], '\zs')) - 1 |
||||
return idx |
||||
endfunction "delimitMate#CursorCol }}} |
||||
|
||||
function! delimitMate#GetSyntaxRegion(line, col) "{{{ |
||||
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name') |
||||
endfunction " }}} |
||||
|
||||
function! delimitMate#GetCurrentSyntaxRegion() "{{{ |
||||
let col = col('.') |
||||
if col == col('$') |
||||
let col = col - 1 |
||||
endif |
||||
return delimitMate#GetSyntaxRegion(line('.'), col) |
||||
endfunction " }}} |
||||
|
||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{ |
||||
let col = col('.') |
||||
let origin_line = getline('.') |
||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char |
||||
\ . strpart(origin_line, col - 1) |
||||
call setline('.', changed_line) |
||||
let region = delimitMate#GetSyntaxRegion(line('.'), col) |
||||
call setline('.', origin_line) |
||||
return region |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#IsForbidden(char) "{{{ |
||||
if !s:g('excluded_regions_enabled') |
||||
return 0 |
||||
endif |
||||
let region = delimitMate#GetCurrentSyntaxRegion() |
||||
"if index(s:g('excluded_regions_list'), region) >= 0 |
||||
" "echom "Forbidden 1!" |
||||
" return 1 |
||||
"endif |
||||
"let region = delimitMate#GetCurrentSyntaxRegionIf(a:char) |
||||
"echom "Forbidden 2!" |
||||
return index(s:g('excluded_regions_list'), region) >= 0 |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#BalancedParens(char) "{{{ |
||||
" Returns: |
||||
" = 0 => Parens balanced. |
||||
" > 0 => More opening parens. |
||||
" < 0 => More closing parens. |
||||
|
||||
let line = getline('.') |
||||
let col = delimitMate#CursorIdx() - 1 |
||||
let col = col >= 0 ? col : 0 |
||||
let list = split(line, '\zs') |
||||
let left = s:g('left_delims')[index(s:g('right_delims'), a:char)] |
||||
let right = a:char |
||||
let opening = 0 |
||||
let closing = 0 |
||||
|
||||
" If the cursor is not at the beginning, count what's behind it. |
||||
if col > 0 |
||||
" Find the first opening paren: |
||||
let start = index(list, left) |
||||
" Must be before cursor: |
||||
let start = start < col ? start : col - 1 |
||||
" Now count from the first opening until the cursor, this will prevent |
||||
" extra closing parens from being counted. |
||||
let opening = count(list[start : col - 1], left) |
||||
let closing = count(list[start : col - 1], right) |
||||
" I don't care if there are more closing parens than opening parens. |
||||
let closing = closing > opening ? opening : closing |
||||
endif |
||||
|
||||
" Evaluate parens from the cursor to the end: |
||||
let opening += count(list[col :], left) |
||||
let closing += count(list[col :], right) |
||||
|
||||
" Return the found balance: |
||||
return opening - closing |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#IsSmartQuote(char) "{{{ |
||||
if !s:g('smart_quotes') |
||||
return 0 |
||||
endif |
||||
let char_at = delimitMate#GetCharFromCursor(0) |
||||
let char_before = delimitMate#GetCharFromCursor(-1) |
||||
let valid_char_re = '\w\|[^[:punct:][:space:]]' |
||||
let word_before = char_before =~ valid_char_re |
||||
let word_at = char_at =~ valid_char_re |
||||
let escaped = delimitMate#CursorIdx() >= 1 |
||||
\ && delimitMate#GetCharFromCursor(-1) == '\' |
||||
let noescaped = substitute(getline('.'), '\\.', '', 'g') |
||||
let odd = (count(split(noescaped, '\zs'), a:char) % 2) |
||||
let result = word_before || escaped || word_at || odd |
||||
return result |
||||
endfunction "delimitMate#SmartQuote }}} |
||||
|
||||
" }}} |
||||
|
||||
" Doers {{{ |
||||
function! delimitMate#SkipDelim(char) "{{{ |
||||
if delimitMate#IsForbidden(a:char) |
||||
return a:char |
||||
endif |
||||
let col = col('.') - 1 |
||||
let line = getline('.') |
||||
if col > 0 |
||||
let cur = delimitMate#GetCharFromCursor(0) |
||||
let pre = delimitMate#GetCharFromCursor(-1) |
||||
else |
||||
let cur = delimitMate#GetCharFromCursor(0) |
||||
let pre = "" |
||||
endif |
||||
if pre == "\\" |
||||
" Escaped character |
||||
return a:char |
||||
elseif cur == a:char |
||||
" Exit pair |
||||
return a:char . "\<Del>" |
||||
elseif delimitMate#IsEmptyPair( pre . a:char ) |
||||
" Add closing delimiter and jump back to the middle. |
||||
return a:char . "\<Left>" |
||||
else |
||||
" Nothing special here, return the same character. |
||||
return a:char |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#ParenDelim(right) " {{{ |
||||
let left = s:g('left_delims')[index(s:g('right_delims'),a:right)] |
||||
if delimitMate#IsForbidden(a:right) |
||||
return left |
||||
endif |
||||
" Try to balance matchpairs |
||||
if s:g('balance_matchpairs') && |
||||
\ delimitMate#BalancedParens(a:right) < 0 |
||||
return left |
||||
endif |
||||
let line = getline('.') |
||||
let col = col('.')-2 |
||||
let tail = len(line) == (col + 1) ? s:g('eol_marker') : '' |
||||
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g') |
||||
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g') |
||||
|
||||
if s:g('smart_matchpairs') != '' && |
||||
\ line[col+1:] =~ smart_matchpairs |
||||
return left |
||||
"elseif (col) < 0 |
||||
" call setline('.',a:right.line) |
||||
endif |
||||
return left . a:right . tail . repeat("\<Left>", len(split(tail, '\zs')) + 1) |
||||
endfunction " }}} |
||||
|
||||
function! delimitMate#QuoteDelim(char) "{{{ |
||||
if delimitMate#IsForbidden(a:char) |
||||
return a:char |
||||
endif |
||||
let char_at = delimitMate#GetCharFromCursor(0) |
||||
let char_before = delimitMate#GetCharFromCursor(-1) |
||||
let nesting_on = index(s:g('nesting_quotes'), a:char) > -1 |
||||
let left_q = nesting_on ? delimitMate#LeftQ(a:char) : 0 |
||||
if nesting_on && left_q > 1 |
||||
" Nesting quotes. |
||||
let right_q = delimitMate#RightQ(a:char) |
||||
let quotes = right_q > left_q + 1 ? 0 : left_q - right_q + 2 |
||||
let lefts = quotes - 1 |
||||
return repeat(a:char, quotes) . repeat("\<Left>", lefts) |
||||
elseif char_at == a:char |
||||
" Inside an empty pair, jump out |
||||
return a:char . "\<Del>" |
||||
elseif delimitMate#IsSmartQuote(a:char) |
||||
" Seems like a smart quote, insert a single char. |
||||
return a:char |
||||
elseif (char_before == a:char && char_at != a:char) |
||||
\ && s:g('smart_quotes') |
||||
" Seems like we have an unbalanced quote, insert one quotation |
||||
" mark and jump to the middle. |
||||
return a:char . "\<Left>" |
||||
else |
||||
" Insert a pair and jump to the middle. |
||||
let sufix = '' |
||||
if !empty(s:g('eol_marker')) && col('.') - 1 == len(getline('.')) |
||||
let idx = len(s:g('eol_marker')) * -1 |
||||
let marker = getline('.')[idx : ] |
||||
let has_marker = marker == s:g('eol_marker') |
||||
let sufix = !has_marker ? s:g('eol_marker') : '' |
||||
endif |
||||
return a:char . a:char . "\<Left>" |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#JumpOut(char) "{{{ |
||||
if delimitMate#IsForbidden(a:char) |
||||
return a:char |
||||
endif |
||||
let jump = delimitMate#ShouldJump(a:char) |
||||
if jump == 1 |
||||
return "\<Right>" |
||||
elseif jump == 3 |
||||
return "\<Right>\<Right>" |
||||
elseif jump == 5 |
||||
return "\<Down>\<C-O>I\<Right>" |
||||
else |
||||
return a:char |
||||
endif |
||||
endfunction " }}} |
||||
|
||||
function! delimitMate#JumpAny(...) " {{{ |
||||
if delimitMate#IsForbidden('') |
||||
return '' |
||||
endif |
||||
if !delimitMate#ShouldJump() |
||||
return '' |
||||
endif |
||||
" Let's get the character on the right. |
||||
let char = delimitMate#GetCharFromCursor(0) |
||||
if char == " " |
||||
" Space expansion. |
||||
return "\<Right>\<Right>" |
||||
elseif char == "" |
||||
" CR expansion. |
||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>\<Del>" |
||||
else |
||||
return "\<Right>" |
||||
endif |
||||
endfunction " delimitMate#JumpAny() }}} |
||||
|
||||
function! delimitMate#JumpMany() " {{{ |
||||
let line = split(getline('.')[col('.') - 1 : ], '\zs') |
||||
let rights = "" |
||||
let found = 0 |
||||
for char in line |
||||
if index(s:g('quotes_list'), char) >= 0 || |
||||
\ index(s:g('right_delims'), char) >= 0 |
||||
let rights .= "\<Right>" |
||||
let found = 1 |
||||
elseif found == 0 |
||||
let rights .= "\<Right>" |
||||
else |
||||
break |
||||
endif |
||||
endfor |
||||
if found == 1 |
||||
return rights |
||||
else |
||||
return '' |
||||
endif |
||||
endfunction " delimitMate#JumpMany() }}} |
||||
|
||||
function! delimitMate#ExpandReturn() "{{{ |
||||
if delimitMate#IsForbidden("") |
||||
return "\<CR>" |
||||
endif |
||||
if delimitMate#WithinEmptyPair() |
||||
" Expand: |
||||
" Not sure why I used the previous combos, but I'm sure somebody will |
||||
" tell me about it. |
||||
" XXX zv prevents breaking expansion with syntax folding enabled by |
||||
" InsertLeave. |
||||
return "\<Esc>a\<CR>\<Esc>zvO" |
||||
else |
||||
return "\<CR>" |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#ExpandSpace() "{{{ |
||||
if delimitMate#IsForbidden("\<Space>") |
||||
return "\<Space>" |
||||
endif |
||||
let escaped = delimitMate#CursorIdx() >= 2 |
||||
\ && delimitMate#GetCharFromCursor(-2) == '\' |
||||
if delimitMate#WithinEmptyPair() && !escaped |
||||
" Expand: |
||||
return "\<Space>\<Space>\<Left>" |
||||
else |
||||
return "\<Space>" |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#BS() " {{{ |
||||
if delimitMate#IsForbidden("") |
||||
let extra = '' |
||||
elseif &bs !~ 'start\|2' |
||||
let extra = '' |
||||
elseif delimitMate#WithinEmptyPair() |
||||
let extra = "\<Del>" |
||||
elseif delimitMate#IsSpaceExpansion() |
||||
let extra = "\<Del>" |
||||
elseif delimitMate#IsCRExpansion() |
||||
let extra = repeat("\<Del>", |
||||
\ len(matchstr(getline(line('.') + 1), '^\s*\S'))) |
||||
else |
||||
let extra = '' |
||||
endif |
||||
return "\<BS>" . extra |
||||
endfunction " }}} delimitMate#BS() |
||||
|
||||
" }}} |
||||
|
||||
" Tools: {{{ |
||||
function! delimitMate#TestMappings() "{{{ |
||||
echom 1 |
||||
%d |
||||
let options = sort(keys(delimitMate#OptionsList())) |
||||
let optoutput = ['delimitMate Report', '==================', '', |
||||
\ '* Options: ( ) default, (g) global, (b) buffer',''] |
||||
for option in options |
||||
let scope = s:exists(option, 'b') ? 'b' |
||||
\ : s:exists(option, 'g') ? 'g' : ' ' |
||||
call add(optoutput, '(' . scope . ')' . ' delimitMate_' . option . ' = ' . string(s:g(option))) |
||||
endfor |
||||
call append(line('$'), optoutput + ['--------------------','']) |
||||
|
||||
" Check if mappings were set. {{{ |
||||
let imaps = s:g('right_delims') |
||||
let imaps += ( s:g('autoclose') ? s:g('left_delims') : [] ) |
||||
let imaps += |
||||
\ s:g('quotes_list') + |
||||
\ s:g('apostrophes_list') + |
||||
\ ['<BS>', '<S-BS>', '<S-Tab>', '<Esc>', '<C-G>g'] |
||||
let imaps += ( s:g('expand_cr') ? ['<CR>'] : [] ) |
||||
let imaps += ( s:g('expand_space') ? ['<Space>'] : [] ) |
||||
|
||||
let imappings = [] |
||||
for map in imaps |
||||
let output = '' |
||||
if map == '|' |
||||
let map = '<Bar>' |
||||
endif |
||||
redir => output | execute "verbose imap ".map | redir END |
||||
let imappings += split(output, '\n') |
||||
endfor |
||||
|
||||
unlet! output |
||||
let output = ['* Mappings:', ''] + imappings + ['--------------------', ''] |
||||
call append('$', output+['* Showcase:', '']) |
||||
" }}} |
||||
if s:g('autoclose') |
||||
" {{{ |
||||
for i in range(len(s:g('left_delims'))) |
||||
exec "normal Go0\<C-D>Open: " . s:g('left_delims')[i]. "|" |
||||
exec "normal o0\<C-D>Delete: " . s:g('left_delims')[i] . "\<BS>|" |
||||
exec "normal o0\<C-D>Exit: " . s:g('left_delims')[i] . s:g('right_delims')[i] . "|" |
||||
if s:g('expand_space') == 1 |
||||
exec "normal o0\<C-D>Space: " . s:g('left_delims')[i] . " |" |
||||
exec "normal o0\<C-D>Delete space: " . s:g('left_delims')[i] |
||||
\ . " \<BS>|" |
||||
endif |
||||
if s:g('expand_cr') == 1 |
||||
exec "normal o0\<C-D>Car return: " . s:g('left_delims')[i] . |
||||
\ "\<CR>|" |
||||
exec "normal Go0\<C-D>Delete car return: " . s:g('left_delims')[i] |
||||
\ . "\<CR>0\<C-D>\<BS>|" |
||||
endif |
||||
call append(line('$'), '') |
||||
endfor |
||||
for i in range(len(s:g('quotes_list'))) |
||||
exec "normal Go0\<C-D>Open: " . s:g('quotes_list')[i] . "|" |
||||
exec "normal o0\<C-D>Delete: " . s:g('quotes_list')[i] . "\<BS>|" |
||||
exec "normal o0\<C-D>Exit: " . s:g('quotes_list')[i] . s:g('quotes_list')[i] . "|" |
||||
if s:g('expand_space') == 1 |
||||
exec "normal o0\<C-D>Space: " . s:g('quotes_list')[i] . " |" |
||||
exec "normal o0\<C-D>Delete space: " . s:g('quotes_list')[i] |
||||
\ . " \<BS>|" |
||||
endif |
||||
if s:g('expand_cr') == 1 |
||||
exec "normal o0\<C-D>Car return: " . s:g('quotes_list')[i] |
||||
\ . "\<CR>|" |
||||
exec "normal Go0\<C-D>Delete car return: " . s:g('quotes_list')[i] |
||||
\ . "\<CR>\<BS>|" |
||||
endif |
||||
call append(line('$'), '') |
||||
endfor |
||||
"}}} |
||||
else |
||||
"{{{ |
||||
for i in range(len(s:g('left_delims'))) |
||||
exec "normal GoOpen & close: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . "|" |
||||
exec "normal oDelete: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . "\<BS>|" |
||||
exec "normal oExit: " . s:g('left_delims')[i] . s:g('right_delims')[i] |
||||
\ . s:g('right_delims')[i] . "|" |
||||
if s:g('expand_space') == 1 |
||||
exec "normal oSpace: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . " |" |
||||
exec "normal oDelete space: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . " \<BS>|" |
||||
endif |
||||
if s:g('expand_cr') == 1 |
||||
exec "normal oCar return: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . "\<CR>|" |
||||
exec "normal GoDelete car return: " . s:g('left_delims')[i] |
||||
\ . s:g('right_delims')[i] . "\<CR>\<BS>|" |
||||
endif |
||||
call append(line('$'), '') |
||||
endfor |
||||
for i in range(len(s:g('quotes_list'))) |
||||
exec "normal GoOpen & close: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . "|" |
||||
exec "normal oDelete: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . "\<BS>|" |
||||
exec "normal oExit: " . s:g('quotes_list')[i] . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . "|" |
||||
if s:g('expand_space') == 1 |
||||
exec "normal oSpace: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . " |" |
||||
exec "normal oDelete space: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . " \<BS>|" |
||||
endif |
||||
if s:g('expand_cr') == 1 |
||||
exec "normal oCar return: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . "\<CR>|" |
||||
exec "normal GoDelete car return: " . s:g('quotes_list')[i] |
||||
\ . s:g('quotes_list')[i] . "\<CR>\<BS>|" |
||||
endif |
||||
call append(line('$'), '') |
||||
endfor |
||||
endif "}}} |
||||
redir => setoptions | set | filetype | version | redir END |
||||
call append(line('$'), split(setoptions,"\n") |
||||
\ + ['--------------------']) |
||||
setlocal nowrap |
||||
call feedkeys("\<Esc>\<Esc>", 'n') |
||||
endfunction "}}} |
||||
|
||||
function! delimitMate#OptionsList() "{{{ |
||||
return { |
||||
\ 'apostrophes' : '', |
||||
\ 'autoclose' : 1, |
||||
\ 'balance_matchpairs' : 0, |
||||
\ 'jump_expansion' : 0, |
||||
\ 'eol_marker' : '', |
||||
\ 'excluded_ft' : '', |
||||
\ 'excluded_regions' : 'Comment', |
||||
\ 'expand_cr' : 0, |
||||
\ 'expand_space' : 0, |
||||
\ 'matchpairs' : &matchpairs, |
||||
\ 'nesting_quotes' : [], |
||||
\ 'quotes' : '" '' `', |
||||
\ 'smart_matchpairs' : '\w', |
||||
\ 'smart_quotes' : 1, |
||||
\} |
||||
endfunction " delimitMate#OptionsList }}} |
||||
"}}} |
||||
|
||||
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2 |
@ -0,0 +1,846 @@
@@ -0,0 +1,846 @@
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.7 *delimitMate* |
||||
|
||||
|
||||
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~ |
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM |
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~ |
||||
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM |
||||
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~ |
||||
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M |
||||
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~ |
||||
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M |
||||
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~ |
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
||||
|
||||
|
||||
|
||||
============================================================================== |
||||
0.- CONTENTS *delimitMate-contents* |
||||
|
||||
1. Introduction____________________________|delimitMateIntro| |
||||
2. Customization___________________________|delimitMateOptions| |
||||
2.1 Options summary____________________|delimitMateOptionSummary| |
||||
2.2 Options details____________________|delimitMateOptionDetails| |
||||
3. Functionality___________________________|delimitMateFunctionality| |
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose| |
||||
3.2 Expansion of space and CR__________|delimitMateExpansion| |
||||
3.3 Backspace__________________________|delimitMateBackspace| |
||||
3.4 Smart Quotes_______________________|delimitMateSmartQuotes| |
||||
3.5 Balancing matching pairs___________|delimitMateBalance| |
||||
3.6 FileType based configuration_______|delimitMateFileType| |
||||
3.7 Syntax awareness___________________|delimitMateSyntax| |
||||
4. Commands________________________________|delimitMateCommands| |
||||
5. Mappings________________________________|delimitMateMappings| |
||||
6. Functions_______________________________|delimitMateFunctions| |
||||
7. TODO list_______________________________|delimitMateTodo| |
||||
8. Maintainer______________________________|delimitMateMaintainer| |
||||
9. Credits_________________________________|delimitMateCredits| |
||||
10. History_________________________________|delimitMateHistory| |
||||
|
||||
============================================================================== |
||||
1.- INTRODUCTION *delimitMateIntro* |
||||
|
||||
This plug-in provides automatic closing of quotes, parenthesis, brackets, |
||||
etc.; besides some other related features that should make your time in insert |
||||
mode a little bit easier. |
||||
|
||||
Most of the features can be modified or disabled permanently, using global |
||||
variables, or on a FileType basis, using autocommands. |
||||
|
||||
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest| |
||||
in a new buffer to see what is not working. |
||||
|
||||
NOTE 2: Abbreviations set with |:iabbrev| will not be expanded by delimiters |
||||
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on |
||||
the go. |
||||
|
||||
============================================================================== |
||||
2. CUSTOMIZATION *delimitMateOptions* |
||||
|
||||
You can create your own mappings for some features using the global functions. |
||||
Read |DelimitMateFunctions| for more info. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary* |
||||
|
||||
The behaviour of this script can be customized setting the following options |
||||
in your vimrc file. You can use local options to set the configuration for |
||||
specific file types, see |delimitMateOptionDetails| for examples. |
||||
|
||||
|'loaded_delimitMate'| Turns off the script. |
||||
|
||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically |
||||
insert the closing delimiter. |
||||
|
||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are |
||||
matching pairs. |
||||
|
||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be |
||||
used. |
||||
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be |
||||
allowed to be nested. |
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>. |
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>. |
||||
|
||||
|'delimitMate_jump_expansion'| Turns on/off jumping over expansions. |
||||
|
||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature. |
||||
|
||||
|'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature. |
||||
|
||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs" |
||||
feature. |
||||
|
||||
|'delimitMate_excluded_regions'| Turns off the script for the given regions or |
||||
syntax group names. |
||||
|
||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types. |
||||
|
||||
|'delimitMate_eol_marker'| Determines what to insert after the closing |
||||
matchpair when typing an opening matchpair on |
||||
the end of the line. |
||||
|
||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix" |
||||
balancing of single quotes when used as |
||||
apostrophes. NOTE: Not needed any more, kept |
||||
for compatibility with older versions. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
2.2 OPTIONS DETAILS *delimitMateOptionDetails* |
||||
|
||||
Add the shown lines to your vimrc file in order to set the below options. |
||||
Buffer variables take precedence over global ones and can be used along with |
||||
autocmd to modify delimitMate's behavior for specific file types, read more in |
||||
|delimitMateFileType|. |
||||
|
||||
Note: Use buffer variables only to set options for specific file types using |
||||
:autocmd, use global variables to set options for all buffers. Read more in |
||||
|g:var| and |b:var|. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
*'loaded_delimitMate'* |
||||
*'b:loaded_delimitMate'* |
||||
This option prevents delimitMate from loading. |
||||
e.g.: > |
||||
let loaded_delimitMate = 1 |
||||
au FileType mail let b:loaded_delimitMate = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_offByDefault'* |
||||
Values: 0 or 1.~ |
||||
Default: 0~ |
||||
|
||||
If this option is set to 1, delimitMate will load, but will not take |
||||
effect in any buffer unless |:DelimitMateSwitch| is called in that |
||||
buffer. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_autoclose'* |
||||
*'b:delimitMate_autoclose'* |
||||
Values: 0 or 1. ~ |
||||
Default: 1 ~ |
||||
|
||||
If this option is set to 0, delimitMate will not add a closing delimiter |
||||
automagically. See |delimitMateAutoClose| for details. |
||||
e.g.: > |
||||
let delimitMate_autoclose = 0 |
||||
au FileType mail let b:delimitMate_autoclose = 0 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_matchpairs'* |
||||
*'b:delimitMate_matchpairs'* |
||||
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~ |
||||
characters.~ |
||||
Default: &matchpairs ~ |
||||
|
||||
Use this option to tell delimitMate which characters should be considered |
||||
matching pairs. Read |delimitMateAutoClose| for details. |
||||
e.g: > |
||||
let delimitMate_matchpairs = "(:),[:],{:},<:>" |
||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>" |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_quotes'* |
||||
*'b:delimitMate_quotes'* |
||||
Values: A string of characters separated by spaces. ~ |
||||
Default: "\" ' `" ~ |
||||
|
||||
Use this option to tell delimitMate which characters should be considered as |
||||
quotes. Read |delimitMateAutoClose| for details. |
||||
e.g.: > |
||||
let delimitMate_quotes = "\" ' ` *" |
||||
au FileType html let b:delimitMate_quotes = "\" '" |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_nesting_quotes'* |
||||
*'b:delimitMate_nesting_quotes'* |
||||
Values: A list of quotes. ~ |
||||
Default: [] ~ |
||||
|
||||
When adding a third quote listed in this option is inserted, three quotes will |
||||
be inserted to the right of the cursor and the cursor will stay in the middle. |
||||
If more quotes are inserted the number of quotes on both sides of the cursor |
||||
will stay balanced. |
||||
e.g.: > |
||||
let delimitMate_nesting_quotes = ['"','`'] |
||||
au FileType python let b:delimitMate_nesting_quotes = ['"'] |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_expand_cr'* |
||||
*'b:delimitMate_expand_cr'* |
||||
Values: 1 or 0 ~ |
||||
Default: 0 ~ |
||||
|
||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion| |
||||
for details. NOTE This feature requires that 'backspace' is either set to 2 or |
||||
has "eol" and "start" as part of its value. |
||||
e.g.: > |
||||
let delimitMate_expand_cr = 1 |
||||
au FileType mail let b:delimitMate_expand_cr = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_expand_space'* |
||||
*'b:delimitMate_expand_space'* |
||||
Values: 1 or 0 ~ |
||||
Default: 0 ~ |
||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion| |
||||
for details. |
||||
e.g.: > |
||||
let delimitMate_expand_space = 1 |
||||
au FileType tcl let b:delimitMate_expand_space = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_jump_expansion'* |
||||
*'b:delimitMate_jump_expansion'* |
||||
Values: 1 or 0 ~ |
||||
Default: 0 ~ |
||||
This option turns on/off the jumping over <CR> and <Space> expansions when |
||||
inserting closing matchpairs. Read |delimitMateExpansion| for details. |
||||
e.g.: > |
||||
let delimitMate_jump_expansion = 1 |
||||
au FileType tcl let b:delimitMate_jump_expansion = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_smart_quotes'* |
||||
*'b:delimitMate_smart_quotes'* |
||||
Values: 1 or 0 ~ |
||||
Default: 1 ~ |
||||
|
||||
This option turns on/off the smart quotes feature. Read |
||||
|delimitMateSmartQuotes| for details. |
||||
e.g.: > |
||||
let delimitMate_smart_quotes = 0 |
||||
au FileType tcl let b:delimitMate_smart_quotes = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_smart_matchpairs'* |
||||
*'b:delimitMate_smart_matchpairs'* |
||||
Values: Regexp ~ |
||||
Default: '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)' ~ |
||||
|
||||
This regex is matched against the text to the right of cursor, if it's not |
||||
empty and there is a match delimitMate will not autoclose the pair. At the |
||||
moment to match the text, an escaped bang (\!) in the regex will be replaced |
||||
by the character being inserted, while an escaped number symbol (\#) will be |
||||
replaced by the closing pair. |
||||
e.g.: > |
||||
let delimitMate_smart_matchpairs = '' |
||||
au FileType tcl let b:delimitMate_smart_matchpairs = '^\%(\w\|\$\)' |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_balance_matchpairs'* |
||||
*'b:delimitMate_balance_matchpairs'* |
||||
Values: 1 or 0 ~ |
||||
Default: 0 ~ |
||||
|
||||
This option turns on/off the balancing of matching pairs. Read |
||||
|delimitMateBalance| for details. |
||||
e.g.: > |
||||
let delimitMate_balance_matchpairs = 1 |
||||
au FileType tcl let b:delimitMate_balance_matchpairs = 1 |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_excluded_regions'* |
||||
Values: A string of syntax group names names separated by single commas. ~ |
||||
Default: Comment ~ |
||||
|
||||
This options turns delimitMate off for the listed regions, read |group-name| |
||||
for more info about what is a region. |
||||
e.g.: > |
||||
let delimitMate_excluded_regions = "Comment,String" |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_excluded_ft'* |
||||
Values: A string of file type names separated by single commas. ~ |
||||
Default: Empty. ~ |
||||
|
||||
This options turns delimitMate off for the listed file types, use this option |
||||
only if you don't want any of the features it provides on those file types. |
||||
e.g.: > |
||||
let delimitMate_excluded_ft = "mail,txt" |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_eol_marker'* |
||||
Values: String. ~ |
||||
Default: Empty. ~ |
||||
|
||||
The contents of this string will be inserted after the closing matchpair or |
||||
quote when the respective opening matchapair or quote is inserted at the end |
||||
of the line. |
||||
e.g.: > |
||||
au FileType c,perl let b:delimitMate_eol_marker = ";" |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
*'delimitMate_apostrophes'* |
||||
Values: Strings separated by ":". ~ |
||||
Default: No longer used. ~ |
||||
|
||||
NOTE: This feature is turned off by default, it's been kept for compatibility |
||||
with older version, read |delimitMateSmartQuotes| for details. |
||||
If auto-close is enabled, this option tells delimitMate how to try to fix the |
||||
balancing of single quotes when used as apostrophes. The values of this option |
||||
are strings of text where a single quote would be used as an apostrophe (e.g.: |
||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to |
||||
disable this feature. |
||||
e.g.: > |
||||
let delimitMate_apostrophes = "" |
||||
au FileType tcl let delimitMate_apostrophes = "" |
||||
< |
||||
============================================================================== |
||||
3. FUNCTIONALITY *delimitMateFunctionality* |
||||
|
||||
------------------------------------------------------------------------------ |
||||
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose* |
||||
|
||||
With automatic closing enabled, if an opening delimiter is inserted the plugin |
||||
inserts the closing delimiter and places the cursor between the pair. With |
||||
automatic closing disabled, no closing delimiters is inserted by delimitMate, |
||||
but when a pair of delimiters is typed, the cursor is placed in the middle. |
||||
|
||||
When the cursor is inside an empty pair or located next to the left of a |
||||
closing delimiter, the cursor is placed outside the pair to the right of the |
||||
closing delimiter. |
||||
|
||||
When |'delimitMate_smart_matchpairs'| is not empty and it matches the text to |
||||
the right of the cursor, delimitMate will not automatically insert the closing |
||||
pair. |
||||
|
||||
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this |
||||
script uses the values in '&matchpairs' to identify the pairs, and ", ' and ` |
||||
for quotes respectively. |
||||
|
||||
<S-Tab> will jump over a single closing delimiter or quote, <C-G>g will jump |
||||
over contiguous delimiters and/or quotes. |
||||
|
||||
The following table shows the behaviour, this applies to quotes too (the final |
||||
position of the cursor is represented by a "|"): |
||||
|
||||
With auto-close: > |
||||
Type | You get |
||||
======================= |
||||
( | (|) |
||||
–––––––––––|––––––––––– |
||||
() | ()| |
||||
–––––––––––|––––––––––– |
||||
(<S-Tab> | ()| |
||||
–––––––––––|––––––––––– |
||||
{("<C-G>g | {("")}| |
||||
< |
||||
Without auto-close: > |
||||
|
||||
Type | You get |
||||
========================= |
||||
() | (|) |
||||
–––––––––-----|–––––––––– |
||||
()) | ()| |
||||
–––––––––-----|–––––––––– |
||||
()<S-Tab> | ()| |
||||
––––––––––––––|––––––––––– |
||||
{}()""<C-G>g | {("")}| |
||||
< |
||||
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate, |
||||
you should use <C-]> (read |i_CTRL-]|) to expand them on the go. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion* |
||||
|
||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be |
||||
expanded, see |'delimitMate_expand_space'| and |
||||
|'delimitMate_expand_cr'|: |
||||
|
||||
Expand <Space> to: > |
||||
|
||||
<Space><Space><Left> | You get |
||||
==================================== |
||||
(|) | ( | ) |
||||
< |
||||
Expand <CR> to: > |
||||
|
||||
<CR><CR><Up> | You get |
||||
============================ |
||||
(|) | ( |
||||
| | |
||||
| ) |
||||
< |
||||
|
||||
NOTE that the expansion of <CR> will break the redo command. |
||||
|
||||
Since <Space> and <CR> are used everywhere, I have made the functions involved |
||||
in expansions global, so they can be used to make custom mappings. Read |
||||
|delimitMateFunctions| for more details. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
3.3 BACKSPACE *delimitMateBackspace* |
||||
|
||||
If you press backspace inside an empty pair, both delimiters are deleted. When |
||||
expansions are enabled, <BS> will also delete the expansions. NOTE that |
||||
deleting <CR> expansions will break the redo command. |
||||
|
||||
If you type <S-BS> (shift + backspace) instead, only the closing delimiter |
||||
will be deleted. NOTE that this will not usually work when using Vim from the |
||||
terminal, see 'delimitMate#JumpAny()' below to see how to fix it. |
||||
|
||||
e.g. typing at the "|": > |
||||
|
||||
What | Before | After |
||||
============================================== |
||||
<BS> | call expand(|) | call expand| |
||||
---------|-------------------|----------------- |
||||
<BS> | call expand( | ) | call expand(|) |
||||
---------|-------------------|----------------- |
||||
<BS> | call expand( | call expand(|) |
||||
| | | |
||||
| ) | |
||||
---------|-------------------|----------------- |
||||
<S-BS> | call expand(|) | call expand(| |
||||
< |
||||
|
||||
------------------------------------------------------------------------------ |
||||
3.4 SMART QUOTES *delimitMateSmartQuotes* |
||||
|
||||
Only one quote will be inserted following a quote, a "\", following or |
||||
preceding a keyword character, or when the number of quotes in the current |
||||
line is odd. This should cover closing quotes after a string, opening quotes |
||||
before a string, escaped quotes and apostrophes. Except for apostrophes, this |
||||
feature can be disabled setting the option |'delimitMate_smart_quotes'| to 0. |
||||
|
||||
e.g. typing at the "|": > |
||||
|
||||
What | Before | After |
||||
======================================= |
||||
" | Text | | Text "|" |
||||
" | "String| | "String"| |
||||
" | let i = "| | let i = "|" |
||||
'm | I| | I'm| |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
3.4 SMART MATCHPAIRS *delimitMateSmartMatchpairs* |
||||
|
||||
This is similar to "smart quotes", but applied to the characters in |
||||
|'delimitMate_matchpairs'|. The difference is that delimitMate will not |
||||
auto-close the pair when the regex matches the text on the right of the |
||||
cursor. See |'delimitMate_smart_matchpairs'| for more details. |
||||
|
||||
|
||||
e.g. typing at the "|": > |
||||
|
||||
What | Before | After |
||||
======================================= |
||||
( | function| | function(|) |
||||
( | |var | (|var |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
3.5 BALANCING MATCHING PAIRS *delimitMateBalance* |
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is |
||||
enabled, delimitMate will try to balance the closing pairs in the current |
||||
line. |
||||
|
||||
e.g. typing at the "|": > |
||||
|
||||
What | Before | After |
||||
======================================= |
||||
( | | | (|) |
||||
( | |) | (|) |
||||
(( | |) | ((|)) |
||||
< |
||||
------------------------------------------------------------------------------ |
||||
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType* |
||||
|
||||
delimitMate options can be set globally for all buffers using global |
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set |
||||
options for specific file types (see |'filetype'|) using buffer variables in |
||||
the following way: > |
||||
|
||||
au FileType mail,text let b:delimitMate_autoclose = 0 |
||||
^ ^ ^ ^ ^ |
||||
| | | | | |
||||
| | | | - Option value. |
||||
| | | - Option name. |
||||
| | - Buffer variable. |
||||
| - File types for which the option will be set. |
||||
- Don't forget to put this event. |
||||
< |
||||
NOTE that you should use buffer variables (|b:var|) only to set options with |
||||
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
3.7 SYNTAX AWARENESS *delimitMateSyntax* |
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings |
||||
usualy don't need auto-completion. delimitMate monitors which region is being |
||||
edited and if it detects that the cursor is in a comment it'll turn itself off |
||||
until the cursor leaves the comment. The excluded regions can be set using the |
||||
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of |
||||
regions or syntax group names. |
||||
|
||||
NOTE that this feature relies on a proper syntax file for the current file |
||||
type, if the appropiate syntax file doesn't define a region, delimitMate won't |
||||
know about it. |
||||
|
||||
============================================================================== |
||||
4. COMMANDS *delimitMateCommands* |
||||
|
||||
------------------------------------------------------------------------------ |
||||
:DelimitMateReload *:DelimitMateReload* |
||||
|
||||
Re-sets all the mappings used for this script, use it if any option has been |
||||
changed or if the filetype option hasn't been set yet. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
:DelimitMateSwitch *:DelimitMateSwitch* |
||||
|
||||
Switches the plug-in on and off. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
:DelimitMateTest *:DelimitMateTest* |
||||
|
||||
This command tests every mapping set-up for this script, useful for testing |
||||
custom configurations. |
||||
|
||||
The following output corresponds to the default values, it will be different |
||||
depending on your configuration. "Open & close:" represents the final result |
||||
when the closing delimiter has been inserted, either manually or |
||||
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an |
||||
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter |
||||
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the |
||||
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L", |
||||
"Visual-R" and "Visual" shows visual wrapping, see |
||||
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see |
||||
|delimitMateExpansion|. The cursor's position at the end of every test is |
||||
represented by an "|": > |
||||
|
||||
* AUTOCLOSE: |
||||
Open & close: (|) |
||||
Delete: | |
||||
Exit: ()| |
||||
Space: ( |) |
||||
Visual-L: (v) |
||||
Visual-R: (v) |
||||
Car return: ( |
||||
|) |
||||
|
||||
Open & close: {|} |
||||
Delete: | |
||||
Exit: {}| |
||||
Space: { |} |
||||
Visual-L: {v} |
||||
Visual-R: {v} |
||||
Car return: { |
||||
|} |
||||
|
||||
Open & close: [|] |
||||
Delete: | |
||||
Exit: []| |
||||
Space: [ |] |
||||
Visual-L: [v] |
||||
Visual-R: [v] |
||||
Car return: [ |
||||
|] |
||||
|
||||
Open & close: "|" |
||||
Delete: | |
||||
Exit: ""| |
||||
Space: " |" |
||||
Visual: "v" |
||||
Car return: " |
||||
|" |
||||
|
||||
Open & close: '|' |
||||
Delete: | |
||||
Exit: ''| |
||||
Space: ' |' |
||||
Visual: 'v' |
||||
Car return: ' |
||||
|' |
||||
|
||||
Open & close: `|` |
||||
Delete: | |
||||
Exit: ``| |
||||
Space: ` |` |
||||
Visual: `v` |
||||
Car return: ` |
||||
|` |
||||
< |
||||
|
||||
============================================================================== |
||||
5. MAPPINGS *delimitMateMappings* |
||||
|
||||
delimitMate doesn't override any existing map, so you may encounter that it |
||||
doesn't work as expected because a mapping is missing. In that case, the |
||||
conflicting mappings should be resolved by either disabling the conflicting |
||||
mapping or creating a custom mappings. |
||||
|
||||
In order to make custom mappings easier and prevent overwritting existing |
||||
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct |
||||
for its mappings. |
||||
|
||||
These are the default mappings for the extra features: |
||||
|
||||
<BS> is mapped to <Plug>delimitMateBS |
||||
<S-BS> is mapped to <Plug>delimitMateS-BS |
||||
<S-Tab> is mapped to <Plug>delimitMateS-Tab |
||||
<C-G>g is mapped to <Plug>delimitMateJumpMany |
||||
|
||||
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they |
||||
depend on the values of the delimitMate options, they have the following form: |
||||
|
||||
<Plug>delimitMate + char |
||||
|
||||
e.g.: for "(": |
||||
|
||||
( is mapped to <Plug>delimitMate( |
||||
|
||||
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up |
||||
menus: |
||||
|
||||
imap <expr> <CR> pumvisible() |
||||
\ ? "\<C-Y>" |
||||
\ : "<Plug>delimitMateCR" |
||||
|
||||
|
||||
============================================================================== |
||||
6. FUNCTIONS *delimitMateFunctions* |
||||
|
||||
------------------------------------------------------------------------------ |
||||
delimitMate#WithinEmptyPair() *delimitMate#WithinEmptyPair()* |
||||
|
||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise. |
||||
e.g.: > |
||||
|
||||
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ? |
||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" : |
||||
\ "external_mapping" |
||||
< |
||||
|
||||
------------------------------------------------------------------------------ |
||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()* |
||||
|
||||
Returns 1 if there is a closing delimiter or a quote to the right of the |
||||
cursor, 0 otherwise. |
||||
|
||||
------------------------------------------------------------------------------ |
||||
delimitMate#JumpAny() *delimitMate#JumpAny()* |
||||
|
||||
This function returns a mapping that will make the cursor jump to the right |
||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise. |
||||
e.g.: You can use this to create your own mapping to jump over any delimiter. |
||||
> |
||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny()<CR> |
||||
< |
||||
|
||||
============================================================================== |
||||
7. TODO LIST *delimitMateTodo* |
||||
|
||||
- Automatic set-up by file type. |
||||
- Make block-wise visual wrapping work on un-even regions. |
||||
|
||||
============================================================================== |
||||
8. MAINTAINER *delimitMateMaintainer* |
||||
|
||||
Hi there! My name is Israel Chauca F. and I can be reached at: |
||||
mailto:israelchauca@gmail.com |
||||
|
||||
Feel free to send me any suggestions and/or comments about this plugin, I'll |
||||
be very pleased to read them. |
||||
|
||||
============================================================================== |
||||
9. CREDITS *delimitMateCredits* |
||||
|
||||
Contributors: ~ |
||||
|
||||
- Kim Silkebækken ~ |
||||
Fixed mappings being echoed in the terminal. |
||||
|
||||
- Eric Van Dewoestine ~ |
||||
Implemented smart matchpairs. |
||||
|
||||
Some of the code that makes this script was modified or just shamelessly |
||||
copied from the following sources: |
||||
|
||||
- Ian McCracken ~ |
||||
Post titled: Vim, Part II: Matching Pairs: |
||||
http://concisionandconcinnity.blogspot.com/ |
||||
|
||||
- Aristotle Pagaltzis ~ |
||||
From the comments on the previous blog post and from: |
||||
http://gist.github.com/144619 |
||||
|
||||
- Karl Guertin ~ |
||||
AutoClose: |
||||
http://www.vim.org/scripts/script.php?script_id=1849 |
||||
|
||||
- Thiago Alves ~ |
||||
AutoClose: |
||||
http://www.vim.org/scripts/script.php?script_id=2009 |
||||
|
||||
- Edoardo Vacchi ~ |
||||
ClosePairs: |
||||
http://www.vim.org/scripts/script.php?script_id=2373 |
||||
|
||||
This script was inspired by the auto-completion of delimiters on TextMate. |
||||
|
||||
============================================================================== |
||||
10. HISTORY *delimitMateHistory* |
||||
|
||||
Version Date Release notes ~ |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.7 2013-07-15 * Current release: |
||||
- Lots of bug fixes. |
||||
- Add delimitMate_offByDefault. |
||||
- Add delimitMate_eol_marker. |
||||
- Reduce the number of mappings. |
||||
- Stop using setline(). |
||||
- Better handling of nested quotes. |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.6 2011-01-14 * - Add smart_matchpairs feature. |
||||
- Add mapping to jump over contiguous delimiters. |
||||
- Fix behaviour of b:loaded_delimitMate. |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.5.1 2010-09-30 * - Remove visual wrapping. Surround.vim offers a much |
||||
better implementation. |
||||
- Minor mods to DelimitMateTest. |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.5 2010-09-22 * - Better handling of mappings. |
||||
- Add report for mappings in |:DelimitMateTest|. |
||||
- Allow the use of "|" and multi-byte characters in |
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|. |
||||
- Allow commands to be concatenated using |. |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>. |
||||
- Add missing doc on |'delimitMate_smart_quotes'|, |
||||
|delimitMateBalance| and |
||||
|'delimitMate_balance_matchpairs'|. |
||||
|---------|------------|-----------------------------------------------------| |
||||
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance. |
||||
- Visual wrapping now works on block-wise visual |
||||
with some limitations. |
||||
- Arrow keys didn't work on terminal. |
||||
- Added option to allow nested quotes. |
||||
- Expand Smart Quotes to look for a string on the |
||||
right of the cursor. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space> |
||||
expansion. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments |
||||
or other regions, customizable. |
||||
- Changed format of most mappings. |
||||
- Fix: <CR> expansion doesn't break automatic |
||||
indentation adjustments anymore. |
||||
- Fix: Arrow keys would insert A, B, C or D instead |
||||
of moving the cursor when using Vim on a terminal. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
2.2 2010-05-16 * - Added command to switch the plug-in on and off. |
||||
- Fix: some problems with <Left>, <Right> and <CR>. |
||||
- Fix: A small problem when inserting a delimiter at |
||||
the beginning of the line. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
2.1 2010-05-10 * - Most of the functions have been moved to an |
||||
autoload script to avoid loading unnecessary ones. |
||||
- Fixed a problem with the redo command. |
||||
- Many small fixes. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
2.0 2010-04-01 * New features: |
||||
- All features are redo/undo-wise safe. |
||||
- A single quote typed after an alphanumeric |
||||
character is considered an apostrophe and one |
||||
single quote is inserted. |
||||
- A quote typed after another quote inserts a single |
||||
quote and the cursor jumps to the middle. |
||||
- <S-Tab> jumps out of any empty pair. |
||||
- <CR> and <Space> expansions are fixed, but the |
||||
functions used for it are global and can be used in |
||||
custom mappings. The previous system is still |
||||
active if you have any of the expansion options |
||||
set. |
||||
- <S-Backspace> deletes the closing delimiter. |
||||
* Fixed bug: |
||||
- s:vars were being used to store buffer options. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single |
||||
quotes when used as apostrophes. You can read |
||||
|delimitMate_apostrophes| for details. |
||||
Fixed an error when |b:delimitMate_expand_space| |
||||
wasn't set but |delimitMate_expand_space| wasn't. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.5 2009-10-05 * Fix: delimitMate should work correctly for files |
||||
passed as arguments to Vim. Thanks to Ben Beuchler |
||||
for helping to nail this bug. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even |
||||
if they don't have set the file type option or were |
||||
opened directly from the terminal. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.3 2009-09-24 * Now local options can be used along with autocmd |
||||
for specific file type configurations. |
||||
Fixes: |
||||
- Unnamed register content is not lost on visual |
||||
mode. |
||||
- Use noremap where appropiate. |
||||
- Wrapping a single empty line works as expected. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.2 2009-09-07 * Fixes: |
||||
- When inside nested empty pairs, deleting the |
||||
innermost left delimiter would delete all right |
||||
contiguous delimiters. |
||||
- When inside an empty pair, inserting a left |
||||
delimiter wouldn't insert the right one, instead |
||||
the cursor would jump to the right. |
||||
- New buffer inside the current window wouldn't |
||||
have the mappings set. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't |
||||
set and added support for GetLatestScripts |
||||
auto-detection. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
1.0 2009-08-23 * Initial upload. |
||||
|
||||
|---------|------------|-----------------------------------------------------| |
||||
|
||||
|
||||
`\|||/´ MMM \|/ www __^__ ~ |
||||
(o o) (o o) @ @ (O-O) /(o o)\\ ~ |
||||
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~ |
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~ |
||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~ |
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~ |
||||
|
||||
vim:tw=78:et:ts=8:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent: |
@ -0,0 +1,374 @@
@@ -0,0 +1,374 @@
|
||||
" File: plugin/delimitMate.vim |
||||
" Version: 2.7 |
||||
" Modified: 2013-07-15 |
||||
" Description: This plugin provides auto-completion for quotes, parens, etc. |
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com> |
||||
" Manual: Read ":help delimitMate". |
||||
" ============================================================================ |
||||
|
||||
" Initialization: {{{ |
||||
|
||||
if exists("g:loaded_delimitMate") || &cp |
||||
" User doesn't want this plugin or compatible is set, let's get out! |
||||
finish |
||||
endif |
||||
let g:loaded_delimitMate = 1 |
||||
let save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing") |
||||
" Don't define the functions if they already exist: just do the work |
||||
" (unless we are testing): |
||||
call s:DelimitMateDo() |
||||
finish |
||||
endif |
||||
|
||||
if v:version < 700 |
||||
echoerr "delimitMate: this plugin requires vim >= 7!" |
||||
finish |
||||
endif |
||||
|
||||
let s:loaded_delimitMate = 1 |
||||
let delimitMate_version = "2.7" |
||||
|
||||
function! s:option_init(name, default) "{{{ |
||||
let b = exists("b:delimitMate_" . a:name) |
||||
let g = exists("g:delimitMate_" . a:name) |
||||
" Find value to use. |
||||
if !b && !g |
||||
let value = a:default |
||||
elseif b |
||||
exec "let value = b:delimitMate_" . a:name |
||||
else |
||||
exec "let value = g:delimitMate_" . a:name |
||||
endif |
||||
call s:s(a:name, value) |
||||
endfunction "}}} |
||||
|
||||
function! s:init() "{{{ |
||||
" Initialize variables: |
||||
|
||||
" autoclose |
||||
call s:option_init("autoclose", 1) |
||||
|
||||
" matchpairs |
||||
call s:option_init("matchpairs", string(&matchpairs)[1:-2]) |
||||
call s:option_init("matchpairs_list", map(split(s:g('matchpairs'), ','), 'split(v:val, '':'')')) |
||||
call s:option_init("left_delims", map(copy(s:g('matchpairs_list')), 'v:val[0]')) |
||||
call s:option_init("right_delims", map(copy(s:g('matchpairs_list')), 'v:val[1]')) |
||||
|
||||
" quotes |
||||
call s:option_init("quotes", "\" ' `") |
||||
call s:option_init("quotes_list",split(s:g('quotes'), '\s\+')) |
||||
|
||||
" nesting_quotes |
||||
call s:option_init("nesting_quotes", []) |
||||
|
||||
" excluded_regions |
||||
call s:option_init("excluded_regions", "Comment") |
||||
call s:option_init("excluded_regions_list", split(s:g('excluded_regions'), ',\s*')) |
||||
let enabled = len(s:g('excluded_regions_list')) > 0 |
||||
call s:option_init("excluded_regions_enabled", enabled) |
||||
|
||||
" excluded filetypes |
||||
call s:option_init("excluded_ft", "") |
||||
|
||||
" expand_space |
||||
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("") |
||||
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!" |
||||
echom "Read :help 'delimitMate_expand_space' for more details." |
||||
unlet b:delimitMate_expand_space |
||||
let b:delimitMate_expand_space = 1 |
||||
endif |
||||
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("") |
||||
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!" |
||||
echom "Read :help 'delimitMate_expand_space' for more details." |
||||
unlet g:delimitMate_expand_space |
||||
let g:delimitMate_expand_space = 1 |
||||
endif |
||||
call s:option_init("expand_space", 0) |
||||
|
||||
" expand_cr |
||||
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("") |
||||
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!" |
||||
echom "Read :help 'delimitMate_expand_cr' for more details." |
||||
unlet b:delimitMate_expand_cr |
||||
let b:delimitMate_expand_cr = 1 |
||||
endif |
||||
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("") |
||||
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!" |
||||
echom "Read :help 'delimitMate_expand_cr' for more details." |
||||
unlet g:delimitMate_expand_cr |
||||
let g:delimitMate_expand_cr = 1 |
||||
endif |
||||
if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) && |
||||
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) || |
||||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1)) |
||||
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details." |
||||
endif |
||||
call s:option_init("expand_cr", 0) |
||||
|
||||
" jump_expansion |
||||
call s:option_init("jump_expansion", 0) |
||||
|
||||
" smart_matchpairs |
||||
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)') |
||||
|
||||
" smart_quotes |
||||
call s:option_init("smart_quotes", 1) |
||||
|
||||
" apostrophes |
||||
call s:option_init("apostrophes", "") |
||||
call s:option_init("apostrophes_list", split(s:g('apostrophes'), ":\s*")) |
||||
|
||||
" tab2exit |
||||
call s:option_init("tab2exit", 1) |
||||
|
||||
" balance_matchpairs |
||||
call s:option_init("balance_matchpairs", 0) |
||||
|
||||
" eol marker |
||||
call s:option_init("eol_marker", "") |
||||
|
||||
call s:s('buffer', []) |
||||
|
||||
endfunction "}}} Init() |
||||
|
||||
"}}} |
||||
|
||||
" Functions: {{{ |
||||
|
||||
function! s:g(...) " {{{ |
||||
return call('delimitMate#Get', a:000) |
||||
endfunction " }}} |
||||
|
||||
function! s:s(...) " {{{ |
||||
return call('delimitMate#Set', a:000) |
||||
endfunction " }}} |
||||
|
||||
function! s:Map() "{{{ |
||||
" Set mappings: |
||||
try |
||||
let save_keymap = &keymap |
||||
let save_iminsert = &iminsert |
||||
let save_imsearch = &imsearch |
||||
let save_cpo = &cpo |
||||
set keymap= |
||||
set cpo&vim |
||||
if s:g('autoclose') |
||||
call s:AutoClose() |
||||
else |
||||
call s:NoAutoClose() |
||||
endif |
||||
call s:ExtraMappings() |
||||
finally |
||||
let &cpo = save_cpo |
||||
let &keymap = save_keymap |
||||
let &iminsert = save_iminsert |
||||
let &imsearch = save_imsearch |
||||
endtry |
||||
|
||||
let b:delimitMate_enabled = 1 |
||||
|
||||
endfunction "}}} Map() |
||||
|
||||
function! s:Unmap() " {{{ |
||||
let imaps = |
||||
\ s:g('right_delims') + |
||||
\ s:g('left_delims') + |
||||
\ s:g('quotes_list') + |
||||
\ s:g('apostrophes_list') + |
||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] + |
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] + |
||||
\ ['<C-Left>', '<C-Right>'] + |
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g'] |
||||
|
||||
for map in imaps |
||||
if maparg(map, "i") =~? 'delimitMate' |
||||
if map == '|' |
||||
let map = '<Bar>' |
||||
endif |
||||
exec 'silent! iunmap <buffer> ' . map |
||||
endif |
||||
endfor |
||||
let b:delimitMate_enabled = 0 |
||||
endfunction " }}} s:Unmap() |
||||
|
||||
function! s:TestMappingsDo() "{{{ |
||||
if &modified |
||||
let confirm = input("Modified buffer, type \"yes\" to write and proceed " |
||||
\ . "with test: ") ==? 'yes' |
||||
if !confirm |
||||
return |
||||
endif |
||||
endif |
||||
call delimitMate#TestMappings() |
||||
g/\%^$/d |
||||
0 |
||||
endfunction "}}} |
||||
|
||||
function! s:DelimitMateDo(...) "{{{ |
||||
|
||||
" First, remove all magic, if needed: |
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1 |
||||
call s:Unmap() |
||||
endif |
||||
|
||||
" Check if this file type is excluded: |
||||
if exists("g:delimitMate_excluded_ft") && |
||||
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0 |
||||
|
||||
" Finish here: |
||||
return 1 |
||||
endif |
||||
|
||||
" Check if user tried to disable using b:loaded_delimitMate |
||||
if exists("b:loaded_delimitMate") |
||||
return 1 |
||||
endif |
||||
|
||||
" Initialize settings: |
||||
call s:init() |
||||
|
||||
" Now, add magic: |
||||
if !exists("g:delimitMate_offByDefault") || !g:delimitMate_offByDefault |
||||
call s:Map() |
||||
endif |
||||
|
||||
if a:0 > 0 |
||||
echo "delimitMate has been reset." |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
function! s:DelimitMateSwitch() "{{{ |
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled |
||||
call s:Unmap() |
||||
echo "delimitMate has been disabled." |
||||
else |
||||
call s:Unmap() |
||||
call s:init() |
||||
call s:Map() |
||||
echo "delimitMate has been enabled." |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
"}}} |
||||
|
||||
" Mappers: {{{ |
||||
function! s:NoAutoClose() "{{{ |
||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR> |
||||
for delim in s:g('right_delims') + s:g('quotes_list') |
||||
if delim == '|' |
||||
let delim = '<Bar>' |
||||
endif |
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>' |
||||
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim |
||||
endfor |
||||
endfunction "}}} |
||||
|
||||
function! s:AutoClose() "{{{ |
||||
" Add matching pair and jump to the midle: |
||||
" inoremap <silent> <buffer> ( ()<Left> |
||||
let i = 0 |
||||
while i < len(s:g('matchpairs_list')) |
||||
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i] |
||||
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('right_delims')[i] |
||||
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' <C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>' |
||||
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld |
||||
let i += 1 |
||||
endwhile |
||||
|
||||
" Exit from inside the matching pair: |
||||
for delim in s:g('right_delims') |
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>' |
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate'. delim |
||||
endfor |
||||
|
||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes: |
||||
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR> |
||||
for delim in s:g('quotes_list') |
||||
if delim == '|' |
||||
let delim = '<Bar>' |
||||
endif |
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>' |
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate' . delim |
||||
endfor |
||||
|
||||
" Try to fix the use of apostrophes (kept for backward compatibility): |
||||
" inoremap <silent> <buffer> n't n't |
||||
for map in s:g('apostrophes_list') |
||||
exec "inoremap <silent> " . map . " " . map |
||||
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map |
||||
endfor |
||||
endfunction "}}} |
||||
|
||||
function! s:ExtraMappings() "{{{ |
||||
" If pair is empty, delete both delimiters: |
||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR> |
||||
if !hasmapto('<Plug>delimitMateBS','i') && maparg('<BS>'. 'i') == '' |
||||
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS |
||||
endif |
||||
" If pair is empty, delete closing delimiter: |
||||
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>" |
||||
if !hasmapto('<Plug>delimitMateS-BS','i') && maparg('<S-BS>', 'i') == '' |
||||
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS |
||||
endif |
||||
" Expand return if inside an empty pair: |
||||
inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR> |
||||
if s:g('expand_cr') && !hasmapto('<Plug>delimitMateCR', 'i') && maparg('<CR>', 'i') == '' |
||||
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR |
||||
endif |
||||
" Expand space if inside an empty pair: |
||||
inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR> |
||||
if s:g('expand_space') && !hasmapto('<Plug>delimitMateSpace', 'i') && maparg('<Space>', 'i') == '' |
||||
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace |
||||
endif |
||||
" Jump over any delimiter: |
||||
inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny()<CR> |
||||
if s:g('tab2exit') && !hasmapto('<Plug>delimitMateS-Tab', 'i') && maparg('<S-Tab>', 'i') == '' |
||||
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab |
||||
endif |
||||
" Jump over next delimiters |
||||
inoremap <buffer> <Plug>delimitMateJumpMany <C-R>=delimitMate#JumpMany()<CR> |
||||
if !hasmapto('<Plug>delimitMateJumpMany', 'i') && maparg("<C-G>g", 'i') == '' |
||||
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
"}}} |
||||
|
||||
" Commands: {{{ |
||||
|
||||
call s:DelimitMateDo() |
||||
|
||||
" Let me refresh without re-loading the buffer: |
||||
command! -bar DelimitMateReload call s:DelimitMateDo(1) |
||||
|
||||
" Quick test: |
||||
command! -bar DelimitMateTest call s:TestMappingsDo() |
||||
|
||||
" Switch On/Off: |
||||
command! -bar DelimitMateSwitch call s:DelimitMateSwitch() |
||||
"}}} |
||||
|
||||
" Autocommands: {{{ |
||||
|
||||
augroup delimitMate |
||||
au! |
||||
" Run on file type change. |
||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo() |
||||
autocmd FileType * call <SID>DelimitMateDo() |
||||
|
||||
" Run on new buffers. |
||||
autocmd BufNewFile,BufRead,BufEnter * |
||||
\ if !exists('b:delimitMate_was_here') | |
||||
\ call <SID>DelimitMateDo() | |
||||
\ let b:delimitMate_was_here = 1 | |
||||
\ endif |
||||
augroup END |
||||
|
||||
"}}} |
||||
|
||||
let &cpo = save_cpo |
||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim |
||||
" vim:foldmethod=marker:foldcolumn=4 |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
The plugins runVimTests (http://www.vim.org/scripts/script.php?script_id=2565) |
||||
and VimTAP (http://www.vim.org/scripts/script.php?script_id=2213) are needed to |
||||
run these tests. |
||||
|
||||
Besides the _setup.vim configuration file present in this repo you need to |
||||
create a global one and place it in the same dir where the runVimTests |
||||
executable is located. Assuming the executable is at '~/bin/runVimTests' this |
||||
global configuration file should be '~/bin/runVimTestsSetup.vim' and should |
||||
have something like the following lines inside of it: |
||||
|
||||
" Prepend tests repos to &rtp |
||||
let &runtimepath = '/path/to/runVimTests_dir,' . &rtp |
||||
let &runtimepath = '/path/to/vimTAP_dir,' . &rtp |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after' |
||||
set bs=2 |
||||
ru plugin/delimitMate.vim |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
let g:delimitMate_autoclose = 1 |
||||
"(x" "(x)" |
||||
"(\<BS>x" "x" |
||||
"()x" "()x" |
||||
"((\<C-G>gx" "(())x" |
||||
"(x\<Esc>u" "" |
||||
"@(x" "@(x)" |
||||
"@#\<Left>(x" "@(x)#" |
||||
"(\<S-Tab>x" "()x" |
||||
let g:delimitMate_autoclose = 0 |
||||
"(x" "(x" |
||||
"()x" "(x)" |
||||
"())x" "()x" |
||||
"()\<BS>x" "x" |
||||
"@()x" "@(x)" |
||||
"@#\<Left>()x" "@(x)#" |
||||
let g:delimitMate_expand_space = 1 |
||||
let g:delimitMate_autoclose = 1 |
||||
"(\<Space>x" "( x )" |
||||
"(\<Space>\<BS>x" "(x)" |
||||
let g:delimitMate_autoclose = 0 |
||||
"()\<Space>\<BS>x" "(x)" |
||||
let g:delimitMate_autoclose = 1 |
||||
# Handle backspace gracefully. |
||||
set backspace= |
||||
"(\<Esc>a\<BS>x" "(x)" |
||||
set bs=2 |
||||
# closing parens removes characters. #133 |
||||
"(a\<Esc>i)" "()a)" |
||||
|
||||
# Add semicolon next to the closing paren. Issue #77. |
||||
new |
||||
let b:delimitMate_eol_marker = ';' |
||||
"abc(x" "abc(x);" |
||||
%d |
||||
# BS should behave accordingly. |
||||
"abc(\<BS>" "abc;" |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!' |
||||
let lines = readfile(expand('<sfile>:t:r').'.txt') |
||||
call vimtest#StartTap() |
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) |
||||
let itemsnumber = len(split(g:delimitMate_matchpairs, ',')) |
||||
call vimtap#Plan(testsnumber * itemsnumber) |
||||
let tcount = 1 |
||||
let reload = 1 |
||||
for item in lines |
||||
if item =~ '^#\|^\s*$' |
||||
" A comment or empty line. |
||||
continue |
||||
endif |
||||
if item !~ '^"' |
||||
" A command. |
||||
exec item |
||||
call vimtap#Diag(item) |
||||
let reload = 1 |
||||
continue |
||||
endif |
||||
if reload |
||||
DelimitMateReload |
||||
call vimtap#Diag('DelimitMateReload') |
||||
let reload = 0 |
||||
endif |
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"') |
||||
for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")') |
||||
let input2 = substitute(input, '(', s:l, 'g') |
||||
let input2 = substitute(input2, ')', s:r, 'g') |
||||
let output2 = substitute(output, '(', s:l, 'g') |
||||
let output2 = substitute(output2, ')', s:r, 'g') |
||||
%d |
||||
exec 'normal i'.eval(input2)."\<Esc>" |
||||
let line = getline('.') |
||||
let passed = line == eval(output2) |
||||
call vimtap#Is(line, eval(output2), input2) |
||||
", input2 . ' => ' . string(line) . |
||||
" \ (passed ? ' =' : ' !') . '= ' . string(eval(output2))) |
||||
let tcount += 1 |
||||
endfor |
||||
endfor |
||||
call vimtest#Quit() |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
let g:delimitMate_autoclose = 1 |
||||
"'x" "'x'" |
||||
"'x\<Esc>u" "" |
||||
"''x" "''x" |
||||
"'\<BS>x" "x" |
||||
"'\<C-G>gx" "''x" |
||||
"'\"x" "'\"x\"'" |
||||
"@'x" "@'x'" |
||||
"@#\<Left>'x" "@'x'#" |
||||
"'\<S-Tab>x" "''x" |
||||
"abc'" "abc'" |
||||
"abc\\'x" "abc\\'x" |
||||
"u'Привет'" "u'Привет'" |
||||
"u'string'" "u'string'" |
||||
let g:delimitMate_autoclose = 0 |
||||
"'x" "'x" |
||||
"''x" "'x'" |
||||
"'''x" "''x" |
||||
"''\<BS>x" "x" |
||||
"@''x" "@'x'" |
||||
"@#\<Left>''x" "@'x'#" |
||||
let g:delimitMate_expand_space = 1 |
||||
let g:delimitMate_autoclose = 1 |
||||
"'\<Space>x" "' x '" |
||||
"'\<Space>\<BS>x" "'x'" |
||||
"abc\\''\<Space>x" "abc\\' x'" |
||||
let g:delimitMate_autoclose = 0 |
||||
"''\<Space>\<BS>x" "'x'" |
||||
let g:delimitMate_autoclose = 1 |
||||
# Handle backspace gracefully. |
||||
set backspace= |
||||
"'\<Esc>a\<BS>x" "'x'" |
||||
set backspace=2 |
||||
set cpo=ces$ |
||||
"'x" "'x'" |
||||
# Make sure smart quote works beyond first column. |
||||
" 'x" " 'x'" |
||||
# Make sure we jump over a quote on the right. #89. |
||||
"('test'x" "('test'x)" |
||||
# Duplicate whole line when inserting quote at bol #105 |
||||
"}\<Home>'" "''}" |
||||
"'\<Del>abc '" "'abc '" |
||||
"''abc '" "''abc ''" |
||||
# Nesting quotes: |
||||
let g:delimitMate_nesting_quotes = split(g:delimitMate_quotes, '\s\+') |
||||
"'''x" "'''x'''" |
||||
"''''x" "''''x''''" |
||||
"''x" "''x" |
||||
"'x" "'x'" |
||||
unlet g:delimitMate_nesting_quotes |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
let g:delimitMate_quotes = '" '' ` ” « |' |
||||
let lines = readfile(expand('<sfile>:t:r').'.txt') |
||||
call vimtest#StartTap() |
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) |
||||
let itemsnumber = len(split(g:delimitMate_quotes, ' ')) |
||||
call vimtap#Plan(testsnumber * itemsnumber) |
||||
let reload = 1 |
||||
let tcount = 1 |
||||
for item in lines |
||||
if item =~ '^#\|^\s*$' |
||||
" A comment or empty line. |
||||
continue |
||||
endif |
||||
if item !~ '^"' |
||||
" A command. |
||||
exec item |
||||
call vimtap#Diag(item) |
||||
let reload = 1 |
||||
continue |
||||
endif |
||||
if reload |
||||
DelimitMateReload |
||||
call vimtap#Diag('DelimitMateReload') |
||||
let reload = 0 |
||||
endif |
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"') |
||||
let quotes = split(g:delimitMate_quotes, '\s') |
||||
for quote in quotes |
||||
let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g') |
||||
let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g') |
||||
%d |
||||
exec 'normal i'.eval(input_q)."\<Esc>" |
||||
let line = getline('.') |
||||
let passed = line == eval(output_q) |
||||
if quote == '”' || tcount == 31 |
||||
call vimtap#Todo(1) |
||||
endif |
||||
if 1 "!vimtap#Skip(1, tcount != 21, 'Test 21') |
||||
call vimtap#Ok(passed, eval(substitute(input_q, '\\<', '<','g')) . ' => ' . line . |
||||
\ (passed ? ' =' : ' !') . '= ' . eval(output_q)) |
||||
endif |
||||
let tcount += 1 |
||||
endfor |
||||
endfor |
||||
call vimtest#Quit() |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
# |
||||
%d |
||||
filetype indent on |
||||
set bs=2 et sts=4 sw=4 ft=javascript |
||||
call setline(1, '$(document).ready(function() {})') |
||||
DelimitMateReload |
||||
exec "normal 31|i\<CR>x\<Esc>" |
||||
================================================================================ |
||||
$(document).ready(function() { |
||||
x |
||||
}) |
||||
-------------------------------------------------------------------------------- |
||||
# Issue #95 |
||||
new |
||||
let b:delimitMate_jump_expansion = 1 |
||||
DelimitMateReload |
||||
exec "normal i(\<CR>test)x" |
||||
================================================================================ |
||||
( |
||||
test |
||||
)x |
||||
-------------------------------------------------------------------------------- |
||||
# Remove CR expansion on BS |
||||
%d |
||||
exec "normal i(\<CR>\<BS>x" |
||||
================================================================================ |
||||
(x) |
||||
-------------------------------------------------------------------------------- |
||||
# Consider indentation with BS inside an empty CR expansion. |
||||
%d |
||||
exec "normal i( \<CR>\<BS>\<BS>x" |
||||
================================================================================ |
||||
(x) |
||||
-------------------------------------------------------------------------------- |
||||
# Conflict with indentation settings (cindent). Issue #95 |
||||
se cindent |
||||
call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}']) |
||||
call cursor(3, 8) |
||||
normal a}x |
||||
================================================================================ |
||||
sub foo { |
||||
while (1) { |
||||
|
||||
}x |
||||
} |
||||
-------------------------------------------------------------------------------- |
||||
%d |
||||
call setline(1, '"{bracketed}') |
||||
normal A"x |
||||
================================================================================ |
||||
"{bracketed}"x |
||||
-------------------------------------------------------------------------------- |
||||
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested |
||||
# with :normal |
||||
new |
||||
autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual |
||||
autocmd InsertLeave * let &foldmethod = w:fdm |
||||
set foldmethod=marker |
||||
set foldmarker={,} |
||||
set foldlevel=0 |
||||
set backspace=2 |
||||
exec "normal iabc {\<CR>x" |
||||
================================================================================ |
||||
abc { |
||||
x |
||||
} |
||||
-------------------------------------------------------------------------------- |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
let g:delimitMate_expand_cr = 1 |
||||
"DelimitMateReload |
||||
let lines = readfile(expand('<sfile>:t:r').'.txt') |
||||
call vimtest#StartTap() |
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$''')) |
||||
call vimtap#Plan(testsnumber) |
||||
let tcount = 1 |
||||
let expect = 0 |
||||
let evaluate = 0 |
||||
let commands = [] |
||||
let header = '' |
||||
for item in lines |
||||
if item =~ '^=\{80}$' |
||||
let expect = 1 |
||||
let expected = [] |
||||
continue |
||||
endif |
||||
|
||||
if item =~ '^#' && expect == 0 |
||||
" A comment. |
||||
let header = empty(header) ? item[1:] : 'Lines should match.' |
||||
continue |
||||
endif |
||||
if item =~ '^\s*$' && expect == 0 |
||||
" An empty line. |
||||
continue |
||||
endif |
||||
if ! expect |
||||
" A command. |
||||
call add(commands, item) |
||||
exec item |
||||
"call vimtap#Diag(item) |
||||
continue |
||||
endif |
||||
if item =~ '^-\{80}$' |
||||
let expect = 0 |
||||
endif |
||||
if expect |
||||
call add(expected, item) |
||||
continue |
||||
endif |
||||
let lines = getline(1, line('$')) |
||||
let passed = lines == expected |
||||
echom string(lines) |
||||
echom string(expected) |
||||
call vimtap#Is(lines, expected, header) |
||||
echom string(commands) |
||||
for cmd in commands |
||||
call vimtap#Diag(cmd) |
||||
endfor |
||||
let commands = [] |
||||
let header = '' |
||||
let tcount += 1 |
||||
endfor |
||||
call vimtest#Quit() |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
# Issue #95 |
||||
new |
||||
let b:delimitMate_jump_expansion = 1 |
||||
DelimitMateReload |
||||
exec "normal i( test)x" |
||||
================================================================================ |
||||
( test )x |
||||
-------------------------------------------------------------------------------- |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
let g:delimitMate_expand_space = 1 |
||||
"DelimitMateReload |
||||
let lines = readfile(expand('<sfile>:t:r').'.txt') |
||||
call vimtest#StartTap() |
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$''')) |
||||
call vimtap#Plan(testsnumber) |
||||
let tcount = 1 |
||||
let expect = 0 |
||||
let evaluate = 0 |
||||
for item in lines |
||||
if item =~ '^=\{80}$' |
||||
let expect = 1 |
||||
let expected = [] |
||||
continue |
||||
endif |
||||
|
||||
if item =~ '^#\|^\s*$' && expect == 0 |
||||
" A comment or empty line. |
||||
continue |
||||
endif |
||||
if ! expect |
||||
" A command. |
||||
exec item |
||||
call vimtap#Diag(item) |
||||
continue |
||||
endif |
||||
if item =~ '^-\{80}$' |
||||
let expect = 0 |
||||
endif |
||||
if expect |
||||
call add(expected, item) |
||||
continue |
||||
endif |
||||
let lines = getline(1, line('$')) |
||||
let passed = lines == expected |
||||
echom string(lines) |
||||
echom string(expected) |
||||
call vimtap#Ok(passed, string(expected) . |
||||
\ (passed ? ' =' : ' !') . '= ' . string(lines)) |
||||
let tcount += 1 |
||||
endfor |
||||
call vimtest#Quit() |
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
*errormarker* Plugin to highlight error positions v0.1.13 |
||||
|
||||
ERROR MARKER REFERENCE MANUAL ~ |
||||
|
||||
1. Usage |errormarker-usage| |
||||
2. Customization |errormarker-customization| |
||||
3. Credits |errormarker-credits| |
||||
4. Changelog |errormarker-changelog| |
||||
|
||||
This plugin is only available if Vim was compiled with the |+signs| feature |
||||
and 'compatible' is not set. |
||||
|
||||
============================================================================== |
||||
1. USAGE *errormarker-usage* |
||||
|
||||
This plugin hooks the quickfix command |QuickFixCmdPost| and generates error |
||||
markers for every line that contains an error. Vim has to be compiled with |
||||
|+signs| for this to work. |
||||
|
||||
Additionally, a tooltip with the error message is shown when you hover with |
||||
the mouse over a line with an error (only available when compiled with the |
||||
|+balloon_eval| feature), or when you press <Leader>cc in normal mode. This |
||||
functionality is also available with the |:ErrorAtCursor| command. |
||||
|
||||
The functionality mentioned here is a plugin, see |add-plugin|. This plugin is |
||||
only available if 'compatible' is not set and Vim was compiled with |+signs| |
||||
and |+autocmd| support. You can avoid loading this plugin by setting the |
||||
"loaded_errormarker" variable in your |vimrc| file: > |
||||
:let loaded_errormarker = 1 |
||||
|
||||
============================================================================== |
||||
2. CUSTOMIZATION *errormarker-customization* |
||||
|
||||
You can customize the signs that are used by Vim to mark warnings and errors |
||||
(see |:sign-define| for details). |
||||
|
||||
*errormarker_erroricon* *errormarker_warningicon* |
||||
The icons that are used for the warnings and error signs in the GUI version of |
||||
Vim can be set by > |
||||
:let errormarker_erroricon = "/path/to/error/icon/name.png" |
||||
:let errormarker_warningicon = "/path/to/warning/icon/name.png" |
||||
If an icon is not found, text-only markers are displayed instead. The bitmap |
||||
should fit into the place of two characters. |
||||
|
||||
You must use full paths for these variables, for icons in your home directory |
||||
expand the paths in your .vimrc with something like > |
||||
:let errormarker_erroricon = expand ("~/.vim/icons/error.png") |
||||
To get working icons on Microsoft Windows, place icons for errors and warnings |
||||
(you can use Google at http://images.google.com/images?q=error&imgsz=icon to |
||||
find some nice ones) as error.bmp and warning.bmp in your home directory at |
||||
C:\Documents and Settings\<user>\vimfiles\icons. |
||||
|
||||
*errormarker_errortext* *errormarker_warningtext* |
||||
The text that is displayed without a GUI or if the icon files can not be found |
||||
can be set by > |
||||
:let errormarker_errortext = "Er" |
||||
:let errormarker_warningtext = "Wa" |
||||
The maximum length is two characters. |
||||
|
||||
*errormarker_errorgroup* *errormarker_warninggroup* |
||||
The hightlighting groups that are used to mark the lines that contain warnings |
||||
and errors can be set by > |
||||
:let errormarker_errorgroup = "ErrorMsg" |
||||
:let errormarker_warninggroup = "Todo" |
||||
< |
||||
*errormarker_warningtypes* |
||||
If the compiler reports a severity for the error messages this can be used to |
||||
distinguish between warnings and errors. Vim uses a single character error |
||||
type that can be parsed with |errorformat| (%t). The error types that should |
||||
be treated as warnings can be set by > |
||||
let errormarker_warningtypes = "wWiI" |
||||
|
||||
For example, the severity of error messages from gcc |
||||
averagergui.cpp|18 warning| unused parameter ‘file’ ~ |
||||
averagergui.cpp|33 error| expected class-name before ‘I’ ~ |
||||
can be parsed by adding the following lines to your .vimrc > |
||||
let &errorformat="%f:%l: %t%*[^:]:%m," . &errorformat |
||||
let &errorformat="%f:%l:%c: %t%*[^:]:%m," . &errorformat |
||||
let errormarker_warningtypes = "wW" |
||||
|
||||
If you use a different locale than English, this may also be needed: > |
||||
set makeprg=LANGUAGE=C\ make |
||||
< |
||||
*errormarker_disablemappings* *\cc* *:ErrorAtCursor* |
||||
To show the error message at the cursor position (e.g. if you are working from |
||||
within a terminal, where tooltips are not available), the following command |
||||
and shortcut are defined: > |
||||
:ErrorAtCursor |
||||
:nmap <silent> <unique> <Leader>cc :ErrorAtCursor<CR> |
||||
|
||||
The shortcut is only defined if no other mapping to ErrorAtCursor<CR> can be |
||||
found, and can be completely disabled by > |
||||
let errormarker_disablemappings = 1 |
||||
< |
||||
|
||||
============================================================================== |
||||
3. CREDITS *errormarker-credits* |
||||
|
||||
Author: Michael Hofmann <mh21 at piware dot de> |
||||
|
||||
============================================================================== |
||||
4. CHANGELOG *errormarker-changelog* |
||||
|
||||
0.1.13 - shortcut can be disabled (thanks Michael Jansen) |
||||
0.1.12 - shortcut (<Leader>cc) to show error at cursor (thanks Eric Rannaud) |
||||
0.1.11 - changelog fix |
||||
0.1.10 - removes accidental dependency on NerdEcho |
||||
0.1.9 - fixes Win32 icon display |
||||
0.1.8 - check for Vim version |
||||
0.1.7 - fixes gcc error message parsing example |
||||
0.1.6 - support for GetLatestVimScripts (vimscript#642) |
||||
0.1.5 - clarified documentation about paths |
||||
0.1.4 - fixes icon name and variable escaping |
||||
0.1.3 - customizable signs |
||||
- distinguishes between warnings and errors |
||||
0.1.2 - documentation |
||||
0.1.1 - handles nonexistent icons gracefully |
||||
- tooltips only used if Vim has balloon-eval support |
||||
0.1 - initial release |
||||
|
||||
============================================================================== |
||||
|
||||
vim:tw=78:ts=8:ft=help:norl: |
@ -0,0 +1,401 @@
@@ -0,0 +1,401 @@
|
||||
" ============================================================================ |
||||
" Copyright: Copyright (C) 2007,2010 Michael Hofmann |
||||
" Permission is hereby granted to use and distribute this code, |
||||
" with or without modifications, provided that this copyright |
||||
" notice is copied with it. Like anything else that's free, |
||||
" errormarker.vim is provided *as is* and comes with no |
||||
" warranty of any kind, either expressed or implied. In no |
||||
" event will the copyright holder be liable for any damages |
||||
" resulting from the use of this software. |
||||
" Name Of File: errormarker.vim |
||||
" Description: Sets markers for compile errors |
||||
" Maintainer: Michael Hofmann (mh21 at piware dot de) |
||||
" Version: See g:loaded_errormarker for version number. |
||||
" Usage: Normally, this file should reside in the plugins |
||||
" directory and be automatically sourced. If not, you must |
||||
" manually source this file using ':source errormarker.vim'. |
||||
|
||||
" === Support for automatic retrieval (Vim script 642) ==================={{{1 |
||||
|
||||
" GetLatestVimScripts: 1861 1 :AutoInstall: errormarker.vim |
||||
|
||||
" === Initialization ====================================================={{{1 |
||||
|
||||
" Exit when the Vim version is too old or missing some features |
||||
if v:version < 700 || !has("signs") || !has("autocmd") |
||||
finish |
||||
endif |
||||
|
||||
" Exit quickly when the script has already been loaded or when 'compatible' |
||||
" is set. |
||||
if exists("g:loaded_errormarker") || &compatible |
||||
finish |
||||
endif |
||||
|
||||
" Version number. |
||||
let g:loaded_errormarker = "0.1.13" |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
command ErrorAtCursor call ShowErrorAtCursor() |
||||
if !hasmapto(":ErrorAtCursor<cr>", "n") && |
||||
\ (!exists('g:errormarker_disablemappings') || !g:errormarker_disablemappings) |
||||
nmap <silent> <unique> <Leader>cc :ErrorAtCursor<CR> |
||||
endif |
||||
|
||||
function! s:DefineVariable(name, default) |
||||
if !exists(a:name) |
||||
execute 'let ' . a:name . ' = "' . escape(a:default, '\"') . '"' |
||||
endif |
||||
endfunction |
||||
|
||||
" === Variables =========================================================={{{1 |
||||
|
||||
" Defines the icon to show for errors in the gui |
||||
call s:DefineVariable("g:errormarker_erroricon", |
||||
\ has('win32') ? expand("~/vimfiles/icons/error.bmp") : |
||||
\ "/usr/share/icons/gnome/16x16/status/dialog-error.png") |
||||
|
||||
" Defines the icon to show for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warningicon", |
||||
\ has('win32') ? expand("~/vimfiles/icons/warning.bmp") : |
||||
\ "/usr/share/icons/gnome/16x16/status/dialog-warning.png") |
||||
|
||||
" Defines the text (two characters) to show for errors in the gui |
||||
call s:DefineVariable("g:errormarker_errortext", "EE") |
||||
|
||||
" Defines the text (two characters) to show for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warningtext", "WW") |
||||
|
||||
" Defines the highlighting group to use for errors in the gui |
||||
call s:DefineVariable("g:errormarker_errorgroup", "Todo") |
||||
|
||||
" Defines the highlighting group to use for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warninggroup", "Todo") |
||||
|
||||
" Defines the error types that should be treated as warning |
||||
call s:DefineVariable("g:errormarker_warningtypes", "wW") |
||||
|
||||
" === Global ============================================================={{{1 |
||||
|
||||
" Define the signs |
||||
let s:erroricon = "" |
||||
if filereadable(g:errormarker_erroricon) |
||||
let s:erroricon = " icon=" . escape(g:errormarker_erroricon, '| \') |
||||
endif |
||||
let s:warningicon = "" |
||||
if filereadable(g:errormarker_warningicon) |
||||
let s:warningicon = " icon=" . escape(g:errormarker_warningicon, '| \') |
||||
endif |
||||
execute "sign define errormarker_error text=" . g:errormarker_errortext . |
||||
\ " linehl=" . g:errormarker_errorgroup . s:erroricon |
||||
|
||||
execute "sign define errormarker_warning text=" . g:errormarker_warningtext . |
||||
\ " linehl=" . g:errormarker_warninggroup . s:warningicon |
||||
|
||||
" Setup the autocommands that handle the MRUList and other stuff. |
||||
augroup errormarker |
||||
autocmd QuickFixCmdPost make call <SID>SetErrorMarkers() |
||||
augroup END |
||||
|
||||
" === Functions =========================================================={{{1 |
||||
|
||||
function! ShowErrorAtCursor() |
||||
let [l:bufnr, l:lnum] = getpos(".")[0:1] |
||||
let l:bufnr = bufnr("%") |
||||
for l:d in getqflist() |
||||
if (l:d.bufnr != l:bufnr || l:d.lnum != l:lnum) |
||||
continue |
||||
endif |
||||
redraw | echomsg l:d.text |
||||
endfor |
||||
echo |
||||
endfunction |
||||
|
||||
function! s:SetErrorMarkers() |
||||
if has ('balloon_eval') |
||||
let &balloonexpr = "<SNR>" . s:SID() . "_ErrorMessageBalloons()" |
||||
set ballooneval |
||||
endif |
||||
|
||||
sign unplace * |
||||
|
||||
let l:positions = {} |
||||
for l:d in getqflist() |
||||
if (l:d.bufnr == 0 || l:d.lnum == 0) |
||||
continue |
||||
endif |
||||
|
||||
let l:key = l:d.bufnr . l:d.lnum |
||||
if has_key(l:positions, l:key) |
||||
continue |
||||
endif |
||||
let l:positions[l:key] = 1 |
||||
|
||||
if strlen(l:d.type) && |
||||
\ stridx(g:errormarker_warningtypes, l:d.type) >= 0 |
||||
let l:name = "errormarker_warning" |
||||
else |
||||
let l:name = "errormarker_error" |
||||
endif |
||||
execute ":sign place " . l:key . " line=" . l:d.lnum . " name=" . |
||||
\ l:name . " buffer=" . l:d.bufnr |
||||
endfor |
||||
endfunction |
||||
|
||||
function! s:ErrorMessageBalloons() |
||||
for l:d in getqflist() |
||||
if (d.bufnr == v:beval_bufnr && d.lnum == v:beval_lnum) |
||||
return l:d.text |
||||
endif |
||||
endfor |
||||
return "" |
||||
endfunction |
||||
|
||||
function! s:SID() |
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$') |
||||
endfunction |
||||
|
||||
" === Help file installation ============================================={{{1 |
||||
|
||||
" Original version: Copyright (C) Mathieu Clabaut, author of vimspell |
||||
" http://www.vim.org/scripts/script.php?script_id=465 |
||||
function! s:InstallDocumentation(full_name, revision) |
||||
" Name of the document path based on the system we use: |
||||
if has("vms") |
||||
" No chance that this script will work with |
||||
" VMS - to much pathname juggling here. |
||||
return 1 |
||||
elseif (has("unix")) |
||||
" On UNIX like system, using forward slash: |
||||
let l:slash_char = '/' |
||||
let l:mkdir_cmd = ':silent !mkdir -p ' |
||||
else |
||||
" On M$ system, use backslash. Also mkdir syntax is different. |
||||
" This should only work on W2K and up. |
||||
let l:slash_char = '\' |
||||
let l:mkdir_cmd = ':silent !mkdir ' |
||||
endif |
||||
|
||||
let l:doc_path = l:slash_char . 'doc' |
||||
let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' |
||||
|
||||
" Figure out document path based on full name of this script: |
||||
let l:vim_plugin_path = fnamemodify(a:full_name, ':h') |
||||
let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
echo "Creating doc path: " . l:vim_doc_path |
||||
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
" Try a default configuration in user home: |
||||
let l:vim_doc_path = expand("~") . l:doc_home |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
echohl WarningMsg |
||||
echo "Unable to create documentation directory.\ntype :help add-local-help for more information." |
||||
echohl None |
||||
return 0 |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
|
||||
" Exit if we have problem to access the document directory: |
||||
if (!isdirectory(l:vim_plugin_path) || !isdirectory(l:vim_doc_path) || filewritable(l:vim_doc_path) != 2) |
||||
return 0 |
||||
endif |
||||
|
||||
" Full name of script and documentation file: |
||||
let l:script_name = fnamemodify(a:full_name, ':t') |
||||
let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt' |
||||
let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name |
||||
let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name |
||||
|
||||
" Bail out if document file is still up to date: |
||||
if (filereadable(l:doc_file) && getftime(l:plugin_file) < getftime(l:doc_file)) |
||||
return 0 |
||||
endif |
||||
|
||||
" Prepare window position restoring command: |
||||
if (strlen(@%)) |
||||
let l:go_back = 'b ' . bufnr("%") |
||||
else |
||||
let l:go_back = 'enew!' |
||||
endif |
||||
|
||||
" Create a new buffer & read in the plugin file (me): |
||||
setl nomodeline |
||||
exe 'enew!' |
||||
silent exe 'r ' . l:plugin_file |
||||
|
||||
setl modeline |
||||
let l:buf = bufnr("%") |
||||
setl noswapfile modifiable |
||||
|
||||
norm zR |
||||
norm gg |
||||
|
||||
" Delete from first line to a line starts with |
||||
" === START_DOC |
||||
silent 1,/^=\{3,}\s\+START_DOC\C/ d |
||||
|
||||
" Delete from a line starts with |
||||
" === END_DOC |
||||
" to the end of the documents: |
||||
silent /^=\{3,}\s\+END_DOC\C/,$ d |
||||
|
||||
" Add modeline for help doc: the modeline string is mangled intentionally |
||||
" to avoid it be recognized by Vim: |
||||
call append(line('$'), '') |
||||
call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:') |
||||
|
||||
" Replace revision: |
||||
silent exe "normal :1s/#version#/ v" . a:revision . "/\<CR>" |
||||
|
||||
" Save the help document: |
||||
silent exe 'w! ' . l:doc_file |
||||
exe l:go_back |
||||
exe 'bw ' . l:buf |
||||
|
||||
" Build help tags: |
||||
exe 'helptags ' . l:vim_doc_path |
||||
|
||||
return 1 |
||||
endfunction |
||||
|
||||
call s:InstallDocumentation(expand('<sfile>:p'), g:loaded_errormarker) |
||||
|
||||
" === Cleanup ============================================================{{{1 |
||||
|
||||
let &cpo = s:save_cpo |
||||
|
||||
finish |
||||
|
||||
" === Help file =========================================================={{{1 |
||||
=== START_DOC |
||||
*errormarker* Plugin to highlight error positions #version# |
||||
|
||||
ERROR MARKER REFERENCE MANUAL ~ |
||||
|
||||
1. Usage |errormarker-usage| |
||||
2. Customization |errormarker-customization| |
||||
3. Credits |errormarker-credits| |
||||
4. Changelog |errormarker-changelog| |
||||
|
||||
This plugin is only available if Vim was compiled with the |+signs| feature |
||||
and 'compatible' is not set. |
||||
|
||||
============================================================================== |
||||
1. USAGE *errormarker-usage* |
||||
|
||||
This plugin hooks the quickfix command |QuickFixCmdPost| and generates error |
||||
markers for every line that contains an error. Vim has to be compiled with |
||||
|+signs| for this to work. |
||||
|
||||
Additionally, a tooltip with the error message is shown when you hover with |
||||
the mouse over a line with an error (only available when compiled with the |
||||
|+balloon_eval| feature), or when you press <Leader>cc in normal mode. This |
||||
functionality is also available with the |:ErrorAtCursor| command. |
||||
|
||||
The functionality mentioned here is a plugin, see |add-plugin|. This plugin is |
||||
only available if 'compatible' is not set and Vim was compiled with |+signs| |
||||
and |+autocmd| support. You can avoid loading this plugin by setting the |
||||
"loaded_errormarker" variable in your |vimrc| file: > |
||||
:let loaded_errormarker = 1 |
||||
|
||||
============================================================================== |
||||
2. CUSTOMIZATION *errormarker-customization* |
||||
|
||||
You can customize the signs that are used by Vim to mark warnings and errors |
||||
(see |:sign-define| for details). |
||||
|
||||
*errormarker_erroricon* *errormarker_warningicon* |
||||
The icons that are used for the warnings and error signs in the GUI version of |
||||
Vim can be set by > |
||||
:let errormarker_erroricon = "/path/to/error/icon/name.png" |
||||
:let errormarker_warningicon = "/path/to/warning/icon/name.png" |
||||
If an icon is not found, text-only markers are displayed instead. The bitmap |
||||
should fit into the place of two characters. |
||||
|
||||
You must use full paths for these variables, for icons in your home directory |
||||
expand the paths in your .vimrc with something like > |
||||
:let errormarker_erroricon = expand ("~/.vim/icons/error.png") |
||||
To get working icons on Microsoft Windows, place icons for errors and warnings |
||||
(you can use Google at http://images.google.com/images?q=error&imgsz=icon to |
||||
find some nice ones) as error.bmp and warning.bmp in your home directory at |
||||
C:\Documents and Settings\<user>\vimfiles\icons. |
||||
|
||||
*errormarker_errortext* *errormarker_warningtext* |
||||
The text that is displayed without a GUI or if the icon files can not be found |
||||
can be set by > |
||||
:let errormarker_errortext = "Er" |
||||
:let errormarker_warningtext = "Wa" |
||||
The maximum length is two characters. |
||||
|
||||
*errormarker_errorgroup* *errormarker_warninggroup* |
||||
The hightlighting groups that are used to mark the lines that contain warnings |
||||
and errors can be set by > |
||||
:let errormarker_errorgroup = "ErrorMsg" |
||||
:let errormarker_warninggroup = "Todo" |
||||
< |
||||
*errormarker_warningtypes* |
||||
If the compiler reports a severity for the error messages this can be used to |
||||
distinguish between warnings and errors. Vim uses a single character error |
||||
type that can be parsed with |errorformat| (%t). The error types that should |
||||
be treated as warnings can be set by > |
||||
let errormarker_warningtypes = "wWiI" |
||||
|
||||
For example, the severity of error messages from gcc |
||||
averagergui.cpp|18 warning| unused parameter ‘file’ ~ |
||||
averagergui.cpp|33 error| expected class-name before ‘I’ ~ |
||||
can be parsed by adding the following lines to your .vimrc > |
||||
let &errorformat="%f:%l: %t%*[^:]:%m," . &errorformat |
||||
let &errorformat="%f:%l:%c: %t%*[^:]:%m," . &errorformat |
||||
let errormarker_warningtypes = "wW" |
||||
|
||||
If you use a different locale than English, this may also be needed: > |
||||
set makeprg=LANGUAGE=C\ make |
||||
< |
||||
*errormarker_disablemappings* *\cc* *:ErrorAtCursor* |
||||
To show the error message at the cursor position (e.g. if you are working from |
||||
within a terminal, where tooltips are not available), the following command |
||||
and shortcut are defined: > |
||||
:ErrorAtCursor |
||||
:nmap <silent> <unique> <Leader>cc :ErrorAtCursor<CR> |
||||
|
||||
The shortcut is only defined if no other mapping to ErrorAtCursor<CR> can be |
||||
found, and can be completely disabled by > |
||||
let errormarker_disablemappings = 1 |
||||
< |
||||
|
||||
============================================================================== |
||||
3. CREDITS *errormarker-credits* |
||||
|
||||
Author: Michael Hofmann <mh21 at piware dot de> |
||||
|
||||
============================================================================== |
||||
4. CHANGELOG *errormarker-changelog* |
||||
|
||||
0.1.13 - shortcut can be disabled (thanks Michael Jansen) |
||||
0.1.12 - shortcut (<Leader>cc) to show error at cursor (thanks Eric Rannaud) |
||||
0.1.11 - changelog fix |
||||
0.1.10 - removes accidental dependency on NerdEcho |
||||
0.1.9 - fixes Win32 icon display |
||||
0.1.8 - check for Vim version |
||||
0.1.7 - fixes gcc error message parsing example |
||||
0.1.6 - support for GetLatestVimScripts (vimscript#642) |
||||
0.1.5 - clarified documentation about paths |
||||
0.1.4 - fixes icon name and variable escaping |
||||
0.1.3 - customizable signs |
||||
- distinguishes between warnings and errors |
||||
0.1.2 - documentation |
||||
0.1.1 - handles nonexistent icons gracefully |
||||
- tooltips only used if Vim has balloon-eval support |
||||
0.1 - initial release |
||||
|
||||
============================================================================== |
||||
=== END_DOC |
||||
|
||||
" vim:ft=vim foldmethod=marker tw=78 |
@ -0,0 +1,401 @@
@@ -0,0 +1,401 @@
|
||||
" ============================================================================ |
||||
" Copyright: Copyright (C) 2007,2010 Michael Hofmann |
||||
" Permission is hereby granted to use and distribute this code, |
||||
" with or without modifications, provided that this copyright |
||||
" notice is copied with it. Like anything else that's free, |
||||
" errormarker.vim is provided *as is* and comes with no |
||||
" warranty of any kind, either expressed or implied. In no |
||||
" event will the copyright holder be liable for any damages |
||||
" resulting from the use of this software. |
||||
" Name Of File: errormarker.vim |
||||
" Description: Sets markers for compile errors |
||||
" Maintainer: Michael Hofmann (mh21 at piware dot de) |
||||
" Version: See g:loaded_errormarker for version number. |
||||
" Usage: Normally, this file should reside in the plugins |
||||
" directory and be automatically sourced. If not, you must |
||||
" manually source this file using ':source errormarker.vim'. |
||||
|
||||
" === Support for automatic retrieval (Vim script 642) ==================={{{1 |
||||
|
||||
" GetLatestVimScripts: 1861 1 :AutoInstall: errormarker.vim |
||||
|
||||
" === Initialization ====================================================={{{1 |
||||
|
||||
" Exit when the Vim version is too old or missing some features |
||||
if v:version < 700 || !has("signs") || !has("autocmd") |
||||
finish |
||||
endif |
||||
|
||||
" Exit quickly when the script has already been loaded or when 'compatible' |
||||
" is set. |
||||
if exists("g:loaded_errormarker") || &compatible |
||||
finish |
||||
endif |
||||
|
||||
" Version number. |
||||
let g:loaded_errormarker = "0.1.13" |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
command ErrorAtCursor call ShowErrorAtCursor() |
||||
if !hasmapto(":ErrorAtCursor<cr>", "n") && |
||||
\ (!exists('g:errormarker_disablemappings') || !g:errormarker_disablemappings) |
||||
nmap <silent> <unique> <Leader>cc :ErrorAtCursor<CR> |
||||
endif |
||||
|
||||
function! s:DefineVariable(name, default) |
||||
if !exists(a:name) |
||||
execute 'let ' . a:name . ' = "' . escape(a:default, '\"') . '"' |
||||
endif |
||||
endfunction |
||||
|
||||
" === Variables =========================================================={{{1 |
||||
|
||||
" Defines the icon to show for errors in the gui |
||||
call s:DefineVariable("g:errormarker_erroricon", |
||||
\ has('win32') ? expand("~/vimfiles/icons/error.bmp") : |
||||
\ "/usr/share/icons/gnome/16x16/status/dialog-error.png") |
||||
|
||||
" Defines the icon to show for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warningicon", |
||||
\ has('win32') ? expand("~/vimfiles/icons/warning.bmp") : |
||||
\ "/usr/share/icons/gnome/16x16/status/dialog-warning.png") |
||||
|
||||
" Defines the text (two characters) to show for errors in the gui |
||||
call s:DefineVariable("g:errormarker_errortext", "EE") |
||||
|
||||
" Defines the text (two characters) to show for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warningtext", "WW") |
||||
|
||||
" Defines the highlighting group to use for errors in the gui |
||||
call s:DefineVariable("g:errormarker_errorgroup", "Todo") |
||||
|
||||
" Defines the highlighting group to use for warnings in the gui |
||||
call s:DefineVariable("g:errormarker_warninggroup", "Todo") |
||||
|
||||
" Defines the error types that should be treated as warning |
||||
call s:DefineVariable("g:errormarker_warningtypes", "wW") |
||||
|
||||
" === Global ============================================================={{{1 |
||||
|
||||
" Define the signs |
||||
let s:erroricon = "" |
||||
if filereadable(g:errormarker_erroricon) |
||||
let s:erroricon = " icon=" . escape(g:errormarker_erroricon, '| \') |
||||
endif |
||||
let s:warningicon = "" |
||||
if filereadable(g:errormarker_warningicon) |
||||
let s:warningicon = " icon=" . escape(g:errormarker_warningicon, '| \') |
||||
endif |
||||
execute "sign define errormarker_error text=" . g:errormarker_errortext . |
||||
\ ' texthl=' . g:errormarker_errorgroup . ' linehl=' . g:errormarker_errorgroup |
||||
|
||||
execute "sign define errormarker_warning text=" . g:errormarker_warningtext . |
||||
\ ' texthl=' . g:errormarker_warninggroup . ' linehl=' . g:errormarker_warninggroup |
||||
|
||||
" Setup the autocommands that handle the MRUList and other stuff. |
||||
augroup errormarker |
||||
autocmd QuickFixCmdPost make call <SID>SetErrorMarkers() |
||||
augroup END |
||||
|
||||
" === Functions =========================================================={{{1 |
||||
|
||||
function! ShowErrorAtCursor() |
||||
let [l:bufnr, l:lnum] = getpos(".")[0:1] |
||||
let l:bufnr = bufnr("%") |
||||
for l:d in getqflist() |
||||
if (l:d.bufnr != l:bufnr || l:d.lnum != l:lnum) |
||||
continue |
||||
endif |
||||
redraw | echomsg l:d.text |
||||
endfor |
||||
echo |
||||
endfunction |
||||
|
||||
function! s:SetErrorMarkers() |
||||
if has ('balloon_eval') |
||||
let &balloonexpr = "<SNR>" . s:SID() . "_ErrorMessageBalloons()" |
||||
set ballooneval |
||||
endif |
||||
|
||||
sign unplace * |
||||
|
||||
let l:positions = {} |
||||
for l:d in getqflist() |
||||
if (l:d.bufnr == 0 || l:d.lnum == 0) |
||||
continue |
||||
endif |
||||
|
||||
let l:key = l:d.bufnr . l:d.lnum |
||||
if has_key(l:positions, l:key) |
||||
continue |
||||
endif |
||||
let l:positions[l:key] = 1 |
||||
|
||||
if strlen(l:d.type) && |
||||
\ stridx(g:errormarker_warningtypes, l:d.type) >= 0 |
||||
let l:name = "errormarker_warning" |
||||
else |
||||
let l:name = "errormarker_error" |
||||
endif |
||||
execute ":sign place " . l:key . " line=" . l:d.lnum . " name=" . |
||||
\ l:name . " buffer=" . l:d.bufnr |
||||
endfor |
||||
endfunction |
||||
|
||||
function! s:ErrorMessageBalloons() |
||||
for l:d in getqflist() |
||||
if (d.bufnr == v:beval_bufnr && d.lnum == v:beval_lnum) |
||||
return l:d.text |
||||
endif |
||||
endfor |
||||
return "" |
||||
endfunction |
||||
|
||||
function! s:SID() |
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$') |
||||
endfunction |
||||
|
||||
" === Help file installation ============================================={{{1 |
||||
|
||||
" Original version: Copyright (C) Mathieu Clabaut, author of vimspell |
||||
" http://www.vim.org/scripts/script.php?script_id=465 |
||||
function! s:InstallDocumentation(full_name, revision) |
||||
" Name of the document path based on the system we use: |
||||
if has("vms") |
||||
" No chance that this script will work with |
||||
" VMS - to much pathname juggling here. |
||||
return 1 |
||||
elseif (has("unix")) |
||||
" On UNIX like system, using forward slash: |
||||
let l:slash_char = '/' |
||||
let l:mkdir_cmd = ':silent !mkdir -p ' |
||||
else |
||||
" On M$ system, use backslash. Also mkdir syntax is different. |
||||
" This should only work on W2K and up. |
||||
let l:slash_char = '\' |
||||
let l:mkdir_cmd = ':silent !mkdir ' |
||||
endif |
||||
|
||||
let l:doc_path = l:slash_char . 'doc' |
||||
let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' |
||||
|
||||
" Figure out document path based on full name of this script: |
||||
let l:vim_plugin_path = fnamemodify(a:full_name, ':h') |
||||
let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
echo "Creating doc path: " . l:vim_doc_path |
||||
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
" Try a default configuration in user home: |
||||
let l:vim_doc_path = expand("~") . l:doc_home |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
||||
if (!(filewritable(l:vim_doc_path) == 2)) |
||||
echohl WarningMsg |
||||
echo "Unable to create documentation directory.\ntype :help add-local-help for more information." |
||||
echohl None |
||||
return 0 |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
|
||||
" Exit if we have problem to access the document directory: |
||||
if (!isdirectory(l:vim_plugin_path) || !isdirectory(l:vim_doc_path) || filewritable(l:vim_doc_path) != 2) |
||||
return 0 |
||||
endif |
||||
|
||||
" Full name of script and documentation file: |
||||
let l:script_name = fnamemodify(a:full_name, ':t') |
||||
let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt' |
||||
let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name |
||||
let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name |
||||
|
||||
" Bail out if document file is still up to date: |
||||
if (filereadable(l:doc_file) && getftime(l:plugin_file) < getftime(l:doc_file)) |
||||
return 0 |
||||
endif |
||||
|
||||
" Prepare window position restoring command: |
||||
if (strlen(@%)) |
||||
let l:go_back = 'b ' . bufnr("%") |
||||
else |
||||
let l:go_back = 'enew!' |
||||
endif |
||||
|
||||
" Create a new buffer & read in the plugin file (me): |
||||
setl nomodeline |
||||
exe 'enew!' |
||||
silent exe 'r ' . l:plugin_file |
||||
|
||||
setl modeline |
||||
let l:buf = bufnr("%") |
||||
setl noswapfile modifiable |
||||
|
||||
norm zR |
||||
norm gg |
||||
|
||||
" Delete from first line to a line starts with |
||||
" === START_DOC |
||||
silent 1,/^=\{3,}\s\+START_DOC\C/ d |
||||
|
||||
" Delete from a line starts with |
||||
" === END_DOC |
||||
" to the end of the documents: |
||||
silent /^=\{3,}\s\+END_DOC\C/,$ d |
||||
|
||||
" Add modeline for help doc: the modeline string is mangled intentionally |
||||
" to avoid it be recognized by Vim: |
||||
call append(line('$'), '') |
||||
call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:') |
||||
|
||||
" Replace revision: |
||||
silent exe "normal :1s/#version#/ v" . a:revision . "/\<CR>" |
||||
|
||||
" Save the help document: |
||||
silent exe 'w! ' . l:doc_file |
||||
exe l:go_back |
||||
exe 'bw ' . l:buf |
||||
|
||||
" Build help tags: |
||||
exe 'helptags ' . l:vim_doc_path |
||||
|
||||
return 1 |
||||
endfunction |
||||
|
||||
call s:InstallDocumentation(expand('<sfile>:p'), g:loaded_errormarker) |
||||
|
||||
" === Cleanup ============================================================{{{1 |
||||
|
||||
let &cpo = s:save_cpo |
||||
|
||||
finish |
||||
|
||||
" === Help file =========================================================={{{1 |
||||
=== START_DOC |
||||
*errormarker* Plugin to highlight error positions #version# |
||||
|
||||
ERROR MARKER REFERENCE MANUAL ~ |
||||
|
||||
1. Usage |errormarker-usage| |
||||
2. Customization |errormarker-customization| |
||||
3. Credits |errormarker-credits| |
||||
4. Changelog |errormarker-changelog| |
||||
|
||||
This plugin is only available if Vim was compiled with the |+signs| feature |
||||
and 'compatible' is not set. |
||||
|
||||
============================================================================== |
||||
1. USAGE *errormarker-usage* |
||||
|
||||
This plugin hooks the quickfix command |QuickFixCmdPost| and generates error |
||||
markers for every line that contains an error. Vim has to be compiled with |
||||
|+signs| for this to work. |
||||
|
||||
Additionally, a tooltip with the error message is shown when you hover with |
||||
the mouse over a line with an error (only available when compiled with the |
||||
|+balloon_eval| feature), or when you press <Leader>cc in normal mode. This |
||||
functionality is also available with the |:ErrorAtCursor| command. |
||||
|
||||
The functionality mentioned here is a plugin, see |add-plugin|. This plugin is |
||||
only available if 'compatible' is not set and Vim was compiled with |+signs| |
||||
and |+autocmd| support. You can avoid loading this plugin by setting the |
||||
"loaded_errormarker" variable in your |vimrc| file: > |
||||
:let loaded_errormarker = 1 |
||||
|
||||
============================================================================== |
||||
2. CUSTOMIZATION *errormarker-customization* |
||||
|
||||
You can customize the signs that are used by Vim to mark warnings and errors |
||||
(see |:sign-define| for details). |
||||
|
||||
*errormarker_erroricon* *errormarker_warningicon* |
||||
The icons that are used for the warnings and error signs in the GUI version of |
||||
Vim can be set by > |
||||
:let errormarker_erroricon = "/path/to/error/icon/name.png" |
||||
:let errormarker_warningicon = "/path/to/warning/icon/name.png" |
||||
If an icon is not found, text-only markers are displayed instead. The bitmap |
||||
should fit into the place of two characters. |
||||
|
||||
You must use full paths for these variables, for icons in your home directory |
||||
expand the paths in your .vimrc with something like > |
||||
:let errormarker_erroricon = expand ("~/.vim/icons/error.png") |
||||
To get working icons on Microsoft Windows, place icons for errors and warnings |
||||
(you can use Google at http://images.google.com/images?q=error&imgsz=icon to |
||||
find some nice ones) as error.bmp and warning.bmp in your home directory at |
||||
C:\Documents and Settings\<user>\vimfiles\icons. |
||||
|
||||
*errormarker_errortext* *errormarker_warningtext* |
||||
The text that is displayed without a GUI or if the icon files can not be found |
||||
can be set by > |
||||
:let errormarker_errortext = "Er" |
||||
:let errormarker_warningtext = "Wa" |
||||
The maximum length is two characters. |
||||
|
||||
*errormarker_errorgroup* *errormarker_warninggroup* |
||||
The hightlighting groups that are used to mark the lines that contain warnings |
||||
and errors can be set by > |
||||
:let errormarker_errorgroup = "ErrorMsg" |
||||
:let errormarker_warninggroup = "Todo" |
||||
< |
||||
*errormarker_warningtypes* |
||||
If the compiler reports a severity for the error messages this can be used to |
||||
distinguish between warnings and errors. Vim uses a single character error |
||||
type that can be parsed with |errorformat| (%t). The error types that should |
||||
be treated as warnings can be set by > |
||||
let errormarker_warningtypes = "wWiI" |
||||
|
||||
For example, the severity of error messages from gcc |
||||
averagergui.cpp|18 warning| unused parameter ‘file’ ~ |
||||
averagergui.cpp|33 error| expected class-name before ‘I’ ~ |
||||
can be parsed by adding the following lines to your .vimrc > |
||||
let &errorformat="%f:%l: %t%*[^:]:%m," . &errorformat |
||||
let &errorformat="%f:%l:%c: %t%*[^:]:%m," . &errorformat |
||||
let errormarker_warningtypes = "wW" |
||||
|
||||
If you use a different locale than English, this may also be needed: > |
||||
set makeprg=LANGUAGE=C\ make |
||||
< |
||||
*errormarker_disablemappings* *\cc* *:ErrorAtCursor* |
||||
To show the error message at the cursor position (e.g. if you are working from |
||||
within a terminal, where tooltips are not available), the following command |
||||
and shortcut are defined: > |
||||
:ErrorAtCursor |
||||
:nmap <silent> <unique> <Leader>cc :ErrorAtCursor<CR> |
||||
|
||||
The shortcut is only defined if no other mapping to ErrorAtCursor<CR> can be |
||||
found, and can be completely disabled by > |
||||
let errormarker_disablemappings = 1 |
||||
< |
||||
|
||||
============================================================================== |
||||
3. CREDITS *errormarker-credits* |
||||
|
||||
Author: Michael Hofmann <mh21 at piware dot de> |
||||
|
||||
============================================================================== |
||||
4. CHANGELOG *errormarker-changelog* |
||||
|
||||
0.1.13 - shortcut can be disabled (thanks Michael Jansen) |
||||
0.1.12 - shortcut (<Leader>cc) to show error at cursor (thanks Eric Rannaud) |
||||
0.1.11 - changelog fix |
||||
0.1.10 - removes accidental dependency on NerdEcho |
||||
0.1.9 - fixes Win32 icon display |
||||
0.1.8 - check for Vim version |
||||
0.1.7 - fixes gcc error message parsing example |
||||
0.1.6 - support for GetLatestVimScripts (vimscript#642) |
||||
0.1.5 - clarified documentation about paths |
||||
0.1.4 - fixes icon name and variable escaping |
||||
0.1.3 - customizable signs |
||||
- distinguishes between warnings and errors |
||||
0.1.2 - documentation |
||||
0.1.1 - handles nonexistent icons gracefully |
||||
- tooltips only used if Vim has balloon-eval support |
||||
0.1 - initial release |
||||
|
||||
============================================================================== |
||||
=== END_DOC |
||||
|
||||
" vim:ft=vim foldmethod=marker tw=78 |
@ -0,0 +1,557 @@
@@ -0,0 +1,557 @@
|
||||
" vim:ft=vim foldmethod=marker tw=78: |
||||
" ========================================================================== |
||||
" File: Figlet.vim (global plugin) |
||||
" Last Changed: 2011-06-22 |
||||
" Maintainer: Erik Falor <ewfalor@gmail.com> |
||||
" Version: 2.0 |
||||
" License: Vim License |
||||
" Source: http://www.vim.org/scripts/script.php?script_id=3359 |
||||
" ========================================================================== |
||||
|
||||
" _____ _ _ _ _ __ |
||||
" | ___(_) __ _| | ___| |_ (_)/ _|_ _ |
||||
" | |_ | |/ _` | |/ _ \ __|____| | |_| | | | |
||||
" | _| | | (_| | | __/ ||_____| | _| |_| | |
||||
" |_| |_|\__, |_|\___|\__| |_|_| \__, | |
||||
" |___/ |___/ |
||||
" , , , . , . |
||||
" . _ . .._. -+- _ \./-+- . ,*-+-|_ -+-|_ _ |
||||
" \_|(_)(_|[ | (/,/'\ | \/\/ | | [ ) | [ )(/, |
||||
" ._| |
||||
" @@@@@@@@@ |
||||
" @@:::::::::@@ |
||||
" @@:::::::::::::@@ |
||||
" ggggggggg ggggg@:::::::@@@:::::::@ |
||||
" g:::::::::ggg::::g@::::::@ @::::::@ |
||||
" g:::::::::::::::::g@:::::@ @@@@:::::@ |
||||
" g::::::ggggg::::::gg@:::::@ @::::::::@ |
||||
" g:::::g g:::::g @:::::@ @::::::::@ |
||||
" g:::::g g:::::g @:::::@ @:::::::@@ |
||||
" g:::::g g:::::g @:::::@ @@@@@@@@ |
||||
" g::::::g g:::::g @::::::@ |
||||
" g:::::::ggggg:::::g @:::::::@@@@@@@@ |
||||
" g::::::::::::::::g @@:::::::::::::@ |
||||
" gg::::::::::::::g @@:::::::::::@ |
||||
" gggggggg::::::g @@@@@@@@@@@ |
||||
" g:::::g |
||||
" gggggg g:::::g |
||||
" g:::::gg gg:::::g |
||||
" g::::::ggg:::::::g |
||||
" gg:::::::::::::g |
||||
" ggg::::::ggg |
||||
" gggggg |
||||
" |
||||
" .-. |
||||
" .' `. |
||||
" .--. .---. .--. .--. .--. `. .'.--. .--. |
||||
" ' .; :: .; `' '_.': ..'' .; ; : :' .; :: ..' |
||||
" `.__.': ._.'`.__.':_; `.__,_;:_;`.__.':_; |
||||
" : : |
||||
" :_; |
||||
" |
||||
" o | |o| o | | | |
||||
" .,---. ,---.,---|,---|.|--- .,---.,---. |--- ,---. |--- |---.,---. |
||||
" || | ,---|| || ||| || || | | | | | | ||---' |
||||
" `` ' `---^`---'`---'``---'``---'` ' `---'`---' `---'` '`---' |
||||
" |
||||
" ______________ ______ _____ |
||||
" ________ ____/__(_)______ ___ /______ /_ |
||||
" ___(_)_ /_ __ /__ __ `/_ /_ _ \ __/ |
||||
" ___ _ __/ _ / _ /_/ /_ / / __/ /_ |
||||
" _(_) /_/ /_/ _\__, / /_/ \___/\__/ |
||||
" /____/ |
||||
" 888 |
||||
" e88'888 e88 88e 888 888 8e 888 888 8e ,"Y88b 888 8e e88 888 |
||||
" d888 '8 d888 888b 888 888 88b 888 888 88b "8" 888 888 88b d888 888 |
||||
" Y888 , Y888 888P 888 888 888 888 888 888 ,ee 888 888 888 Y888 888 |
||||
" "88,e8' "88 88" 888 888 888 888 888 888 "88 888 888 888 "88 888 |
||||
" |
||||
" |
||||
" .-._.).--. |
||||
" `-=-.`-=-. ( )/ `-=-.`-=-. |
||||
" `-'/ |
||||
" |
||||
" (o)__(o)\\ // wWw wWw\\\ ///, |
||||
" (__ __)(o)(o) wWw wWw (O) (O)((O)(O)) |
||||
" ( ) || || (O)_ (O)_ / ) ( \ | \ || |
||||
" )( |(__)| .' __) .' __)/ / \ \||\\|| |
||||
" ( ) /.--.\( _) ( _) | \____/ ||| \ | |
||||
" )/ -' `-`.__) )/ '. `--' .`|| || |
||||
" ( ( `-..-' (_/ \_) |
||||
" ___ ___ ___ ____ ________ __ __ __ __ ___ _ _ |
||||
" ||\\//|| // \\ || \\ || || \\||\ || || ||// \\\\// |
||||
" || \/ ||(( ))|| ))||== ||_//||\\|| \\ /\ //||=|| )/ |
||||
" || || \\_// ||_// ||___|| \\|| \|| \V/\V/ || ||// |
||||
" _ _ |
||||
" _| |_ ___ ._ _ _ ___ | |__ ___ |
||||
" | | / . \ | ' ' |<_> || / // ._> |
||||
" |_| \___/ |_|_|_|<___||_\_\\___. |
||||
" |
||||
" _ _ _ _ |
||||
" ___ | | _| | ___ ___ ___ | |_ ___ ___ | | |
||||
" / . \| |/ . ||___|<_-</ | '| . |/ . \/ . \| | |
||||
" \___/|_|\___| /__/\_|_.|_|_|\___/\___/|_| |
||||
" |
||||
" _ _ |
||||
" (_) (_) |
||||
" _ (_) _ _ _ _ _ _ _ _ _ (_) _ _ |
||||
" (_)(_)(_)(_) (_)(_)(_)(_)_(_) _ _ (_)(_)(_)(_)(_) |
||||
" (_) (_) _ _ _ (_) (_)_(_) (_) |
||||
" (_) _ (_)(_)(_)(_)(_) _(_)_ (_) _ |
||||
" (_)_ _(_)(_)_ _ _ _ _ (_) (_) _ (_)_ _(_) |
||||
" (_)(_) (_)(_)(_)(_)(_) (_) (_)(_) |
||||
" |
||||
" |
||||
" _ _ _ _ _ |
||||
" _(_)(_) (_) (_)(_) |
||||
" _ (_) _ _ _ (_) _ _ _ _ _ _ _ _ |
||||
" (_)(_)(_)(_)(_) (_) (_)(_)(_)(_)_ _(_)(_)(_)(_) |
||||
" (_) (_) (_) (_) _ _ _ (_)(_)_ _ _ _ |
||||
" (_) (_) (_) (_)(_)(_)(_)(_) (_)(_)(_)(_)_ |
||||
" (_) _ (_) _ _ (_) _(_)_ _ _ _ _ _ _ _(_) |
||||
" (_) (_)(_)(_)(_)(_)(_) (_)(_)(_)(_) (_)(_)(_)(_) |
||||
" |
||||
" |
||||
" ___ _ _ ____ ____ _ _ _ ____ ____ _ ____ ____ |
||||
" |__] \_/ . |___ |__/ | |_/ |___ |__| | | | |__/ |
||||
" |__] | . |___ | \ | | \_ | | | |___ |__| | \ |
||||
|
||||
|
||||
" This plugin requires that the fully awesome program `figlet' be installed on |
||||
" your system. |
||||
" |
||||
" If you're on Windows, hope is not lost. There is a figlet port for MS-DOS |
||||
" here: ftp://ftp.figlet.org/pub/figlet/program/ms-dos/figdos22.zip. |
||||
" Be sure to specify the font directory in your _vimrc through the |
||||
" g:filgetOpts variable. |
||||
" |
||||
" Figlet for MS-DOS is an old program, so you should make sure that your font |
||||
" files conform to FAT-16 style 8.3 filenames, and don't use fancy paths with |
||||
" spaces: |
||||
" |
||||
" let g:figletFontDir = 'C:\PROGRA~1\FIGLET\FONTS' |
||||
|
||||
" _ , |
||||
" ,- - , |
||||
" _||_ _ || |
||||
" ' || _-_ < \, =||= \\ \\ ,._-_ _-_ _-_, <> |
||||
" || || \\ /-|| || || || || || \\ ||_. |
||||
" |, ||/ (( || || || || || ||/ ~ || |
||||
" _-/ \\,/ \/\\ \\, \\/\\ \\, \\,/ ,-_- <> |
||||
|
||||
"1. If figlet fails to run, your original text is put back w/o messing up your |
||||
" undo history too much (you can still redo to the oopsie). |
||||
|
||||
"2. :Figlet command can accept a range, and does completion. Hit tab after |
||||
" typing the -f switch to list available fonts. |
||||
" Get a lot of fonts at http://www.figlet.org/fontdb.cgi |
||||
" |
||||
" Ex. Render lines 1 through 7 in the tengwar font: |
||||
" :1,7Figlet -f tengwar |
||||
" |
||||
|
||||
"3. Width is inferred from your 'textwidth' (except on Windows with the DOS |
||||
" build of figlet, as noted above). |
||||
|
||||
"4. The :FigletFontDemo command will show you a sample of each font installed |
||||
" in your font directory. By default this command will render each font |
||||
" eponymously, or you may specify a snippet of text to render so as to allow |
||||
" comparison between fonts. |
||||
" |
||||
" Ex. See what the word "Supercalifragilisticexpialidocious" looks like in each font: |
||||
" :FigletFontDemo Supercalifragilisticexpialidocious |
||||
|
||||
"5. The g@ operator takes all of the chosen text (selected with motion |
||||
" commands or text-objects) and puts it all into the same paragraph. |
||||
" the :Figlet command works one line at a time. It makes a difference |
||||
" when rendering text like this: |
||||
" |
||||
"1. |
||||
"2. |
||||
" |
||||
" :Figlet outputs: |
||||
" _ |
||||
" / | |
||||
" | | |
||||
" | |_ |
||||
" |_(_) |
||||
" |
||||
" ____ |
||||
" |___ \ |
||||
" __) | |
||||
" / __/ _ |
||||
" |_____(_) |
||||
" |
||||
" g@ instead outputs: |
||||
" _ ____ |
||||
" / | |___ \ |
||||
" | | __) | |
||||
" | |_ / __/ _ |
||||
" |_(_) |_____(_) |
||||
" |
||||
|
||||
" _ _ _ , |
||||
" - - / - - |
||||
" ('|| || _ _ |
||||
" (( ||--|| _-_, < \, / \\ _-_ <> |
||||
" (( ||--|| ||_. /-|| || || || \\ |
||||
" (( / || ~ || (( || || || ||/ |
||||
" -___-\\, ,-_- \/\\ \\_-| \\,/ <> |
||||
" / \ |
||||
" '----` |
||||
|
||||
" :Figlet takes the same arguments that the program figlet accepts. It does a |
||||
" little bit of parsing for arguments it can grok, and passes the rest through. |
||||
" If no arguments are given, it will fall back to the global parameters you can |
||||
" set in your .vimrc, or the defaults. That usually means the 'standard' font |
||||
" and a width of 76 columns. |
||||
" |
||||
" g@, on the other hand, doesn't take arguments. You can only control it |
||||
" through the globals: |
||||
" |
||||
" g:figletFont - the name of the font to use |
||||
" g:figletFontDir - full path to the directory storing your figlet fonts |
||||
" g:figletOpts - the other arguments you want to pass figlet |
||||
|
||||
|
||||
" 8""""8 8""""8 |
||||
" 8 8 eeee eeeee e eeeee 8 eeee eeeee e eeeee eeeee |
||||
" 8eeee8ee 8 8 8 8 8 8 8eeeee 8 8 8 8 8 8 8 8 |
||||
" 88 8 8eee 8e 8e 8e 8 88 8e 8eee8e 8e 8eee8 8e 88 |
||||
" 88 8 88 88 "8 88 88 8 e 88 88 88 8 88 88 88 |
||||
" 88eeeee8 88ee 88ee8 88 88 8 8eee88 88e8 88 8 88 88 88 88 |
||||
" |
||||
"eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee |
||||
"eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee eeeee |
||||
|
||||
|
||||
" Exit quickly when the script has already been loaded |
||||
if exists('g:loaded_Figlet') |
||||
finish |
||||
endif |
||||
"autocmd! BufWritePost Figlet.vim nested source % |
||||
|
||||
let g:loaded_Figlet = '2.0' |
||||
|
||||
|
||||
" A function to inform the user if there is a problem finding Figlet |
||||
function! FigletFail(...) |
||||
echoerr 'figlet executable is not installed in your $PATH' |
||||
endfunction |
||||
|
||||
|
||||
" Check to see if there is a figlet program in the path |
||||
if !executable('figlet') |
||||
set operatorfunc=FigletFail |
||||
command! -range -nargs=* Figlet :call FigletFail(<f-args>) |
||||
finish |
||||
endif |
||||
|
||||
|
||||
" Work around some bugs with the DOS build of figlet.exe |
||||
" {{{ |
||||
if has('dos16') || has('dos32') || has('win16') || has ('win32') || |
||||
\has('win64') || has('win95') |
||||
"Passing -w causes a stack overflow in figlet.exe about 50% of the time |
||||
let s:overrideWidth = 1 |
||||
"using -- to separate options from text crashes figlet about 50% of the |
||||
"time as well. |
||||
let s:argsep = '' |
||||
else |
||||
let s:argsep = '--' |
||||
endif "}}} |
||||
|
||||
|
||||
" Run the Figlet program, passing in the applicable options |
||||
function! <SID>RunFiglet(text, opts, width, font, fontdir) "{{{ |
||||
" set any custom options (such as path to fonts) |
||||
if '' != a:opts |
||||
let opts = a:opts |
||||
elseif exists('g:figletOpts') |
||||
let opts = g:figletOpts |
||||
else |
||||
let opts = '' |
||||
endif |
||||
|
||||
" set the width to &textwidth or default |
||||
if exists('s:overrideWidth') |
||||
let width = '' |
||||
elseif '' != a:width |
||||
let width = '-w ' . a:width |
||||
elseif &textwidth != 0 |
||||
let width = '-w ' . &textwidth |
||||
else |
||||
let width = '-w 76' |
||||
endif |
||||
|
||||
" set the font (figlet itself defaults to 'standard') |
||||
if '' != a:font |
||||
let font = '-f ' . a:font |
||||
elseif exists('g:figletFont') |
||||
let font = '-f ' . g:figletFont |
||||
else |
||||
let font = '' |
||||
endif |
||||
|
||||
" set the font (figlet itself defaults to 'standard') |
||||
if '' != a:fontdir |
||||
let fontdir = '-d ' . a:fontdir |
||||
elseif exists('g:figletFontDir') |
||||
let fontdir = '-d ' . g:figletFontDir |
||||
else |
||||
let fontdir = '' |
||||
endif |
||||
|
||||
let command = printf('figlet %s %s %s %s %s %s', |
||||
\opts, width, font, fontdir, s:argsep, shellescape(a:text)) |
||||
|
||||
try |
||||
let result = system(command) |
||||
catch /^Vim\%((\a\+)\)\=:E484/ " Can't open file [tempfile] |
||||
throw 'figlet error' |
||||
endtry |
||||
|
||||
if 0 != v:shell_error |
||||
throw 'figlet error' |
||||
endif |
||||
return split(result, "\n") |
||||
endfunction "}}} |
||||
|
||||
|
||||
" Return the font directory to be used by Figlet - it's either the value of |
||||
" g:figletFontDir, or the one compiled-in to Figlet itself |
||||
let s:figletFontDir = '' |
||||
function! s:GetFigletFontDir() "{{{ |
||||
if exists('g:figletFontDir') |
||||
let s:figletFontDir = g:figletFontDir |
||||
else |
||||
let s:figletFontDir = split(system('figlet -I2'), "\n")[0] |
||||
endif |
||||
return s:figletFontDir |
||||
endfunction "}}} |
||||
|
||||
|
||||
" Return a list of names of all font files in Figlet's font directory |
||||
let s:figletFonts = [] |
||||
function! s:GetFigletFonts() "{{{ |
||||
if [] == s:figletFonts |
||||
let fontDir = s:GetFigletFontDir() |
||||
let fonts = split(glob(fontDir . '/*.fl?'), "\n") |
||||
"strip fontDir and ext from each entry |
||||
let s:figletFonts = map(fonts, 'fnamemodify(v:val, ":t:r")') |
||||
endif |
||||
return s:figletFonts |
||||
endfunction "}}} |
||||
|
||||
|
||||
" For each font found in Figlet's font directory, generate a small sample |
||||
" & show the results in a new scratch buffer. If this buffer hasn't been |
||||
" wiped out, subsequent invocations will reload the buffer instead of |
||||
" re-generating it |
||||
function! FigFontDemo(...) "{{{ |
||||
let bufname = 'FigletFontDemo.txt' |
||||
let bufnum = bufnr(bufname) |
||||
let vwinnum = bufwinnr(bufnum) |
||||
if bufnum >= 0 && vwinnum < 0 |
||||
" the buffer already exists && window not open |
||||
try |
||||
if winnr("$") == 1 && bufname("%") == '' && &modified == 0 |
||||
execute 'buffer ' . bufnum |
||||
else |
||||
execute 'sbuffer ' . bufnum |
||||
endif |
||||
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room |
||||
" Can't split, then switch |
||||
execute 'buffer ' . bufnum |
||||
endtry |
||||
elseif bufnum >= 0 && vwinnum >= 0 |
||||
" else if buffer exists in a window |
||||
" switch to the window |
||||
if vwinnum != bufwinnr('%') |
||||
execute "normal \<c-w>" . vwinnum . 'w' |
||||
endif |
||||
else |
||||
" else if no buffer, create it |
||||
try |
||||
if winnr("$") == 1 && bufname("%") == '' && &modified == 0 |
||||
execute 'edit ' . bufname |
||||
else |
||||
execute 'split ' . bufname |
||||
endif |
||||
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room |
||||
"Can't split, then switch |
||||
execute 'edit ' . bufname |
||||
endtry |
||||
|
||||
"set up buffer-local settings for this window |
||||
setlocal bufhidden=hide foldcolumn=0 nofoldenable |
||||
\nonumber norightleft noswapfile nowrap |
||||
|
||||
"arrange to have these settings restored upon re-entering the buffer |
||||
autocmd BufEnter <buffer> setlocal noswapfile |
||||
\bufhidden=hide nonumber nowrap norightleft |
||||
\foldcolumn=0 nofoldenable |
||||
|
||||
"now that the buffer is set-up |
||||
0put =printf('All figlet fonts in %s:', s:GetFigletFontDir()) |
||||
put ='' |
||||
for font in s:GetFigletFonts() |
||||
try |
||||
echon printf("Demoing font %s...\r", font) |
||||
put =font |
||||
put ='===========================' |
||||
if a:0 == 1 && len(a:1) > 0 |
||||
silent put =<SID>RunFiglet(a:1, '', '', font, '') |
||||
else |
||||
silent put =<SID>RunFiglet(font, '', '', font, '') |
||||
endif |
||||
catch /figlet error/ |
||||
put =printf('figlet failed on font %s', font) |
||||
finally |
||||
put ='' |
||||
endtry |
||||
endfor |
||||
echon "Done" |
||||
|
||||
endif |
||||
setlocal nomodifiable nomodified nofoldenable |
||||
1 |
||||
endfunction "}}} |
||||
|
||||
command! -nargs=? FigletFontDemo :call FigFontDemo(<f-args>) |
||||
|
||||
|
||||
" Implements command-line completion for the :Figlet command |
||||
let s:completionFonts = '' |
||||
function! FigletComplete(arglead, cmdline, cursorpos) "{{{ |
||||
if -1 < strridx(a:cmdline, '-f', a:cursorpos) && |
||||
\strridx(a:cmdline, '-f', a:cursorpos) == strridx(a:cmdline, '-', a:cursorpos) |
||||
"get a dirlisting of *.flf *.flc files in s:figletFontDir |
||||
if '' == s:completionFonts |
||||
let s:completionFonts = join(s:GetFigletFonts(), "\n") |
||||
endif |
||||
return s:completionFonts |
||||
else |
||||
return "-f\n-d\n-p\n-n\n-s\n-S\n-k\n-W\n-o\n-c\n-l\n-r\n-x\n-L\n-R\n-X\n" |
||||
endif |
||||
endfunction "}}} |
||||
|
||||
|
||||
" The guts of the :Figlet command - runs figlet over a range of lines |
||||
function! FigRange(...) range "{{{ |
||||
"figure out the arguments |
||||
let i = 0 |
||||
let opts = '' |
||||
let width = '' |
||||
let font = '' |
||||
let fontdir = '' |
||||
while i < len(a:000) |
||||
if '-w' == a:000[i] |
||||
let width = a:000[i+1] |
||||
let i += 2 |
||||
elseif '-f' == a:000[i] |
||||
let font = a:000[i+1] |
||||
let i += 2 |
||||
elseif '-d' == a:000[i] |
||||
let fontdir = a:000[i+1] |
||||
let i += 2 |
||||
else |
||||
let opts .= a:000[i] . ' ' |
||||
let i += 1 |
||||
endif |
||||
endwhile |
||||
|
||||
"set the cursor's position at the begining of the range |
||||
let pos = [0, a:firstline, 0, 0] |
||||
|
||||
"collect the specified text into a list |
||||
let text = getline(a:firstline, a:lastline) |
||||
|
||||
"delete the original text |
||||
execute printf("%d,%dd", a:firstline, a:lastline) |
||||
|
||||
let figletText = [] |
||||
|
||||
"render each line in turn, and accumulate the text |
||||
try |
||||
for line in text |
||||
call extend(figletText, <SID>RunFiglet(line, opts, width, font, fontdir)) |
||||
endfor |
||||
catch /figlet error/ |
||||
undo |
||||
echoerr "Figlet failed to render this text" |
||||
endtry |
||||
|
||||
"undo the Figlet text replacement in one move instead of two |
||||
undojoin |
||||
|
||||
" the append function appends below the cursor line; |
||||
" so we need to rewind the line by one |
||||
call append(pos[1] - 1, figletText) |
||||
|
||||
"restore cursor position |
||||
call setpos('.', pos) |
||||
endfunction "}}} |
||||
|
||||
command! -range -complete=custom,FigletComplete -nargs=* Figlet :<line1>,<line2>call FigRange(<f-args>) |
||||
|
||||
|
||||
" The guts of the g@ operator - delete the text specified by the motion |
||||
" & replace it with the result of calling figlet |
||||
function! FigOper(motionType) "{{{ |
||||
"save the cursor's position |
||||
let pos = getpos('.') |
||||
|
||||
" save the contents and attributes of the " register |
||||
let saveReg = getreg('"') |
||||
let saveRegType = getregtype('"') |
||||
|
||||
" delete the specified text into register " |
||||
if a:0 " Invoked from Visual mode, use '< and '> marks. |
||||
silent exe "normal! `<" . a:motionType . "`>x" |
||||
elseif a:motionType == 'line' |
||||
silent exe "normal! '[V']x" |
||||
elseif a:motionType == 'block' |
||||
silent exe "normal! `[\<C-V>`]x" |
||||
else |
||||
silent exe "normal! `[v`]lx" |
||||
endif |
||||
|
||||
" restore register " |
||||
let text = substitute(@", '\_s\+', ' ', 'g') |
||||
call setreg('"', saveReg, saveRegType) |
||||
|
||||
" call RunFiglet() using defaults or global options |
||||
try |
||||
let figletText = <SID>RunFiglet(text, '', '', '', '') |
||||
catch /figlet error/ |
||||
undo |
||||
echoerr "Figlet failed to render this text" |
||||
endtry |
||||
|
||||
"undo the Figlet text replacement in one move instead of two |
||||
undojoin |
||||
|
||||
" the append function appends below the cursor line; |
||||
" so we need to rewind the line by one |
||||
call append(pos[1] - 1, figletText) |
||||
|
||||
"restore cursor position |
||||
call setpos('.', pos) |
||||
endfunction "}}} |
||||
|
||||
set operatorfunc=FigOper |
||||
|
||||
|
||||
" 8"""" 8"""" |
||||
" 8 eeeee eeeee eeeee eeee 8 e e eeee |
||||
" 8eeee 8 8 8 8 8 88 8 8eeee 8 8 8 |
||||
" 88 8e 8 8e 8 8 8 8eee 88 8e 8e 8eee |
||||
" 88 88 8 88 8 8 8 88 88 88 88 88 |
||||
" 88eee 88 8 88ee8 8eee8 88 88 88 88eee 88ee |
||||
|
||||
" _ _ _ _ _ _ _ _ _ _ _ _ |
||||
" / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ |
||||
" ( C | o | p | y | l | e | f | t ) ( 2 | 0 | 1 | 1 ) |
||||
" \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ |
||||
|
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
|
||||
" Author: Cornelius <cornelius.howl@gmail.com> |
||||
" Date: 一 12/21 20:29:23 2009 |
||||
" Script type: plugin |
||||
" Script id: |
||||
|
||||
" filetype completion hacks |
||||
fun! FiletypeCompletion(lead,cmd,pos) |
||||
let list = glob(expand('$VIMRUNTIME/syntax'). '/*.vim') |
||||
let items = split(list,"\n") |
||||
cal map(items,'matchstr(v:val,''\w\+\(.vim$\)\@='')') |
||||
cal filter(items,"v:val =~ '^" . a:lead . "'") |
||||
return items |
||||
endf |
||||
com! -complete=customlist,FiletypeCompletion -nargs=1 SetFiletype :setf <args> |
||||
cabbr sft SetFiletype |
||||
cabbr setf SetFiletype |
||||
|
||||
|
||||
|
@ -0,0 +1,375 @@
@@ -0,0 +1,375 @@
|
||||
" {{{ |
||||
" Name: help.vim ("help subsystem") |
||||
" Version: 1.19 |
||||
" Authors: Slava Gorbanev (author 1.16 version) and |
||||
" Nikolay Panov (author >1.16 version) |
||||
" Date: 09/03/2003 (21:03) |
||||
" Description: call man or perldoc -f or many other help system in dependent from context |
||||
" Changes: |
||||
" * 1.20 now pydoc is supported |
||||
" * 1.19 several bugfixes, impruvements and other... |
||||
" * 1.18 several bugfixes, added call apropos if man page not found. |
||||
" * 1.17 support fvwm, muttrc filetype, many fixes... |
||||
" * 1.17g new, extended implementation of help.vim (http://www.vim.org/scripts/script.php?script_id=561) |
||||
" * 1.17b forked by help.vim,v 1.16 2002/01/05 19:58:38 from Slava Gorbanev, added support tcl/tk and many fixes |
||||
" Installation: put this into your plugin directory (~/.vim/plugin) |
||||
" Usage: |
||||
" use <F1> by default or other key (if you remap it) to call Help(expand("<cword>")) |
||||
" this function creating in half window buffer with contex-dependent |
||||
" manual (or other) page about word under corsor. |
||||
" You can use new commands now: |
||||
" Man something the same as man into your system |
||||
" Perldoc something the same as perldoc into your system |
||||
" GoToSection something try to find <something> section into window |
||||
" Help something try to show context-dependent help |
||||
" Dict something the same as dict into your system |
||||
" |
||||
" By default in help-buffer set key-mapping: |
||||
" q for exit (and ``Esc'' in GUI mode) |
||||
" o for command :only |
||||
" D for go to DESCRIPTION section |
||||
" S for go to SYN section |
||||
" (and other --- see source code by detail) |
||||
" |
||||
" You can mapping go to any other section: |
||||
" for example for go to NAME section by N key call next command: |
||||
" map N :call GoToSection('NAME') |
||||
" |
||||
" Now support: sh, vim, perl, python, tcl/tk, C/C++, fvwm, muttrc and many other. |
||||
" |
||||
" TODO nicier documentation (oh - my terrible english)... |
||||
" TODO support many other language" }}} |
||||
|
||||
" {{{ Builtin function (sh, perl) |
||||
let sh_builtin='^\(alias\|bg\|bind\|break\|builtin\|case\|cd\|co\(mmand\|ntinue\)\|declare\|dirs\|echo\|enable\|eval\|ex\(ec\|it\|port\)\|fc\|fg\|for\|function\|getopts\|hash\|help\|history\|if\|jobs\|kill\|let\|lo\(cal\|gout\)\|popd\|pushd\|pwd\|read\(\|only\)\|return\|se\(lect\|t\)\|shift\|source\|suspend\|test\|times\|trap\|ty\(pe\|peset\)\|ulimit\|umask\|un\(alias\|set\|til\)\|variables\|wait\|while\)$' |
||||
let perl_builtin='^\(abs\|accept\|alarm\|atan2\|bind\|binmode\|bless\|caller\|chdir\|chmod\|chom\=p\|chown\|chr\|chroot\|close\|closedir\|connect\|continue\|cos\|crypt\|dbmclose\|dbmopen\|defined\|delete\|die\|do\|dump\|each\|end\(grent\|hostent\|netent\|protoent\|pwent\|servent\)\|eof\|eval\|exec\|exp\|exists\|exit\|fcntl\|fileno\|flock\|fork\|format\|formline\|getc\|getgrent\|getgrgid\|getgrnam\|gethostbyaddr\|gethostbyname\|gethostent\|getlogin\|getnetbyaddr\|getnetbyname\|getnetent\|getpeername\|getpgrp\|getppid\|getpriority\|getprotobyname\|getprotobynumber\|getprotoent\|getpwent\|getpwnam\|getpwuid\|getservbyname\|getservbyport\|getservent\|getsockname\|getsockopt\|glob\|gmtime\|goto\|grep\|hex\|import\|index\|int\|ioctl\|join\|keys\|kill\|last\|lc\|lcfirst\|length\|link\|listen\|local\|localtime\|log\|lstat\|map\|mkdir\|msgctl\|msgget\|msgrcv\|msgsnd\|my\|next\|no\|open\|opendir\|ord\|pack\|package\|pipe\|po[ps]\|printf\=\|push\|quotemeta\|rand\|read\(\|dir\|link\)\|recv\|redo\|ref\|rename\|require\|reset\|return\|reverse\|rewinddir\|rindex\|rmdir\|scalar\|seek\|seekdir\|select\|semctl\|semget\|semop\|send\|set\(gr\|host\|net\)ent\|setp\(grp\|riority\|rotoent\|went\)\|setservent\|setsockopt\|shift\|shmctl\|shmget\|shmread\|shmwrite\|shutdown\|sin\|sleep\|socket\(\|pair\)\|sort\|splice\|split\|sprintf\|sqrt\|srand\|stat\|study\|sub\|substr\|symlink\|sys\(call\|read\|seek\|write\|tem\)\|tell\|telldir\|tied\=\|times\=\|truncate\|uc\|ucfirst\|umask\|undef\|unlink\|unpack\|unshift\|untie\|use\|utime\|values\|vec\|wait\(\|pid\)\|wa\(ntarray\|rn\)\|write\)$' |
||||
" }}} |
||||
" {{{ Global definition variables and command |
||||
let $MANPL='1100i' " no page breaks inside man pages |
||||
|
||||
command! -nargs=* Man call Man(<f-args>) |
||||
command! -nargs=1 Perldoc call Perldoc(<f-args>) |
||||
command! -nargs=1 Pydoc call Pydoc(<f-args>) |
||||
command! -nargs=1 GoToSection call GoToSection(<f-args>) |
||||
" }}} |
||||
" {{{ Mappings |
||||
nmap fs :call Src(expand("<cword>"))<CR> |
||||
nmap fm :call Help(expand("<cword>"))<CR> |
||||
nmap fw :call Dict(expand("<cword>"))<CR> |
||||
nmap <F1> :call Help(expand("<cword>"))<CR> |
||||
nmap <F1><F1> :call Dict(expand("<cword>"))<CR> |
||||
imap <F1><F1> <ESC>:call Dict(expand("<cword>"))<CR> |
||||
imap <F1> <ESC>:call Help(expand("<cword>"))<CR> |
||||
" }}} |
||||
" {{{ Funcitions definition |
||||
" {{{ The GoToSection(section) function close all fond and go to... |
||||
fun! GoToSection(search) |
||||
let search = a:search |
||||
if search =~ '\/' |
||||
let cmd = search |
||||
else |
||||
let search = substitute(search, "^un", "", "") |
||||
let cmd = '/^\s*\(\[un\]\)\='.search.'.\{-,50}/' |
||||
endif |
||||
normal zM |
||||
silent exec cmd |
||||
normal zvjzvztk0 |
||||
endfun |
||||
" }}} |
||||
" {{{ The OpenHelpWin(cmd, ft, ...) function get manual page and creating window |
||||
fun! OpenHelpWin(cmd, ft, ...) |
||||
if a:0 |
||||
let buf_name = a:1 |
||||
else |
||||
let buf_name = 'Help' |
||||
endif |
||||
exe 'silent new' escape(buf_name, '\ ') |
||||
setlocal modifiable buftype=nofile noswapfile |
||||
""endif |
||||
let &ft = a:ft |
||||
exe "0r!".a:cmd |
||||
if line('$') == 1 |
||||
exe "0r! man ".a:1." 2>/dev/null" |
||||
if line('$') == 1 |
||||
exe "0r! apropos ".a:1." 2>/dev/null" |
||||
endif |
||||
endif |
||||
let helpsize = line('$') |
||||
if helpsize > &helpheight |
||||
let helpsize = &helpheight |
||||
endif |
||||
set nomod |
||||
if winheight(2) != -1 |
||||
exe 'resize' helpsize |
||||
endif |
||||
1 |
||||
" {{{ key-mapping and definition local parameter |
||||
noremap <buffer> <Space> <C-F> |
||||
noremap <buffer> <Backspace> <C-B> |
||||
noremap <buffer> o :only<CR> |
||||
noremap <buffer> q :bdel<CR> |
||||
noremap <buffer> D :call GoToSection('DESCRIPTION')<CR> |
||||
noremap <buffer> E :call GoToSection('EXAMPLE')<CR> |
||||
noremap <buffer> S :call GoToSection('SYN')<CR> |
||||
noremap <buffer> <C-Up> zM?^[A-Z]\+<CR>jzvztk0 |
||||
noremap <buffer> <C-Down> zM/^[A-Z]\+<CR>jzvztk0 |
||||
if has("gui_running") |
||||
noremap <buffer> <Esc> :bdel<CR> |
||||
endif |
||||
|
||||
setlocal foldmethod=indent |
||||
setlocal nohlsearch |
||||
setlocal nomodifiable |
||||
|
||||
hi Error ctermfg=NONE ctermbg=NONE |
||||
" }}} |
||||
""endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The Man(page, ...) function gets a man page |
||||
fun! Man(page, ...) |
||||
if a:0 |
||||
let page = a:1 |
||||
let section = '-S '.a:page.' ' |
||||
if a:0 > 1 |
||||
let go_to = a:2 |
||||
else |
||||
let go_to = '' |
||||
endif |
||||
else |
||||
let page = a:page |
||||
let section = '' |
||||
let go_to = '' |
||||
endif |
||||
call OpenHelpWin("man ".section.page." 2>/dev/null \|col -b\|uniq", 'man', page) |
||||
if go_to != '' |
||||
call GoToSection(go_to) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The Dict(word) function call a dict command for word |
||||
fun! Dict(word) |
||||
let dict = $HOME . "/.shellrc/var/memory/dictionary" |
||||
|
||||
if filereadable(expand('%:p')) |
||||
let dict = expand('%:p') . ".dict" |
||||
endif |
||||
|
||||
call writefile(readfile(dict)+[a:word], dict) |
||||
call OpenHelpWin("sdcv -n --data-dir ~/.shellrc/etc/soft/sdcv/dictionaries/ ".a:word." 2>/dev/null", 'dict', a:word) |
||||
normal G2kzvztk0 |
||||
endfun |
||||
" }}} |
||||
" {{{ The Pydoc(word) function gets a python documentation for word |
||||
fun! Pydoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'man' |
||||
let cmd = 'pydoc '.a:word |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The Perldoc(word) function gets a perl documentation for word |
||||
fun! Perldoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'perl' |
||||
if a:word =~ g:perl_builtin |
||||
let cmd = 'perldoc -f '.a:word |
||||
elseif a:word =~# '^\(s\|m\|qr\)$' |
||||
let cmd = 'man perlop' |
||||
let move_to_pattern = '/^ \+'.a:word.'\/PATTERN\//' |
||||
elseif a:word =~# '^\(tr\|y\)$' |
||||
let cmd = 'man perlop' |
||||
let move_to_pattern = '/^ \+'.a:word.'\/SEARCHLIST\//' |
||||
elseif a:word =~# '^q[qxw]\=$' |
||||
let cmd = 'man perlop' |
||||
let move_to_pattern = '/^ \+'.a:word.'\/STRING\//' |
||||
elseif a:word =~# '^\(y\|tr\)$' |
||||
let cmd = 'man perlop' |
||||
let move_to_pattern = '/^ \+'.a:word.'\/SEARCHLIST\//' |
||||
else |
||||
let cmd = 'man -S 3perl:3pm:3 '.a:word |
||||
endif |
||||
call OpenHelpWin(cmd." 2>/dev/null \|col -b\|uniq", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The ShBuiltin(word) function gets a help for sh builin function |
||||
fun! ShBuiltin(word) |
||||
let WORD = expand("<cword>") |
||||
if a:word =~ g:sh_builtin |
||||
let cmd = "bash -c '\command \help ".a:word."'" |
||||
elseif WORD == '\[' || WORD =~ '^-[a-z]$' |
||||
let cmd = "bash -c '\command \help test'" |
||||
elseif WORD == ':' || WORD == '.' || WORD == '{' |
||||
let cmd = "bash -c '\command \help ".WORD."'" |
||||
else |
||||
call Man('1:5:8', a:word) |
||||
return |
||||
endif |
||||
call OpenHelpWin(cmd, 'man', WORD) |
||||
normal zR |
||||
endfun |
||||
" }}} |
||||
|
||||
" {{{ The PrologDoc(word) function gets a swi-prolog documentation for word |
||||
fun! PrologDoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'prolog' |
||||
let cmd = 'echo "help('.a:word.')." | swipl --nopce 2>/dev/null | cat -v | sed "s/.\^H//g"' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The GuileDoc(word) function gets a guile scheme documentation for word |
||||
fun! GuileDoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'scheme' |
||||
let cmd = 'echo "(help '.a:word.')" | guile | sed "s/guile.//g"' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The SBCLDoc(word) function gets a sbcl scheme documentation for word |
||||
fun! SBCLDoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'lisp' |
||||
" let cmd = "echo \\(documentation " |
||||
" \."\\'" .a:word. " \\'" |
||||
" \."function\\) | sbcl | tail -n +8" |
||||
let cmd = "echo \\(describe " ."\\'" .a:word ."\\) | sbcl | tail -n +8" |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The MySQL(word) function gets a guile scheme documentation for word |
||||
fun! MySQL(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'mysql' |
||||
let cmd = 'echo "help '.a:word.';" | mysql -u anonymous' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The RebolDoc(word) function gets a Rebol documentation for word |
||||
fun! RebolDoc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'rebol' |
||||
let cmd = 'echo "quit" | rebol -v --do "help '.a:word.'"' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" ---------------------------------------------------------------------- |
||||
" {{{ The GuileSrc(word) function gets a guile scheme documentation for word |
||||
fun! GuileSrc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'scheme' |
||||
let cmd = 'echo "(pretty-print (source '.a:word.'))" | guile | sed "s/guile.//g"' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The PrologSrc(word) function gets a prolog source for word |
||||
fun! PrologSrc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'prolog' |
||||
let cmd = 'echo "listing('.a:word.')." | swipl 2>/dev/null' |
||||
call OpenHelpWin(cmd." 2>/dev/null", filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The TclSrc(word) function gets a tcl source for word |
||||
fun! TclSrc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'tcl' |
||||
let cmd = '~/.vim/+scripts/sources/getTclSrc '.a:word |
||||
" echo system(cmd) |
||||
call OpenHelpWin(cmd, filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" {{{ The RebolSrc(word) function gets a Rebol source for word |
||||
fun! RebolSrc(word) |
||||
let move_to_pattern = '' |
||||
let filetype = 'rebol' |
||||
let cmd = 'echo "quit" | rebol -v --do "source '.a:word.'"' |
||||
call OpenHelpWin(cmd, filetype, a:word) |
||||
if move_to_pattern != '' |
||||
call GoToSection(move_to_pattern) |
||||
endif |
||||
endfun |
||||
" }}} |
||||
" ---------------------------------------------------------------------- |
||||
" {{{ The Src(word) function gets a help for word (in depend on context) |
||||
fun! Src(word) |
||||
if &ft =~ 'scheme' |
||||
call GuileSrc(a:word) |
||||
elseif &ft =~ 'prolog' |
||||
call PrologSrc(a:word) |
||||
elseif &ft =~ 'tcl' |
||||
call TclSrc(expand("<cWORD>")) |
||||
elseif &ft =~ 'rebol' |
||||
call RebolSrc(a:word) |
||||
else |
||||
echohl Error | echo 'No identifier under cursor' | echohl None |
||||
endif |
||||
normal zv |
||||
endfun |
||||
" }}} |
||||
" ---------------------------------------------------------------------- |
||||
" {{{ The Help(word) function gets a help for word (in depend on context) |
||||
fun! Help(word) |
||||
if &ft == 'vim' || &ft == 'help' |
||||
exe "help" a:word |
||||
elseif &ft == 'c' || &ft == 'cpp' |
||||
call Man('2:3', a:word) |
||||
elseif &ft =~ 'perl' |
||||
call Perldoc(a:word) |
||||
elseif &ft =~ 'scheme' |
||||
call GuileDoc(a:word) |
||||
elseif &ft =~ 'lisp' |
||||
call SBCLDoc(a:word) |
||||
elseif &ft =~ 'rebol' |
||||
call RebolDoc(a:word) |
||||
elseif &ft =~ 'prolog' |
||||
call PrologDoc(a:word) |
||||
elseif &ft =~ 'mysql' |
||||
call MySQL(a:word) |
||||
elseif &ft =~ 'python' |
||||
call Pydoc(a:word) |
||||
elseif &ft =~ 'tcl' |
||||
call Man('3tcl:3tk:n', a:word) |
||||
elseif &ft =~ '^\(fvwm\|muttrc\)$' |
||||
call Man('1:5',&ft, a:word) |
||||
elseif &ft =~ '^z\=sh' |
||||
call ShBuiltin(a:word) |
||||
elseif a:word =~ '^\i\+' |
||||
call Man(a:word) |
||||
else |
||||
echohl Error | echo 'No identifier under cursor' | echohl None |
||||
endif |
||||
normal zv |
||||
endfun |
||||
" }}} |
||||
" }}} |
@ -0,0 +1,182 @@
@@ -0,0 +1,182 @@
|
||||
" Vim completion script |
||||
" Language: lisp |
||||
" Maintainer: Andrew Beyer <abeyer@alum.rpi.edu> |
||||
" Version: 1.0 |
||||
" Last Change: Fri Jan 19 00:28:27 PST 2007 |
||||
" Usage: put in autoload, set omnifunc=lispcomplete#Complete |
||||
" Options: g:omni_lisp_ignorecase 0|1 [&ignorecase] |
||||
" g:omni_lisp_mode 'compound'|'simple' ['compound'] |
||||
" |
||||
|
||||
" Set completion with CTRL-X CTRL-O to autoloaded function. |
||||
" This check is in place in case this script is |
||||
" sourced directly instead of using the autoload feature. |
||||
if exists('+omnifunc') |
||||
" Do not set the option if already set since this |
||||
" results in an E117 warning. |
||||
if &omnifunc == "" |
||||
setlocal omnifunc=lispcomplete#Complete |
||||
endif |
||||
endif |
||||
|
||||
if exists('g:loaded_lisp_completion') |
||||
finish |
||||
endif |
||||
let g:loaded_lisp_completion = 20 |
||||
|
||||
" Set ignorecase to the ftplugin standard |
||||
if !exists('g:omni_lisp_ignorecase') |
||||
let g:omni_lisp_ignorecase = &ignorecase |
||||
endif |
||||
|
||||
" This script will build a completion list based on the syntax |
||||
" elements defined by the files in $VIMRUNTIME/syntax. |
||||
let s:syn_remove_words = 'match,matchgroup=,contains,'. |
||||
\ 'links to,start=,end=,nextgroup=' |
||||
|
||||
let s:cache_name = [] |
||||
let s:cache_list = [] |
||||
|
||||
" This function is used for the 'omnifunc' option. |
||||
function! lispcomplete#Complete(findstart, base) |
||||
|
||||
if a:findstart |
||||
" Locate the start of the item, including "." |
||||
let line = getline('.') |
||||
let start = col('.') - 1 |
||||
while start > 0 |
||||
if line[start - 1] =~ '\k' |
||||
let start -= 1 |
||||
else |
||||
break |
||||
endif |
||||
endwhile |
||||
|
||||
return start |
||||
endif |
||||
|
||||
" escape '*' in a:base |
||||
let base = substitute(a:base, '\*', '\\\*', 'g') |
||||
|
||||
let filetype = substitute(&filetype, '\.', '_', 'g') |
||||
let list_idx = index(s:cache_name, filetype, 0, &ignorecase) |
||||
if list_idx > -1 |
||||
let compl_list = s:cache_list[list_idx] |
||||
else |
||||
let compl_list = LispSyntaxList() |
||||
let s:cache_name = add( s:cache_name, filetype ) |
||||
let s:cache_list = add( s:cache_list, compl_list ) |
||||
endif |
||||
|
||||
" Return list of matches. |
||||
|
||||
if base =~ '\k' |
||||
" complete a word |
||||
if (!exists('g:omni_lisp_mode')) || (g:omni_lisp_mode ==? 'compound') |
||||
let slime_list = compl_list |
||||
let compl_list = [] |
||||
let slime_base = '^' . substitute(base, '-', '[a-zA-Z0-9*+/<=>]*-', 'g') |
||||
let slime_start = 0 |
||||
let slime_end = len(slime_list) - 1 |
||||
while (slime_start != -1) && (slime_start < slime_end) |
||||
let slime_start = match(slime_list, slime_base, slime_start) |
||||
if slime_start != -1 |
||||
let compl_list = add(compl_list, slime_list[slime_start]) |
||||
let slime_start = slime_start + 1 |
||||
endif |
||||
endwhile |
||||
elseif g:omni_lisp_mode ==? 'simple' |
||||
let compstr = join(compl_list, ' ') |
||||
let expr = (g:omni_lisp_ignorecase==0?'\C':'').'\<\%('.base.'\)\@!\k\+\s*' |
||||
let compstr = substitute(compstr, expr, '', 'g') |
||||
let compl_list = split(compstr, '\s\+') |
||||
else |
||||
echoerr "Invalid g:omni_lisp_mode: " g:omni_lisp_mode |
||||
endif |
||||
else |
||||
" TODO: complete a form |
||||
endif |
||||
|
||||
return compl_list |
||||
endfunc |
||||
|
||||
function! LispSyntaxList() |
||||
|
||||
let saveL = @l |
||||
redir @l |
||||
silent! exec 'syntax list ' |
||||
redir END |
||||
|
||||
let syntax_full = "\n".@l |
||||
let @l = saveL |
||||
|
||||
if syntax_full =~ 'E28' |
||||
\ || syntax_full =~ 'E411' |
||||
\ || syntax_full =~ 'E415' |
||||
\ || syntax_full =~ 'No Syntax items' |
||||
return [] |
||||
endif |
||||
|
||||
let syn_list = s:SyntaxCSyntaxGroupItems('lispVar', syntax_full) |
||||
let syn_list = syn_list . s:SyntaxCSyntaxGroupItems('lispFunc', syntax_full) |
||||
let syn_list = syn_list . s:SyntaxCSyntaxGroupItems('lispKey', syntax_full) |
||||
|
||||
" Convert the string to a List and sort it. |
||||
let compl_list = sort(split(syn_list)) |
||||
|
||||
return compl_list |
||||
endfunction |
||||
|
||||
function! s:SyntaxCSyntaxGroupItems( group_name, syntax_full ) |
||||
|
||||
let syn_list = "" |
||||
|
||||
" From the full syntax listing, strip out the portion for the |
||||
" request group. |
||||
" Query: |
||||
" \n - must begin with a newline |
||||
" a:group_name - the group name we are interested in |
||||
" \s\+xxx\s\+ - group names are always followed by xxx |
||||
" \zs - start the match |
||||
" .\{-} - everything ... |
||||
" \ze - end the match |
||||
" \n\w - at the first newline starting with a character |
||||
let syntax_group = matchstr(a:syntax_full, |
||||
\ "\n".a:group_name.'\s\+xxx\s\+\zs.\{-}\ze'."\n".'\w' |
||||
\ ) |
||||
|
||||
if syntax_group != "" |
||||
" let syn_list = substitute( @l, '^.*xxx\s*\%(contained\s*\)\?', "", '' ) |
||||
" let syn_list = substitute( @l, '^.*xxx\s*', "", '' ) |
||||
|
||||
" We only want the words for the lines begining with |
||||
" containedin, but there could be other items. |
||||
|
||||
" Tried to remove all lines that do not begin with contained |
||||
" but this does not work in all cases since you can have |
||||
" contained nextgroup=... |
||||
" So this will strip off the ending of lines with known |
||||
" keywords. |
||||
let syn_list = substitute( |
||||
\ syntax_group, '\<\('. |
||||
\ substitute( |
||||
\ escape(s:syn_remove_words, '\\/.*$^~[]') |
||||
\ , ',', '\\|', 'g' |
||||
\ ). |
||||
\ '\).\{-}\%($\|'."\n".'\)' |
||||
\ , "\n", 'g' |
||||
\ ) |
||||
|
||||
" Now strip off the newline + blank space + contained |
||||
let syn_list = substitute( |
||||
\ syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\)' |
||||
\ , "", 'g' |
||||
\ ) |
||||
|
||||
else |
||||
let syn_list = '' |
||||
endif |
||||
|
||||
return syn_list |
||||
endfunction |
||||
|
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
--- ./asdg 2010-08-27 14:19:02.000000000 +0600
|
||||
+++ ./marks_corey.vim 2010-10-30 20:06:42.000000000 +0600
|
||||
@@ -110,7 +110,7 @@
|
||||
if vIndex > -1
|
||||
call s:Remove_sign(vIndex)
|
||||
else
|
||||
- silent! exe 'sign define CS' . vFlagNum . ' text='. vFlagNum .' texthl=ErrorMsg'
|
||||
+ silent! exe 'sign define CS' . vFlagNum . ' text='. vFlagNum .' texthl=SignColor linehl=SignColor'
|
||||
silent! exe 'sign place ' . vFlagNum . ' line=' . vLn . ' name=CS'. vFlagNum . ' file=' . vFileName
|
||||
|
||||
"let s:Cs_sign_number = s:Cs_sign_number + 1
|
||||
@@ -406,26 +406,26 @@
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
if !hasmapto('<Plug>Place_sign')
|
||||
- map <unique> <c-F2> <Plug>Place_sign
|
||||
+ " map <unique> <c-F2> <Plug>Place_sign
|
||||
map <silent> <unique> mm <Plug>Place_sign
|
||||
endif
|
||||
nnoremap <silent> <script> <Plug>Place_sign :call Place_sign()<cr>
|
||||
|
||||
if !hasmapto('<Plug>Goto_next_sign')
|
||||
- map <unique> <F2> <Plug>Goto_next_sign
|
||||
+ " map <unique> <F2> <Plug>Goto_next_sign
|
||||
map <silent> <unique> mb <Plug>Goto_next_sign
|
||||
endif
|
||||
nnoremap <silent> <script> <Plug>Goto_next_sign :call Goto_next_sign()<cr>
|
||||
|
||||
if !hasmapto('<Plug>Goto_prev_sign')
|
||||
- map <unique> <s-F2> <Plug>Goto_prev_sign
|
||||
+ " map <unique> <s-F2> <Plug>Goto_prev_sign
|
||||
map <silent> <unique> mv <Plug>Goto_prev_sign
|
||||
endif
|
||||
nnoremap <silent> <script> <Plug>Goto_prev_sign :call Goto_prev_sign()<cr>
|
||||
|
||||
-if !hasmapto('<Plug>Remove_all_signs')
|
||||
- map <unique> <F4> <Plug>Remove_all_signs
|
||||
-endif
|
||||
+" if !hasmapto('<Plug>Remove_all_signs')
|
||||
+ " map <unique> <F4> <Plug>Remove_all_signs
|
||||
+" endif
|
||||
nnoremap <silent> <script> <Plug>Remove_all_signs :call Remove_all_signs()<cr>
|
||||
|
||||
if !hasmapto('<Plug>Move_sign')
|
||||
@@ -434,8 +434,8 @@
|
||||
nnoremap <silent> <script> <Plug>Move_sign :call Move_sign()<cr>
|
||||
|
||||
|
||||
-noremap <F6> :call SaveP()<cr>
|
||||
-noremap <F5> :call ReloadP()<cr>
|
||||
+" noremap <F6> :call SaveP()<cr>
|
||||
+" noremap <F5> :call ReloadP()<cr>
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
|
@ -0,0 +1,441 @@
@@ -0,0 +1,441 @@
|
||||
" Vim plugin for showing marks using number array. |
||||
" Maintainer: Hongli Gao <left.slipper at gmail dot com> |
||||
" Last Change: 2010 August 27 |
||||
" Version: 1.4 |
||||
" |
||||
" USAGE: |
||||
" Copy this file to your vim's plugin folder. |
||||
" #### You can set marks only less 100. #### |
||||
" |
||||
" make a mark, or delete it: |
||||
" ctrl + F2 |
||||
" mm |
||||
" move to ahead mark: |
||||
" shift + F2 |
||||
" mv |
||||
" move to next mark: |
||||
" F2 |
||||
" mb |
||||
" moving a mark: |
||||
" m. |
||||
" (press m. to mark a mark, and move the cursor to new line, |
||||
" press the m. again, you can moving a mark.) |
||||
" |
||||
" delete all marks: |
||||
" F4 |
||||
" |
||||
" If you want to save the marks to a file. Do it like this: |
||||
" Add |
||||
" |
||||
" let g:Signs_file_path_corey='c:\\' |
||||
" |
||||
" to your gvimrc, change it to your path. |
||||
" |
||||
" press F6, input a name on command line, press ENTER. # Save marks. |
||||
" press F5, input a name that you used, press ENTER. # Reload marks. |
||||
" |
||||
" copyright (c) 2010 Hongli Gao; |
||||
" Distributed under the GNU General Public License. |
||||
" --------------------------------------------------------------------- |
||||
|
||||
if !has("signs") |
||||
echoerr "Sorry, your vim does not support signs!" |
||||
finish |
||||
endif |
||||
|
||||
if has("win32") |
||||
let s:win32Flag = 1 |
||||
else |
||||
let s:win32Flag = 0 |
||||
endif |
||||
|
||||
"[ sign id, line number, file name] |
||||
let s:mylist = [["00","0","DO NOT CHANGE ANYTHING, THIS USING FOR A VIM PLUGIN. BY HONGLI GAO @2010/08"]] |
||||
let s:myIndex = 1 |
||||
let s:tmplist = ["00","0","corey"] |
||||
let s:deleteFlag = 0 |
||||
let s:outputFileName = "DO_NOT_DELETE_IT" |
||||
let s:remarkItem = ["REMARK","SEARCH","FLAG"] |
||||
|
||||
" --------------------------------------------------------------------- |
||||
fun! SaveP() |
||||
call inputsave() |
||||
let Pname = input('Save Marks to: ') |
||||
call inputrestore() |
||||
if len(Pname) > 0 |
||||
if exists("g:Signs_file_path_corey") |
||||
let temp = g:Signs_file_path_corey |
||||
let g:Signs_file_path_corey = g:Signs_file_path_corey . Pname |
||||
call Save_signs_to_file() |
||||
let g:Signs_file_path_corey = temp |
||||
endif |
||||
endif |
||||
endfun |
||||
|
||||
fun! ReloadP() |
||||
call inputsave() |
||||
let Pbname = input('Load Marks from: ') |
||||
call inputrestore() |
||||
if len(Pbname) > 0 |
||||
if exists("g:Signs_file_path_corey") |
||||
let temp = g:Signs_file_path_corey |
||||
let g:Signs_file_path_corey = g:Signs_file_path_corey . Pbname |
||||
call Load_signs_from_file() |
||||
let g:Signs_file_path_corey = temp |
||||
endif |
||||
endif |
||||
endfun |
||||
" --------------------------------------------------------------------- |
||||
" put on one sign |
||||
fun! Place_sign() |
||||
|
||||
if !exists("s:Cs_sign_number") |
||||
let s:Cs_sign_number = 1 |
||||
endif |
||||
|
||||
if s:Cs_sign_number > 99 |
||||
echo "Sorry, you only can use these marks less 100!" |
||||
return -1 |
||||
else |
||||
let s:Cs_sign_number = (s:mylist[len(s:mylist) - 1][0] * 1) + 1 |
||||
endif |
||||
|
||||
let vLn = "".line(".") |
||||
let vFileName = expand("%:p") |
||||
|
||||
let vFlagNum = (s:Cs_sign_number < 10 ? "0" . s:Cs_sign_number : s:Cs_sign_number) |
||||
let newItem = [vFlagNum,vLn,vFileName] |
||||
let vIndex = s:Check_list(newItem) |
||||
|
||||
if vIndex > -1 |
||||
call s:Remove_sign(vIndex) |
||||
else |
||||
silent! exe 'sign define CS' . vFlagNum . ' text='. vFlagNum .' texthl=SignColor linehl=SignColor' |
||||
silent! exe 'sign place ' . vFlagNum . ' line=' . vLn . ' name=CS'. vFlagNum . ' file=' . vFileName |
||||
|
||||
"let s:Cs_sign_number = s:Cs_sign_number + 1 |
||||
let s:mylist = s:mylist + [newItem] |
||||
" record the last index. |
||||
let s:myIndex = len(s:mylist) - 1 |
||||
let s:deleteFlag = 0 |
||||
endif |
||||
"echo s:mylist |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Remove all signs |
||||
fun! Remove_all_signs() |
||||
|
||||
silent! exe 'sign unplace *' |
||||
if len(s:mylist) > 1 |
||||
let i = remove(s:mylist, 1, -1) |
||||
let s:Cs_sign_number = 1 |
||||
endif |
||||
"echo s:mylist |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Goto prev sign: |
||||
fun! Goto_prev_sign() |
||||
|
||||
if len(s:mylist) > 1 |
||||
if s:deleteFlag == 0 |
||||
let s:myIndex = s:myIndex - 1 |
||||
endif |
||||
let s:deleteFlag = 0 |
||||
|
||||
if s:myIndex <= 0 |
||||
let s:myIndex = len(s:mylist) - 1 |
||||
endif |
||||
call s:Sign_jump(s:mylist[s:myIndex]) |
||||
endif |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Goto next sign: |
||||
fun! Goto_next_sign() |
||||
|
||||
let s:deleteFlag = 0 |
||||
if len(s:mylist) > 1 |
||||
let s:myIndex = s:myIndex + 1 |
||||
if ((s:myIndex >= len(s:mylist)) || (s:myIndex == 1)) |
||||
let s:myIndex = 1 |
||||
endif |
||||
call s:Sign_jump(s:mylist[s:myIndex]) |
||||
endif |
||||
endfun |
||||
" --------------------------------------------------------------------- |
||||
" Save_signs_to_file |
||||
fun! Save_signs_to_file() |
||||
|
||||
call s:Get_signs_file_name() |
||||
let tempList = [] |
||||
for item in s:mylist |
||||
let tempList = tempList + [item[0] . "#" . item[1]. "#" . item[2]] |
||||
endfor |
||||
if exists("g:Signs_file_path_corey") |
||||
let writeFlag = writefile(tempList, s:outputFileName) |
||||
endif |
||||
endfun |
||||
" --------------------------------------------------------------------- |
||||
" Load_signs_from_file |
||||
fun! Load_signs_from_file() |
||||
|
||||
call s:Get_signs_file_name() |
||||
if filereadable(s:outputFileName) |
||||
let tempList = [[]] |
||||
let iflag = 0 |
||||
for line in readfile(s:outputFileName) |
||||
let first = stridx(line, "#", 0) |
||||
let second = stridx(line, "#", first + 1) |
||||
if iflag != 0 |
||||
let tempList = tempList + [[strpart(line, 0, first), strpart(line, first + 1, second - first - 1), strpart(line, second + 1)]] |
||||
else |
||||
let tempList = [[strpart(line, 0, first), strpart(line, first + 1, second - first - 1), strpart(line, second + 1)]] |
||||
endif |
||||
let iflag = 1 |
||||
endfor |
||||
let s:mylist = tempList |
||||
endif |
||||
|
||||
call s:Flash_signs() |
||||
|
||||
"echo s:mylist |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
fun! s:Get_signs_file_name() |
||||
|
||||
if exists("g:Signs_file_path_corey") |
||||
let s:outputFileName = g:Signs_file_path_corey . "_DO_NOT_DELETE_IT" |
||||
endif |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Remove one sign |
||||
fun! s:Remove_sign(aIndex) |
||||
|
||||
if len(s:mylist) > 1 |
||||
silent! exe 'sign unplace ' .s:mylist[a:aIndex][0] . ' file=' . s:mylist[a:aIndex][2] |
||||
|
||||
" record the before item |
||||
let s:tmplist = s:mylist[a:aIndex - 1] |
||||
|
||||
let i = remove(s:mylist, a:aIndex) |
||||
|
||||
" record the current index. |
||||
let s:myIndex = s:Check_list(s:tmplist) |
||||
let s:deleteFlag = 1 |
||||
"echo s:mylist |
||||
endif |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
fun! s:Flash_signs() |
||||
|
||||
silent! exe 'sign unplace *' |
||||
silent! exe 'sign undefine *' |
||||
if len(s:mylist) > 1 |
||||
for item in s:mylist |
||||
silent! exe 'sign define CS' . item[0] . ' text='. item[0] .' texthl=ErrorMsg' |
||||
silent! exe 'badd ' . item[2] |
||||
silent! exe 'sign place ' . item[0] . ' line=' . item[1] . ' name=CS'. item[0] . ' file=' . item[2] |
||||
endfor |
||||
endif |
||||
let s:Cs_sign_number = s:mylist[len(s:mylist) - 1][0] * 1 + 1 |
||||
"let s:myIndex = 1 ##you don't need reset the pointer |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" if line number and file name both same, return the aitem's index of s:mylist |
||||
" else return -1 |
||||
" index 0 of s:mylist is the output message in the record file. |
||||
fun! s:Check_list(aItem) |
||||
|
||||
let vResult = -1 |
||||
let index = 0 |
||||
|
||||
for item in s:mylist |
||||
if ((s:Compare(item[1], a:aItem[1]) == 1) && (s:Compare(item[2],a:aItem[2]) == 1)) |
||||
return index |
||||
endif |
||||
let index = index + 1 |
||||
endfor |
||||
|
||||
return vResult |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" Move_sign |
||||
fun! Move_sign() |
||||
|
||||
let s:tempItem = ["","",""] |
||||
let vRLn = "".line(".") |
||||
let vRFileName = expand("%:p") |
||||
|
||||
let s:tempItem[1] = vRLn |
||||
let s:tempItem[2] = vRFileName |
||||
"echo s:tempItem |
||||
let vRIndex = s:Check_list(s:tempItem) |
||||
|
||||
if (s:remarkItem[0] ==# "REMARK" ) |
||||
if vRIndex > 0 |
||||
silent! exe 'sign define CS' . s:mylist[vRIndex][0] . ' text='. s:mylist[vRIndex][0] .' texthl=Search' |
||||
silent! exe 'sign place ' . s:mylist[vRIndex][0] . ' line=' . vRLn . ' name=CS'. s:mylist[vRIndex][0] . ' file=' . vRFileName |
||||
let s:remarkItem = s:mylist[vRIndex] |
||||
let s:myIndex = vRIndex |
||||
"echo s:remarkItem |
||||
endif |
||||
else |
||||
let pionter = s:Check_list(s:remarkItem) |
||||
"echo vRIndex ."|" .pionter |
||||
if ((vRIndex < 0) && (pionter > 0)) |
||||
silent! exe 'sign unplace ' .s:remarkItem[0] . ' file=' . s:remarkItem[2] |
||||
"silent! exe 'sign undefine' .s:remarkItem[0] |
||||
silent! exe 'sign define CS' . s:remarkItem[0] . ' text='. s:remarkItem[0] .' texthl=ErrorMsg' |
||||
silent! exe 'sign place ' . s:remarkItem[0] . ' line=' . vRLn . ' name=CS' . s:remarkItem[0] . ' file=' . vRFileName |
||||
let s:mylist[pionter][1] = vRLn |
||||
let s:mylist[pionter][2] = vRFileName |
||||
"echo s:mylist[pionter] |
||||
let s:myIndex = pionter |
||||
let s:remarkItem = ["REMARK","SEARCH","FLAG"] |
||||
endif |
||||
endif |
||||
endfun |
||||
|
||||
" -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
||||
" all of them used for the jump. |
||||
fun! s:Sign_jump(aSignItem) |
||||
let bufferExits = s:GetTabpage(a:aSignItem) |
||||
|
||||
if bufferExits > 0 |
||||
silent! exe 'tabn ' . bufferExits |
||||
silent! exe 'sign jump '. a:aSignItem[0] . ' file='. a:aSignItem[2] |
||||
else |
||||
call s:Open_file(a:aSignItem[2]) |
||||
silent! exe 'sign place ' . a:aSignItem[0] . ' line=' . a:aSignItem[1] . ' name=CS'. a:aSignItem[0] . ' file=' . a:aSignItem[2] |
||||
silent! exe 'sign jump '. a:aSignItem[0] . ' file='. a:aSignItem[2] |
||||
endif |
||||
|
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" GetTabpage |
||||
fun! s:GetTabpage(aSignItem) |
||||
|
||||
let bufname = expand("%:p") |
||||
if s:Compare(bufname,a:aSignItem[2]) == 1 |
||||
return tabpagenr() |
||||
endif |
||||
|
||||
let i = 0 |
||||
|
||||
while i < tabpagenr('$') |
||||
|
||||
if i == 0 |
||||
silent! exe 'tabfirst' |
||||
else |
||||
silent! exe 'tabnext' |
||||
endif |
||||
let bufname = expand("%:p") |
||||
|
||||
if s:Compare(bufname,a:aSignItem[2]) == 1 |
||||
return i + 1 |
||||
endif |
||||
|
||||
let i = i + 1 |
||||
endwhile |
||||
|
||||
return -1 |
||||
endfun |
||||
" --------------------------------------------------------------------- |
||||
" compare |
||||
fun! s:Compare(a1,a2) |
||||
if s:win32Flag == 1 |
||||
if a:a1 ==? a:a2 |
||||
return 1 |
||||
endif |
||||
else |
||||
if a:a1 ==# a:a2 |
||||
return 1 |
||||
endif |
||||
endif |
||||
return 0 |
||||
endfun |
||||
|
||||
" --------------------------------------------------------------------- |
||||
" open file |
||||
fun! s:Open_file(aFileName) |
||||
if filereadable(a:aFileName) |
||||
"call s:Flash_signs() |
||||
if tabpagenr('$') > 1 |
||||
silent! exe 'tabnew '. a:aFileName |
||||
silent! exe 'tabn ' . tabpagenr('$') |
||||
else |
||||
silent! exe 'e '. a:aFileName |
||||
endif |
||||
endif |
||||
endfun |
||||
" --------------------------------------------------------------------- |
||||
" search file |
||||
" find the file, return the position; else return -1 |
||||
fun! s:Seach_file(aFileName, aBufferList) |
||||
|
||||
let vResult = -1 |
||||
|
||||
if len(a:aBufferList) > 1 |
||||
if s:win32Flag == 1 |
||||
for item in a:aBufferList |
||||
" file name is ignoring case |
||||
if (item[1] ==? a:aFileName) |
||||
return item[0] |
||||
endif |
||||
endfor |
||||
else |
||||
for item in a:aBufferList |
||||
" file name is matching case |
||||
if (item[1] ==# a:aFileName) |
||||
return item[0] |
||||
endif |
||||
endfor |
||||
endif |
||||
endif |
||||
return vResult |
||||
endfun |
||||
|
||||
|
||||
" --------------------------------------------------------------------- |
||||
if !hasmapto('<Plug>Place_sign') |
||||
" map <unique> <c-F2> <Plug>Place_sign |
||||
map <silent> <unique> mm <Plug>Place_sign |
||||
endif |
||||
nnoremap <silent> <script> <Plug>Place_sign :call Place_sign()<cr> |
||||
|
||||
if !hasmapto('<Plug>Goto_next_sign') |
||||
" map <unique> <F2> <Plug>Goto_next_sign |
||||
map <silent> <unique> mb <Plug>Goto_next_sign |
||||
endif |
||||
nnoremap <silent> <script> <Plug>Goto_next_sign :call Goto_next_sign()<cr> |
||||
|
||||
if !hasmapto('<Plug>Goto_prev_sign') |
||||
" map <unique> <s-F2> <Plug>Goto_prev_sign |
||||
map <silent> <unique> mv <Plug>Goto_prev_sign |
||||
endif |
||||
nnoremap <silent> <script> <Plug>Goto_prev_sign :call Goto_prev_sign()<cr> |
||||
|
||||
" if !hasmapto('<Plug>Remove_all_signs') |
||||
" map <unique> <F4> <Plug>Remove_all_signs |
||||
" endif |
||||
nnoremap <silent> <script> <Plug>Remove_all_signs :call Remove_all_signs()<cr> |
||||
|
||||
if !hasmapto('<Plug>Move_sign') |
||||
map <silent> <unique> m. <Plug>Move_sign |
||||
endif |
||||
nnoremap <silent> <script> <Plug>Move_sign :call Move_sign()<cr> |
||||
|
||||
|
||||
" noremap <F6> :call SaveP()<cr> |
||||
" noremap <F5> :call ReloadP()<cr> |
||||
|
||||
" --------------------------------------------------------------------- |
||||
|
@ -0,0 +1,406 @@
@@ -0,0 +1,406 @@
|
||||
*matchit.txt* Extended "%" matching |
||||
|
||||
For instructions on installing this file, type |
||||
:help matchit-install |
||||
inside Vim. |
||||
|
||||
For Vim version 6.3. Last change: 2007 Aug 29 |
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Benji Fisher |
||||
|
||||
*matchit* *matchit.vim* |
||||
|
||||
1. Extended matching with "%" |matchit-intro| |
||||
2. Activation |matchit-activate| |
||||
3. Configuration |matchit-configure| |
||||
4. Supporting a New Language |matchit-newlang| |
||||
5. Known Bugs and Limitations |matchit-bugs| |
||||
|
||||
The functionality mentioned here is a plugin, see |add-plugin|. |
||||
This plugin is only available if 'compatible' is not set. |
||||
You can avoid loading this plugin by setting the "loaded_matchit" variable |
||||
in your |vimrc| file: > |
||||
:let loaded_matchit = 1 |
||||
|
||||
{Vi does not have any of this} |
||||
|
||||
============================================================================== |
||||
1. Extended matching with "%" *matchit-intro* |
||||
|
||||
*matchit-%* |
||||
% Cycle forward through matching groups, such as "if", "else", "endif", |
||||
as specified by |b:match_words|. |
||||
|
||||
*g%* *v_g%* *o_g%* |
||||
g% Cycle backwards through matching groups, as specified by |
||||
|b:match_words|. For example, go from "if" to "endif" to "else". |
||||
|
||||
*[%* *v_[%* *o_[%* |
||||
[% Go to [count] previous unmatched group, as specified by |
||||
|b:match_words|. Similar to |[{|. |
||||
|
||||
*]%* *v_]%* *o_]%* |
||||
]% Go to [count] next unmatched group, as specified by |
||||
|b:match_words|. Similar to |]}|. |
||||
|
||||
*v_a%* |
||||
a% In Visual mode, select the matching group, as specified by |
||||
|b:match_words|, containing the cursor. Similar to |v_a[|. |
||||
A [count] is ignored, and only the first character of the closing |
||||
pattern is selected. |
||||
|
||||
In Vim, as in plain vi, the percent key, |%|, jumps the cursor from a brace, |
||||
bracket, or paren to its match. This can be configured with the 'matchpairs' |
||||
option. The matchit plugin extends this in several ways: |
||||
|
||||
You can match whole words, such as "if" and "endif", not just |
||||
single characters. You can also specify a |regular-expression|. |
||||
You can define groups with more than two words, such as "if", |
||||
"else", "endif". Banging on the "%" key will cycle from the "if" to |
||||
the first "else", the next "else", ..., the closing "endif", and back |
||||
to the opening "if". Nested structures are skipped. Using |g%| goes |
||||
in the reverse direction. |
||||
By default, words inside comments and strings are ignored, unless |
||||
the cursor is inside a comment or string when you type "%". If the |
||||
only thing you want to do is modify the behavior of "%" so that it |
||||
behaves this way, you do not have to define |b:match_words|, since the |
||||
script uses the 'matchpairs' option as well as this variable. |
||||
|
||||
See |matchit-details| for details on what the script does, and |b:match_words| |
||||
for how to specify matching patterns. |
||||
|
||||
MODES: *matchit-modes* *matchit-v_%* *matchit-o_%* |
||||
|
||||
Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in |
||||
|motion| commands in |Operator-pending| and |Visual| modes. However, you |
||||
cannot make these motions |linewise| or |characterwise|, since the |:omap|s |
||||
that define them start with "v" in order to make the default behavior |
||||
inclusive. (See |o_v|.) In other words, "dV%" will not work. The |
||||
work-around is to go through Visual mode: "V%d" will work. |
||||
|
||||
LANGUAGES: *matchit-languages* |
||||
|
||||
Currently, the following languages are supported: Ada, ASP with VBS, Csh, |
||||
DTD, Entity, Essbase, Fortran, HTML, JSP (same as HTML), LaTeX, Lua, Pascal, |
||||
SGML, Shell, Tcsh, Vim, XML. Other languages may already have support via |
||||
the default |filetype-plugin|s in the standard vim distribution. |
||||
|
||||
To support a new language, see |matchit-newlang| below. |
||||
|
||||
DETAILS: *matchit-details* *matchit-parse* |
||||
|
||||
Here is an outline of what matchit.vim does each time you hit the "%" key. If |
||||
there are |backref|s in |b:match_words| then the first step is to produce a |
||||
version in which these back references have been eliminated; if there are no |
||||
|backref|s then this step is skipped. This step is called parsing. For |
||||
example, "\(foo\|bar\):end\1" is parsed to yield |
||||
"\(foo\|bar\):end\(foo\|bar\)". This can get tricky, especially if there are |
||||
nested groups. If debugging is turned on, the parsed version is saved as |
||||
|b:match_pat|. |
||||
|
||||
*matchit-choose* |
||||
Next, the script looks for a word on the current line that matches the pattern |
||||
just constructed. It includes the patterns from the 'matchpairs' option. |
||||
The goal is to do what you expect, which turns out to be a little complicated. |
||||
The script follows these rules: |
||||
|
||||
Insist on a match that ends on or after the cursor. |
||||
Prefer a match that includes the cursor position (that is, one that |
||||
starts on or before the cursor). |
||||
Prefer a match that starts as close to the cursor as possible. |
||||
If more than one pattern in |b:match_words| matches, choose the one |
||||
that is listed first. |
||||
|
||||
Examples: |
||||
|
||||
Suppose you > |
||||
:let b:match_words = '<:>,<tag>:</tag>' |
||||
< and hit "%" with the cursor on or before the "<" in "a <tag> is born". |
||||
The pattern '<' comes first, so it is preferred over '<tag>', which |
||||
also matches. If the cursor is on the "t", however, then '<tag>' is |
||||
preferred, because this matches a bit of text containing the cursor. |
||||
If the two groups of patterns were reversed then '<' would never be |
||||
preferred. |
||||
|
||||
Suppose you > |
||||
:let b:match_words = 'if:end if' |
||||
< (Note the space!) and hit "%" with the cursor at the end of "end if". |
||||
Then "if" matches, which is probably not what you want, but if the |
||||
cursor starts on the "end " then "end if" is chosen. (You can avoid |
||||
this problem by using a more complicated pattern.) |
||||
|
||||
If there is no match, the cursor does not move. (Before version 1.13 of the |
||||
script, it would fall back on the usual behavior of |%|). If debugging is |
||||
turned on, the matched bit of text is saved as |b:match_match| and the cursor |
||||
column of the start of the match is saved as |b:match_col|. |
||||
|
||||
Next, the script looks through |b:match_words| (original and parsed versions) |
||||
for the group and pattern that match. If debugging is turned on, the group is |
||||
saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest). If |
||||
there are |backref|s then, in addition, the matching pattern is saved as |
||||
|b:match_word| and a table of translations is saved as |b:match_table|. If |
||||
there are |backref|s, these are determined from the matching pattern and |
||||
|b:match_match| and substituted into each pattern in the matching group. |
||||
|
||||
The script decides whether to search forwards or backwards and chooses |
||||
arguments for the |searchpair()| function. Then, the cursor is moved to the |
||||
start of the match, and |searchpair()| is called. By default, matching |
||||
structures inside strings and comments are ignored. This can be changed by |
||||
setting |b:match_skip|. |
||||
|
||||
============================================================================== |
||||
2. Activation *matchit-activate* |
||||
|
||||
You can use this script as a plugin, by copying it to your plugin directory. |
||||
See |add-global-plugin| for instructions. You can also add a line to your |
||||
|vimrc| file, such as > |
||||
:source $VIMRUNTIME/macros/matchit.vim |
||||
or > |
||||
:runtime macros/matchit.vim |
||||
Either way, the script should start working the next time you start up Vim. |
||||
|
||||
(Earlier versions of the script did nothing unless a |buffer-variable| named |
||||
|b:match_words| was defined. Even earlier versions contained autocommands |
||||
that set this variable for various file types. Now, |b:match_words| is |
||||
defined in many of the default |filetype-plugin|s instead.) |
||||
|
||||
For a new language, you can add autocommands to the script or to your vimrc |
||||
file, but the recommended method is to add a line such as > |
||||
let b:match_words = '\<foo\>:\<bar\>' |
||||
to the |filetype-plugin| for your language. See |b:match_words| below for how |
||||
this variable is interpreted. |
||||
|
||||
TROUBLESHOOTING *matchit-troubleshoot* |
||||
|
||||
The script should work in most installations of Vim. It may not work if Vim |
||||
was compiled with a minimal feature set, for example if the |+syntax| option |
||||
was not enabled. If your Vim has support for syntax compiled in, but you do |
||||
not have |syntax| highlighting turned on, matchit.vim should work, but it may |
||||
fail to skip matching groups in comments and strings. If the |filetype| |
||||
mechanism is turned off, the |b:match_words| variable will probably not be |
||||
defined automatically. |
||||
|
||||
============================================================================== |
||||
3. Configuration *matchit-configure* |
||||
|
||||
There are several variables that govern the behavior of matchit.vim. Note |
||||
that these are variables local to the buffer, not options, so use |:let| to |
||||
define them, not |:set|. Some of these variables have values that matter; for |
||||
others, it only matters whether the variable has been defined. All of these |
||||
can be defined in the |filetype-plugin| or autocommand that defines |
||||
|b:match_words| or "on the fly." |
||||
|
||||
The main variable is |b:match_words|. It is described in the section below on |
||||
supporting a new language. |
||||
|
||||
*MatchError* *matchit-hl* *matchit-highlight* |
||||
MatchError is the highlight group for error messages from the script. By |
||||
default, it is linked to WarningMsg. If you do not want to be bothered by |
||||
error messages, you can define this to be something invisible. For example, |
||||
if you use the GUI version of Vim and your command line is normally white, you |
||||
can do > |
||||
:hi MatchError guifg=white guibg=white |
||||
< |
||||
*b:match_ignorecase* |
||||
If you > |
||||
:let b:match_ignorecase = 1 |
||||
then matchit.vim acts as if 'ignorecase' is set: for example, "end" and "END" |
||||
are equivalent. If you > |
||||
:let b:match_ignorecase = 0 |
||||
then matchit.vim treats "end" and "END" differently. (There will be no |
||||
b:match_infercase option unless someone requests it.) |
||||
|
||||
*b:match_debug* |
||||
Define b:match_debug if you want debugging information to be saved. See |
||||
|matchit-debug|, below. |
||||
|
||||
*b:match_skip* |
||||
If b:match_skip is defined, it is passed as the skip argument to |
||||
|searchpair()|. This controls when matching structures are skipped, or |
||||
ignored. By default, they are ignored inside comments and strings, as |
||||
determined by the |syntax| mechanism. (If syntax highlighting is turned off, |
||||
nothing is skipped.) You can set b:match_skip to a string, which evaluates to |
||||
a non-zero, numerical value if the match is to be skipped or zero if the match |
||||
should not be skipped. In addition, the following special values are |
||||
supported by matchit.vim: |
||||
s:foo becomes (current syntax item) =~ foo |
||||
S:foo becomes (current syntax item) !~ foo |
||||
r:foo becomes (line before cursor) =~ foo |
||||
R:foo becomes (line before cursor) !~ foo |
||||
(The "s" is meant to suggest "syntax", and the "r" is meant to suggest |
||||
"regular expression".) |
||||
|
||||
Examples: |
||||
|
||||
You can get the default behavior with > |
||||
:let b:match_skip = 's:comment\|string' |
||||
< |
||||
If you want to skip matching structures unless they are at the start |
||||
of the line (ignoring whitespace) then you can > |
||||
:let b:match_skip = 'R:^\s*' |
||||
< Do not do this if strings or comments can span several lines, since |
||||
the normal syntax checking will not be done if you set b:match_skip. |
||||
|
||||
In LaTeX, since "%" is used as the comment character, you can > |
||||
:let b:match_skip = 'r:%' |
||||
< Unfortunately, this will skip anything after "\%", an escaped "%". To |
||||
allow for this, and also "\\%" (an excaped backslash followed by the |
||||
comment character) you can > |
||||
:let b:match_skip = 'r:\(^\|[^\\]\)\(\\\\\)*%' |
||||
< |
||||
See the $VIMRUNTIME/ftplugin/vim.vim for an example that uses both |
||||
syntax and a regular expression. |
||||
|
||||
============================================================================== |
||||
4. Supporting a New Language *matchit-newlang* |
||||
*b:match_words* |
||||
In order for matchit.vim to support a new language, you must define a suitable |
||||
pattern for |b:match_words|. You may also want to set some of the |
||||
|matchit-configure| variables, as described above. If your language has a |
||||
complicated syntax, or many keywords, you will need to know something about |
||||
Vim's |regular-expression|s. |
||||
|
||||
The format for |b:match_words| is similar to that of the 'matchpairs' option: |
||||
it is a comma (,)-separated list of groups; each group is a colon(:)-separated |
||||
list of patterns (regular expressions). Commas and backslashes that are part |
||||
of a pattern should be escaped with backslashes ('\:' and '\,'). It is OK to |
||||
have only one group; the effect is undefined if a group has only one pattern. |
||||
A simple example is > |
||||
:let b:match_words = '\<if\>:\<endif\>,' |
||||
\ . '\<while\>:\<continue\>:\<break\>:\<endwhile\>' |
||||
(In Vim regular expressions, |\<| and |\>| denote word boundaries. Thus "if" |
||||
matches the end of "endif" but "\<if\>" does not.) Then banging on the "%" |
||||
key will bounce the cursor between "if" and the matching "endif"; and from |
||||
"while" to any matching "continue" or "break", then to the matching "endwhile" |
||||
and back to the "while". It is almost always easier to use |literal-string|s |
||||
(single quotes) as above: '\<if\>' rather than "\\<if\\>" and so on. |
||||
|
||||
Exception: If the ":" character does not appear in b:match_words, then it is |
||||
treated as an expression to be evaluated. For example, > |
||||
:let b:match_words = 'GetMatchWords()' |
||||
allows you to define a function. This can return a different string depending |
||||
on the current syntax, for example. |
||||
|
||||
Once you have defined the appropriate value of |b:match_words|, you will |
||||
probably want to have this set automatically each time you edit the |
||||
appropriate file type. The recommended way to do this is by adding the |
||||
definition to a |filetype-plugin| file. |
||||
|
||||
Tips: Be careful that your initial pattern does not match your final pattern. |
||||
See the example above for the use of word-boundary expressions. It is usually |
||||
better to use ".\{-}" (as many as necessary) instead of ".*" (as many as |
||||
possible). See |\{-|. For example, in the string "<tag>label</tag>", "<.*>" |
||||
matches the whole string whereas "<.\{-}>" and "<[^>]*>" match "<tag>" and |
||||
"</tag>". |
||||
|
||||
*matchit-spaces* *matchit-s:notend* |
||||
If "if" is to be paired with "end if" (Note the space!) then word boundaries |
||||
are not enough. Instead, define a regular expression s:notend that will match |
||||
anything but "end" and use it as follows: > |
||||
:let s:notend = '\%(\<end\s\+\)\@<!' |
||||
:let b:match_words = s:notend . '\<if\>:\<end\s\+if\>' |
||||
< *matchit-s:sol* |
||||
This is a simplified version of what is done for Ada. The s:notend is a |
||||
|script-variable|. Similarly, you may want to define a start-of-line regular |
||||
expression > |
||||
:let s:sol = '\%(^\|;\)\s*' |
||||
if keywords are only recognized after the start of a line or after a |
||||
semicolon (;), with optional white space. |
||||
|
||||
*matchit-backref* *matchit-\1* |
||||
In any group, the expressions |\1|, |\2|, ..., |\9| refer to parts of the |
||||
INITIAL pattern enclosed in |\(|escaped parentheses|\)|. These are referred |
||||
to as back references, or backrefs. For example, > |
||||
:let b:match_words = '\<b\(o\+\)\>:\(h\)\1\>' |
||||
means that "bo" pairs with "ho" and "boo" pairs with "hoo" and so on. Note |
||||
that "\1" does not refer to the "\(h\)" in this example. If you have |
||||
"\(nested \(parentheses\)\) then "\d" refers to the d-th "\(" and everything |
||||
up to and including the matching "\)": in "\(nested\(parentheses\)\)", "\1" |
||||
refers to everything and "\2" refers to "\(parentheses\)". If you use a |
||||
variable such as |s:notend| or |s:sol| in the previous paragraph then remember |
||||
to count any "\(" patterns in this variable. You do not have to count groups |
||||
defined by |\%(\)|. |
||||
|
||||
It should be possible to resolve back references from any pattern in the |
||||
group. For example, > |
||||
:let b:match_words = '\(foo\)\(bar\):more\1:and\2:end\1\2' |
||||
would not work because "\2" cannot be determined from "morefoo" and "\1" |
||||
cannot be determined from "andbar". On the other hand, > |
||||
:let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1' |
||||
should work (and have the same effect as "foobar:barfoo:endfoobar"), although |
||||
this has not been thoroughly tested. |
||||
|
||||
You can use |zero-width| patterns such as |\@<=| and |\zs|. (The latter has |
||||
not been thouroughly tested in matchit.vim.) For example, if the keyword "if" |
||||
must occur at the start of the line, with optional white space, you might use |
||||
the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of |
||||
at the start of the line. For another example, if HTML had only one tag then |
||||
one could > |
||||
:let b:match_words = '<:>,<\@<=tag>:<\@<=/tag>' |
||||
so that "%" can bounce between matching "<" and ">" pairs or (starting on |
||||
"tag" or "/tag") between matching tags. Without the |\@<=|, the script would |
||||
bounce from "tag" to the "<" in "</tag>", and another "%" would not take you |
||||
back to where you started. |
||||
|
||||
DEBUGGING *matchit-debug* *:MatchDebug* |
||||
|
||||
If you are having trouble figuring out the appropriate definition of |
||||
|b:match_words| then you can take advantage of the same information I use when |
||||
debugging the script. This is especially true if you are not sure whether |
||||
your patterns or my script are at fault! To make this more convenient, I have |
||||
made the command :MatchDebug, which defines the variable |b:match_debug| and |
||||
creates a Matchit menu. This menu makes it convenient to check the values of |
||||
the variables described below. You will probably also want to read |
||||
|matchit-details| above. |
||||
|
||||
Defining the variable |b:match_debug| causes the script to set the following |
||||
variables, each time you hit the "%" key. Several of these are only defined |
||||
if |b:match_words| includes |backref|s. |
||||
|
||||
*b:match_pat* |
||||
The b:match_pat variable is set to |b:match_words| with |backref|s parsed. |
||||
*b:match_match* |
||||
The b:match_match variable is set to the bit of text that is recognized as a |
||||
match. |
||||
*b:match_col* |
||||
The b:match_col variable is set to the cursor column of the start of the |
||||
matching text. |
||||
*b:match_wholeBR* |
||||
The b:match_wholeBR variable is set to the comma-separated group of patterns |
||||
that matches, with |backref|s unparsed. |
||||
*b:match_iniBR* |
||||
The b:match_iniBR variable is set to the first pattern in |b:match_wholeBR|. |
||||
*b:match_ini* |
||||
The b:match_ini variable is set to the first pattern in |b:match_wholeBR|, |
||||
with |backref|s resolved from |b:match_match|. |
||||
*b:match_tail* |
||||
The b:match_tail variable is set to the remaining patterns in |
||||
|b:match_wholeBR|, with |backref|s resolved from |b:match_match|. |
||||
*b:match_word* |
||||
The b:match_word variable is set to the pattern from |b:match_wholeBR| that |
||||
matches |b:match_match|. |
||||
*b:match_table* |
||||
The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in |
||||
|b:match_word|. |
||||
|
||||
============================================================================== |
||||
5. Known Bugs and Limitations *matchit-bugs* |
||||
|
||||
Just because I know about a bug does not mean that it is on my todo list. I |
||||
try to respond to reports of bugs that cause real problems. If it does not |
||||
cause serious problems, or if there is a work-around, a bug may sit there for |
||||
a while. Moral: if a bug (known or not) bothers you, let me know. |
||||
|
||||
The various |:vmap|s defined in the script (%, |g%|, |[%|, |]%|, |a%|) may |
||||
have undesired effects in Select mode |Select-mode-mapping|. At least, if you |
||||
want to replace the selection with any character in "ag%[]" there will be a |
||||
pause of |'updatetime'| first. |
||||
|
||||
It would be nice if "\0" were recognized as the entire pattern. That is, it |
||||
would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1". I may |
||||
try to implement this in a future version. (This is not so easy to arrange as |
||||
you might think!) |
||||
|
||||
============================================================================== |
||||
vim:tw=78:fo=tcq2: |
@ -0,0 +1,812 @@
@@ -0,0 +1,812 @@
|
||||
" matchit.vim: (global plugin) Extended "%" matching |
||||
" Last Change: Fri Jan 25 10:00 AM 2008 EST |
||||
" Maintainer: Benji Fisher PhD <benji@member.AMS.org> |
||||
" Version: 1.13.2, for Vim 6.3+ |
||||
" URL: http://www.vim.org/script.php?script_id=39 |
||||
|
||||
" Documentation: |
||||
" The documentation is in a separate file, matchit.txt . |
||||
|
||||
" Credits: |
||||
" Vim editor by Bram Moolenaar (Thanks, Bram!) |
||||
" Original script and design by Raul Segura Acevedo |
||||
" Support for comments by Douglas Potts |
||||
" Support for back references and other improvements by Benji Fisher |
||||
" Support for many languages by Johannes Zellner |
||||
" Suggestions for improvement, bug reports, and support for additional |
||||
" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark |
||||
" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner. |
||||
|
||||
" Debugging: |
||||
" If you'd like to try the built-in debugging commands... |
||||
" :MatchDebug to activate debugging for the current buffer |
||||
" This saves the values of several key script variables as buffer-local |
||||
" variables. See the MatchDebug() function, below, for details. |
||||
|
||||
" TODO: I should think about multi-line patterns for b:match_words. |
||||
" This would require an option: how many lines to scan (default 1). |
||||
" This would be useful for Python, maybe also for *ML. |
||||
" TODO: Maybe I should add a menu so that people will actually use some of |
||||
" the features that I have implemented. |
||||
" TODO: Eliminate the MultiMatch function. Add yet another argument to |
||||
" Match_wrapper() instead. |
||||
" TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1' |
||||
" TODO: Make backrefs safer by using '\V' (very no-magic). |
||||
" TODO: Add a level of indirection, so that custom % scripts can use my |
||||
" work but extend it. |
||||
|
||||
" allow user to prevent loading |
||||
" and prevent duplicate loading |
||||
if exists("loaded_matchit") || &cp |
||||
finish |
||||
endif |
||||
let loaded_matchit = 1 |
||||
let s:last_mps = "" |
||||
let s:last_words = ":" |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR> |
||||
nnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'n') <CR> |
||||
vnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv`` |
||||
vnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'v') <CR>m'gv`` |
||||
onoremap <silent> % v:<C-U>call <SID>Match_wrapper('',1,'o') <CR> |
||||
onoremap <silent> g% v:<C-U>call <SID>Match_wrapper('',0,'o') <CR> |
||||
|
||||
" Analogues of [{ and ]} using matching patterns: |
||||
nnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "n") <CR> |
||||
nnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "n") <CR> |
||||
vmap [% <Esc>[%m'gv`` |
||||
vmap ]% <Esc>]%m'gv`` |
||||
" vnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "v") <CR>m'gv`` |
||||
" vnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "v") <CR>m'gv`` |
||||
onoremap <silent> [% v:<C-U>call <SID>MultiMatch("bW", "o") <CR> |
||||
onoremap <silent> ]% v:<C-U>call <SID>MultiMatch("W", "o") <CR> |
||||
|
||||
" text object: |
||||
vmap a% <Esc>[%v]% |
||||
|
||||
" Auto-complete mappings: (not yet "ready for prime time") |
||||
" TODO Read :help write-plugin for the "right" way to let the user |
||||
" specify a key binding. |
||||
" let g:match_auto = '<C-]>' |
||||
" let g:match_autoCR = '<C-CR>' |
||||
" if exists("g:match_auto") |
||||
" execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls' |
||||
" endif |
||||
" if exists("g:match_autoCR") |
||||
" execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>' |
||||
" endif |
||||
" if exists("g:match_gthhoh") |
||||
" execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>' |
||||
" endif " gthhoh = "Get the heck out of here!" |
||||
|
||||
let s:notslash = '\\\@<!\%(\\\\\)*' |
||||
|
||||
function! s:Match_wrapper(word, forward, mode) range |
||||
" In s:CleanUp(), :execute "set" restore_options . |
||||
let restore_options = (&ic ? " " : " no") . "ignorecase" |
||||
if exists("b:match_ignorecase") |
||||
let &ignorecase = b:match_ignorecase |
||||
endif |
||||
let restore_options = " ve=" . &ve . restore_options |
||||
set ve= |
||||
" If this function was called from Visual mode, make sure that the cursor |
||||
" is at the correct end of the Visual range: |
||||
if a:mode == "v" |
||||
execute "normal! gv\<Esc>" |
||||
endif |
||||
" In s:CleanUp(), we may need to check whether the cursor moved forward. |
||||
let startline = line(".") |
||||
let startcol = col(".") |
||||
" Use default behavior if called with a count. |
||||
if v:count |
||||
exe "normal! " . v:count . "%" |
||||
return s:CleanUp(restore_options, a:mode, startline, startcol) |
||||
end |
||||
|
||||
" First step: if not already done, set the script variables |
||||
" s:do_BR flag for whether there are backrefs |
||||
" s:pat parsed version of b:match_words |
||||
" s:all regexp based on s:pat and the default groups |
||||
" |
||||
if !exists("b:match_words") || b:match_words == "" |
||||
let match_words = "" |
||||
" Allow b:match_words = "GetVimMatchWords()" . |
||||
elseif b:match_words =~ ":" |
||||
let match_words = b:match_words |
||||
else |
||||
execute "let match_words =" b:match_words |
||||
endif |
||||
" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! |
||||
if (match_words != s:last_words) || (&mps != s:last_mps) || |
||||
\ exists("b:match_debug") |
||||
let s:last_words = match_words |
||||
let s:last_mps = &mps |
||||
" The next several lines were here before |
||||
" BF started messing with this script. |
||||
" quote the special chars in 'matchpairs', replace [,:] with \| and then |
||||
" append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif) |
||||
" let default = substitute(escape(&mps, '[$^.*~\\/?]'), '[,:]\+', |
||||
" \ '\\|', 'g').'\|\/\*\|\*\/\|#if\>\|#ifdef\>\|#else\>\|#elif\>\|#endif\>' |
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . |
||||
\ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>' |
||||
" s:all = pattern with all the keywords |
||||
let match_words = match_words . (strlen(match_words) ? "," : "") . default |
||||
if match_words !~ s:notslash . '\\\d' |
||||
let s:do_BR = 0 |
||||
let s:pat = match_words |
||||
else |
||||
let s:do_BR = 1 |
||||
let s:pat = s:ParseWords(match_words) |
||||
endif |
||||
let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g') |
||||
let s:all = '\%(' . s:all . '\)' |
||||
" let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)' |
||||
if exists("b:match_debug") |
||||
let b:match_pat = s:pat |
||||
endif |
||||
endif |
||||
|
||||
" Second step: set the following local variables: |
||||
" matchline = line on which the cursor started |
||||
" curcol = number of characters before match |
||||
" prefix = regexp for start of line to start of match |
||||
" suffix = regexp for end of match to end of line |
||||
" Require match to end on or after the cursor and prefer it to |
||||
" start on or before the cursor. |
||||
let matchline = getline(startline) |
||||
if a:word != '' |
||||
" word given |
||||
if a:word !~ s:all |
||||
echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE |
||||
return s:CleanUp(restore_options, a:mode, startline, startcol) |
||||
endif |
||||
let matchline = a:word |
||||
let curcol = 0 |
||||
let prefix = '^\%(' |
||||
let suffix = '\)$' |
||||
" Now the case when "word" is not given |
||||
else " Find the match that ends on or after the cursor and set curcol. |
||||
let regexp = s:Wholematch(matchline, s:all, startcol-1) |
||||
let curcol = match(matchline, regexp) |
||||
" If there is no match, give up. |
||||
if curcol == -1 |
||||
return s:CleanUp(restore_options, a:mode, startline, startcol) |
||||
endif |
||||
let endcol = matchend(matchline, regexp) |
||||
let suf = strlen(matchline) - endcol |
||||
let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(') |
||||
let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$') |
||||
endif |
||||
if exists("b:match_debug") |
||||
let b:match_match = matchstr(matchline, regexp) |
||||
let b:match_col = curcol+1 |
||||
endif |
||||
|
||||
" Third step: Find the group and single word that match, and the original |
||||
" (backref) versions of these. Then, resolve the backrefs. |
||||
" Set the following local variable: |
||||
" group = colon-separated list of patterns, one of which matches |
||||
" = ini:mid:fin or ini:fin |
||||
" |
||||
" Reconstruct the version with unresolved backrefs. |
||||
let patBR = substitute(match_words.',', |
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') |
||||
let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g') |
||||
" Now, set group and groupBR to the matching group: 'if:endif' or |
||||
" 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns |
||||
" group . "," . groupBR, and we pick it apart. |
||||
let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) |
||||
let i = matchend(group, s:notslash . ",") |
||||
let groupBR = strpart(group, i) |
||||
let group = strpart(group, 0, i-1) |
||||
" Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix |
||||
if s:do_BR " Do the hard part: resolve those backrefs! |
||||
let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) |
||||
endif |
||||
if exists("b:match_debug") |
||||
let b:match_wholeBR = groupBR |
||||
let i = matchend(groupBR, s:notslash . ":") |
||||
let b:match_iniBR = strpart(groupBR, 0, i-1) |
||||
endif |
||||
|
||||
" Fourth step: Set the arguments for searchpair(). |
||||
let i = matchend(group, s:notslash . ":") |
||||
let j = matchend(group, '.*' . s:notslash . ":") |
||||
let ini = strpart(group, 0, i-1) |
||||
let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g') |
||||
let fin = strpart(group, j) |
||||
"Un-escape the remaining , and : characters. |
||||
let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') |
||||
let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') |
||||
let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') |
||||
" searchpair() requires that these patterns avoid \(\) groups. |
||||
let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g') |
||||
let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g') |
||||
let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g') |
||||
" Set mid. This is optimized for readability, not micro-efficiency! |
||||
if a:forward && matchline =~ prefix . fin . suffix |
||||
\ || !a:forward && matchline =~ prefix . ini . suffix |
||||
let mid = "" |
||||
endif |
||||
" Set flag. This is optimized for readability, not micro-efficiency! |
||||
if a:forward && matchline =~ prefix . fin . suffix |
||||
\ || !a:forward && matchline !~ prefix . ini . suffix |
||||
let flag = "bW" |
||||
else |
||||
let flag = "W" |
||||
endif |
||||
" Set skip. |
||||
if exists("b:match_skip") |
||||
let skip = b:match_skip |
||||
elseif exists("b:match_comment") " backwards compatibility and testing! |
||||
let skip = "r:" . b:match_comment |
||||
else |
||||
let skip = 's:comment\|string' |
||||
endif |
||||
let skip = s:ParseSkip(skip) |
||||
if exists("b:match_debug") |
||||
let b:match_ini = ini |
||||
let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin |
||||
endif |
||||
|
||||
" Fifth step: actually start moving the cursor and call searchpair(). |
||||
" Later, :execute restore_cursor to get to the original screen. |
||||
let restore_cursor = virtcol(".") . "|" |
||||
normal! g0 |
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor |
||||
normal! H |
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor |
||||
execute restore_cursor |
||||
call cursor(0, curcol + 1) |
||||
" normal! 0 |
||||
" if curcol |
||||
" execute "normal!" . curcol . "l" |
||||
" endif |
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) |
||||
let skip = "0" |
||||
else |
||||
execute "if " . skip . "| let skip = '0' | endif" |
||||
endif |
||||
let sp_return = searchpair(ini, mid, fin, flag, skip) |
||||
let final_position = "call cursor(" . line(".") . "," . col(".") . ")" |
||||
" Restore cursor position and original screen. |
||||
execute restore_cursor |
||||
normal! m' |
||||
if sp_return > 0 |
||||
execute final_position |
||||
endif |
||||
return s:CleanUp(restore_options, a:mode, startline, startcol, mid.'\|'.fin) |
||||
endfun |
||||
|
||||
" Restore options and do some special handling for Operator-pending mode. |
||||
" The optional argument is the tail of the matching group. |
||||
fun! s:CleanUp(options, mode, startline, startcol, ...) |
||||
execute "set" a:options |
||||
" Open folds, if appropriate. |
||||
if a:mode != "o" |
||||
if &foldopen =~ "percent" |
||||
normal! zv |
||||
endif |
||||
" In Operator-pending mode, we want to include the whole match |
||||
" (for example, d%). |
||||
" This is only a problem if we end up moving in the forward direction. |
||||
elseif (a:startline < line(".")) || |
||||
\ (a:startline == line(".") && a:startcol < col(".")) |
||||
if a:0 |
||||
" Check whether the match is a single character. If not, move to the |
||||
" end of the match. |
||||
let matchline = getline(".") |
||||
let currcol = col(".") |
||||
let regexp = s:Wholematch(matchline, a:1, currcol-1) |
||||
let endcol = matchend(matchline, regexp) |
||||
if endcol > currcol " This is NOT off by one! |
||||
execute "normal!" . (endcol - currcol) . "l" |
||||
endif |
||||
endif " a:0 |
||||
endif " a:mode != "o" && etc. |
||||
return 0 |
||||
endfun |
||||
|
||||
" Example (simplified HTML patterns): if |
||||
" a:groupBR = '<\(\k\+\)>:</\1>' |
||||
" a:prefix = '^.\{3}\(' |
||||
" a:group = '<\(\k\+\)>:</\(\k\+\)>' |
||||
" a:suffix = '\).\{2}$' |
||||
" a:matchline = "123<tag>12" or "123</tag>12" |
||||
" then extract "tag" from a:matchline and return "<tag>:</tag>" . |
||||
fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline) |
||||
if a:matchline !~ a:prefix . |
||||
\ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix |
||||
return a:group |
||||
endif |
||||
let i = matchend(a:groupBR, s:notslash . ':') |
||||
let ini = strpart(a:groupBR, 0, i-1) |
||||
let tailBR = strpart(a:groupBR, i) |
||||
let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix, |
||||
\ a:groupBR) |
||||
let i = matchend(word, s:notslash . ":") |
||||
let wordBR = strpart(word, i) |
||||
let word = strpart(word, 0, i-1) |
||||
" Now, a:matchline =~ a:prefix . word . a:suffix |
||||
if wordBR != ini |
||||
let table = s:Resolve(ini, wordBR, "table") |
||||
else |
||||
" let table = "----------" |
||||
let table = "" |
||||
let d = 0 |
||||
while d < 10 |
||||
if tailBR =~ s:notslash . '\\' . d |
||||
" let table[d] = d |
||||
let table = table . d |
||||
else |
||||
let table = table . "-" |
||||
endif |
||||
let d = d + 1 |
||||
endwhile |
||||
endif |
||||
let d = 9 |
||||
while d |
||||
if table[d] != "-" |
||||
let backref = substitute(a:matchline, a:prefix.word.a:suffix, |
||||
\ '\'.table[d], "") |
||||
" Are there any other characters that should be escaped? |
||||
let backref = escape(backref, '*,:') |
||||
execute s:Ref(ini, d, "start", "len") |
||||
let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len) |
||||
let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d, |
||||
\ escape(backref, '\\'), 'g') |
||||
endif |
||||
let d = d-1 |
||||
endwhile |
||||
if exists("b:match_debug") |
||||
if s:do_BR |
||||
let b:match_table = table |
||||
let b:match_word = word |
||||
else |
||||
let b:match_table = "" |
||||
let b:match_word = "" |
||||
endif |
||||
endif |
||||
return ini . ":" . tailBR |
||||
endfun |
||||
|
||||
" Input a comma-separated list of groups with backrefs, such as |
||||
" a:groups = '\(foo\):end\1,\(bar\):end\1' |
||||
" and return a comma-separated list of groups with backrefs replaced: |
||||
" return '\(foo\):end\(foo\),\(bar\):end\(bar\)' |
||||
fun! s:ParseWords(groups) |
||||
let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g') |
||||
let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g') |
||||
let parsed = "" |
||||
while groups =~ '[^,:]' |
||||
let i = matchend(groups, s:notslash . ':') |
||||
let j = matchend(groups, s:notslash . ',') |
||||
let ini = strpart(groups, 0, i-1) |
||||
let tail = strpart(groups, i, j-i-1) . ":" |
||||
let groups = strpart(groups, j) |
||||
let parsed = parsed . ini |
||||
let i = matchend(tail, s:notslash . ':') |
||||
while i != -1 |
||||
" In 'if:else:endif', ini='if' and word='else' and then word='endif'. |
||||
let word = strpart(tail, 0, i-1) |
||||
let tail = strpart(tail, i) |
||||
let i = matchend(tail, s:notslash . ':') |
||||
let parsed = parsed . ":" . s:Resolve(ini, word, "word") |
||||
endwhile " Now, tail has been used up. |
||||
let parsed = parsed . "," |
||||
endwhile " groups =~ '[^,:]' |
||||
let parsed = substitute(parsed, ',$', '', '') |
||||
return parsed |
||||
endfun |
||||
|
||||
" TODO I think this can be simplified and/or made more efficient. |
||||
" TODO What should I do if a:start is out of range? |
||||
" Return a regexp that matches all of a:string, such that |
||||
" matchstr(a:string, regexp) represents the match for a:pat that starts |
||||
" as close to a:start as possible, before being preferred to after, and |
||||
" ends after a:start . |
||||
" Usage: |
||||
" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1) |
||||
" let i = match(getline("."), regexp) |
||||
" let j = matchend(getline("."), regexp) |
||||
" let match = matchstr(getline("."), regexp) |
||||
fun! s:Wholematch(string, pat, start) |
||||
let group = '\%(' . a:pat . '\)' |
||||
let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^') |
||||
let len = strlen(a:string) |
||||
let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$') |
||||
if a:string !~ prefix . group . suffix |
||||
let prefix = '' |
||||
endif |
||||
return prefix . group . suffix |
||||
endfun |
||||
|
||||
" No extra arguments: s:Ref(string, d) will |
||||
" find the d'th occurrence of '\(' and return it, along with everything up |
||||
" to and including the matching '\)'. |
||||
" One argument: s:Ref(string, d, "start") returns the index of the start |
||||
" of the d'th '\(' and any other argument returns the length of the group. |
||||
" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be |
||||
" executed, having the effect of |
||||
" :let foo = s:Ref(string, d, "start") |
||||
" :let bar = s:Ref(string, d, "len") |
||||
fun! s:Ref(string, d, ...) |
||||
let len = strlen(a:string) |
||||
if a:d == 0 |
||||
let start = 0 |
||||
else |
||||
let cnt = a:d |
||||
let match = a:string |
||||
while cnt |
||||
let cnt = cnt - 1 |
||||
let index = matchend(match, s:notslash . '\\(') |
||||
if index == -1 |
||||
return "" |
||||
endif |
||||
let match = strpart(match, index) |
||||
endwhile |
||||
let start = len - strlen(match) |
||||
if a:0 == 1 && a:1 == "start" |
||||
return start - 2 |
||||
endif |
||||
let cnt = 1 |
||||
while cnt |
||||
let index = matchend(match, s:notslash . '\\(\|\\)') - 1 |
||||
if index == -2 |
||||
return "" |
||||
endif |
||||
" Increment if an open, decrement if a ')': |
||||
let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')' |
||||
" let cnt = stridx('0(', match[index]) + cnt |
||||
let match = strpart(match, index+1) |
||||
endwhile |
||||
let start = start - 2 |
||||
let len = len - start - strlen(match) |
||||
endif |
||||
if a:0 == 1 |
||||
return len |
||||
elseif a:0 == 2 |
||||
return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len |
||||
else |
||||
return strpart(a:string, start, len) |
||||
endif |
||||
endfun |
||||
|
||||
" Count the number of disjoint copies of pattern in string. |
||||
" If the pattern is a literal string and contains no '0' or '1' characters |
||||
" then s:Count(string, pattern, '0', '1') should be faster than |
||||
" s:Count(string, pattern). |
||||
fun! s:Count(string, pattern, ...) |
||||
let pat = escape(a:pattern, '\\') |
||||
if a:0 > 1 |
||||
let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g") |
||||
let foo = substitute(a:string, pat, a:2, "g") |
||||
let foo = substitute(foo, '[^' . a:2 . ']', "", "g") |
||||
return strlen(foo) |
||||
endif |
||||
let result = 0 |
||||
let foo = a:string |
||||
let index = matchend(foo, pat) |
||||
while index != -1 |
||||
let result = result + 1 |
||||
let foo = strpart(foo, index) |
||||
let index = matchend(foo, pat) |
||||
endwhile |
||||
return result |
||||
endfun |
||||
|
||||
" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where |
||||
" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first |
||||
" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this |
||||
" indicates that all other instances of '\1' in target are to be replaced |
||||
" by '\3'. The hard part is dealing with nesting... |
||||
" Note that ":" is an illegal character for source and target, |
||||
" unless it is preceded by "\". |
||||
fun! s:Resolve(source, target, output) |
||||
let word = a:target |
||||
let i = matchend(word, s:notslash . '\\\d') - 1 |
||||
let table = "----------" |
||||
while i != -2 " There are back references to be replaced. |
||||
let d = word[i] |
||||
let backref = s:Ref(a:source, d) |
||||
" The idea is to replace '\d' with backref. Before we do this, |
||||
" replace any \(\) groups in backref with :1, :2, ... if they |
||||
" correspond to the first, second, ... group already inserted |
||||
" into backref. Later, replace :1 with \1 and so on. The group |
||||
" number w+b within backref corresponds to the group number |
||||
" s within a:source. |
||||
" w = number of '\(' in word before the current one |
||||
let w = s:Count( |
||||
\ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1') |
||||
let b = 1 " number of the current '\(' in backref |
||||
let s = d " number of the current '\(' in a:source |
||||
while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1') |
||||
\ && s < 10 |
||||
if table[s] == "-" |
||||
if w + b < 10 |
||||
" let table[s] = w + b |
||||
let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1) |
||||
endif |
||||
let b = b + 1 |
||||
let s = s + 1 |
||||
else |
||||
execute s:Ref(backref, b, "start", "len") |
||||
let ref = strpart(backref, start, len) |
||||
let backref = strpart(backref, 0, start) . ":". table[s] |
||||
\ . strpart(backref, start+len) |
||||
let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1') |
||||
endif |
||||
endwhile |
||||
let word = strpart(word, 0, i-1) . backref . strpart(word, i+1) |
||||
let i = matchend(word, s:notslash . '\\\d') - 1 |
||||
endwhile |
||||
let word = substitute(word, s:notslash . '\zs:', '\\', 'g') |
||||
if a:output == "table" |
||||
return table |
||||
elseif a:output == "word" |
||||
return word |
||||
else |
||||
return table . word |
||||
endif |
||||
endfun |
||||
|
||||
" Assume a:comma = ",". Then the format for a:patterns and a:1 is |
||||
" a:patterns = "<pat1>,<pat2>,..." |
||||
" a:1 = "<alt1>,<alt2>,..." |
||||
" If <patn> is the first pattern that matches a:string then return <patn> |
||||
" if no optional arguments are given; return <patn>,<altn> if a:1 is given. |
||||
fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...) |
||||
let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma) |
||||
let i = matchend(tail, s:notslash . a:comma) |
||||
if a:0 |
||||
let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma) |
||||
let j = matchend(alttail, s:notslash . a:comma) |
||||
endif |
||||
let current = strpart(tail, 0, i-1) |
||||
if a:branch == "" |
||||
let currpat = current |
||||
else |
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') |
||||
endif |
||||
while a:string !~ a:prefix . currpat . a:suffix |
||||
let tail = strpart(tail, i) |
||||
let i = matchend(tail, s:notslash . a:comma) |
||||
if i == -1 |
||||
return -1 |
||||
endif |
||||
let current = strpart(tail, 0, i-1) |
||||
if a:branch == "" |
||||
let currpat = current |
||||
else |
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') |
||||
endif |
||||
if a:0 |
||||
let alttail = strpart(alttail, j) |
||||
let j = matchend(alttail, s:notslash . a:comma) |
||||
endif |
||||
endwhile |
||||
if a:0 |
||||
let current = current . a:comma . strpart(alttail, 0, j-1) |
||||
endif |
||||
return current |
||||
endfun |
||||
|
||||
" Call this function to turn on debugging information. Every time the main |
||||
" script is run, buffer variables will be saved. These can be used directly |
||||
" or viewed using the menu items below. |
||||
if !exists(":MatchDebug") |
||||
command! -nargs=0 MatchDebug call s:Match_debug() |
||||
endif |
||||
|
||||
fun! s:Match_debug() |
||||
let b:match_debug = 1 " Save debugging information. |
||||
" pat = all of b:match_words with backrefs parsed |
||||
amenu &Matchit.&pat :echo b:match_pat<CR> |
||||
" match = bit of text that is recognized as a match |
||||
amenu &Matchit.&match :echo b:match_match<CR> |
||||
" curcol = cursor column of the start of the matching text |
||||
amenu &Matchit.&curcol :echo b:match_col<CR> |
||||
" wholeBR = matching group, original version |
||||
amenu &Matchit.wh&oleBR :echo b:match_wholeBR<CR> |
||||
" iniBR = 'if' piece, original version |
||||
amenu &Matchit.ini&BR :echo b:match_iniBR<CR> |
||||
" ini = 'if' piece, with all backrefs resolved from match |
||||
amenu &Matchit.&ini :echo b:match_ini<CR> |
||||
" tail = 'else\|endif' piece, with all backrefs resolved from match |
||||
amenu &Matchit.&tail :echo b:match_tail<CR> |
||||
" fin = 'endif' piece, with all backrefs resolved from match |
||||
amenu &Matchit.&word :echo b:match_word<CR> |
||||
" '\'.d in ini refers to the same thing as '\'.table[d] in word. |
||||
amenu &Matchit.t&able :echo '0:' . b:match_table . ':9'<CR> |
||||
endfun |
||||
|
||||
" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW" |
||||
" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W". |
||||
" Return a "mark" for the original position, so that |
||||
" let m = MultiMatch("bW", "n") ... execute m |
||||
" will return to the original position. If there is a problem, do not |
||||
" move the cursor and return "", unless a count is given, in which case |
||||
" go up or down as many levels as possible and again return "". |
||||
" TODO This relies on the same patterns as % matching. It might be a good |
||||
" idea to give it its own matching patterns. |
||||
fun! s:MultiMatch(spflag, mode) |
||||
if !exists("b:match_words") || b:match_words == "" |
||||
return "" |
||||
end |
||||
let restore_options = (&ic ? "" : "no") . "ignorecase" |
||||
if exists("b:match_ignorecase") |
||||
let &ignorecase = b:match_ignorecase |
||||
endif |
||||
let startline = line(".") |
||||
let startcol = col(".") |
||||
|
||||
" First step: if not already done, set the script variables |
||||
" s:do_BR flag for whether there are backrefs |
||||
" s:pat parsed version of b:match_words |
||||
" s:all regexp based on s:pat and the default groups |
||||
" This part is copied and slightly modified from s:Match_wrapper(). |
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . |
||||
\ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>' |
||||
" Allow b:match_words = "GetVimMatchWords()" . |
||||
if b:match_words =~ ":" |
||||
let match_words = b:match_words |
||||
else |
||||
execute "let match_words =" b:match_words |
||||
endif |
||||
if (match_words != s:last_words) || (&mps != s:last_mps) || |
||||
\ exists("b:match_debug") |
||||
let s:last_words = match_words |
||||
let s:last_mps = &mps |
||||
if match_words !~ s:notslash . '\\\d' |
||||
let s:do_BR = 0 |
||||
let s:pat = match_words |
||||
else |
||||
let s:do_BR = 1 |
||||
let s:pat = s:ParseWords(match_words) |
||||
endif |
||||
let s:all = '\%(' . substitute(s:pat . (strlen(s:pat)?",":"") . default, |
||||
\ '[,:]\+','\\|','g') . '\)' |
||||
if exists("b:match_debug") |
||||
let b:match_pat = s:pat |
||||
endif |
||||
endif |
||||
|
||||
" Second step: figure out the patterns for searchpair() |
||||
" and save the screen, cursor position, and 'ignorecase'. |
||||
" - TODO: A lot of this is copied from s:Match_wrapper(). |
||||
" - maybe even more functionality should be split off |
||||
" - into separate functions! |
||||
let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default |
||||
let open = substitute(s:pat . cdefault, |
||||
\ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g') |
||||
let open = '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '') |
||||
let close = substitute(s:pat . cdefault, |
||||
\ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g') |
||||
let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)' |
||||
if exists("b:match_skip") |
||||
let skip = b:match_skip |
||||
elseif exists("b:match_comment") " backwards compatibility and testing! |
||||
let skip = "r:" . b:match_comment |
||||
else |
||||
let skip = 's:comment\|string' |
||||
endif |
||||
let skip = s:ParseSkip(skip) |
||||
" let restore_cursor = line(".") . "G" . virtcol(".") . "|" |
||||
" normal! H |
||||
" let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor |
||||
let restore_cursor = virtcol(".") . "|" |
||||
normal! g0 |
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor |
||||
normal! H |
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor |
||||
execute restore_cursor |
||||
|
||||
" Third step: call searchpair(). |
||||
" Replace '\('--but not '\\('--with '\%(' and ',' with '\|'. |
||||
let openpat = substitute(open, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g') |
||||
let openpat = substitute(openpat, ',', '\\|', 'g') |
||||
let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g') |
||||
let closepat = substitute(closepat, ',', '\\|', 'g') |
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) |
||||
let skip = '0' |
||||
else |
||||
execute "if " . skip . "| let skip = '0' | endif" |
||||
endif |
||||
mark ' |
||||
let level = v:count1 |
||||
while level |
||||
if searchpair(openpat, '', closepat, a:spflag, skip) < 1 |
||||
call s:CleanUp(restore_options, a:mode, startline, startcol) |
||||
return "" |
||||
endif |
||||
let level = level - 1 |
||||
endwhile |
||||
|
||||
" Restore options and return a string to restore the original position. |
||||
call s:CleanUp(restore_options, a:mode, startline, startcol) |
||||
return restore_cursor |
||||
endfun |
||||
|
||||
" Search backwards for "if" or "while" or "<tag>" or ... |
||||
" and return "endif" or "endwhile" or "</tag>" or ... . |
||||
" For now, this uses b:match_words and the same script variables |
||||
" as s:Match_wrapper() . Later, it may get its own patterns, |
||||
" either from a buffer variable or passed as arguments. |
||||
" fun! s:Autocomplete() |
||||
" echo "autocomplete not yet implemented :-(" |
||||
" if !exists("b:match_words") || b:match_words == "" |
||||
" return "" |
||||
" end |
||||
" let startpos = s:MultiMatch("bW") |
||||
" |
||||
" if startpos == "" |
||||
" return "" |
||||
" endif |
||||
" " - TODO: figure out whether 'if' or '<tag>' matched, and construct |
||||
" " - the appropriate closing. |
||||
" let matchline = getline(".") |
||||
" let curcol = col(".") - 1 |
||||
" " - TODO: Change the s:all argument if there is a new set of match pats. |
||||
" let regexp = s:Wholematch(matchline, s:all, curcol) |
||||
" let suf = strlen(matchline) - matchend(matchline, regexp) |
||||
" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(') |
||||
" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$') |
||||
" " Reconstruct the version with unresolved backrefs. |
||||
" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g') |
||||
" let patBR = substitute(patBR, ':\{2,}', ':', "g") |
||||
" " Now, set group and groupBR to the matching group: 'if:endif' or |
||||
" " 'while:endwhile' or whatever. |
||||
" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) |
||||
" let i = matchend(group, s:notslash . ",") |
||||
" let groupBR = strpart(group, i) |
||||
" let group = strpart(group, 0, i-1) |
||||
" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix |
||||
" if s:do_BR |
||||
" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) |
||||
" endif |
||||
" " let g:group = group |
||||
" |
||||
" " - TODO: Construct the closing from group. |
||||
" let fake = "end" . expand("<cword>") |
||||
" execute startpos |
||||
" return fake |
||||
" endfun |
||||
|
||||
" Close all open structures. "Get the heck out of here!" |
||||
" fun! s:Gthhoh() |
||||
" let close = s:Autocomplete() |
||||
" while strlen(close) |
||||
" put=close |
||||
" let close = s:Autocomplete() |
||||
" endwhile |
||||
" endfun |
||||
|
||||
" Parse special strings as typical skip arguments for searchpair(): |
||||
" s:foo becomes (current syntax item) =~ foo |
||||
" S:foo becomes (current syntax item) !~ foo |
||||
" r:foo becomes (line before cursor) =~ foo |
||||
" R:foo becomes (line before cursor) !~ foo |
||||
fun! s:ParseSkip(str) |
||||
let skip = a:str |
||||
if skip[1] == ":" |
||||
if skip[0] == "s" |
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . |
||||
\ strpart(skip,2) . "'" |
||||
elseif skip[0] == "S" |
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" . |
||||
\ strpart(skip,2) . "'" |
||||
elseif skip[0] == "r" |
||||
let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'" |
||||
elseif skip[0] == "R" |
||||
let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'" |
||||
endif |
||||
endif |
||||
return skip |
||||
endfun |
||||
|
||||
let &cpo = s:save_cpo |
||||
|
||||
" vim:sts=2:sw=2: |
@ -0,0 +1,151 @@
@@ -0,0 +1,151 @@
|
||||
**neocomplcache** |
||||
================= |
||||
|
||||
Description |
||||
----------- |
||||
|
||||
neocomplcache is the abbreviation of "neo-completion with cache". It |
||||
provides keyword completion system by maintaining a cache of keywords in the |
||||
current buffer. neocomplcache could be customized easily and has a lot more |
||||
features than the Vim's standard completion feature. |
||||
|
||||
If you use Vim 7.3.885 or above with if\_lua feature, you should use |
||||
neocomplete. It is faster than neocomplcache. |
||||
|
||||
https://github.com/Shougo/neocomplete.vim |
||||
|
||||
Installation |
||||
============ |
||||
|
||||
* Extract the file and put files in your Vim directory |
||||
(usually ~/.vim/ or Program Files/Vim/vimfiles on Windows). |
||||
* Execute `|:NeoComplCacheEnable|` command or |
||||
`let g:neocomplcache_enable_at_startup = 1` |
||||
in your `.vimrc`. Not in `.gvimrc`(`_gvimrc`)! |
||||
|
||||
Caution |
||||
------- |
||||
|
||||
Because all variable names were changed in neocomplcache Ver.5, it is not |
||||
backwards compatible. If you want to upgrade, you should use the following |
||||
script from Mr.thinca. |
||||
|
||||
http://gist.github.com/422503 |
||||
|
||||
Snippets feature(snippets\_complete source) was split from Ver.7. |
||||
If you used it, please install neosnippet source manually. |
||||
|
||||
https://github.com/Shougo/neosnippet |
||||
|
||||
Screen shots |
||||
============ |
||||
|
||||
Original filename completion. |
||||
----------- |
||||
 |
||||
|
||||
Omni completion. |
||||
---------------- |
||||
 |
||||
|
||||
Completion with vimshell(http://github.com/Shougo/vimshell). |
||||
------------------------------------------------------------ |
||||
 |
||||
|
||||
Vim completion |
||||
------------------------------------------------------------ |
||||
 |
||||
|
||||
Setting examples |
||||
|
||||
```vim |
||||
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! |
||||
" Disable AutoComplPop. |
||||
let g:acp_enableAtStartup = 0 |
||||
" Use neocomplcache. |
||||
let g:neocomplcache_enable_at_startup = 1 |
||||
" Use smartcase. |
||||
let g:neocomplcache_enable_smart_case = 1 |
||||
" Set minimum syntax keyword length. |
||||
let g:neocomplcache_min_syntax_length = 3 |
||||
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' |
||||
|
||||
" Enable heavy features. |
||||
" Use camel case completion. |
||||
"let g:neocomplcache_enable_camel_case_completion = 1 |
||||
" Use underbar completion. |
||||
"let g:neocomplcache_enable_underbar_completion = 1 |
||||
|
||||
" Define dictionary. |
||||
let g:neocomplcache_dictionary_filetype_lists = { |
||||
\ 'default' : '', |
||||
\ 'vimshell' : $HOME.'/.vimshell_hist', |
||||
\ 'scheme' : $HOME.'/.gosh_completions' |
||||
\ } |
||||
|
||||
" Define keyword. |
||||
if !exists('g:neocomplcache_keyword_patterns') |
||||
let g:neocomplcache_keyword_patterns = {} |
||||
endif |
||||
let g:neocomplcache_keyword_patterns['default'] = '\h\w*' |
||||
|
||||
" Plugin key-mappings. |
||||
inoremap <expr><C-g> neocomplcache#undo_completion() |
||||
inoremap <expr><C-l> neocomplcache#complete_common_string() |
||||
|
||||
" Recommended key-mappings. |
||||
" <CR>: close popup and save indent. |
||||
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> |
||||
function! s:my_cr_function() |
||||
return neocomplcache#smart_close_popup() . "\<CR>" |
||||
" For no inserting <CR> key. |
||||
"return pumvisible() ? neocomplcache#close_popup() : "\<CR>" |
||||
endfunction |
||||
" <TAB>: completion. |
||||
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" |
||||
" <C-h>, <BS>: close popup and delete backword char. |
||||
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" |
||||
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" |
||||
inoremap <expr><C-y> neocomplcache#close_popup() |
||||
inoremap <expr><C-e> neocomplcache#cancel_popup() |
||||
" Close popup by <Space>. |
||||
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>" |
||||
|
||||
" For cursor moving in insert mode(Not recommended) |
||||
"inoremap <expr><Left> neocomplcache#close_popup() . "\<Left>" |
||||
"inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>" |
||||
"inoremap <expr><Up> neocomplcache#close_popup() . "\<Up>" |
||||
"inoremap <expr><Down> neocomplcache#close_popup() . "\<Down>" |
||||
" Or set this. |
||||
"let g:neocomplcache_enable_cursor_hold_i = 1 |
||||
" Or set this. |
||||
"let g:neocomplcache_enable_insert_char_pre = 1 |
||||
|
||||
" AutoComplPop like behavior. |
||||
"let g:neocomplcache_enable_auto_select = 1 |
||||
|
||||
" Shell like behavior(not recommended). |
||||
"set completeopt+=longest |
||||
"let g:neocomplcache_enable_auto_select = 1 |
||||
"let g:neocomplcache_disable_auto_complete = 1 |
||||
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>" |
||||
|
||||
" Enable omni completion. |
||||
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS |
||||
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags |
||||
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS |
||||
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete |
||||
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags |
||||
|
||||
" Enable heavy omni completion. |
||||
if !exists('g:neocomplcache_omni_patterns') |
||||
let g:neocomplcache_omni_patterns = {} |
||||
endif |
||||
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' |
||||
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' |
||||
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' |
||||
|
||||
" For perlomni.vim setting. |
||||
" https://github.com/c9s/perlomni.vim |
||||
let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::' |
||||
``` |
@ -0,0 +1,405 @@
@@ -0,0 +1,405 @@
|
||||
"============================================================================= |
||||
" FILE: neocomplcache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 09 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
if !exists('g:loaded_neocomplcache') |
||||
runtime! plugin/neocomplcache.vim |
||||
endif |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
scriptencoding utf-8 |
||||
|
||||
function! neocomplcache#initialize() "{{{ |
||||
return neocomplcache#init#enable() |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#get_current_neocomplcache() "{{{ |
||||
if !exists('b:neocomplcache') |
||||
call neocomplcache#init#_current_neocomplcache() |
||||
endif |
||||
|
||||
return b:neocomplcache |
||||
endfunction"}}} |
||||
function! neocomplcache#get_context() "{{{ |
||||
return neocomplcache#get_current_neocomplcache().context |
||||
endfunction"}}} |
||||
|
||||
" Source helper. "{{{ |
||||
function! neocomplcache#define_source(source) "{{{ |
||||
let sources = neocomplcache#variables#get_sources() |
||||
for source in neocomplcache#util#convert2list(a:source) |
||||
let sources[source.name] = neocomplcache#init#_source(source) |
||||
endfor |
||||
endfunction"}}} |
||||
function! neocomplcache#define_filter(filter) "{{{ |
||||
let filters = neocomplcache#variables#get_filters() |
||||
for filter in neocomplcache#util#convert2list(a:filter) |
||||
let filters[filter.name] = neocomplcache#init#_filter(filter) |
||||
endfor |
||||
endfunction"}}} |
||||
function! neocomplcache#available_sources() "{{{ |
||||
return copy(neocomplcache#variables#get_sources()) |
||||
endfunction"}}} |
||||
function! neocomplcache#custom_source(source_name, option_name, value) "{{{ |
||||
let custom_sources = neocomplcache#variables#get_custom().sources |
||||
|
||||
for key in split(a:source_name, '\s*,\s*') |
||||
if !has_key(custom_sources, key) |
||||
let custom_sources[key] = {} |
||||
endif |
||||
|
||||
let custom_sources[key][a:option_name] = a:value |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#is_enabled_source(source_name) "{{{ |
||||
return neocomplcache#helper#is_enabled_source(a:source_name) |
||||
endfunction"}}} |
||||
function! neocomplcache#is_disabled_source(source_name) "{{{ |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
let disabled_sources = get( |
||||
\ g:neocomplcache_disabled_sources_list, filetype, |
||||
\ get(g:neocomplcache_disabled_sources_list, '_', [])) |
||||
return index(disabled_sources, a:source_name) >= 0 |
||||
endfunction"}}} |
||||
function! neocomplcache#keyword_escape(complete_str) "{{{ |
||||
return neocomplcache#helper#keyword_escape(a:complete_str) |
||||
endfunction"}}} |
||||
function! neocomplcache#keyword_filter(list, complete_str) "{{{ |
||||
return neocomplcache#filters#keyword_filter(a:list, a:complete_str) |
||||
endfunction"}}} |
||||
function! neocomplcache#dup_filter(list) "{{{ |
||||
return neocomplcache#util#dup_filter(a:list) |
||||
endfunction"}}} |
||||
function! neocomplcache#check_match_filter(complete_str) "{{{ |
||||
return neocomplcache#keyword_escape(a:complete_str) =~ '[^\\]\*\|\\+' |
||||
endfunction"}}} |
||||
function! neocomplcache#check_completion_length_match(complete_str, completion_length) "{{{ |
||||
return neocomplcache#keyword_escape( |
||||
\ a:complete_str[: a:completion_length-1]) =~ |
||||
\'[^\\]\*\|\\+\|\\%(\|\\|' |
||||
endfunction"}}} |
||||
function! neocomplcache#dictionary_filter(dictionary, complete_str) "{{{ |
||||
return neocomplcache#filters#dictionary_filter(a:dictionary, a:complete_str) |
||||
endfunction"}}} |
||||
function! neocomplcache#unpack_dictionary(dict) "{{{ |
||||
let ret = [] |
||||
let values = values(a:dict) |
||||
for l in (type(values) == type([]) ? |
||||
\ values : values(values)) |
||||
let ret += (type(l) == type([])) ? copy(l) : values(l) |
||||
endfor |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
function! neocomplcache#pack_dictionary(list) "{{{ |
||||
let completion_length = 2 |
||||
let ret = {} |
||||
for candidate in a:list |
||||
let key = tolower(candidate.word[: completion_length-1]) |
||||
if !has_key(ret, key) |
||||
let ret[key] = {} |
||||
endif |
||||
|
||||
let ret[key][candidate.word] = candidate |
||||
endfor |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
function! neocomplcache#add_dictionaries(dictionaries) "{{{ |
||||
if empty(a:dictionaries) |
||||
return {} |
||||
endif |
||||
|
||||
let ret = a:dictionaries[0] |
||||
for dict in a:dictionaries[1:] |
||||
for [key, value] in items(dict) |
||||
if has_key(ret, key) |
||||
let ret[key] += value |
||||
else |
||||
let ret[key] = value |
||||
endif |
||||
endfor |
||||
endfor |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#system(...) "{{{ |
||||
let V = vital#of('neocomplcache') |
||||
return call(V.system, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#has_vimproc() "{{{ |
||||
return neocomplcache#util#has_vimproc() |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#get_cur_text(...) "{{{ |
||||
" Return cached text. |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
return (a:0 == 0 && mode() ==# 'i' && |
||||
\ neocomplcache.cur_text != '') ? |
||||
\ neocomplcache.cur_text : neocomplcache#helper#get_cur_text() |
||||
endfunction"}}} |
||||
function! neocomplcache#get_next_keyword() "{{{ |
||||
" Get next keyword. |
||||
let pattern = '^\%(' . neocomplcache#get_next_keyword_pattern() . '\m\)' |
||||
|
||||
return matchstr('a'.getline('.')[len(neocomplcache#get_cur_text()) :], pattern)[1:] |
||||
endfunction"}}} |
||||
function! neocomplcache#get_completion_length(source_name) "{{{ |
||||
let sources = neocomplcache#variables#get_sources() |
||||
if !has_key(sources, a:source_name) |
||||
" Unknown. |
||||
return -1 |
||||
endif |
||||
|
||||
if neocomplcache#is_auto_complete() |
||||
\ && neocomplcache#get_current_neocomplcache().completion_length >= 0 |
||||
return neocomplcache#get_current_neocomplcache().completion_length |
||||
else |
||||
return sources[a:source_name].min_pattern_length |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#set_completion_length(source_name, length) "{{{ |
||||
let custom = neocomplcache#variables#get_custom().sources |
||||
if !has_key(custom, a:source_name) |
||||
let custom[a:source_name] = {} |
||||
endif |
||||
|
||||
if !has_key(custom[a:source_name], 'min_pattern_length') |
||||
let custom[a:source_name].min_pattern_length = a:length |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#get_keyword_pattern(...) "{{{ |
||||
let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() |
||||
|
||||
return neocomplcache#helper#unite_patterns( |
||||
\ g:neocomplcache_keyword_patterns, filetype) |
||||
endfunction"}}} |
||||
function! neocomplcache#get_next_keyword_pattern(...) "{{{ |
||||
let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() |
||||
let next_pattern = neocomplcache#helper#unite_patterns( |
||||
\ g:neocomplcache_next_keyword_patterns, filetype) |
||||
|
||||
return (next_pattern == '' ? '' : next_pattern.'\m\|') |
||||
\ . neocomplcache#get_keyword_pattern(filetype) |
||||
endfunction"}}} |
||||
function! neocomplcache#get_keyword_pattern_end(...) "{{{ |
||||
let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() |
||||
|
||||
return '\%('.neocomplcache#get_keyword_pattern(filetype).'\m\)$' |
||||
endfunction"}}} |
||||
function! neocomplcache#match_word(...) "{{{ |
||||
return call('neocomplcache#helper#match_word', a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#is_enabled() "{{{ |
||||
return neocomplcache#init#is_enabled() |
||||
endfunction"}}} |
||||
function! neocomplcache#is_locked(...) "{{{ |
||||
let bufnr = a:0 > 0 ? a:1 : bufnr('%') |
||||
return !neocomplcache#is_enabled() || &paste |
||||
\ || g:neocomplcache_disable_auto_complete |
||||
\ || &l:completefunc == '' |
||||
\ || neocomplcache#get_current_neocomplcache().lock |
||||
\ || (g:neocomplcache_lock_buffer_name_pattern != '' && |
||||
\ bufname(bufnr) =~ g:neocomplcache_lock_buffer_name_pattern) |
||||
\ || &l:omnifunc ==# 'fuf#onComplete' |
||||
endfunction"}}} |
||||
function! neocomplcache#is_plugin_locked(source_name) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return 1 |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
return get(neocomplcache.lock_sources, a:source_name, 0) |
||||
endfunction"}}} |
||||
function! neocomplcache#is_auto_select() "{{{ |
||||
return g:neocomplcache_enable_auto_select && !neocomplcache#is_eskk_enabled() |
||||
endfunction"}}} |
||||
function! neocomplcache#is_auto_complete() "{{{ |
||||
return &l:completefunc == 'neocomplcache#complete#auto_complete' |
||||
endfunction"}}} |
||||
function! neocomplcache#is_sources_complete() "{{{ |
||||
return &l:completefunc == 'neocomplcache#complete#sources_manual_complete' |
||||
endfunction"}}} |
||||
function! neocomplcache#is_eskk_enabled() "{{{ |
||||
return exists('*eskk#is_enabled') && eskk#is_enabled() |
||||
endfunction"}}} |
||||
function! neocomplcache#is_eskk_convertion(cur_text) "{{{ |
||||
return neocomplcache#is_eskk_enabled() |
||||
\ && eskk#get_preedit().get_henkan_phase() !=# |
||||
\ g:eskk#preedit#PHASE_NORMAL |
||||
endfunction"}}} |
||||
function! neocomplcache#is_multibyte_input(cur_text) "{{{ |
||||
return (exists('b:skk_on') && b:skk_on) |
||||
\ || char2nr(split(a:cur_text, '\zs')[-1]) > 0x80 |
||||
endfunction"}}} |
||||
function! neocomplcache#is_text_mode() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
return get(g:neocomplcache_text_mode_filetypes, |
||||
\ neocomplcache.context_filetype, 0) |
||||
endfunction"}}} |
||||
function! neocomplcache#is_windows() "{{{ |
||||
return neocomplcache#util#is_windows() |
||||
endfunction"}}} |
||||
function! neocomplcache#is_win() "{{{ |
||||
return neocomplcache#util#is_windows() |
||||
endfunction"}}} |
||||
function! neocomplcache#is_prefetch() "{{{ |
||||
return !neocomplcache#is_locked() && |
||||
\ (g:neocomplcache_enable_prefetch || &l:formatoptions =~# 'a') |
||||
endfunction"}}} |
||||
function! neocomplcache#exists_echodoc() "{{{ |
||||
return exists('g:loaded_echodoc') && g:loaded_echodoc |
||||
endfunction"}}} |
||||
function! neocomplcache#within_comment() "{{{ |
||||
return neocomplcache#helper#get_syn_name(1) ==# 'Comment' |
||||
endfunction"}}} |
||||
function! neocomplcache#print_caching(string) "{{{ |
||||
if g:neocomplcache_enable_caching_message |
||||
redraw |
||||
echon a:string |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#print_error(string) "{{{ |
||||
echohl Error | echomsg a:string | echohl None |
||||
endfunction"}}} |
||||
function! neocomplcache#print_warning(string) "{{{ |
||||
echohl WarningMsg | echomsg a:string | echohl None |
||||
endfunction"}}} |
||||
function! neocomplcache#head_match(checkstr, headstr) "{{{ |
||||
let checkstr = &ignorecase ? |
||||
\ tolower(a:checkstr) : a:checkstr |
||||
let headstr = &ignorecase ? |
||||
\ tolower(a:headstr) : a:headstr |
||||
return stridx(checkstr, headstr) == 0 |
||||
endfunction"}}} |
||||
function! neocomplcache#get_source_filetypes(filetype) "{{{ |
||||
return neocomplcache#helper#get_source_filetypes(a:filetype) |
||||
endfunction"}}} |
||||
function! neocomplcache#get_sources_list(dictionary, filetype) "{{{ |
||||
return neocomplcache#helper#ftdictionary2list(a:dictionary, a:filetype) |
||||
endfunction"}}} |
||||
function! neocomplcache#escape_match(str) "{{{ |
||||
return escape(a:str, '~"*\.^$[]') |
||||
endfunction"}}} |
||||
function! neocomplcache#get_context_filetype(...) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return &filetype |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
if a:0 != 0 || mode() !=# 'i' || |
||||
\ neocomplcache.context_filetype == '' |
||||
call neocomplcache#context_filetype#set() |
||||
endif |
||||
|
||||
return neocomplcache.context_filetype |
||||
endfunction"}}} |
||||
function! neocomplcache#get_context_filetype_range(...) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return [[1, 1], [line('$'), len(getline('$'))+1]] |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
if a:0 != 0 || mode() !=# 'i' || |
||||
\ neocomplcache.context_filetype == '' |
||||
call neocomplcache#context_filetype#set() |
||||
endif |
||||
|
||||
if neocomplcache.context_filetype ==# &filetype |
||||
return [[1, 1], [line('$'), len(getline('$'))+1]] |
||||
endif |
||||
|
||||
return neocomplcache.context_filetype_range |
||||
endfunction"}}} |
||||
function! neocomplcache#print_debug(expr) "{{{ |
||||
if g:neocomplcache_enable_debug |
||||
echomsg string(a:expr) |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#get_temporary_directory() "{{{ |
||||
let directory = neocomplcache#util#substitute_path_separator( |
||||
\ neocomplcache#util#expand(g:neocomplcache_temporary_dir)) |
||||
if !isdirectory(directory) |
||||
call mkdir(directory, 'p') |
||||
endif |
||||
|
||||
return directory |
||||
endfunction"}}} |
||||
function! neocomplcache#complete_check() "{{{ |
||||
return neocomplcache#helper#complete_check() |
||||
endfunction"}}} |
||||
function! neocomplcache#check_invalid_omnifunc(omnifunc) "{{{ |
||||
return a:omnifunc == '' || (a:omnifunc !~ '#' && !exists('*' . a:omnifunc)) |
||||
endfunction"}}} |
||||
function! neocomplcache#skip_next_complete() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.skip_next_complete = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#set_dictionary_helper(variable, keys, value) "{{{ |
||||
return neocomplcache#util#set_dictionary_helper( |
||||
\ a:variable, a:keys, a:value) |
||||
endfunction"}}} |
||||
function! neocomplcache#disable_default_dictionary(variable) "{{{ |
||||
return neocomplcache#util#disable_default_dictionary(a:variable) |
||||
endfunction"}}} |
||||
function! neocomplcache#filetype_complete(arglead, cmdline, cursorpos) "{{{ |
||||
return neocomplcache#helper#filetype_complete(a:arglead, a:cmdline, a:cursorpos) |
||||
endfunction"}}} |
||||
"}}} |
||||
|
||||
" Key mapping functions. "{{{ |
||||
function! neocomplcache#smart_close_popup() |
||||
return neocomplcache#mappings#smart_close_popup() |
||||
endfunction |
||||
function! neocomplcache#close_popup() |
||||
return neocomplcache#mappings#close_popup() |
||||
endfunction |
||||
function! neocomplcache#cancel_popup() |
||||
return neocomplcache#mappings#cancel_popup() |
||||
endfunction |
||||
function! neocomplcache#undo_completion() |
||||
return neocomplcache#mappings#undo_completion() |
||||
endfunction |
||||
function! neocomplcache#complete_common_string() |
||||
return neocomplcache#mappings#complete_common_string() |
||||
endfunction |
||||
function! neocomplcache#start_manual_complete(...) |
||||
return call('neocomplcache#mappings#start_manual_complete', a:000) |
||||
endfunction |
||||
"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,315 @@
@@ -0,0 +1,315 @@
|
||||
"============================================================================= |
||||
" FILE: async_cache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 16 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following condition |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! s:main(argv) "{{{ |
||||
" args: funcname, outputname filename pattern_file_name mark minlen maxfilename |
||||
let [funcname, outputname, filename, pattern_file_name, mark, minlen, maxfilename, fileencoding] |
||||
\ = a:argv |
||||
|
||||
if funcname ==# 'load_from_file' |
||||
let keyword_list = s:load_from_file( |
||||
\ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, 1) |
||||
else |
||||
let keyword_list = s:load_from_tags( |
||||
\ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding) |
||||
endif |
||||
|
||||
if empty(keyword_list) |
||||
return |
||||
endif |
||||
|
||||
" Output cache. |
||||
call writefile([string(keyword_list)], outputname) |
||||
endfunction"}}} |
||||
|
||||
function! s:load_from_file(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, is_string) "{{{ |
||||
if !filereadable(a:filename) |
||||
" File not found. |
||||
return [] |
||||
endif |
||||
|
||||
let lines = map(readfile(a:filename), |
||||
\ 's:iconv(v:val, a:fileencoding, &encoding)') |
||||
|
||||
let pattern = get(readfile(a:pattern_file_name), 0, '\h\w*') |
||||
|
||||
let max_lines = len(lines) |
||||
|
||||
let keyword_list = [] |
||||
let dup_check = {} |
||||
let keyword_pattern2 = '^\%('.pattern.'\m\)' |
||||
|
||||
for line in lines "{{{ |
||||
let match = match(line, pattern) |
||||
while match >= 0 "{{{ |
||||
let match_str = matchstr(line, keyword_pattern2, match) |
||||
|
||||
if !has_key(dup_check, match_str) && len(match_str) >= a:minlen |
||||
" Append list. |
||||
call add(keyword_list, (a:is_string ? |
||||
\ match_str : { 'word' : match_str })) |
||||
|
||||
let dup_check[match_str] = 1 |
||||
endif |
||||
|
||||
let match += len(match_str) |
||||
|
||||
let match = match(line, pattern, match) |
||||
endwhile"}}} |
||||
endfor"}}} |
||||
|
||||
return keyword_list |
||||
endfunction"}}} |
||||
|
||||
function! s:load_from_tags(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding) "{{{ |
||||
let keyword_lists = [] |
||||
let dup_check = {} |
||||
|
||||
let [pattern, tags_file_name, filter_pattern, filetype] = |
||||
\ readfile(a:pattern_file_name)[: 4] |
||||
if tags_file_name !=# '$dummy$' |
||||
" Check output. |
||||
let tags_list = [] |
||||
|
||||
let i = 0 |
||||
while i < 2 |
||||
if filereadable(tags_file_name) |
||||
" Use filename. |
||||
let tags_list = map(readfile(tags_file_name), |
||||
\ 's:iconv(v:val, a:fileencoding, &encoding)') |
||||
break |
||||
endif |
||||
|
||||
sleep 500m |
||||
let i += 1 |
||||
endwhile |
||||
else |
||||
if !filereadable(a:filename) |
||||
return [] |
||||
endif |
||||
|
||||
" Use filename. |
||||
let tags_list = map(readfile(a:filename), |
||||
\ 's:iconv(v:val, a:fileencoding, &encoding)') |
||||
endif |
||||
|
||||
if empty(tags_list) |
||||
" File caching. |
||||
return s:load_from_file(a:filename, a:pattern_file_name, |
||||
\ a:mark, a:minlen, a:maxfilename, a:fileencoding, 0) |
||||
endif |
||||
|
||||
for line in tags_list "{{{ |
||||
let tag = split(substitute(line, "\<CR>", '', 'g'), '\t', 1) |
||||
|
||||
" Add keywords. |
||||
if line =~ '^!' || len(tag) < 3 || len(tag[0]) < a:minlen |
||||
\ || has_key(dup_check, tag[0]) |
||||
continue |
||||
endif |
||||
|
||||
let opt = join(tag[2:], "\<TAB>") |
||||
let cmd = matchstr(opt, '.*/;"') |
||||
|
||||
let option = { |
||||
\ 'cmd' : substitute(substitute(substitute(cmd, |
||||
\'^\%([/?]\^\?\)\?\s*\|\%(\$\?[/?]\)\?;"$', '', 'g'), |
||||
\ '\\\\', '\\', 'g'), '\\/', '/', 'g'), |
||||
\ 'kind' : '' |
||||
\} |
||||
if option.cmd =~ '\d\+' |
||||
let option.cmd = tag[0] |
||||
endif |
||||
|
||||
for opt in split(opt[len(cmd):], '\t', 1) |
||||
let key = matchstr(opt, '^\h\w*\ze:') |
||||
if key == '' |
||||
let option['kind'] = opt |
||||
else |
||||
let option[key] = matchstr(opt, '^\h\w*:\zs.*') |
||||
endif |
||||
endfor |
||||
|
||||
if has_key(option, 'file') |
||||
\ || (has_key(option, 'access') && option.access != 'public') |
||||
continue |
||||
endif |
||||
|
||||
let abbr = has_key(option, 'signature')? tag[0] . option.signature : |
||||
\ (option['kind'] == 'd' || option['cmd'] == '') ? |
||||
\ tag[0] : option['cmd'] |
||||
let abbr = substitute(abbr, '\s\+', ' ', 'g') |
||||
" Substitute "namespace foobar" to "foobar <namespace>". |
||||
let abbr = substitute(abbr, |
||||
\'^\(namespace\|class\|struct\|enum\|union\)\s\+\(.*\)$', |
||||
\'\2 <\1>', '') |
||||
" Substitute typedef. |
||||
let abbr = substitute(abbr, |
||||
\'^typedef\s\+\(.*\)\s\+\(\h\w*\%(::\w*\)*\);\?$', |
||||
\'\2 <typedef \1>', 'g') |
||||
|
||||
let keyword = { |
||||
\ 'word' : tag[0], 'abbr' : abbr, |
||||
\ 'kind' : option['kind'], 'dup' : 1, |
||||
\ } |
||||
if has_key(option, 'struct') |
||||
let keyword.menu = option.struct |
||||
elseif has_key(option, 'class') |
||||
let keyword.menu = option.class |
||||
elseif has_key(option, 'enum') |
||||
let keyword.menu = option.enum |
||||
elseif has_key(option, 'union') |
||||
let keyword.menu = option.union |
||||
endif |
||||
|
||||
call add(keyword_lists, keyword) |
||||
let dup_check[tag[0]] = 1 |
||||
endfor"}}} |
||||
|
||||
if filter_pattern != '' |
||||
call filter(keyword_lists, filter_pattern) |
||||
endif |
||||
|
||||
return keyword_lists |
||||
endfunction"}}} |
||||
|
||||
function! s:truncate(str, width) "{{{ |
||||
" Original function is from mattn. |
||||
" http://github.com/mattn/googlereader-vim/tree/master |
||||
|
||||
if a:str =~# '^[\x00-\x7f]*$' |
||||
return len(a:str) < a:width ? |
||||
\ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width) |
||||
endif |
||||
|
||||
let ret = a:str |
||||
let width = s:wcswidth(a:str) |
||||
if width > a:width |
||||
let ret = s:strwidthpart(ret, a:width) |
||||
let width = s:wcswidth(ret) |
||||
endif |
||||
|
||||
if width < a:width |
||||
let ret .= repeat(' ', a:width - width) |
||||
endif |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
|
||||
function! s:strwidthpart(str, width) "{{{ |
||||
let ret = a:str |
||||
let width = s:wcswidth(a:str) |
||||
while width > a:width |
||||
let char = matchstr(ret, '.$') |
||||
let ret = ret[: -1 - len(char)] |
||||
let width -= s:wcwidth(char) |
||||
endwhile |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
|
||||
function! s:iconv(expr, from, to) |
||||
if a:from == '' || a:to == '' || a:from ==? a:to |
||||
return a:expr |
||||
endif |
||||
let result = iconv(a:expr, a:from, a:to) |
||||
return result != '' ? result : a:expr |
||||
endfunction |
||||
|
||||
if v:version >= 703 |
||||
" Use builtin function. |
||||
function! s:wcswidth(str) "{{{ |
||||
return strdisplaywidth(a:str) |
||||
endfunction"}}} |
||||
function! s:wcwidth(str) "{{{ |
||||
return strwidth(a:str) |
||||
endfunction"}}} |
||||
else |
||||
function! s:wcswidth(str) "{{{ |
||||
if a:str =~# '^[\x00-\x7f]*$' |
||||
return strlen(a:str) |
||||
end |
||||
|
||||
let mx_first = '^\(.\)' |
||||
let str = a:str |
||||
let width = 0 |
||||
while 1 |
||||
let ucs = char2nr(substitute(str, mx_first, '\1', '')) |
||||
if ucs == 0 |
||||
break |
||||
endif |
||||
let width += s:wcwidth(ucs) |
||||
let str = substitute(str, mx_first, '', '') |
||||
endwhile |
||||
return width |
||||
endfunction"}}} |
||||
|
||||
" UTF-8 only. |
||||
function! s:wcwidth(ucs) "{{{ |
||||
let ucs = a:ucs |
||||
if (ucs >= 0x1100 |
||||
\ && (ucs <= 0x115f |
||||
\ || ucs == 0x2329 |
||||
\ || ucs == 0x232a |
||||
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf |
||||
\ && ucs != 0x303f) |
||||
\ || (ucs >= 0xac00 && ucs <= 0xd7a3) |
||||
\ || (ucs >= 0xf900 && ucs <= 0xfaff) |
||||
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f) |
||||
\ || (ucs >= 0xff00 && ucs <= 0xff60) |
||||
\ || (ucs >= 0xffe0 && ucs <= 0xffe6) |
||||
\ || (ucs >= 0x20000 && ucs <= 0x2fffd) |
||||
\ || (ucs >= 0x30000 && ucs <= 0x3fffd) |
||||
\ )) |
||||
return 2 |
||||
endif |
||||
return 1 |
||||
endfunction"}}} |
||||
endif |
||||
|
||||
if argc() == 8 && |
||||
\ (argv(0) ==# 'load_from_file' || argv(0) ==# 'load_from_tags') |
||||
try |
||||
call s:main(argv()) |
||||
catch |
||||
call writefile([v:throwpoint, v:exception], |
||||
\ fnamemodify(argv(1), ':h:h').'/async_error_log') |
||||
endtry |
||||
|
||||
qall! |
||||
else |
||||
function! neocomplcache#async_cache#main(argv) "{{{ |
||||
call s:main(a:argv) |
||||
endfunction"}}} |
||||
endif |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,326 @@
@@ -0,0 +1,326 @@
|
||||
"============================================================================= |
||||
" FILE: cache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 27 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditionneocomplcache#cache# |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:Cache = vital#of('neocomplcache').import('System.Cache') |
||||
|
||||
" Cache loader. |
||||
function! neocomplcache#cache#check_cache_list(cache_dir, key, async_cache_dictionary, index_keyword_list, ...) "{{{ |
||||
if !has_key(a:async_cache_dictionary, a:key) |
||||
return |
||||
endif |
||||
|
||||
let is_string = get(a:000, 0, 0) |
||||
|
||||
let keyword_list = [] |
||||
let cache_list = a:async_cache_dictionary[a:key] |
||||
for cache in cache_list |
||||
if filereadable(cache.cachename) |
||||
let keyword_list += neocomplcache#cache#load_from_cache( |
||||
\ a:cache_dir, cache.filename, is_string) |
||||
endif |
||||
endfor |
||||
|
||||
call neocomplcache#cache#list2index(keyword_list, a:index_keyword_list, is_string) |
||||
call filter(cache_list, '!filereadable(v:val.cachename)') |
||||
|
||||
if empty(cache_list) |
||||
" Delete from dictionary. |
||||
call remove(a:async_cache_dictionary, a:key) |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#check_cache(cache_dir, key, async_cache_dictionary, keyword_list_dictionary, ...) "{{{ |
||||
let is_string = get(a:000, 0, 0) |
||||
|
||||
" Caching. |
||||
if !has_key(a:keyword_list_dictionary, a:key) |
||||
let a:keyword_list_dictionary[a:key] = {} |
||||
endif |
||||
return neocomplcache#cache#check_cache_list( |
||||
\ a:cache_dir, a:key, a:async_cache_dictionary, |
||||
\ a:keyword_list_dictionary[a:key], is_string) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#load_from_cache(cache_dir, filename, ...) "{{{ |
||||
let is_string = get(a:000, 0, 0) |
||||
|
||||
try |
||||
let list = eval(get(neocomplcache#cache#readfile( |
||||
\ a:cache_dir, a:filename), 0, '[]')) |
||||
if !empty(list) && is_string && type(list[0]) != type('') |
||||
" Type check. |
||||
throw 'Type error' |
||||
endif |
||||
|
||||
return list |
||||
catch |
||||
" Delete old cache file. |
||||
let cache_name = |
||||
\ neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
if filereadable(cache_name) |
||||
call delete(cache_name) |
||||
endif |
||||
|
||||
return [] |
||||
endtry |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#index_load_from_cache(cache_dir, filename, ...) "{{{ |
||||
let is_string = get(a:000, 0, 0) |
||||
let keyword_lists = {} |
||||
|
||||
let completion_length = 2 |
||||
for keyword in neocomplcache#cache#load_from_cache( |
||||
\ a:cache_dir, a:filename, is_string) |
||||
let key = tolower( |
||||
\ (is_string ? keyword : keyword.word)[: completion_length-1]) |
||||
if !has_key(keyword_lists, key) |
||||
let keyword_lists[key] = [] |
||||
endif |
||||
call add(keyword_lists[key], keyword) |
||||
endfor |
||||
|
||||
return keyword_lists |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#list2index(list, dictionary, is_string) "{{{ |
||||
let completion_length = 2 |
||||
for keyword in a:list |
||||
let word = a:is_string ? keyword : keyword.word |
||||
|
||||
let key = tolower(word[: completion_length-1]) |
||||
if !has_key(a:dictionary, key) |
||||
let a:dictionary[key] = {} |
||||
endif |
||||
let a:dictionary[key][word] = keyword |
||||
endfor |
||||
|
||||
return a:dictionary |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#cache#save_cache(cache_dir, filename, keyword_list) "{{{ |
||||
call neocomplcache#cache#writefile( |
||||
\ a:cache_dir, a:filename, [string(a:keyword_list)]) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#save_cache_old(cache_dir, filename, keyword_list) "{{{ |
||||
" Create dictionary key. |
||||
for keyword in a:keyword_list |
||||
if !has_key(keyword, 'abbr') |
||||
let keyword.abbr = keyword.word |
||||
endif |
||||
if !has_key(keyword, 'kind') |
||||
let keyword.kind = '' |
||||
endif |
||||
if !has_key(keyword, 'menu') |
||||
let keyword.menu = '' |
||||
endif |
||||
endfor |
||||
|
||||
" Output cache. |
||||
let word_list = [] |
||||
for keyword in a:keyword_list |
||||
call add(word_list, printf('%s|||%s|||%s|||%s', |
||||
\keyword.word, keyword.abbr, keyword.menu, keyword.kind)) |
||||
endfor |
||||
|
||||
call neocomplcache#cache#writefile( |
||||
\ a:cache_dir, a:filename, word_list) |
||||
endfunction"}}} |
||||
|
||||
" Cache helper. |
||||
function! neocomplcache#cache#getfilename(cache_dir, filename) "{{{ |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.getfilename(cache_dir, a:filename) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#filereadable(cache_dir, filename) "{{{ |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.filereadable(cache_dir, a:filename) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#readfile(cache_dir, filename) "{{{ |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.readfile(cache_dir, a:filename) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#writefile(cache_dir, filename, list) "{{{ |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.writefile(cache_dir, a:filename, a:list) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#encode_name(cache_dir, filename) |
||||
" Check cache directory. |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.getfilename(cache_dir, a:filename) |
||||
endfunction |
||||
function! neocomplcache#cache#check_old_cache(cache_dir, filename) "{{{ |
||||
let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir |
||||
return s:Cache.check_old_cache(cache_dir, a:filename) |
||||
endfunction"}}} |
||||
|
||||
let s:sdir = neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(expand('<sfile>'), ':p:h')) |
||||
|
||||
function! neocomplcache#cache#async_load_from_file(cache_dir, filename, pattern, mark) "{{{ |
||||
if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename) |
||||
return neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
endif |
||||
|
||||
let pattern_file_name = |
||||
\ neocomplcache#cache#encode_name('keyword_patterns', a:filename) |
||||
let cache_name = |
||||
\ neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
|
||||
" Create pattern file. |
||||
call neocomplcache#cache#writefile( |
||||
\ 'keyword_patterns', a:filename, [a:pattern]) |
||||
|
||||
" args: funcname, outputname, filename pattern mark |
||||
" minlen maxlen encoding |
||||
let fileencoding = |
||||
\ &fileencoding == '' ? &encoding : &fileencoding |
||||
let argv = [ |
||||
\ 'load_from_file', cache_name, a:filename, pattern_file_name, a:mark, |
||||
\ g:neocomplcache_min_keyword_length, |
||||
\ g:neocomplcache_max_menu_width, fileencoding |
||||
\ ] |
||||
return s:async_load(argv, a:cache_dir, a:filename) |
||||
endfunction"}}} |
||||
function! neocomplcache#cache#async_load_from_tags(cache_dir, filename, filetype, mark, is_create_tags) "{{{ |
||||
if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename) |
||||
return neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
endif |
||||
|
||||
let cache_name = |
||||
\ neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
let pattern_file_name = |
||||
\ neocomplcache#cache#encode_name('tags_pattens', a:filename) |
||||
|
||||
if a:is_create_tags |
||||
if !executable(g:neocomplcache_ctags_program) |
||||
echoerr 'Create tags error! Please install ' |
||||
\ . g:neocomplcache_ctags_program . '.' |
||||
return neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
endif |
||||
|
||||
" Create tags file. |
||||
let tags_file_name = |
||||
\ neocomplcache#cache#encode_name('tags_output', a:filename) |
||||
|
||||
let default = get(g:neocomplcache_ctags_arguments_list, '_', '') |
||||
let args = get(g:neocomplcache_ctags_arguments_list, a:filetype, default) |
||||
|
||||
if has('win32') || has('win64') |
||||
let filename = |
||||
\ neocomplcache#util#substitute_path_separator(a:filename) |
||||
let command = printf('%s -f "%s" %s "%s" ', |
||||
\ g:neocomplcache_ctags_program, tags_file_name, args, filename) |
||||
else |
||||
let command = printf('%s -f ''%s'' 2>/dev/null %s ''%s''', |
||||
\ g:neocomplcache_ctags_program, tags_file_name, args, a:filename) |
||||
endif |
||||
|
||||
if neocomplcache#has_vimproc() |
||||
call vimproc#system_bg(command) |
||||
else |
||||
call system(command) |
||||
endif |
||||
else |
||||
let tags_file_name = '$dummy$' |
||||
endif |
||||
|
||||
let filter_pattern = |
||||
\ get(g:neocomplcache_tags_filter_patterns, a:filetype, '') |
||||
call neocomplcache#cache#writefile('tags_pattens', a:filename, |
||||
\ [neocomplcache#get_keyword_pattern(), |
||||
\ tags_file_name, filter_pattern, a:filetype]) |
||||
|
||||
" args: funcname, outputname, filename pattern mark |
||||
" minlen maxlen encoding |
||||
let fileencoding = &fileencoding == '' ? &encoding : &fileencoding |
||||
let argv = [ |
||||
\ 'load_from_tags', cache_name, a:filename, pattern_file_name, a:mark, |
||||
\ g:neocomplcache_min_keyword_length, |
||||
\ g:neocomplcache_max_menu_width, fileencoding |
||||
\ ] |
||||
return s:async_load(argv, a:cache_dir, a:filename) |
||||
endfunction"}}} |
||||
function! s:async_load(argv, cache_dir, filename) "{{{ |
||||
" if 0 |
||||
if neocomplcache#has_vimproc() |
||||
let paths = vimproc#get_command_name(v:progname, $PATH, -1) |
||||
if empty(paths) |
||||
if has('gui_macvim') |
||||
" MacVim check. |
||||
if !executable('/Applications/MacVim.app/Contents/MacOS/Vim') |
||||
call neocomplcache#print_error( |
||||
\ 'You installed MacVim in not default directory!'. |
||||
\ ' You must add MacVim installed path in $PATH.') |
||||
let g:neocomplcache_use_vimproc = 0 |
||||
return |
||||
endif |
||||
|
||||
let vim_path = '/Applications/MacVim.app/Contents/MacOS/Vim' |
||||
else |
||||
call neocomplcache#print_error( |
||||
\ printf('Vim path : "%s" is not found.'. |
||||
\ ' You must add "%s" installed path in $PATH.', |
||||
\ v:progname, v:progname)) |
||||
let g:neocomplcache_use_vimproc = 0 |
||||
return |
||||
endif |
||||
else |
||||
let base_path = neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(paths[0], ':p:h')) |
||||
|
||||
let vim_path = base_path . |
||||
\ (neocomplcache#util#is_windows() ? '/vim.exe' : '/vim') |
||||
endif |
||||
|
||||
if !executable(vim_path) && neocomplcache#util#is_mac() |
||||
" Note: Search "Vim" instead of vim. |
||||
let vim_path = base_path. '/Vim' |
||||
endif |
||||
|
||||
if !executable(vim_path) |
||||
call neocomplcache#print_error( |
||||
\ printf('Vim path : "%s" is not executable.', vim_path)) |
||||
let g:neocomplcache_use_vimproc = 0 |
||||
return |
||||
endif |
||||
|
||||
let args = [vim_path, '-u', 'NONE', '-i', 'NONE', '-n', |
||||
\ '-N', '-S', s:sdir.'/async_cache.vim'] |
||||
\ + a:argv |
||||
call vimproc#system_bg(args) |
||||
" call vimproc#system(args) |
||||
" call system(join(args)) |
||||
else |
||||
call neocomplcache#async_cache#main(a:argv) |
||||
endif |
||||
|
||||
return neocomplcache#cache#encode_name(a:cache_dir, a:filename) |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,277 @@
@@ -0,0 +1,277 @@
|
||||
"============================================================================= |
||||
" FILE: commands.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 12 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#commands#_initialize() "{{{ |
||||
command! -nargs=? Neco call s:display_neco(<q-args>) |
||||
command! -nargs=1 NeoComplCacheAutoCompletionLength |
||||
\ call s:set_auto_completion_length(<args>) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_toggle_lock() "{{{ |
||||
if neocomplcache#get_current_neocomplcache().lock |
||||
echo 'neocomplcache is unlocked!' |
||||
call neocomplcache#commands#_unlock() |
||||
else |
||||
echo 'neocomplcache is locked!' |
||||
call neocomplcache#commands#_lock() |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_lock() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.lock = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_unlock() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.lock = 0 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_lock_source(source_name) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
call neocomplcache#print_warning( |
||||
\ 'neocomplcache is disabled! This command is ignored.') |
||||
return |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let neocomplcache.lock_sources[a:source_name] = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_unlock_source(source_name) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
call neocomplcache#print_warning( |
||||
\ 'neocomplcache is disabled! This command is ignored.') |
||||
return |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let neocomplcache.lock_sources[a:source_name] = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_clean() "{{{ |
||||
" Delete cache files. |
||||
for directory in filter(neocomplcache#util#glob( |
||||
\ g:neocomplcache_temporary_dir.'/*'), 'isdirectory(v:val)') |
||||
for filename in filter(neocomplcache#util#glob(directory.'/*'), |
||||
\ '!isdirectory(v:val)') |
||||
call delete(filename) |
||||
endfor |
||||
endfor |
||||
|
||||
echo 'Cleaned cache files in: ' . g:neocomplcache_temporary_dir |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#commands#_set_file_type(filetype) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.filetype = a:filetype |
||||
endfunction"}}} |
||||
|
||||
function! s:display_neco(number) "{{{ |
||||
let cmdheight_save = &cmdheight |
||||
|
||||
let animation = [ |
||||
\[ |
||||
\[ |
||||
\ " A A", |
||||
\ "~(-'_'-)" |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A ", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-^_^-)", |
||||
\], |
||||
\], |
||||
\[ |
||||
\[ |
||||
\ " A A", |
||||
\ "~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A ", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A ", |
||||
\ " ~(-'_'-)" |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)" |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)" |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ "~(-'_'-)" |
||||
\], |
||||
\], |
||||
\[ |
||||
\[ |
||||
\ " A A", |
||||
\ "~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[" A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\], |
||||
\[ |
||||
\[ |
||||
\ "", |
||||
\ " A A", |
||||
\ "~(-'_'-)", |
||||
\], |
||||
\[" A A", |
||||
\ " ~(-'_'-)", |
||||
\ "", |
||||
\], |
||||
\[ |
||||
\ "", |
||||
\ " A A", |
||||
\ " ~(-'_'-)", |
||||
\], |
||||
\[ |
||||
\ " A A ", |
||||
\ " ~(-'_'-)", |
||||
\ "", |
||||
\], |
||||
\[ |
||||
\ "", |
||||
\ " A A", |
||||
\ " ~(-^_^-)", |
||||
\], |
||||
\], |
||||
\[ |
||||
\[ |
||||
\ " A A A A", |
||||
\ "~(-'_'-) -8(*'_'*)" |
||||
\], |
||||
\[ |
||||
\ " A A A A", |
||||
\ " ~(-'_'-) -8(*'_'*)" |
||||
\], |
||||
\[ |
||||
\ " A A A A", |
||||
\ " ~(-'_'-) -8(*'_'*)" |
||||
\], |
||||
\[ |
||||
\ " A A A A", |
||||
\ " ~(-'_'-) -8(*'_'*)" |
||||
\], |
||||
\[ |
||||
\ " A A A A", |
||||
\ "~(-'_'-) -8(*'_'*)" |
||||
\], |
||||
\], |
||||
\[ |
||||
\[ |
||||
\ " A\\_A\\", |
||||
\ "(=' .' ) ~w", |
||||
\ "(,(\")(\")", |
||||
\], |
||||
\], |
||||
\] |
||||
|
||||
let number = (a:number != '') ? a:number : len(animation) |
||||
let anim = get(animation, number, animation[s:rand(len(animation) - 1)]) |
||||
let &cmdheight = len(anim[0]) |
||||
|
||||
for frame in anim |
||||
echo repeat("\n", &cmdheight-2) |
||||
redraw |
||||
echon join(frame, "\n") |
||||
sleep 300m |
||||
endfor |
||||
redraw |
||||
|
||||
let &cmdheight = cmdheight_save |
||||
endfunction"}}} |
||||
|
||||
function! s:rand(max) "{{{ |
||||
if !has('reltime') |
||||
" Same value. |
||||
return 0 |
||||
endif |
||||
|
||||
let time = reltime()[1] |
||||
return (time < 0 ? -time : time)% (a:max + 1) |
||||
endfunction"}}} |
||||
|
||||
function! s:set_auto_completion_length(len) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.completion_length = a:len |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,383 @@
@@ -0,0 +1,383 @@
|
||||
"============================================================================= |
||||
" FILE: complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 06 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#complete#manual_complete(findstart, base) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
if a:findstart |
||||
let cur_text = neocomplcache#get_cur_text() |
||||
if !neocomplcache#is_enabled() |
||||
\ || neocomplcache#helper#is_omni_complete(cur_text) |
||||
call neocomplcache#helper#clear_result() |
||||
let &l:completefunc = 'neocomplcache#complete#manual_complete' |
||||
|
||||
return (neocomplcache#is_prefetch() |
||||
\ || g:neocomplcache_enable_insert_char_pre) ? |
||||
\ -1 : -3 |
||||
endif |
||||
|
||||
" Get complete_pos. |
||||
if neocomplcache#is_prefetch() && !empty(neocomplcache.complete_results) |
||||
" Use prefetch results. |
||||
else |
||||
let neocomplcache.complete_results = |
||||
\ neocomplcache#complete#_get_results(cur_text) |
||||
endif |
||||
let complete_pos = |
||||
\ neocomplcache#complete#_get_complete_pos(neocomplcache.complete_results) |
||||
|
||||
if complete_pos < 0 |
||||
call neocomplcache#helper#clear_result() |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let complete_pos = (neocomplcache#is_prefetch() || |
||||
\ g:neocomplcache_enable_insert_char_pre || |
||||
\ neocomplcache#get_current_neocomplcache().skipped) ? -1 : -3 |
||||
let neocomplcache.skipped = 0 |
||||
endif |
||||
|
||||
return complete_pos |
||||
else |
||||
let complete_pos = neocomplcache#complete#_get_complete_pos( |
||||
\ neocomplcache.complete_results) |
||||
let neocomplcache.candidates = neocomplcache#complete#_get_words( |
||||
\ neocomplcache.complete_results, complete_pos, a:base) |
||||
let neocomplcache.complete_str = a:base |
||||
|
||||
if v:version > 703 || v:version == 703 && has('patch418') |
||||
let dict = { 'words' : neocomplcache.candidates } |
||||
|
||||
if (g:neocomplcache_enable_cursor_hold_i |
||||
\ || v:version > 703 || v:version == 703 && has('patch561')) |
||||
\ && len(a:base) < g:neocomplcache_auto_completion_start_length |
||||
" Note: If Vim is less than 7.3.561, it have broken register "." problem. |
||||
let dict.refresh = 'always' |
||||
endif |
||||
return dict |
||||
else |
||||
return neocomplcache.candidates |
||||
endif |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#sources_manual_complete(findstart, base) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
if a:findstart |
||||
if !neocomplcache#is_enabled() |
||||
call neocomplcache#helper#clear_result() |
||||
return -2 |
||||
endif |
||||
|
||||
" Get complete_pos. |
||||
let complete_results = neocomplcache#complete#_get_results( |
||||
\ neocomplcache#get_cur_text(1), neocomplcache.manual_sources) |
||||
let neocomplcache.complete_pos = |
||||
\ neocomplcache#complete#_get_complete_pos(complete_results) |
||||
|
||||
if neocomplcache.complete_pos < 0 |
||||
call neocomplcache#helper#clear_result() |
||||
|
||||
return -2 |
||||
endif |
||||
|
||||
let neocomplcache.complete_results = complete_results |
||||
|
||||
return neocomplcache.complete_pos |
||||
endif |
||||
|
||||
let neocomplcache.complete_pos = |
||||
\ neocomplcache#complete#_get_complete_pos( |
||||
\ neocomplcache.complete_results) |
||||
let candidates = neocomplcache#complete#_get_words( |
||||
\ neocomplcache.complete_results, |
||||
\ neocomplcache.complete_pos, a:base) |
||||
|
||||
let neocomplcache.candidates = candidates |
||||
let neocomplcache.complete_str = a:base |
||||
|
||||
return candidates |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#unite_complete(findstart, base) "{{{ |
||||
" Dummy. |
||||
return a:findstart ? -1 : [] |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#auto_complete(findstart, base) "{{{ |
||||
return neocomplcache#complete#manual_complete(a:findstart, a:base) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#_get_results(cur_text, ...) "{{{ |
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'start get_complete_results' |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.start_time = reltime() |
||||
|
||||
let complete_results = call( |
||||
\ 'neocomplcache#complete#_set_results_pos', [a:cur_text] + a:000) |
||||
call neocomplcache#complete#_set_results_words(complete_results) |
||||
|
||||
return filter(complete_results, |
||||
\ '!empty(v:val.neocomplcache__context.candidates)') |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#_get_complete_pos(sources) "{{{ |
||||
if empty(a:sources) |
||||
return -1 |
||||
endif |
||||
|
||||
return min([col('.')] + map(copy(a:sources), |
||||
\ 'v:val.neocomplcache__context.complete_pos')) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#complete#_get_words(sources, complete_pos, complete_str) "{{{ |
||||
let frequencies = neocomplcache#variables#get_frequencies() |
||||
if exists('*neocomplcache#sources#buffer_complete#get_frequencies') |
||||
let frequencies = extend(copy( |
||||
\ neocomplcache#sources#buffer_complete#get_frequencies()), |
||||
\ frequencies) |
||||
endif |
||||
|
||||
" Append prefix. |
||||
let candidates = [] |
||||
let len_words = 0 |
||||
for source in sort(filter(copy(a:sources), |
||||
\ '!empty(v:val.neocomplcache__context.candidates)'), |
||||
\ 's:compare_source_rank') |
||||
let context = source.neocomplcache__context |
||||
let words = |
||||
\ type(context.candidates[0]) == type('') ? |
||||
\ map(copy(context.candidates), "{'word': v:val}") : |
||||
\ deepcopy(context.candidates) |
||||
let context.candidates = words |
||||
|
||||
call neocomplcache#helper#call_hook( |
||||
\ source, 'on_post_filter', {}) |
||||
|
||||
if context.complete_pos > a:complete_pos |
||||
let prefix = a:complete_str[: context.complete_pos |
||||
\ - a:complete_pos - 1] |
||||
|
||||
for candidate in words |
||||
let candidate.word = prefix . candidate.word |
||||
endfor |
||||
endif |
||||
|
||||
for candidate in words |
||||
if !has_key(candidate, 'menu') && has_key(source, 'mark') |
||||
" Set default menu. |
||||
let candidate.menu = source.mark |
||||
endif |
||||
if has_key(frequencies, candidate.word) |
||||
let candidate.rank = frequencies[candidate.word] |
||||
endif |
||||
endfor |
||||
|
||||
let words = neocomplcache#helper#call_filters( |
||||
\ source.sorters, source, {}) |
||||
|
||||
if source.max_candidates > 0 |
||||
let words = words[: len(source.max_candidates)-1] |
||||
endif |
||||
|
||||
let words = neocomplcache#helper#call_filters( |
||||
\ source.converters, source, {}) |
||||
|
||||
let candidates += words |
||||
let len_words += len(words) |
||||
|
||||
if g:neocomplcache_max_list > 0 |
||||
\ && len_words > g:neocomplcache_max_list |
||||
break |
||||
endif |
||||
|
||||
if neocomplcache#complete_check() |
||||
return [] |
||||
endif |
||||
endfor |
||||
|
||||
if g:neocomplcache_max_list > 0 |
||||
let candidates = candidates[: g:neocomplcache_max_list] |
||||
endif |
||||
|
||||
" Check dup and set icase. |
||||
let icase = g:neocomplcache_enable_ignore_case && |
||||
\!(g:neocomplcache_enable_smart_case && a:complete_str =~ '\u') |
||||
\ && !neocomplcache#is_text_mode() |
||||
for candidate in candidates |
||||
if has_key(candidate, 'kind') && candidate.kind == '' |
||||
" Remove kind key. |
||||
call remove(candidate, 'kind') |
||||
endif |
||||
|
||||
let candidate.icase = icase |
||||
endfor |
||||
|
||||
if neocomplcache#complete_check() |
||||
return [] |
||||
endif |
||||
|
||||
return candidates |
||||
endfunction"}}} |
||||
function! neocomplcache#complete#_set_results_pos(cur_text, ...) "{{{ |
||||
" Set context filetype. |
||||
call neocomplcache#context_filetype#set() |
||||
|
||||
" Initialize sources. |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
for source in filter(values(neocomplcache#variables#get_sources()), |
||||
\ '!v:val.loaded && (empty(v:val.filetypes) || |
||||
\ get(v:val.filetypes, |
||||
\ neocomplcache.context_filetype, 0))') |
||||
call neocomplcache#helper#call_hook(source, 'on_init', {}) |
||||
let source.loaded = 1 |
||||
endfor |
||||
|
||||
let sources = filter(copy(get(a:000, 0, |
||||
\ neocomplcache#helper#get_sources_list())), 'v:val.loaded') |
||||
if a:0 < 1 |
||||
call filter(sources, '!neocomplcache#is_plugin_locked(v:key)') |
||||
endif |
||||
|
||||
" Try source completion. "{{{ |
||||
let complete_sources = [] |
||||
for source in values(sources) |
||||
let context = source.neocomplcache__context |
||||
let context.input = a:cur_text |
||||
let context.complete_pos = -1 |
||||
let context.complete_str = '' |
||||
let context.candidates = [] |
||||
|
||||
let pos = winsaveview() |
||||
|
||||
try |
||||
let complete_pos = |
||||
\ has_key(source, 'get_keyword_pos') ? |
||||
\ source.get_keyword_pos(context.input) : |
||||
\ has_key(source, 'get_complete_position') ? |
||||
\ source.get_complete_position(context) : |
||||
\ neocomplcache#match_word(context.input)[0] |
||||
catch |
||||
call neocomplcache#print_error(v:throwpoint) |
||||
call neocomplcache#print_error(v:exception) |
||||
call neocomplcache#print_error( |
||||
\ 'Error occured in source''s get_complete_position()!') |
||||
call neocomplcache#print_error( |
||||
\ 'Source name is ' . source.name) |
||||
return complete_sources |
||||
finally |
||||
if winsaveview() != pos |
||||
call winrestview(pos) |
||||
endif |
||||
endtry |
||||
|
||||
if complete_pos < 0 |
||||
continue |
||||
endif |
||||
|
||||
let complete_str = context.input[complete_pos :] |
||||
if neocomplcache#is_auto_complete() && |
||||
\ neocomplcache#util#mb_strlen(complete_str) |
||||
\ < neocomplcache#get_completion_length(source.name) |
||||
" Skip. |
||||
continue |
||||
endif |
||||
|
||||
let context.complete_pos = complete_pos |
||||
let context.complete_str = complete_str |
||||
call add(complete_sources, source) |
||||
endfor |
||||
"}}} |
||||
|
||||
return complete_sources |
||||
endfunction"}}} |
||||
function! neocomplcache#complete#_set_results_words(sources) "{{{ |
||||
" Try source completion. |
||||
for source in a:sources |
||||
if neocomplcache#complete_check() |
||||
return |
||||
endif |
||||
|
||||
" Save options. |
||||
let ignorecase_save = &ignorecase |
||||
|
||||
let context = source.neocomplcache__context |
||||
|
||||
if neocomplcache#is_text_mode() |
||||
let &ignorecase = 1 |
||||
elseif g:neocomplcache_enable_smart_case |
||||
\ && context.complete_str =~ '\u' |
||||
let &ignorecase = 0 |
||||
else |
||||
let &ignorecase = g:neocomplcache_enable_ignore_case |
||||
endif |
||||
|
||||
let pos = winsaveview() |
||||
|
||||
try |
||||
let context.candidates = has_key(source, 'get_keyword_list') ? |
||||
\ source.get_keyword_list(context.complete_str) : |
||||
\ has_key(source, 'get_complete_words') ? |
||||
\ source.get_complete_words( |
||||
\ context.complete_pos, context.complete_str) : |
||||
\ source.gather_candidates(context) |
||||
catch |
||||
call neocomplcache#print_error(v:throwpoint) |
||||
call neocomplcache#print_error(v:exception) |
||||
call neocomplcache#print_error( |
||||
\ 'Source name is ' . source.name) |
||||
call neocomplcache#print_error( |
||||
\ 'Error occured in source''s gather_candidates()!') |
||||
return |
||||
finally |
||||
if winsaveview() != pos |
||||
call winrestview(pos) |
||||
endif |
||||
endtry |
||||
|
||||
if g:neocomplcache_enable_debug |
||||
echomsg source.name |
||||
endif |
||||
|
||||
let &ignorecase = ignorecase_save |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
" Source rank order. "{{{ |
||||
function! s:compare_source_rank(i1, i2) |
||||
return a:i2.rank - a:i1.rank |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,207 @@
@@ -0,0 +1,207 @@
|
||||
"============================================================================= |
||||
" FILE: context_filetype.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 18 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#context_filetype#initialize() "{{{ |
||||
" Initialize context filetype lists. |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_context_filetype_lists', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'c,cpp', [ |
||||
\ {'filetype' : 'masm', |
||||
\ 'start' : '_*asm_*\s\+\h\w*', 'end' : '$'}, |
||||
\ {'filetype' : 'masm', |
||||
\ 'start' : '_*asm_*\s*\%(\n\s*\)\?{', 'end' : '}'}, |
||||
\ {'filetype' : 'gas', |
||||
\ 'start' : '_*asm_*\s*\%(_*volatile_*\s*\)\?(', 'end' : ');'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'd', [ |
||||
\ {'filetype' : 'masm', |
||||
\ 'start' : 'asm\s*\%(\n\s*\)\?{', 'end' : '}'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'perl6', [ |
||||
\ {'filetype' : 'pir', 'start' : 'Q:PIR\s*{', 'end' : '}'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'vimshell', [ |
||||
\ {'filetype' : 'vim', |
||||
\ 'start' : 'vexe \([''"]\)', 'end' : '\\\@<!\1'}, |
||||
\ {'filetype' : 'vim', 'start' : ' :\w*', 'end' : '\n'}, |
||||
\ {'filetype' : 'vim', 'start' : ' vexe\s\+', 'end' : '\n'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'eruby', [ |
||||
\ {'filetype' : 'ruby', 'start' : '<%[=#]\?', 'end' : '%>'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'vim', [ |
||||
\ {'filetype' : 'python', |
||||
\ 'start' : '^\s*py\%[thon\]3\? <<\s*\(\h\w*\)', 'end' : '^\1'}, |
||||
\ {'filetype' : 'ruby', |
||||
\ 'start' : '^\s*rub\%[y\] <<\s*\(\h\w*\)', 'end' : '^\1'}, |
||||
\ {'filetype' : 'lua', |
||||
\ 'start' : '^\s*lua <<\s*\(\h\w*\)', 'end' : '^\1'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'html,xhtml', [ |
||||
\ {'filetype' : 'javascript', 'start' : |
||||
\'<script\%( [^>]*\)\? type="text/javascript"\%( [^>]*\)\?>', |
||||
\ 'end' : '</script>'}, |
||||
\ {'filetype' : 'coffee', 'start' : |
||||
\'<script\%( [^>]*\)\? type="text/coffeescript"\%( [^>]*\)\?>', |
||||
\ 'end' : '</script>'}, |
||||
\ {'filetype' : 'css', 'start' : |
||||
\'<style\%( [^>]*\)\? type="text/css"\%( [^>]*\)\?>', |
||||
\ 'end' : '</style>'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'python', [ |
||||
\ {'filetype' : 'vim', |
||||
\ 'start' : 'vim.command\s*(\([''"]\)', 'end' : '\\\@<!\1\s*)'}, |
||||
\ {'filetype' : 'vim', |
||||
\ 'start' : 'vim.eval\s*(\([''"]\)', 'end' : '\\\@<!\1\s*)'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'help', [ |
||||
\ {'filetype' : 'vim', 'start' : '^>', 'end' : '^<'}, |
||||
\]) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_context_filetype_lists', |
||||
\ 'nyaos,int-nyaos', [ |
||||
\ {'filetype' : 'lua', |
||||
\ 'start' : '\<lua_e\s\+\(["'']\)', 'end' : '^\1'}, |
||||
\]) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#context_filetype#set() "{{{ |
||||
let old_filetype = neocomplcache#get_current_neocomplcache().filetype |
||||
if old_filetype == '' |
||||
let old_filetype = &filetype |
||||
endif |
||||
if old_filetype == '' |
||||
let old_filetype = 'nothing' |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let dup_check = {} |
||||
while 1 |
||||
let new_filetype = neocomplcache#context_filetype#get(old_filetype) |
||||
|
||||
" Check filetype root. |
||||
if get(dup_check, old_filetype, '') ==# new_filetype |
||||
let neocomplcache.context_filetype = old_filetype |
||||
break |
||||
endif |
||||
|
||||
" Save old -> new filetype graph. |
||||
let dup_check[old_filetype] = new_filetype |
||||
let old_filetype = new_filetype |
||||
endwhile |
||||
|
||||
return neocomplcache.context_filetype |
||||
endfunction"}}} |
||||
function! neocomplcache#context_filetype#get(filetype) "{{{ |
||||
" Default. |
||||
let filetype = a:filetype |
||||
if filetype == '' |
||||
let filetype = 'nothing' |
||||
endif |
||||
|
||||
" Default range. |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let pos = [line('.'), col('.')] |
||||
for include in get(g:neocomplcache_context_filetype_lists, filetype, []) |
||||
let start_backward = searchpos(include.start, 'bneW') |
||||
|
||||
" Check pos > start. |
||||
if start_backward[0] == 0 || s:compare_pos(start_backward, pos) > 0 |
||||
continue |
||||
endif |
||||
|
||||
let end_pattern = include.end |
||||
if end_pattern =~ '\\1' |
||||
let match_list = matchlist(getline(start_backward[0]), include.start) |
||||
let end_pattern = substitute(end_pattern, '\\1', '\=match_list[1]', 'g') |
||||
endif |
||||
let end_forward = searchpos(end_pattern, 'nW') |
||||
if end_forward[0] == 0 |
||||
let end_forward = [line('$'), len(getline('$'))+1] |
||||
endif |
||||
|
||||
" Check end > pos. |
||||
if s:compare_pos(pos, end_forward) > 0 |
||||
continue |
||||
endif |
||||
|
||||
let end_backward = searchpos(end_pattern, 'bnW') |
||||
|
||||
" Check start <= end. |
||||
if s:compare_pos(start_backward, end_backward) < 0 |
||||
continue |
||||
endif |
||||
|
||||
if start_backward[1] == len(getline(start_backward[0])) |
||||
" Next line. |
||||
let start_backward[0] += 1 |
||||
let start_backward[1] = 1 |
||||
endif |
||||
if end_forward[1] == 1 |
||||
" Previous line. |
||||
let end_forward[0] -= 1 |
||||
let end_forward[1] = len(getline(end_forward[0])) |
||||
endif |
||||
|
||||
let neocomplcache.context_filetype_range = |
||||
\ [ start_backward, end_forward ] |
||||
return include.filetype |
||||
endfor |
||||
|
||||
return filetype |
||||
endfunction"}}} |
||||
|
||||
function! s:compare_pos(i1, i2) |
||||
return a:i1[0] == a:i2[0] ? a:i1[1] - a:i2[1] : a:i1[0] - a:i2[0] |
||||
endfunction" |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
"============================================================================= |
||||
" FILE: filters.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 28 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#keyword_filter(list, complete_str) "{{{ |
||||
let complete_str = a:complete_str |
||||
|
||||
if g:neocomplcache_enable_debug |
||||
echomsg len(a:list) |
||||
endif |
||||
|
||||
" Delimiter check. |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
for delimiter in get(g:neocomplcache_delimiter_patterns, filetype, []) |
||||
let complete_str = substitute(complete_str, |
||||
\ delimiter, '*' . delimiter, 'g') |
||||
endfor |
||||
|
||||
if complete_str == '' || |
||||
\ &l:completefunc ==# 'neocomplcache#complete#unite_complete' || |
||||
\ empty(a:list) |
||||
return a:list |
||||
elseif neocomplcache#check_match_filter(complete_str) |
||||
" Match filter. |
||||
let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word' |
||||
|
||||
let expr = printf('%s =~ %s', |
||||
\ word, string('^' . |
||||
\ neocomplcache#keyword_escape(complete_str))) |
||||
if neocomplcache#is_auto_complete() |
||||
" Don't complete cursor word. |
||||
let expr .= printf(' && %s !=? a:complete_str', word) |
||||
endif |
||||
|
||||
" Check head character. |
||||
if complete_str[0] != '\' && complete_str[0] != '.' |
||||
let expr = word.'[0] == ' . |
||||
\ string(complete_str[0]) .' && ' . expr |
||||
endif |
||||
|
||||
call neocomplcache#print_debug(expr) |
||||
|
||||
return filter(a:list, expr) |
||||
else |
||||
" Use fast filter. |
||||
return s:head_filter(a:list, complete_str) |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:head_filter(list, complete_str) "{{{ |
||||
let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word' |
||||
|
||||
if &ignorecase |
||||
let expr = printf('!stridx(tolower(%s), %s)', |
||||
\ word, string(tolower(a:complete_str))) |
||||
else |
||||
let expr = printf('!stridx(%s, %s)', |
||||
\ word, string(a:complete_str)) |
||||
endif |
||||
|
||||
if neocomplcache#is_auto_complete() |
||||
" Don't complete cursor word. |
||||
let expr .= printf(' && %s !=? a:complete_str', word) |
||||
endif |
||||
|
||||
return filter(a:list, expr) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#filters#dictionary_filter(dictionary, complete_str) "{{{ |
||||
if empty(a:dictionary) |
||||
return [] |
||||
endif |
||||
|
||||
let completion_length = 2 |
||||
if len(a:complete_str) < completion_length || |
||||
\ neocomplcache#check_completion_length_match( |
||||
\ a:complete_str, completion_length) || |
||||
\ &l:completefunc ==# 'neocomplcache#cunite_complete' |
||||
return neocomplcache#keyword_filter( |
||||
\ neocomplcache#unpack_dictionary(a:dictionary), a:complete_str) |
||||
endif |
||||
|
||||
let key = tolower(a:complete_str[: completion_length-1]) |
||||
|
||||
if !has_key(a:dictionary, key) |
||||
return [] |
||||
endif |
||||
|
||||
let list = a:dictionary[key] |
||||
if type(list) == type({}) |
||||
" Convert dictionary dictionary. |
||||
unlet list |
||||
let list = values(a:dictionary[key]) |
||||
else |
||||
let list = copy(list) |
||||
endif |
||||
|
||||
return (len(a:complete_str) == completion_length && &ignorecase |
||||
\ && !neocomplcache#check_completion_length_match( |
||||
\ a:complete_str, completion_length)) ? |
||||
\ list : neocomplcache#keyword_filter(list, a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
"============================================================================= |
||||
" FILE: converter_abbr.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 06 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#converter_abbr#define() "{{{ |
||||
return s:converter |
||||
endfunction"}}} |
||||
|
||||
let s:converter = { |
||||
\ 'name' : 'converter_abbr', |
||||
\ 'description' : 'abbr converter', |
||||
\} |
||||
|
||||
function! s:converter.filter(context) "{{{ |
||||
if g:neocomplcache_max_keyword_width < 0 |
||||
return a:context.candidates |
||||
endif |
||||
|
||||
for candidate in a:context.candidates |
||||
let abbr = get(candidate, 'abbr', candidate.word) |
||||
if len(abbr) > g:neocomplcache_max_keyword_width |
||||
let len = neocomplcache#util#wcswidth(abbr) |
||||
|
||||
if len > g:neocomplcache_max_keyword_width |
||||
let candidate.abbr = neocomplcache#util#truncate_smart( |
||||
\ abbr, g:neocomplcache_max_keyword_width, |
||||
\ g:neocomplcache_max_keyword_width/2, '..') |
||||
endif |
||||
endif |
||||
endfor |
||||
|
||||
return a:context.candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
"============================================================================= |
||||
" FILE: converter_case.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 02 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#converter_case#define() "{{{ |
||||
return s:converter |
||||
endfunction"}}} |
||||
|
||||
let s:converter = { |
||||
\ 'name' : 'converter_case', |
||||
\ 'description' : 'case converter', |
||||
\} |
||||
|
||||
function! s:converter.filter(context) "{{{ |
||||
if !neocomplcache#is_text_mode() && !neocomplcache#within_comment() |
||||
return a:context.candidates |
||||
endif |
||||
|
||||
let convert_candidates = filter(copy(a:context.candidates), |
||||
\ "get(v:val, 'neocomplcache__convertable', 1) |
||||
\ && v:val.word =~ '^[a-zA-Z0-9_''-]\\+$'") |
||||
|
||||
if a:context.complete_str =~ '^\l\+$' |
||||
for candidate in convert_candidates |
||||
let candidate.word = tolower(candidate.word) |
||||
if has_key(candidate, 'abbr') |
||||
let candidate.abbr = tolower(candidate.abbr) |
||||
endif |
||||
endfor |
||||
elseif a:context.complete_str =~ '^\u\+$' |
||||
for candidate in convert_candidates |
||||
let candidate.word = toupper(candidate.word) |
||||
if has_key(candidate, 'abbr') |
||||
let candidate.abbr = toupper(candidate.abbr) |
||||
endif |
||||
endfor |
||||
elseif a:context.complete_str =~ '^\u\l\+$' |
||||
for candidate in convert_candidates |
||||
let candidate.word = toupper(candidate.word[0]). |
||||
\ tolower(candidate.word[1:]) |
||||
if has_key(candidate, 'abbr') |
||||
let candidate.abbr = toupper(candidate.abbr[0]). |
||||
\ tolower(candidate.abbr[1:]) |
||||
endif |
||||
endfor |
||||
endif |
||||
|
||||
return a:context.candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
"============================================================================= |
||||
" FILE: converter_delimiter.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 06 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#converter_delimiter#define() "{{{ |
||||
return s:converter |
||||
endfunction"}}} |
||||
|
||||
let s:converter = { |
||||
\ 'name' : 'converter_delimiter', |
||||
\ 'description' : 'delimiter converter', |
||||
\} |
||||
|
||||
function! s:converter.filter(context) "{{{ |
||||
if g:neocomplcache_max_keyword_width < 0 |
||||
return a:context.candidates |
||||
endif |
||||
|
||||
" Delimiter check. |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
let next_keyword = neocomplcache#filters# |
||||
\converter_remove_next_keyword#get_next_keyword(a:context.source_name) |
||||
for delimiter in ['/'] + |
||||
\ get(g:neocomplcache_delimiter_patterns, filetype, []) |
||||
" Count match. |
||||
let delim_cnt = 0 |
||||
let matchend = matchend(a:context.complete_str, delimiter) |
||||
while matchend >= 0 |
||||
let matchend = matchend(a:context.complete_str, |
||||
\ delimiter, matchend) |
||||
let delim_cnt += 1 |
||||
endwhile |
||||
|
||||
for candidate in a:context.candidates |
||||
let split_list = split(candidate.word, delimiter.'\ze.', 1) |
||||
if len(split_list) > 1 |
||||
let delimiter_sub = substitute( |
||||
\ delimiter, '\\\([.^$]\)', '\1', 'g') |
||||
let candidate.word = join(split_list[ : delim_cnt], delimiter_sub) |
||||
let candidate.abbr = join( |
||||
\ split(get(candidate, 'abbr', candidate.word), |
||||
\ delimiter.'\ze.', 1)[ : delim_cnt], |
||||
\ delimiter_sub) |
||||
|
||||
if g:neocomplcache_max_keyword_width >= 0 |
||||
\ && len(candidate.abbr) > g:neocomplcache_max_keyword_width |
||||
let candidate.abbr = substitute(candidate.abbr, |
||||
\ '\(\h\)\w*'.delimiter, '\1'.delimiter_sub, 'g') |
||||
endif |
||||
if delim_cnt+1 < len(split_list) |
||||
let candidate.abbr .= delimiter_sub . '~' |
||||
let candidate.dup = 0 |
||||
|
||||
if g:neocomplcache_enable_auto_delimiter && next_keyword == '' |
||||
let candidate.word .= delimiter_sub |
||||
endif |
||||
endif |
||||
endif |
||||
endfor |
||||
endfor |
||||
|
||||
return a:context.candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
"============================================================================= |
||||
" FILE: converter_nothing.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#converter_nothing#define() "{{{ |
||||
return s:converter |
||||
endfunction"}}} |
||||
|
||||
let s:converter = { |
||||
\ 'name' : 'converter_nothing', |
||||
\ 'description' : 'nothing converter', |
||||
\} |
||||
|
||||
function! s:converter.filter(context) "{{{ |
||||
" Nothing. |
||||
return a:context.candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
"============================================================================= |
||||
" FILE: converter_remove_next_keyword.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 31 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#converter_remove_next_keyword#define() "{{{ |
||||
return s:converter |
||||
endfunction"}}} |
||||
|
||||
let s:converter = { |
||||
\ 'name' : 'converter_remove_next_keyword', |
||||
\ 'description' : 'remove next keyword converter', |
||||
\} |
||||
|
||||
function! s:converter.filter(context) "{{{ |
||||
" Remove next keyword. |
||||
let next_keyword = neocomplcache#filters# |
||||
\converter_remove_next_keyword#get_next_keyword(a:context.source_name) |
||||
if next_keyword == '' |
||||
return a:context.candidates |
||||
endif |
||||
|
||||
let next_keyword = substitute( |
||||
\ substitute(escape(next_keyword, |
||||
\ '~" \.^$*[]'), "'", "''", 'g'), ')$', '', '').'$' |
||||
|
||||
" No ignorecase. |
||||
let ignorecase_save = &ignorecase |
||||
let &ignorecase = 0 |
||||
try |
||||
for r in a:context.candidates |
||||
let pos = match(r.word, next_keyword) |
||||
if pos >= 0 |
||||
if !has_key(r, 'abbr') |
||||
let r.abbr = r.word |
||||
endif |
||||
|
||||
let r.word = r.word[: pos-1] |
||||
endif |
||||
endfor |
||||
finally |
||||
let &ignorecase = ignorecase_save |
||||
endtry |
||||
|
||||
return a:context.candidates |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#filters#converter_remove_next_keyword#get_next_keyword(source_name) "{{{ |
||||
let pattern = '^\%(' . |
||||
\ ((a:source_name ==# 'filename_complete' || |
||||
\ a:source_name ==# 'filename_complete') ? |
||||
\ neocomplcache#get_next_keyword_pattern('filename') : |
||||
\ neocomplcache#get_next_keyword_pattern()) . '\m\)' |
||||
|
||||
let next_keyword = matchstr('a'. |
||||
\ getline('.')[len(neocomplcache#get_cur_text(1)) :], pattern)[1:] |
||||
return next_keyword |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
"============================================================================= |
||||
" FILE: matcher_fuzzy.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#matcher_fuzzy#define() "{{{ |
||||
return s:matcher |
||||
endfunction"}}} |
||||
|
||||
let s:matcher = { |
||||
\ 'name' : 'matcher_fuzzy', |
||||
\ 'description' : 'fuzzy matcher', |
||||
\} |
||||
|
||||
function! s:matcher.filter(context) "{{{ |
||||
" Todo: |
||||
return [] |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
"============================================================================= |
||||
" FILE: matcher_head.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 25 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#matcher_head#define() "{{{ |
||||
return s:matcher |
||||
endfunction"}}} |
||||
|
||||
let s:matcher = { |
||||
\ 'name' : 'matcher_head', |
||||
\ 'description' : 'head matcher', |
||||
\} |
||||
|
||||
function! s:matcher.filter(context) "{{{ |
||||
" Todo: |
||||
return [] |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
"============================================================================= |
||||
" FILE: matcher_old.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 25 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#matcher_old#define() "{{{ |
||||
return s:matcher |
||||
endfunction"}}} |
||||
|
||||
let s:matcher = { |
||||
\ 'name' : 'matcher_old', |
||||
\ 'description' : 'old matcher', |
||||
\} |
||||
|
||||
function! s:matcher.filter(candidates, context) "{{{ |
||||
if a:context.input == '' |
||||
return neocomplcache#util#filter_matcher( |
||||
\ a:candidates, '', a:context) |
||||
endif |
||||
|
||||
let candidates = a:candidates |
||||
for input in a:context.input_list |
||||
let candidates = neocomplcache#filters#matcher_old#glob_matcher( |
||||
\ candidates, input, a:context) |
||||
endfor |
||||
|
||||
return candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
"============================================================================= |
||||
" FILE: sorter_length.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 09 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#sorter_length#define() "{{{ |
||||
return s:sorter |
||||
endfunction"}}} |
||||
|
||||
let s:sorter = { |
||||
\ 'name' : 'sorter_length', |
||||
\ 'description' : 'sort by length order', |
||||
\} |
||||
|
||||
function! s:sorter.filter(context) "{{{ |
||||
return sort(a:context.candidates, 's:compare') |
||||
endfunction"}}} |
||||
|
||||
function! s:compare(i1, i2) |
||||
let diff = len(a:i1.word) - len(a:i2.word) |
||||
if !diff |
||||
let diff = (a:i1.word ># a:i2.word) ? 1 : -1 |
||||
endif |
||||
return diff |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
"============================================================================= |
||||
" FILE: sorter_nothing.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#sorter_nothing#define() "{{{ |
||||
return s:sorter |
||||
endfunction"}}} |
||||
|
||||
let s:sorter = { |
||||
\ 'name' : 'sorter_nothing', |
||||
\ 'description' : 'nothing sorter', |
||||
\} |
||||
|
||||
function! s:sorter.filter(context) "{{{ |
||||
" Nothing. |
||||
return a:candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
"============================================================================= |
||||
" FILE: sorter_rank.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 09 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#filters#sorter_rank#define() "{{{ |
||||
return s:sorter |
||||
endfunction"}}} |
||||
|
||||
let s:sorter = { |
||||
\ 'name' : 'sorter_rank', |
||||
\ 'description' : 'sort by matched rank order', |
||||
\} |
||||
|
||||
function! s:sorter.filter(context) "{{{ |
||||
return sort(a:context.candidates, 's:compare') |
||||
endfunction"}}} |
||||
|
||||
function! s:compare(i1, i2) |
||||
let diff = (get(a:i2, 'rank', 0) - get(a:i1, 'rank', 0)) |
||||
return (diff != 0) ? diff : (a:i1.word ># a:i2.word) ? 1 : -1 |
||||
endfunction" |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,291 @@
@@ -0,0 +1,291 @@
|
||||
"============================================================================= |
||||
" FILE: handler.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 29 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#handler#_on_moved_i() "{{{ |
||||
" Get cursor word. |
||||
let cur_text = neocomplcache#get_cur_text(1) |
||||
|
||||
call s:close_preview_window() |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_on_insert_enter() "{{{ |
||||
if &l:foldmethod ==# 'expr' && foldlevel('.') != 0 |
||||
foldopen |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_on_insert_leave() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let neocomplcache.cur_text = '' |
||||
let neocomplcache.old_cur_text = '' |
||||
|
||||
call s:close_preview_window() |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_on_write_post() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
" Restore foldinfo. |
||||
for winnr in filter(range(1, winnr('$')), |
||||
\ "!empty(getwinvar(v:val, 'neocomplcache_foldinfo'))") |
||||
let neocomplcache_foldinfo = |
||||
\ getwinvar(winnr, 'neocomplcache_foldinfo') |
||||
call setwinvar(winnr, '&foldmethod', |
||||
\ neocomplcache_foldinfo.foldmethod) |
||||
call setwinvar(winnr, '&foldexpr', |
||||
\ neocomplcache_foldinfo.foldexpr) |
||||
call setwinvar(winnr, |
||||
\ 'neocomplcache_foldinfo', {}) |
||||
endfor |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_on_complete_done() "{{{ |
||||
" Get cursor word. |
||||
let [_, candidate] = neocomplcache#match_word( |
||||
\ neocomplcache#get_cur_text(1)) |
||||
if candidate == '' |
||||
return |
||||
endif |
||||
|
||||
let frequencies = neocomplcache#variables#get_frequencies() |
||||
if !has_key(frequencies, candidate) |
||||
let frequencies[candidate] = 20 |
||||
else |
||||
let frequencies[candidate] += 20 |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_change_update_time() "{{{ |
||||
if &updatetime > g:neocomplcache_cursor_hold_i_time |
||||
" Change updatetime. |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.update_time_save = &updatetime |
||||
let &updatetime = g:neocomplcache_cursor_hold_i_time |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#handler#_restore_update_time() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
if &updatetime < neocomplcache.update_time_save |
||||
" Restore updatetime. |
||||
let &updatetime = neocomplcache.update_time_save |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#handler#_do_auto_complete(event) "{{{ |
||||
if s:check_in_do_auto_complete() |
||||
return |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.skipped = 0 |
||||
let neocomplcache.event = a:event |
||||
|
||||
let cur_text = neocomplcache#get_cur_text(1) |
||||
|
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'cur_text = ' . cur_text |
||||
endif |
||||
|
||||
" Prevent infinity loop. |
||||
if s:is_skip_auto_complete(cur_text) |
||||
" Make cache. |
||||
if cur_text =~ '^\s*$\|\s\+$' |
||||
if neocomplcache#is_enabled_source('buffer_complete') |
||||
" Caching current cache line. |
||||
call neocomplcache#sources#buffer_complete#caching_current_line() |
||||
endif |
||||
if neocomplcache#is_enabled_source('member_complete') |
||||
" Caching current cache line. |
||||
call neocomplcache#sources#member_complete#caching_current_line() |
||||
endif |
||||
endif |
||||
|
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'Skipped.' |
||||
endif |
||||
|
||||
call neocomplcache#helper#clear_result() |
||||
return |
||||
endif |
||||
|
||||
let neocomplcache.old_cur_text = cur_text |
||||
|
||||
if neocomplcache#helper#is_omni_complete(cur_text) |
||||
call feedkeys("\<Plug>(neocomplcache_start_omni_complete)") |
||||
return |
||||
endif |
||||
|
||||
" Check multibyte input or eskk. |
||||
if neocomplcache#is_eskk_enabled() |
||||
\ || neocomplcache#is_multibyte_input(cur_text) |
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'Skipped.' |
||||
endif |
||||
|
||||
return |
||||
endif |
||||
|
||||
" Check complete position. |
||||
let complete_results = neocomplcache#complete#_set_results_pos(cur_text) |
||||
if empty(complete_results) |
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'Skipped.' |
||||
endif |
||||
|
||||
return |
||||
endif |
||||
|
||||
let &l:completefunc = 'neocomplcache#complete#auto_complete' |
||||
|
||||
if neocomplcache#is_prefetch() |
||||
" Do prefetch. |
||||
let neocomplcache.complete_results = |
||||
\ neocomplcache#complete#_get_results(cur_text) |
||||
|
||||
if empty(neocomplcache.complete_results) |
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'Skipped.' |
||||
endif |
||||
|
||||
" Skip completion. |
||||
let &l:completefunc = 'neocomplcache#complete#manual_complete' |
||||
call neocomplcache#helper#clear_result() |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
call s:save_foldinfo() |
||||
|
||||
" Set options. |
||||
set completeopt-=menu |
||||
set completeopt-=longest |
||||
set completeopt+=menuone |
||||
|
||||
" Start auto complete. |
||||
call feedkeys(&l:formatoptions !~ 'a' ? |
||||
\ "\<Plug>(neocomplcache_start_auto_complete)": |
||||
\ "\<Plug>(neocomplcache_start_auto_complete_no_select)") |
||||
endfunction"}}} |
||||
|
||||
function! s:save_foldinfo() "{{{ |
||||
" Save foldinfo. |
||||
let winnrs = filter(range(1, winnr('$')), |
||||
\ "winbufnr(v:val) == bufnr('%')") |
||||
|
||||
" Note: for foldmethod=expr or syntax. |
||||
call filter(winnrs, " |
||||
\ (getwinvar(v:val, '&foldmethod') ==# 'expr' || |
||||
\ getwinvar(v:val, '&foldmethod') ==# 'syntax') && |
||||
\ getwinvar(v:val, '&modifiable')") |
||||
for winnr in winnrs |
||||
call setwinvar(winnr, 'neocomplcache_foldinfo', { |
||||
\ 'foldmethod' : getwinvar(winnr, '&foldmethod'), |
||||
\ 'foldexpr' : getwinvar(winnr, '&foldexpr') |
||||
\ }) |
||||
call setwinvar(winnr, '&foldmethod', 'manual') |
||||
call setwinvar(winnr, '&foldexpr', 0) |
||||
endfor |
||||
endfunction"}}} |
||||
function! s:check_in_do_auto_complete() "{{{ |
||||
if neocomplcache#is_locked() |
||||
return 1 |
||||
endif |
||||
|
||||
" Detect completefunc. |
||||
if &l:completefunc !~# '^neocomplcache#' |
||||
if g:neocomplcache_force_overwrite_completefunc |
||||
" Set completefunc. |
||||
let &l:completefunc = 'neocomplcache#complete#manual_complete' |
||||
else |
||||
" Warning. |
||||
redir => output |
||||
99verbose setl completefunc |
||||
redir END |
||||
call neocomplcache#print_error(output) |
||||
call neocomplcache#print_error( |
||||
\ 'Another plugin set completefunc! Disabled neocomplcache.') |
||||
NeoComplCacheLock |
||||
return 1 |
||||
endif |
||||
endif |
||||
|
||||
" Detect AutoComplPop. |
||||
if exists('g:acp_enableAtStartup') && g:acp_enableAtStartup |
||||
call neocomplcache#print_error( |
||||
\ 'Detected enabled AutoComplPop! Disabled neocomplcache.') |
||||
NeoComplCacheLock |
||||
return 1 |
||||
endif |
||||
endfunction"}}} |
||||
function! s:is_skip_auto_complete(cur_text) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
if a:cur_text =~ '^\s*$\|\s\+$' |
||||
\ || a:cur_text == neocomplcache.old_cur_text |
||||
\ || (g:neocomplcache_lock_iminsert && &l:iminsert) |
||||
\ || (&l:formatoptions =~# '[tc]' && &l:textwidth > 0 |
||||
\ && neocomplcache#util#wcswidth(a:cur_text) >= &l:textwidth) |
||||
return 1 |
||||
endif |
||||
|
||||
if !neocomplcache.skip_next_complete |
||||
return 0 |
||||
endif |
||||
|
||||
" Check delimiter pattern. |
||||
let is_delimiter = 0 |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
for delimiter in ['/', '\.'] + |
||||
\ get(g:neocomplcache_delimiter_patterns, filetype, []) |
||||
if a:cur_text =~ delimiter . '$' |
||||
let is_delimiter = 1 |
||||
break |
||||
endif |
||||
endfor |
||||
|
||||
if is_delimiter && neocomplcache.skip_next_complete == 2 |
||||
let neocomplcache.skip_next_complete = 0 |
||||
return 0 |
||||
endif |
||||
|
||||
let neocomplcache.skip_next_complete = 0 |
||||
let neocomplcache.cur_text = '' |
||||
let neocomplcache.old_cur_text = '' |
||||
|
||||
return 1 |
||||
endfunction"}}} |
||||
function! s:close_preview_window() "{{{ |
||||
if g:neocomplcache_enable_auto_close_preview && |
||||
\ bufname('%') !=# '[Command Line]' && winnr('$') != 1 |
||||
" Close preview window. |
||||
pclose! |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,438 @@
@@ -0,0 +1,438 @@
|
||||
"============================================================================= |
||||
" FILE: helper.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 03 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#helper#get_cur_text() "{{{ |
||||
let cur_text = |
||||
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ? |
||||
\ getline('.') : |
||||
\ matchstr(getline('.'), |
||||
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.')) |
||||
|
||||
if cur_text =~ '^.\{-}\ze\S\+$' |
||||
let complete_str = matchstr(cur_text, '\S\+$') |
||||
let cur_text = matchstr(cur_text, '^.\{-}\ze\S\+$') |
||||
else |
||||
let complete_str = '' |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
if neocomplcache.event ==# 'InsertCharPre' |
||||
let complete_str .= v:char |
||||
endif |
||||
|
||||
let filetype = neocomplcache#get_context_filetype() |
||||
let wildcard = get(g:neocomplcache_wildcard_characters, filetype, |
||||
\ get(g:neocomplcache_wildcard_characters, '_', '*')) |
||||
if g:neocomplcache_enable_wildcard && |
||||
\ wildcard !=# '*' && len(wildcard) == 1 |
||||
" Substitute wildcard character. |
||||
while 1 |
||||
let index = stridx(complete_str, wildcard) |
||||
if index <= 0 |
||||
break |
||||
endif |
||||
|
||||
let complete_str = complete_str[: index-1] |
||||
\ . '*' . complete_str[index+1: ] |
||||
endwhile |
||||
endif |
||||
|
||||
let neocomplcache.cur_text = cur_text . complete_str |
||||
|
||||
" Save cur_text. |
||||
return neocomplcache.cur_text |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#keyword_escape(complete_str) "{{{ |
||||
" Fuzzy completion. |
||||
let keyword_len = len(a:complete_str) |
||||
let keyword_escape = s:keyword_escape(a:complete_str) |
||||
if g:neocomplcache_enable_fuzzy_completion |
||||
\ && (g:neocomplcache_fuzzy_completion_start_length |
||||
\ <= keyword_len && keyword_len < 20) |
||||
let pattern = keyword_len >= 8 ? |
||||
\ '\0\\w*' : '\\%(\0\\w*\\|\U\0\E\\l*\\)' |
||||
|
||||
let start = g:neocomplcache_fuzzy_completion_start_length |
||||
if start <= 1 |
||||
let keyword_escape = |
||||
\ substitute(keyword_escape, '\w', pattern, 'g') |
||||
elseif keyword_len < 8 |
||||
let keyword_escape = keyword_escape[: start - 2] |
||||
\ . substitute(keyword_escape[start-1 :], '\w', pattern, 'g') |
||||
else |
||||
let keyword_escape = keyword_escape[: 3] . |
||||
\ substitute(keyword_escape[4:12], '\w', |
||||
\ pattern, 'g') . keyword_escape[13:] |
||||
endif |
||||
else |
||||
" Underbar completion. "{{{ |
||||
if g:neocomplcache_enable_underbar_completion |
||||
\ && keyword_escape =~ '[^_]_\|^_' |
||||
let keyword_escape = substitute(keyword_escape, |
||||
\ '\%(^\|[^_]\)\zs_', '[^_]*_', 'g') |
||||
endif |
||||
if g:neocomplcache_enable_underbar_completion |
||||
\ && '-' =~ '\k' && keyword_escape =~ '[^-]-' |
||||
let keyword_escape = substitute(keyword_escape, |
||||
\ '[^-]\zs-', '[^-]*-', 'g') |
||||
endif |
||||
"}}} |
||||
" Camel case completion. "{{{ |
||||
if g:neocomplcache_enable_camel_case_completion |
||||
\ && keyword_escape =~ '\u\?\U*' |
||||
let keyword_escape = |
||||
\ substitute(keyword_escape, |
||||
\ '\u\?\zs\U*', |
||||
\ '\\%(\0\\l*\\|\U\0\E\\u*_\\?\\)', 'g') |
||||
endif |
||||
"}}} |
||||
endif |
||||
|
||||
call neocomplcache#print_debug(keyword_escape) |
||||
return keyword_escape |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#is_omni_complete(cur_text) "{{{ |
||||
" Check eskk complete length. |
||||
if neocomplcache#is_eskk_enabled() |
||||
\ && exists('g:eskk#start_completion_length') |
||||
if !neocomplcache#is_eskk_convertion(a:cur_text) |
||||
\ || !neocomplcache#is_multibyte_input(a:cur_text) |
||||
return 0 |
||||
endif |
||||
|
||||
let complete_pos = call(&l:omnifunc, [1, '']) |
||||
let complete_str = a:cur_text[complete_pos :] |
||||
return neocomplcache#util#mb_strlen(complete_str) >= |
||||
\ g:eskk#start_completion_length |
||||
endif |
||||
|
||||
let filetype = neocomplcache#get_context_filetype() |
||||
let omnifunc = get(g:neocomplcache_omni_functions, |
||||
\ filetype, &l:omnifunc) |
||||
|
||||
if neocomplcache#check_invalid_omnifunc(omnifunc) |
||||
return 0 |
||||
endif |
||||
|
||||
let syn_name = neocomplcache#helper#get_syn_name(1) |
||||
if syn_name ==# 'Comment' || syn_name ==# 'String' |
||||
" Skip omni_complete in string literal. |
||||
return 0 |
||||
endif |
||||
|
||||
if has_key(g:neocomplcache_force_omni_patterns, omnifunc) |
||||
let pattern = g:neocomplcache_force_omni_patterns[omnifunc] |
||||
elseif filetype != '' && |
||||
\ get(g:neocomplcache_force_omni_patterns, filetype, '') != '' |
||||
let pattern = g:neocomplcache_force_omni_patterns[filetype] |
||||
else |
||||
return 0 |
||||
endif |
||||
|
||||
if a:cur_text !~# '\%(' . pattern . '\m\)$' |
||||
return 0 |
||||
endif |
||||
|
||||
" Set omnifunc. |
||||
let &omnifunc = omnifunc |
||||
|
||||
return 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#is_enabled_source(source_name) "{{{ |
||||
if neocomplcache#is_disabled_source(a:source_name) |
||||
return 0 |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
if !has_key(neocomplcache, 'sources') |
||||
call neocomplcache#helper#get_sources_list() |
||||
endif |
||||
|
||||
return index(keys(neocomplcache.sources), a:source_name) >= 0 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#get_source_filetypes(filetype) "{{{ |
||||
let filetype = (a:filetype == '') ? 'nothing' : a:filetype |
||||
|
||||
let filetype_dict = {} |
||||
|
||||
let filetypes = [filetype] |
||||
if filetype =~ '\.' |
||||
if exists('g:neocomplcache_ignore_composite_filetype_lists') |
||||
\ && has_key(g:neocomplcache_ignore_composite_filetype_lists, filetype) |
||||
let filetypes = [g:neocomplcache_ignore_composite_filetype_lists[filetype]] |
||||
else |
||||
" Set composite filetype. |
||||
let filetypes += split(filetype, '\.') |
||||
endif |
||||
endif |
||||
|
||||
if exists('g:neocomplcache_same_filetype_lists') |
||||
for ft in copy(filetypes) |
||||
let filetypes += split(get(g:neocomplcache_same_filetype_lists, ft, |
||||
\ get(g:neocomplcache_same_filetype_lists, '_', '')), ',') |
||||
endfor |
||||
endif |
||||
|
||||
return neocomplcache#util#uniq(filetypes) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#get_completion_length(plugin_name) "{{{ |
||||
" Todo. |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#complete_check() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
if g:neocomplcache_enable_debug |
||||
echomsg split(reltimestr(reltime(neocomplcache.start_time)))[0] |
||||
endif |
||||
let ret = (!neocomplcache#is_prefetch() && complete_check()) |
||||
\ || (neocomplcache#is_auto_complete() |
||||
\ && g:neocomplcache_skip_auto_completion_time != '' |
||||
\ && split(reltimestr(reltime(neocomplcache.start_time)))[0] > |
||||
\ g:neocomplcache_skip_auto_completion_time) |
||||
if ret |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.skipped = 1 |
||||
|
||||
redraw |
||||
echo 'Skipped.' |
||||
endif |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#get_syn_name(is_trans) "{{{ |
||||
return len(getline('.')) < 200 ? |
||||
\ synIDattr(synIDtrans(synID(line('.'), mode() ==# 'i' ? |
||||
\ col('.')-1 : col('.'), a:is_trans)), 'name') : '' |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#match_word(cur_text, ...) "{{{ |
||||
let pattern = a:0 >= 1 ? a:1 : neocomplcache#get_keyword_pattern_end() |
||||
|
||||
" Check wildcard. |
||||
let complete_pos = s:match_wildcard( |
||||
\ a:cur_text, pattern, match(a:cur_text, pattern)) |
||||
|
||||
let complete_str = (complete_pos >=0) ? |
||||
\ a:cur_text[complete_pos :] : '' |
||||
|
||||
return [complete_pos, complete_str] |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#filetype_complete(arglead, cmdline, cursorpos) "{{{ |
||||
" Dup check. |
||||
let ret = {} |
||||
for item in map( |
||||
\ split(globpath(&runtimepath, 'syntax/*.vim'), '\n') + |
||||
\ split(globpath(&runtimepath, 'indent/*.vim'), '\n') + |
||||
\ split(globpath(&runtimepath, 'ftplugin/*.vim'), '\n') |
||||
\ , 'fnamemodify(v:val, ":t:r")') |
||||
if !has_key(ret, item) && item =~ '^'.a:arglead |
||||
let ret[item] = 1 |
||||
endif |
||||
endfor |
||||
|
||||
return sort(keys(ret)) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#unite_patterns(pattern_var, filetype) "{{{ |
||||
let keyword_patterns = [] |
||||
let dup_check = {} |
||||
|
||||
" Composite filetype. |
||||
for ft in split(a:filetype, '\.') |
||||
if has_key(a:pattern_var, ft) && !has_key(dup_check, ft) |
||||
let dup_check[ft] = 1 |
||||
call add(keyword_patterns, a:pattern_var[ft]) |
||||
endif |
||||
|
||||
" Same filetype. |
||||
if exists('g:neocomplcache_same_filetype_lists') |
||||
\ && has_key(g:neocomplcache_same_filetype_lists, ft) |
||||
for ft in split(g:neocomplcache_same_filetype_lists[ft], ',') |
||||
if has_key(a:pattern_var, ft) && !has_key(dup_check, ft) |
||||
let dup_check[ft] = 1 |
||||
call add(keyword_patterns, a:pattern_var[ft]) |
||||
endif |
||||
endfor |
||||
endif |
||||
endfor |
||||
|
||||
if empty(keyword_patterns) |
||||
let default = get(a:pattern_var, '_', get(a:pattern_var, 'default', '')) |
||||
if default != '' |
||||
call add(keyword_patterns, default) |
||||
endif |
||||
endif |
||||
|
||||
return join(keyword_patterns, '\m\|') |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#ftdictionary2list(dictionary, filetype) "{{{ |
||||
let list = [] |
||||
for filetype in neocomplcache#get_source_filetypes(a:filetype) |
||||
if has_key(a:dictionary, filetype) |
||||
call add(list, a:dictionary[filetype]) |
||||
endif |
||||
endfor |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#get_sources_list(...) "{{{ |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
let source_names = exists('b:neocomplcache_sources_list') ? |
||||
\ b:neocomplcache_sources_list : |
||||
\ get(a:000, 0, |
||||
\ get(g:neocomplcache_sources_list, filetype, |
||||
\ get(g:neocomplcache_sources_list, '_', ['_']))) |
||||
let disabled_sources = get( |
||||
\ g:neocomplcache_disabled_sources_list, filetype, |
||||
\ get(g:neocomplcache_disabled_sources_list, '_', [])) |
||||
call neocomplcache#init#_sources(source_names) |
||||
|
||||
let all_sources = neocomplcache#available_sources() |
||||
let sources = {} |
||||
for source_name in source_names |
||||
if source_name ==# '_' |
||||
" All sources. |
||||
let sources = all_sources |
||||
break |
||||
endif |
||||
|
||||
if !has_key(all_sources, source_name) |
||||
call neocomplcache#print_warning(printf( |
||||
\ 'Invalid source name "%s" is given.', source_name)) |
||||
continue |
||||
endif |
||||
|
||||
let sources[source_name] = all_sources[source_name] |
||||
endfor |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.sources = filter(sources, " |
||||
\ index(disabled_sources, v:val.name) < 0 && |
||||
\ (empty(v:val.filetypes) || |
||||
\ get(v:val.filetypes, neocomplcache.context_filetype, 0))") |
||||
|
||||
return neocomplcache.sources |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#clear_result() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let neocomplcache.complete_str = '' |
||||
let neocomplcache.candidates = [] |
||||
let neocomplcache.complete_results = [] |
||||
let neocomplcache.complete_pos = -1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#call_hook(sources, hook_name, context) "{{{ |
||||
for source in neocomplcache#util#convert2list(a:sources) |
||||
try |
||||
if !has_key(source.hooks, a:hook_name) |
||||
if a:hook_name ==# 'on_init' && has_key(source, 'initialize') |
||||
call source.initialize() |
||||
elseif a:hook_name ==# 'on_final' && has_key(source, 'finalize') |
||||
call source.finalize() |
||||
endif |
||||
else |
||||
call call(source.hooks[a:hook_name], |
||||
\ [extend(source.neocomplcache__context, a:context)], |
||||
\ source.hooks) |
||||
endif |
||||
catch |
||||
call unite#print_error(v:throwpoint) |
||||
call unite#print_error(v:exception) |
||||
call unite#print_error( |
||||
\ '[unite.vim] Error occured in calling hook "' . a:hook_name . '"!') |
||||
call unite#print_error( |
||||
\ '[unite.vim] Source name is ' . source.name) |
||||
endtry |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#helper#call_filters(filters, source, context) "{{{ |
||||
let context = extend(a:source.neocomplcache__context, a:context) |
||||
let _ = [] |
||||
for filter in neocomplcache#init#_filters( |
||||
\ neocomplcache#util#convert2list(a:filters)) |
||||
try |
||||
let context.candidates = call(filter.filter, [context], filter) |
||||
catch |
||||
call unite#print_error(v:throwpoint) |
||||
call unite#print_error(v:exception) |
||||
call unite#print_error( |
||||
\ '[unite.vim] Error occured in calling filter ' |
||||
\ . filter.name . '!') |
||||
call unite#print_error( |
||||
\ '[unite.vim] Source name is ' . a:source.name) |
||||
endtry |
||||
endfor |
||||
|
||||
return context.candidates |
||||
endfunction"}}} |
||||
|
||||
function! s:match_wildcard(cur_text, pattern, complete_pos) "{{{ |
||||
let complete_pos = a:complete_pos |
||||
while complete_pos > 1 && a:cur_text[complete_pos - 1] == '*' |
||||
let left_text = a:cur_text[: complete_pos - 2] |
||||
if left_text == '' || left_text !~ a:pattern |
||||
break |
||||
endif |
||||
|
||||
let complete_pos = match(left_text, a:pattern) |
||||
endwhile |
||||
|
||||
return complete_pos |
||||
endfunction"}}} |
||||
|
||||
function! s:keyword_escape(complete_str) "{{{ |
||||
let keyword_escape = escape(a:complete_str, '~" \.^$[]') |
||||
if g:neocomplcache_enable_wildcard |
||||
let keyword_escape = substitute( |
||||
\ substitute(keyword_escape, '.\zs\*', '.*', 'g'), |
||||
\ '\%(^\|\*\)\zs\*', '\\*', 'g') |
||||
else |
||||
let keyword_escape = escape(keyword_escape, '*') |
||||
endif |
||||
|
||||
return keyword_escape |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,866 @@
@@ -0,0 +1,866 @@
|
||||
"============================================================================= |
||||
" FILE: init.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
if !exists('s:is_enabled') |
||||
let s:is_enabled = 0 |
||||
endif |
||||
|
||||
function! neocomplcache#init#lazy() "{{{ |
||||
if !exists('s:lazy_progress') |
||||
let s:lazy_progress = 0 |
||||
endif |
||||
|
||||
if s:lazy_progress == 0 |
||||
call neocomplcache#init#_others() |
||||
let s:is_enabled = 0 |
||||
elseif s:lazy_progress == 1 |
||||
call neocomplcache#init#_sources(get(g:neocomplcache_sources_list, |
||||
\ neocomplcache#get_context_filetype(), ['_'])) |
||||
else |
||||
call neocomplcache#init#_autocmds() |
||||
let s:is_enabled = 1 |
||||
endif |
||||
|
||||
let s:lazy_progress += 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#enable() "{{{ |
||||
if neocomplcache#is_enabled() |
||||
return |
||||
endif |
||||
|
||||
call neocomplcache#init#_autocmds() |
||||
call neocomplcache#init#_others() |
||||
|
||||
call neocomplcache#init#_sources(get(g:neocomplcache_sources_list, |
||||
\ neocomplcache#get_context_filetype(), ['_'])) |
||||
let s:is_enabled = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#disable() "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
call neocomplcache#print_warning( |
||||
\ 'neocomplcache is disabled! This command is ignored.') |
||||
return |
||||
endif |
||||
|
||||
let s:is_enabled = 0 |
||||
|
||||
augroup neocomplcache |
||||
autocmd! |
||||
augroup END |
||||
|
||||
delcommand NeoComplCacheDisable |
||||
|
||||
call neocomplcache#helper#call_hook(filter(values( |
||||
\ neocomplcache#variables#get_sources()), 'v:val.loaded'), |
||||
\ 'on_final', {}) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#is_enabled() "{{{ |
||||
return s:is_enabled |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_autocmds() "{{{ |
||||
augroup neocomplcache |
||||
autocmd! |
||||
autocmd InsertEnter * |
||||
\ call neocomplcache#handler#_on_insert_enter() |
||||
autocmd InsertLeave * |
||||
\ call neocomplcache#handler#_on_insert_leave() |
||||
autocmd CursorMovedI * |
||||
\ call neocomplcache#handler#_on_moved_i() |
||||
autocmd BufWritePost * |
||||
\ call neocomplcache#handler#_on_write_post() |
||||
augroup END |
||||
|
||||
if g:neocomplcache_enable_insert_char_pre |
||||
\ && (v:version > 703 || v:version == 703 && has('patch418')) |
||||
autocmd neocomplcache InsertCharPre * |
||||
\ call neocomplcache#handler#_do_auto_complete('InsertCharPre') |
||||
elseif g:neocomplcache_enable_cursor_hold_i |
||||
augroup neocomplcache |
||||
autocmd CursorHoldI * |
||||
\ call neocomplcache#handler#_do_auto_complete('CursorHoldI') |
||||
autocmd InsertEnter * |
||||
\ call neocomplcache#handler#_change_update_time() |
||||
autocmd InsertLeave * |
||||
\ call neocomplcache#handler#_restore_update_time() |
||||
augroup END |
||||
else |
||||
autocmd neocomplcache CursorMovedI * |
||||
\ call neocomplcache#handler#_do_auto_complete('CursorMovedI') |
||||
endif |
||||
|
||||
if (v:version > 703 || v:version == 703 && has('patch598')) |
||||
autocmd neocomplcache CompleteDone * |
||||
\ call neocomplcache#handler#_on_complete_done() |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_others() "{{{ |
||||
call neocomplcache#init#_variables() |
||||
|
||||
call neocomplcache#context_filetype#initialize() |
||||
|
||||
call neocomplcache#commands#_initialize() |
||||
|
||||
" Save options. |
||||
let s:completefunc_save = &completefunc |
||||
let s:completeopt_save = &completeopt |
||||
|
||||
" Set completefunc. |
||||
let &completefunc = 'neocomplcache#complete#manual_complete' |
||||
|
||||
" For auto complete keymappings. |
||||
call neocomplcache#mappings#define_default_mappings() |
||||
|
||||
" Detect set paste. |
||||
if &paste |
||||
redir => output |
||||
99verbose set paste |
||||
redir END |
||||
call neocomplcache#print_error(output) |
||||
call neocomplcache#print_error( |
||||
\ 'Detected set paste! Disabled neocomplcache.') |
||||
endif |
||||
|
||||
command! -nargs=0 -bar NeoComplCacheDisable |
||||
\ call neocomplcache#init#disable() |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_variables() "{{{ |
||||
" Initialize keyword patterns. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_keyword_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'_', |
||||
\'\k\+') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_keyword_patterns', |
||||
\'filename', |
||||
\ neocomplcache#util#is_windows() ? |
||||
\'\%(\a\+:/\)\?\%([/[:alnum:]()$+_~.\x80-\xff-]\|[^[:print:]]\|\\.\)\+' : |
||||
\'\%([/\[\][:alnum:]()$+_~.-]\|[^[:print:]]\|\\.\)\+') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'lisp,scheme,clojure,int-gosh,int-clisp,int-clj', |
||||
\'[[:alpha:]+*/@$_=.!?-][[:alnum:]+*/@$_:=.!?-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'ruby,int-irb', |
||||
\'^=\%(b\%[egin]\|e\%[nd]\)\|\%(@@\|[:$@]\)\h\w*\|\h\w*\%(::\w*\)*[!?]\?') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'php,int-php', |
||||
\'</\?\%(\h[[:alnum:]_-]*\s*\)\?\%(/\?>\)\?'. |
||||
\'\|\$\h\w*\|\h\w*\%(\%(\\\|::\)\w*\)*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'perl,int-perlsh', |
||||
\'<\h\w*>\?\|[$@%&*]\h\w*\|\h\w*\%(::\w*\)*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'perl6,int-perl6', |
||||
\'<\h\w*>\?\|[$@%&][!.*?]\?\h[[:alnum:]_-]*'. |
||||
\'\|\h[[:alnum:]_-]*\%(::[[:alnum:]_-]*\)*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'pir', |
||||
\'[$@%.=]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'pasm', |
||||
\'[=]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'vim,help', |
||||
\'-\h[[:alnum:]-]*=\?\|\c\[:\%(\h\w*:\]\)\?\|&\h[[:alnum:]_:]*\|'. |
||||
\'<SID>\%(\h\w*\)\?\|<Plug>([^)]*)\?'. |
||||
\'\|<\h[[:alnum:]_-]*>\?\|\h[[:alnum:]_:#]*!\?\|$\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'tex', |
||||
\'\\\a{\a\{1,2}}\|\\[[:alpha:]@][[:alnum:]@]*'. |
||||
\'\%({\%([[:alnum:]:_]\+\*\?}\?\)\?\)\?\|\a[[:alnum:]:_]*\*\?') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'sh,zsh,int-zsh,int-bash,int-sh', |
||||
\'[[:alpha:]_.-][[:alnum:]_.-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'vimshell', |
||||
\'\$\$\?\w*\|[[:alpha:]_.\\/~-][[:alnum:]_.\\/~-]*\|\d\+\%(\.\d\+\)\+') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'ps1,int-powershell', |
||||
\'\[\h\%([[:alnum:]_.]*\]::\)\?\|[$%@.]\?[[:alpha:]_.:-][[:alnum:]_.:-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'c', |
||||
\'^\s*#\s*\h\w*\|\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'cpp', |
||||
\'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'objc', |
||||
\'^\s*#\s*\h\w*\|\h\w*\|@\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'objcpp', |
||||
\'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*\|@\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'objj', |
||||
\'\h\w*\|@\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'d', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'python,int-python,int-ipython', |
||||
\'[@]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'cs', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'java', |
||||
\'[@]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'javascript,actionscript,int-js,int-kjs,int-rhino', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'coffee,int-coffee', |
||||
\'[@]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'awk', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'haskell,int-ghci', |
||||
\'\%(\u\w*\.\)\+[[:alnum:]_'']*\|[[:alpha:]_''][[:alnum:]_'']*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'ml,ocaml,int-ocaml,int-sml,int-smlsharp', |
||||
\'[''`#.]\?\h[[:alnum:]_'']*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'erlang,int-erl', |
||||
\'^\s*-\h\w*\|\%(\h\w*:\)*\h\w\|\h[[:alnum:]_@]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'html,xhtml,xml,markdown,eruby', |
||||
\'</\?\%([[:alnum:]_:-]\+\s*\)\?\%(/\?>\)\?\|&\h\%(\w*;\)\?'. |
||||
\'\|\h[[:alnum:]_-]*="\%([^"]*"\?\)\?\|\h[[:alnum:]_:-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'css,stylus,scss,less', |
||||
\'[@#.]\?[[:alpha:]_:-][[:alnum:]_:-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'tags', |
||||
\'^[^!][^/[:blank:]]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'pic', |
||||
\'^\s*#\h\w*\|\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'arm', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'asmh8300', |
||||
\'[[:alpha:]_.][[:alnum:]_.]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'masm', |
||||
\'\.\h\w*\|[[:alpha:]_@?$][[:alnum:]_@?$]*\|\h\w*:\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'nasm', |
||||
\'^\s*\[\h\w*\|[%.]\?\h\w*\|\%(\.\.@\?\|%[%$!]\)\%(\h\w*\)\?\|\h\w*:\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'asm', |
||||
\'[%$.]\?\h\w*\%(\$\h\w*\)\?') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'gas', |
||||
\'[$.]\?\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'gdb,int-gdb', |
||||
\'$\h\w*\|[[:alnum:]:._-]\+') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'make', |
||||
\'[[:alpha:]_.-][[:alnum:]_.-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'scala,int-scala', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'int-termtter', |
||||
\'\h[[:alnum:]_/-]*\|\$\a\+\|#\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'int-earthquake', |
||||
\'[:#$]\h\w*\|\h[[:alnum:]_/-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'dosbatch,int-cmdproxy', |
||||
\'\$\w+\|[[:alpha:]_./-][[:alnum:]_.-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'vb', |
||||
\'\h\w*\|#\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'lua', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\ 'zimbu', |
||||
\'\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'konoha', |
||||
\'[*$@%]\h\w*\|\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'cobol', |
||||
\'\a[[:alnum:]-]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'coq', |
||||
\'\h[[:alnum:]_'']*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'tcl', |
||||
\'[.-]\h\w*\|\h\w*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_keyword_patterns', |
||||
\'nyaos,int-nyaos', |
||||
\'\h\w*') |
||||
"}}} |
||||
|
||||
" Initialize next keyword patterns. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_next_keyword_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'perl', |
||||
\'\h\w*>') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'perl6', |
||||
\'\h\w*>') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'vim,help', |
||||
\'\w*()\?\|\w*:\]\|[[:alnum:]_-]*[)>=]') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'python', |
||||
\'\w*()\?') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'tex', |
||||
\'[[:alnum:]:_]\+[*[{}]') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_next_keyword_patterns', 'html,xhtml,xml,mkd', |
||||
\'[^"]*"\|[[:alnum:]_:-]*>') |
||||
"}}} |
||||
|
||||
" Initialize same file type lists. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_same_filetype_lists', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'c', 'cpp') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'cpp', 'c') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'erb', 'ruby,html,xhtml') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'html,xml', 'xhtml') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'html,xhtml', 'css,stylus,less') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'css', 'scss') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'scss', 'css') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'stylus', 'css') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'less', 'css') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'xhtml', 'html,xml') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'help', 'vim') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'tex', 'bib,plaintex') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'plaintex', 'bib,tex') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'lingr-say', 'lingr-messages,lingr-members') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'J6uil_say', 'J6uil') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'vimconsole', 'vim') |
||||
|
||||
" Interactive filetypes. |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-irb', 'ruby') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-ghci,int-hugs', 'haskell') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-python,int-ipython', 'python') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-gosh', 'scheme') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-clisp', 'lisp') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-erl', 'erlang') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-zsh', 'zsh') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-bash', 'bash') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-sh', 'sh') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-cmdproxy', 'dosbatch') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-powershell', 'powershell') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-perlsh', 'perl') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-perl6', 'perl6') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-ocaml', 'ocaml') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-clj', 'clojure') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-sml,int-smlsharp', 'sml') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-js,int-kjs,int-rhino', 'javascript') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-coffee', 'coffee') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-gdb', 'gdb') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-scala', 'scala') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-nyaos', 'nyaos') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_same_filetype_lists', |
||||
\ 'int-php', 'php') |
||||
"}}} |
||||
|
||||
" Initialize delimiter patterns. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_delimiter_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'vim,help', ['#']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'erlang,lisp,int-clisp', [':']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'lisp,int-clisp', ['/', ':']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'clojure,int-clj', ['/', '\.']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'perl,cpp', ['::']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'php', ['\', '::']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'java,d,javascript,actionscript,'. |
||||
\ 'ruby,eruby,haskell,int-ghci,coffee,zimbu,konoha', |
||||
\ ['\.']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'lua', ['\.', ':']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_delimiter_patterns', |
||||
\ 'perl6', ['\.', '::']) |
||||
"}}} |
||||
|
||||
" Initialize ctags arguments. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_ctags_arguments_list', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_ctags_arguments_list', |
||||
\ '_', '') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_ctags_arguments_list', 'vim', |
||||
\ '--extra=fq --fields=afmiKlnsStz ' . |
||||
\ "--regex-vim='/function!? ([a-z#:_0-9A-Z]+)/\\1/function/'") |
||||
if neocomplcache#util#is_mac() |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_ctags_arguments_list', 'c', |
||||
\ '--c-kinds=+p --fields=+iaS --extra=+q |
||||
\ -I__DARWIN_ALIAS,__DARWIN_ALIAS_C,__DARWIN_ALIAS_I,__DARWIN_INODE64 |
||||
\ -I__DARWIN_1050,__DARWIN_1050ALIAS,__DARWIN_1050ALIAS_C,__DARWIN_1050ALIAS_I,__DARWIN_1050INODE64 |
||||
\ -I__DARWIN_EXTSN,__DARWIN_EXTSN_C |
||||
\ -I__DARWIN_LDBL_COMPAT,__DARWIN_LDBL_COMPAT2') |
||||
else |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_ctags_arguments_list', 'c', |
||||
\ '-R --sort=1 --c-kinds=+p --fields=+iaS --extra=+q ' . |
||||
\ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'. |
||||
\ '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+') |
||||
endif |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_ctags_arguments_list', 'cpp', |
||||
\ '--language-force=C++ -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q '. |
||||
\ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'. |
||||
\ '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+') |
||||
"}}} |
||||
|
||||
" Initialize text mode filetypes. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_text_mode_filetypes', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_text_mode_filetypes', |
||||
\ 'hybrid,text,help,tex,gitcommit,gitrebase,vcs-commit,markdown,'. |
||||
\ 'textile,creole,org,rdoc,mediawiki,rst,asciidoc,pod', 1) |
||||
"}}} |
||||
|
||||
" Initialize tags filter patterns. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_tags_filter_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_tags_filter_patterns', 'c,cpp', |
||||
\'v:val.word !~ ''^[~_]''') |
||||
"}}} |
||||
|
||||
" Initialize force omni completion pattern. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_force_omni_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_force_omni_patterns', 'objc', |
||||
\'\h\w\+\|[^.[:digit:] *\t]\%(\.\|->\)') |
||||
"}}} |
||||
|
||||
" Initialize ignore composite filetypes |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_ignore_composite_filetype_lists', {}) |
||||
|
||||
" Must g:neocomplcache_auto_completion_start_length > 1. |
||||
if g:neocomplcache_auto_completion_start_length < 1 |
||||
let g:neocomplcache_auto_completion_start_length = 1 |
||||
endif |
||||
" Must g:neocomplcache_min_keyword_length > 1. |
||||
if g:neocomplcache_min_keyword_length < 1 |
||||
let g:neocomplcache_min_keyword_length = 1 |
||||
endif |
||||
|
||||
" Initialize omni function list. "{{{ |
||||
if !exists('g:neocomplcache_omni_functions') |
||||
let g:neocomplcache_omni_functions = {} |
||||
endif |
||||
"}}} |
||||
|
||||
" Set custom. |
||||
call s:set_default_custom() |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_current_neocomplcache() "{{{ |
||||
let b:neocomplcache = { |
||||
\ 'context' : { |
||||
\ 'input' : '', |
||||
\ 'complete_pos' : -1, |
||||
\ 'complete_str' : '', |
||||
\ 'candidates' : [], |
||||
\ }, |
||||
\ 'lock' : 0, |
||||
\ 'skip_next_complete' : 0, |
||||
\ 'filetype' : '', |
||||
\ 'context_filetype' : '', |
||||
\ 'context_filetype_range' : |
||||
\ [[1, 1], [line('$'), len(getline('$'))+1]], |
||||
\ 'completion_length' : -1, |
||||
\ 'update_time_save' : &updatetime, |
||||
\ 'foldinfo' : [], |
||||
\ 'lock_sources' : {}, |
||||
\ 'skipped' : 0, |
||||
\ 'event' : '', |
||||
\ 'cur_text' : '', |
||||
\ 'old_cur_text' : '', |
||||
\ 'complete_str' : '', |
||||
\ 'complete_pos' : -1, |
||||
\ 'candidates' : [], |
||||
\ 'complete_results' : [], |
||||
\ 'complete_sources' : [], |
||||
\ 'manual_sources' : [], |
||||
\ 'start_time' : reltime(), |
||||
\} |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_sources(names) "{{{ |
||||
if !exists('s:loaded_source_files') |
||||
" Initialize. |
||||
let s:loaded_source_files = {} |
||||
let s:loaded_all_sources = 0 |
||||
let s:runtimepath_save = '' |
||||
endif |
||||
|
||||
" Initialize sources table. |
||||
if s:loaded_all_sources && &runtimepath ==# s:runtimepath_save |
||||
return |
||||
endif |
||||
|
||||
let runtimepath_save = neocomplcache#util#split_rtp(s:runtimepath_save) |
||||
let runtimepath = neocomplcache#util#join_rtp( |
||||
\ filter(neocomplcache#util#split_rtp(), |
||||
\ 'index(runtimepath_save, v:val) < 0')) |
||||
let sources = neocomplcache#variables#get_sources() |
||||
|
||||
for name in filter(copy(a:names), '!has_key(sources, v:val)') |
||||
" Search autoload. |
||||
for source_name in map(split(globpath(runtimepath, |
||||
\ 'autoload/neocomplcache/sources/*.vim'), '\n'), |
||||
\ "fnamemodify(v:val, ':t:r')") |
||||
if has_key(s:loaded_source_files, source_name) |
||||
continue |
||||
endif |
||||
|
||||
let s:loaded_source_files[source_name] = 1 |
||||
|
||||
let source = neocomplcache#sources#{source_name}#define() |
||||
if empty(source) |
||||
" Ignore. |
||||
continue |
||||
endif |
||||
|
||||
call neocomplcache#define_source(source) |
||||
endfor |
||||
|
||||
if name == '_' |
||||
let s:loaded_all_sources = 1 |
||||
let s:runtimepath_save = &runtimepath |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_source(source) "{{{ |
||||
let default = { |
||||
\ 'max_candidates' : 0, |
||||
\ 'filetypes' : {}, |
||||
\ 'hooks' : {}, |
||||
\ 'matchers' : ['matcher_old'], |
||||
\ 'sorters' : ['sorter_rank'], |
||||
\ 'converters' : [ |
||||
\ 'converter_remove_next_keyword', |
||||
\ 'converter_delimiter', |
||||
\ 'converter_case', |
||||
\ 'converter_abbr', |
||||
\ ], |
||||
\ 'neocomplcache__context' : copy(neocomplcache#get_context()), |
||||
\ } |
||||
|
||||
let source = extend(copy(default), a:source) |
||||
|
||||
" Overwritten by user custom. |
||||
let custom = neocomplcache#variables#get_custom().sources |
||||
let source = extend(source, get(custom, source.name, |
||||
\ get(custom, '_', {}))) |
||||
|
||||
let source.loaded = 0 |
||||
" Source kind convertion. |
||||
if source.kind ==# 'plugin' || |
||||
\ (!has_key(source, 'gather_candidates') && |
||||
\ !has_key(source, 'get_complete_words')) |
||||
let source.kind = 'keyword' |
||||
elseif source.kind ==# 'ftplugin' || source.kind ==# 'complfunc' |
||||
" For compatibility. |
||||
let source.kind = 'manual' |
||||
else |
||||
let source.kind = 'manual' |
||||
endif |
||||
|
||||
if !has_key(source, 'rank') |
||||
" Set default rank. |
||||
let source.rank = (source.kind ==# 'keyword') ? 5 : |
||||
\ empty(source.filetypes) ? 10 : 100 |
||||
endif |
||||
|
||||
if !has_key(source, 'min_pattern_length') |
||||
" Set min_pattern_length. |
||||
let source.min_pattern_length = (source.kind ==# 'keyword') ? |
||||
\ g:neocomplcache_auto_completion_start_length : 0 |
||||
endif |
||||
|
||||
let source.neocomplcache__context.source_name = source.name |
||||
|
||||
" Note: This routine is for compatibility of old sources implementation. |
||||
" Initialize sources. |
||||
if empty(source.filetypes) && has_key(source, 'initialize') |
||||
try |
||||
call source.initialize() |
||||
catch |
||||
call neocomplcache#print_error(v:throwpoint) |
||||
call neocomplcache#print_error(v:exception) |
||||
call neocomplcache#print_error( |
||||
\ 'Error occured in source''s initialize()!') |
||||
call neocomplcache#print_error( |
||||
\ 'Source name is ' . source.name) |
||||
endtry |
||||
|
||||
let source.loaded = 1 |
||||
endif |
||||
|
||||
return source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_filters(names) "{{{ |
||||
let _ = [] |
||||
let filters = neocomplcache#variables#get_filters() |
||||
|
||||
for name in a:names |
||||
if !has_key(filters, name) |
||||
" Search autoload. |
||||
for filter_name in map(split(globpath(&runtimepath, |
||||
\ 'autoload/neocomplcache/filters/'. |
||||
\ substitute(name, |
||||
\'^\%(matcher\|sorter\|converter\)_[^/_-]\+\zs[/_-].*$', '', '') |
||||
\ .'*.vim'), '\n'), "fnamemodify(v:val, ':t:r')") |
||||
let filter = neocomplcache#filters#{filter_name}#define() |
||||
if empty(filter) |
||||
" Ignore. |
||||
continue |
||||
endif |
||||
|
||||
call neocomplcache#define_filter(filter) |
||||
endfor |
||||
|
||||
if !has_key(filters, name) |
||||
" Not found. |
||||
call neocomplcache#print_error( |
||||
\ printf('filter name : %s is not found.', string(name))) |
||||
continue |
||||
endif |
||||
endif |
||||
|
||||
if has_key(filters, name) |
||||
call add(_, filters[name]) |
||||
endif |
||||
endfor |
||||
|
||||
return _ |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#init#_filter(filter) "{{{ |
||||
let default = { |
||||
\ } |
||||
|
||||
let filter = extend(default, a:filter) |
||||
if !has_key(filter, 'kind') |
||||
let filter.kind = |
||||
\ (filter.name =~# '^matcher_') ? 'matcher' : |
||||
\ (filter.name =~# '^sorter_') ? 'sorter' : 'converter' |
||||
endif |
||||
|
||||
return filter |
||||
endfunction"}}} |
||||
|
||||
function! s:set_default_custom() "{{{ |
||||
let custom = neocomplcache#variables#get_custom().sources |
||||
|
||||
" Initialize completion length. |
||||
for [source_name, length] in items( |
||||
\ g:neocomplcache_source_completion_length) |
||||
if !has_key(custom, source_name) |
||||
let custom[source_name] = {} |
||||
endif |
||||
let custom[source_name].min_pattern_length = length |
||||
endfor |
||||
|
||||
" Initialize rank. |
||||
for [source_name, rank] in items( |
||||
\ g:neocomplcache_source_rank) |
||||
if !has_key(custom, source_name) |
||||
let custom[source_name] = {} |
||||
endif |
||||
let custom[source_name].rank = rank |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,188 @@
@@ -0,0 +1,188 @@
|
||||
"============================================================================= |
||||
" FILE: mappings.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 19 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#mappings#define_default_mappings() "{{{ |
||||
inoremap <expr><silent> <Plug>(neocomplcache_start_unite_complete) |
||||
\ unite#sources#neocomplcache#start_complete() |
||||
inoremap <expr><silent> <Plug>(neocomplcache_start_unite_quick_match) |
||||
\ unite#sources#neocomplcache#start_quick_match() |
||||
inoremap <silent> <Plug>(neocomplcache_start_auto_complete) |
||||
\ <C-x><C-u><C-r>=neocomplcache#mappings#popup_post()<CR> |
||||
inoremap <silent> <Plug>(neocomplcache_start_auto_complete_no_select) |
||||
\ <C-x><C-u><C-p> |
||||
" \ <C-x><C-u><C-p> |
||||
inoremap <silent> <Plug>(neocomplcache_start_omni_complete) |
||||
\ <C-x><C-o><C-p> |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#mappings#smart_close_popup() "{{{ |
||||
return g:neocomplcache_enable_auto_select ? |
||||
\ neocomplcache#mappings#cancel_popup() : |
||||
\ neocomplcache#mappings#close_popup() |
||||
endfunction |
||||
"}}} |
||||
function! neocomplcache#mappings#close_popup() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.complete_str = '' |
||||
let neocomplcache.skip_next_complete = 2 |
||||
let neocomplcache.candidates = [] |
||||
|
||||
return pumvisible() ? "\<C-y>" : '' |
||||
endfunction |
||||
"}}} |
||||
function! neocomplcache#mappings#cancel_popup() "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let neocomplcache.skip_next_complete = 1 |
||||
call neocomplcache#helper#clear_result() |
||||
|
||||
return pumvisible() ? "\<C-e>" : '' |
||||
endfunction |
||||
"}}} |
||||
|
||||
function! neocomplcache#mappings#popup_post() "{{{ |
||||
return !pumvisible() ? "" : |
||||
\ g:neocomplcache_enable_auto_select ? "\<C-p>\<Down>" : |
||||
\ "\<C-p>" |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#mappings#undo_completion() "{{{ |
||||
if !exists(':NeoComplCacheDisable') |
||||
return '' |
||||
endif |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
" Get cursor word. |
||||
let [complete_pos, complete_str] = |
||||
\ neocomplcache#match_word(neocomplcache#get_cur_text(1)) |
||||
let old_keyword_str = neocomplcache.complete_str |
||||
let neocomplcache.complete_str = complete_str |
||||
|
||||
return (!pumvisible() ? '' : |
||||
\ complete_str ==# old_keyword_str ? "\<C-e>" : "\<C-y>") |
||||
\. repeat("\<BS>", len(complete_str)) . old_keyword_str |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#mappings#complete_common_string() "{{{ |
||||
if !exists(':NeoComplCacheDisable') |
||||
return '' |
||||
endif |
||||
|
||||
" Save options. |
||||
let ignorecase_save = &ignorecase |
||||
|
||||
" Get cursor word. |
||||
let [complete_pos, complete_str] = |
||||
\ neocomplcache#match_word(neocomplcache#get_cur_text(1)) |
||||
|
||||
if neocomplcache#is_text_mode() |
||||
let &ignorecase = 1 |
||||
elseif g:neocomplcache_enable_smart_case && complete_str =~ '\u' |
||||
let &ignorecase = 0 |
||||
else |
||||
let &ignorecase = g:neocomplcache_enable_ignore_case |
||||
endif |
||||
|
||||
let is_fuzzy = g:neocomplcache_enable_fuzzy_completion |
||||
|
||||
try |
||||
let g:neocomplcache_enable_fuzzy_completion = 0 |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let candidates = neocomplcache#keyword_filter( |
||||
\ copy(neocomplcache.candidates), complete_str) |
||||
finally |
||||
let g:neocomplcache_enable_fuzzy_completion = is_fuzzy |
||||
endtry |
||||
|
||||
if empty(candidates) |
||||
let &ignorecase = ignorecase_save |
||||
|
||||
return '' |
||||
endif |
||||
|
||||
let common_str = candidates[0].word |
||||
for keyword in candidates[1:] |
||||
while !neocomplcache#head_match(keyword.word, common_str) |
||||
let common_str = common_str[: -2] |
||||
endwhile |
||||
endfor |
||||
if &ignorecase |
||||
let common_str = tolower(common_str) |
||||
endif |
||||
|
||||
let &ignorecase = ignorecase_save |
||||
|
||||
if common_str == '' |
||||
return '' |
||||
endif |
||||
|
||||
return (pumvisible() ? "\<C-e>" : '') |
||||
\ . repeat("\<BS>", len(complete_str)) . common_str |
||||
endfunction"}}} |
||||
|
||||
" Manual complete wrapper. |
||||
function! neocomplcache#mappings#start_manual_complete(...) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return '' |
||||
endif |
||||
|
||||
" Set context filetype. |
||||
call neocomplcache#context_filetype#set() |
||||
|
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
|
||||
let sources = get(a:000, 0, |
||||
\ keys(neocomplcache#available_sources())) |
||||
let neocomplcache.manual_sources = neocomplcache#helper#get_sources_list( |
||||
\ neocomplcache#util#convert2list(sources)) |
||||
|
||||
" Set function. |
||||
let &l:completefunc = 'neocomplcache#complete#sources_manual_complete' |
||||
|
||||
" Start complete. |
||||
return "\<C-x>\<C-u>\<C-p>" |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#mappings#start_manual_complete_list(complete_pos, complete_str, candidates) "{{{ |
||||
let neocomplcache = neocomplcache#get_current_neocomplcache() |
||||
let [neocomplcache.complete_pos, |
||||
\ neocomplcache.complete_str, neocomplcache.candidates] = |
||||
\ [a:complete_pos, a:complete_str, a:candidates] |
||||
|
||||
" Set function. |
||||
let &l:completefunc = 'neocomplcache#complete#auto_complete' |
||||
|
||||
" Start complete. |
||||
return "\<C-x>\<C-u>\<C-p>" |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,435 @@
@@ -0,0 +1,435 @@
|
||||
"============================================================================= |
||||
" FILE: buffer_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 27 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Important variables. |
||||
if !exists('s:buffer_sources') |
||||
let s:buffer_sources = {} |
||||
let s:async_dictionary_list = {} |
||||
endif |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'buffer_complete', |
||||
\ 'kind' : 'manual', |
||||
\ 'mark' : '[B]', |
||||
\ 'rank' : 5, |
||||
\ 'min_pattern_length' : |
||||
\ g:neocomplcache_auto_completion_start_length, |
||||
\ 'hooks' : {}, |
||||
\} |
||||
|
||||
function! s:source.hooks.on_init(context) "{{{ |
||||
let s:buffer_sources = {} |
||||
|
||||
augroup neocomplcache "{{{ |
||||
" Caching events |
||||
autocmd BufEnter,BufRead,BufWinEnter * |
||||
\ call s:check_source() |
||||
autocmd CursorHold,CursorHoldI * |
||||
\ call s:check_cache() |
||||
autocmd BufWritePost * |
||||
\ call s:check_recache() |
||||
autocmd InsertEnter,InsertLeave * |
||||
\ call neocomplcache#sources#buffer_complete#caching_current_line() |
||||
augroup END"}}} |
||||
|
||||
" Create cache directory. |
||||
if !isdirectory(neocomplcache#get_temporary_directory() . '/buffer_cache') |
||||
call mkdir(neocomplcache#get_temporary_directory() . '/buffer_cache', 'p') |
||||
endif |
||||
|
||||
" Initialize script variables. "{{{ |
||||
let s:buffer_sources = {} |
||||
let s:cache_line_count = 70 |
||||
let s:rank_cache_count = 1 |
||||
let s:disable_caching_list = {} |
||||
let s:async_dictionary_list = {} |
||||
"}}} |
||||
|
||||
call s:check_source() |
||||
endfunction |
||||
"}}} |
||||
|
||||
function! s:source.hooks.on_final(context) "{{{ |
||||
delcommand NeoComplCacheCachingBuffer |
||||
delcommand NeoComplCachePrintSource |
||||
delcommand NeoComplCacheOutputKeyword |
||||
delcommand NeoComplCacheDisableCaching |
||||
delcommand NeoComplCacheEnableCaching |
||||
|
||||
let s:buffer_sources = {} |
||||
endfunction"}}} |
||||
|
||||
function! s:source.gather_candidates(context) "{{{ |
||||
call s:check_source() |
||||
|
||||
let keyword_list = [] |
||||
for [key, source] in s:get_sources_list() |
||||
call neocomplcache#cache#check_cache_list('buffer_cache', |
||||
\ source.path, s:async_dictionary_list, source.keyword_cache, 1) |
||||
|
||||
let keyword_list += neocomplcache#dictionary_filter( |
||||
\ source.keyword_cache, a:context.complete_str) |
||||
if key == bufnr('%') |
||||
let source.accessed_time = localtime() |
||||
endif |
||||
endfor |
||||
|
||||
return keyword_list |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#buffer_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#buffer_complete#get_frequencies() "{{{ |
||||
" Current line caching. |
||||
return get(get(s:buffer_sources, bufnr('%'), {}), 'frequencies', {}) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#buffer_complete#caching_current_line() "{{{ |
||||
" Current line caching. |
||||
return s:caching_current_buffer( |
||||
\ max([1, line('.') - 10]), min([line('.') + 10, line('$')])) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#buffer_complete#caching_current_block() "{{{ |
||||
" Current line caching. |
||||
return s:caching_current_buffer( |
||||
\ max([1, line('.') - 500]), min([line('.') + 500, line('$')])) |
||||
endfunction"}}} |
||||
function! s:caching_current_buffer(start, end) "{{{ |
||||
" Current line caching. |
||||
|
||||
if !s:exists_current_source() |
||||
call s:word_caching(bufnr('%')) |
||||
endif |
||||
|
||||
let source = s:buffer_sources[bufnr('%')] |
||||
let keyword_pattern = source.keyword_pattern |
||||
let keyword_pattern2 = '^\%('.keyword_pattern.'\m\)' |
||||
let keywords = source.keyword_cache |
||||
|
||||
let completion_length = 2 |
||||
let line = join(getline(a:start, a:end)) |
||||
let match = match(line, keyword_pattern) |
||||
while match >= 0 "{{{ |
||||
let match_str = matchstr(line, keyword_pattern2, match) |
||||
|
||||
" Ignore too short keyword. |
||||
if len(match_str) >= g:neocomplcache_min_keyword_length "{{{ |
||||
" Check dup. |
||||
let key = tolower(match_str[: completion_length-1]) |
||||
if !has_key(keywords, key) |
||||
let keywords[key] = {} |
||||
endif |
||||
if !has_key(keywords[key], match_str) |
||||
" Append list. |
||||
let keywords[key][match_str] = match_str |
||||
let source.frequencies[match_str] = 30 |
||||
endif |
||||
endif"}}} |
||||
|
||||
" Next match. |
||||
let match = match(line, keyword_pattern, match + len(match_str)) |
||||
endwhile"}}} |
||||
endfunction"}}} |
||||
|
||||
function! s:get_sources_list() "{{{ |
||||
let sources_list = [] |
||||
|
||||
let filetypes_dict = {} |
||||
for filetype in neocomplcache#get_source_filetypes( |
||||
\ neocomplcache#get_context_filetype()) |
||||
let filetypes_dict[filetype] = 1 |
||||
endfor |
||||
|
||||
for [key, source] in items(s:buffer_sources) |
||||
if has_key(filetypes_dict, source.filetype) |
||||
\ || has_key(filetypes_dict, '_') |
||||
\ || bufnr('%') == key |
||||
\ || (source.name ==# '[Command Line]' && bufnr('#') == key) |
||||
call add(sources_list, [key, source]) |
||||
endif |
||||
endfor |
||||
|
||||
return sources_list |
||||
endfunction"}}} |
||||
|
||||
function! s:initialize_source(srcname) "{{{ |
||||
let path = fnamemodify(bufname(a:srcname), ':p') |
||||
let filename = fnamemodify(path, ':t') |
||||
if filename == '' |
||||
let filename = '[No Name]' |
||||
let path .= '/[No Name]' |
||||
endif |
||||
|
||||
let ft = getbufvar(a:srcname, '&filetype') |
||||
if ft == '' |
||||
let ft = 'nothing' |
||||
endif |
||||
|
||||
let buflines = getbufline(a:srcname, 1, '$') |
||||
let keyword_pattern = neocomplcache#get_keyword_pattern(ft) |
||||
|
||||
let s:buffer_sources[a:srcname] = { |
||||
\ 'keyword_cache' : {}, |
||||
\ 'frequencies' : {}, |
||||
\ 'name' : filename, 'filetype' : ft, |
||||
\ 'keyword_pattern' : keyword_pattern, |
||||
\ 'end_line' : len(buflines), |
||||
\ 'accessed_time' : 0, |
||||
\ 'cached_time' : 0, |
||||
\ 'path' : path, 'loaded_cache' : 0, |
||||
\ 'cache_name' : neocomplcache#cache#encode_name( |
||||
\ 'buffer_cache', path), |
||||
\} |
||||
endfunction"}}} |
||||
|
||||
function! s:word_caching(srcname) "{{{ |
||||
" Initialize source. |
||||
call s:initialize_source(a:srcname) |
||||
|
||||
let source = s:buffer_sources[a:srcname] |
||||
|
||||
if !filereadable(source.path) |
||||
\ || getbufvar(a:srcname, '&buftype') =~ 'nofile' |
||||
return |
||||
endif |
||||
|
||||
let source.cache_name = |
||||
\ neocomplcache#cache#async_load_from_file( |
||||
\ 'buffer_cache', source.path, |
||||
\ source.keyword_pattern, 'B') |
||||
let source.cached_time = localtime() |
||||
let source.end_line = len(getbufline(a:srcname, 1, '$')) |
||||
let s:async_dictionary_list[source.path] = [{ |
||||
\ 'filename' : source.path, |
||||
\ 'cachename' : source.cache_name, |
||||
\ }] |
||||
endfunction"}}} |
||||
|
||||
function! s:check_changed_buffer(bufnumber) "{{{ |
||||
let source = s:buffer_sources[a:bufnumber] |
||||
|
||||
let ft = getbufvar(a:bufnumber, '&filetype') |
||||
if ft == '' |
||||
let ft = 'nothing' |
||||
endif |
||||
|
||||
let filename = fnamemodify(bufname(a:bufnumber), ':t') |
||||
if filename == '' |
||||
let filename = '[No Name]' |
||||
endif |
||||
|
||||
return s:buffer_sources[a:bufnumber].name != filename |
||||
\ || s:buffer_sources[a:bufnumber].filetype != ft |
||||
endfunction"}}} |
||||
|
||||
function! s:check_source() "{{{ |
||||
if !s:exists_current_source() |
||||
call neocomplcache#sources#buffer_complete#caching_current_block() |
||||
return |
||||
endif |
||||
|
||||
for bufnumber in range(1, bufnr('$')) |
||||
" Check new buffer. |
||||
let bufname = fnamemodify(bufname(bufnumber), ':p') |
||||
if (!has_key(s:buffer_sources, bufnumber) |
||||
\ || s:check_changed_buffer(bufnumber)) |
||||
\ && !has_key(s:disable_caching_list, bufnumber) |
||||
\ && (!neocomplcache#is_locked(bufnumber) || |
||||
\ g:neocomplcache_disable_auto_complete) |
||||
\ && !getwinvar(bufwinnr(bufnumber), '&previewwindow') |
||||
\ && getfsize(bufname) < |
||||
\ g:neocomplcache_caching_limit_file_size |
||||
" Caching. |
||||
call s:word_caching(bufnumber) |
||||
endif |
||||
|
||||
if has_key(s:buffer_sources, bufnumber) |
||||
let source = s:buffer_sources[bufnumber] |
||||
call neocomplcache#cache#check_cache_list('buffer_cache', |
||||
\ source.path, s:async_dictionary_list, source.keyword_cache, 1) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
function! s:check_cache() "{{{ |
||||
let release_accessd_time = |
||||
\ localtime() - g:neocomplcache_release_cache_time |
||||
|
||||
for [key, source] in items(s:buffer_sources) |
||||
" Check deleted buffer and access time. |
||||
if !bufloaded(str2nr(key)) |
||||
\ || (source.accessed_time > 0 && |
||||
\ source.accessed_time < release_accessd_time) |
||||
" Remove item. |
||||
call remove(s:buffer_sources, key) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
function! s:check_recache() "{{{ |
||||
if !s:exists_current_source() |
||||
return |
||||
endif |
||||
|
||||
let release_accessd_time = |
||||
\ localtime() - g:neocomplcache_release_cache_time |
||||
|
||||
let source = s:buffer_sources[bufnr('%')] |
||||
|
||||
" Check buffer access time. |
||||
if (source.cached_time > 0 && source.cached_time < release_accessd_time) |
||||
\ || (neocomplcache#util#has_vimproc() && line('$') != source.end_line) |
||||
" Buffer recache. |
||||
if g:neocomplcache_enable_debug |
||||
echomsg 'Caching buffer: ' . bufname('%') |
||||
endif |
||||
|
||||
call neocomplcache#sources#buffer_complete#caching_current_block() |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:exists_current_source() "{{{ |
||||
return has_key(s:buffer_sources, bufnr('%')) |
||||
endfunction"}}} |
||||
|
||||
" Command functions. "{{{ |
||||
function! neocomplcache#sources#buffer_complete#caching_buffer(name) "{{{ |
||||
if a:name == '' |
||||
let number = bufnr('%') |
||||
else |
||||
let number = bufnr(a:name) |
||||
|
||||
if number < 0 |
||||
let bufnr = bufnr('%') |
||||
|
||||
" No swap warning. |
||||
let save_shm = &shortmess |
||||
set shortmess+=A |
||||
|
||||
" Open new buffer. |
||||
execute 'silent! edit' fnameescape(a:name) |
||||
|
||||
let &shortmess = save_shm |
||||
|
||||
if bufnr('%') != bufnr |
||||
setlocal nobuflisted |
||||
execute 'buffer' bufnr |
||||
endif |
||||
endif |
||||
|
||||
let number = bufnr(a:name) |
||||
endif |
||||
|
||||
" Word recaching. |
||||
call s:word_caching(number) |
||||
call s:caching_current_buffer(1, line('$')) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#buffer_complete#print_source(name) "{{{ |
||||
if a:name == '' |
||||
let number = bufnr('%') |
||||
else |
||||
let number = bufnr(a:name) |
||||
|
||||
if number < 0 |
||||
call neocomplcache#print_error('Invalid buffer name.') |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
if !has_key(s:buffer_sources, number) |
||||
return |
||||
endif |
||||
|
||||
silent put=printf('Print neocomplcache %d source.', number) |
||||
for key in keys(s:buffer_sources[number]) |
||||
silent put =printf('%s => %s', key, string(s:buffer_sources[number][key])) |
||||
endfor |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#buffer_complete#output_keyword(name) "{{{ |
||||
if a:name == '' |
||||
let number = bufnr('%') |
||||
else |
||||
let number = bufnr(a:name) |
||||
|
||||
if number < 0 |
||||
call neocomplcache#print_error('Invalid buffer name.') |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
if !has_key(s:buffer_sources, number) |
||||
return |
||||
endif |
||||
|
||||
" Output buffer. |
||||
for keyword in neocomplcache#unpack_dictionary( |
||||
\ s:buffer_sources[number].keyword_cache) |
||||
silent put=string(keyword) |
||||
endfor |
||||
endfunction "}}} |
||||
function! neocomplcache#sources#buffer_complete#disable_caching(name) "{{{ |
||||
if a:name == '' |
||||
let number = bufnr('%') |
||||
else |
||||
let number = bufnr(a:name) |
||||
|
||||
if number < 0 |
||||
call neocomplcache#print_error('Invalid buffer name.') |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
let s:disable_caching_list[number] = 1 |
||||
|
||||
if has_key(s:buffer_sources, number) |
||||
" Delete source. |
||||
call remove(s:buffer_sources, number) |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#buffer_complete#enable_caching(name) "{{{ |
||||
if a:name == '' |
||||
let number = bufnr('%') |
||||
else |
||||
let number = bufnr(a:name) |
||||
|
||||
if number < 0 |
||||
call neocomplcache#print_error('Invalid buffer name.') |
||||
return |
||||
endif |
||||
endif |
||||
|
||||
if has_key(s:disable_caching_list, number) |
||||
call remove(s:disable_caching_list, number) |
||||
endif |
||||
endfunction"}}} |
||||
"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,172 @@
@@ -0,0 +1,172 @@
|
||||
"============================================================================= |
||||
" FILE: dictionary_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 28 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Important variables. |
||||
if !exists('s:dictionary_list') |
||||
let s:dictionary_list = {} |
||||
let s:async_dictionary_list = {} |
||||
endif |
||||
|
||||
function! neocomplcache#sources#dictionary_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'dictionary_complete', |
||||
\ 'kind' : 'keyword', |
||||
\ 'mark' : '[D]', |
||||
\ 'rank' : 4, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
" Initialize dictionary. "{{{ |
||||
if !exists('g:neocomplcache_dictionary_filetype_lists') |
||||
let g:neocomplcache_dictionary_filetype_lists = {} |
||||
endif |
||||
if !has_key(g:neocomplcache_dictionary_filetype_lists, 'default') |
||||
let g:neocomplcache_dictionary_filetype_lists['default'] = '' |
||||
endif |
||||
"}}} |
||||
|
||||
" Initialize dictionary completion pattern. "{{{ |
||||
if !exists('g:neocomplcache_dictionary_patterns') |
||||
let g:neocomplcache_dictionary_patterns = {} |
||||
endif |
||||
"}}} |
||||
|
||||
" Set caching event. |
||||
autocmd neocomplcache FileType * call s:caching() |
||||
|
||||
" Create cache directory. |
||||
if !isdirectory(neocomplcache#get_temporary_directory() . '/dictionary_cache') |
||||
call mkdir(neocomplcache#get_temporary_directory() . '/dictionary_cache') |
||||
endif |
||||
|
||||
" Initialize check. |
||||
call s:caching() |
||||
endfunction"}}} |
||||
|
||||
function! s:source.finalize() "{{{ |
||||
delcommand NeoComplCacheCachingDictionary |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_list(complete_str) "{{{ |
||||
let list = [] |
||||
|
||||
let filetype = neocomplcache#is_text_mode() ? |
||||
\ 'text' : neocomplcache#get_context_filetype() |
||||
if !has_key(s:dictionary_list, filetype) |
||||
" Caching. |
||||
call s:caching() |
||||
endif |
||||
|
||||
for ft in neocomplcache#get_source_filetypes(filetype) |
||||
call neocomplcache#cache#check_cache('dictionary_cache', ft, |
||||
\ s:async_dictionary_list, s:dictionary_list, 1) |
||||
|
||||
for dict in neocomplcache#get_sources_list(s:dictionary_list, ft) |
||||
let list += neocomplcache#dictionary_filter(dict, a:complete_str) |
||||
endfor |
||||
endfor |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
|
||||
function! s:caching() "{{{ |
||||
if !bufloaded(bufnr('%')) |
||||
return |
||||
endif |
||||
|
||||
let key = neocomplcache#is_text_mode() ? |
||||
\ 'text' : neocomplcache#get_context_filetype() |
||||
for filetype in neocomplcache#get_source_filetypes(key) |
||||
if !has_key(s:dictionary_list, filetype) |
||||
\ && !has_key(s:async_dictionary_list, filetype) |
||||
call neocomplcache#sources#dictionary_complete#recaching(filetype) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! s:caching_dictionary(filetype) |
||||
let filetype = a:filetype |
||||
if filetype == '' |
||||
let filetype = neocomplcache#get_context_filetype(1) |
||||
endif |
||||
|
||||
if has_key(s:async_dictionary_list, filetype) |
||||
\ && filereadable(s:async_dictionary_list[filetype].cache_name) |
||||
" Delete old cache. |
||||
call delete(s:async_dictionary_list[filetype].cache_name) |
||||
endif |
||||
|
||||
call neocomplcache#sources#dictionary_complete#recaching(filetype) |
||||
endfunction |
||||
function! neocomplcache#sources#dictionary_complete#recaching(filetype) "{{{ |
||||
if !exists('g:neocomplcache_dictionary_filetype_lists') |
||||
call neocomplcache#initialize() |
||||
endif |
||||
|
||||
let filetype = a:filetype |
||||
if filetype == '' |
||||
let filetype = neocomplcache#get_context_filetype(1) |
||||
endif |
||||
|
||||
" Caching. |
||||
let dictionaries = get( |
||||
\ g:neocomplcache_dictionary_filetype_lists, filetype, '') |
||||
|
||||
if dictionaries == '' |
||||
if filetype != &filetype && |
||||
\ &l:dictionary != '' && &l:dictionary !=# &g:dictionary |
||||
let dictionaries .= &l:dictionary |
||||
endif |
||||
endif |
||||
|
||||
let s:async_dictionary_list[filetype] = [] |
||||
|
||||
let pattern = get(g:neocomplcache_dictionary_patterns, filetype, |
||||
\ neocomplcache#get_keyword_pattern(filetype)) |
||||
for dictionary in split(dictionaries, ',') |
||||
let dictionary = neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(dictionary, ':p')) |
||||
if filereadable(dictionary) |
||||
call neocomplcache#print_debug('Caching dictionary: ' . dictionary) |
||||
call add(s:async_dictionary_list[filetype], { |
||||
\ 'filename' : dictionary, |
||||
\ 'cachename' : neocomplcache#cache#async_load_from_file( |
||||
\ 'dictionary_cache', dictionary, pattern, 'D') |
||||
\ }) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,202 @@
@@ -0,0 +1,202 @@
|
||||
"============================================================================= |
||||
" FILE: filename_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 20 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'filename_complete', |
||||
\ 'kind' : 'manual', |
||||
\ 'mark' : '[F]', |
||||
\ 'rank' : 3, |
||||
\ 'min_pattern_length' : |
||||
\ g:neocomplcache_auto_completion_start_length, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
endfunction"}}} |
||||
function! s:source.finalize() "{{{ |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_pos(cur_text) "{{{ |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
if filetype ==# 'vimshell' || filetype ==# 'unite' || filetype ==# 'int-ssh' |
||||
return -1 |
||||
endif |
||||
|
||||
" Filename pattern. |
||||
let pattern = neocomplcache#get_keyword_pattern_end('filename') |
||||
let [complete_pos, complete_str] = |
||||
\ neocomplcache#match_word(a:cur_text, pattern) |
||||
if complete_str =~ '//' || |
||||
\ (neocomplcache#is_auto_complete() && |
||||
\ (complete_str !~ '/' || |
||||
\ complete_str =~# |
||||
\ '\\[^ ;*?[]"={}'']\|\.\.\+$\|/c\%[ygdrive/]$')) |
||||
" Not filename pattern. |
||||
return -1 |
||||
endif |
||||
|
||||
if neocomplcache#is_sources_complete() && complete_pos < 0 |
||||
let complete_pos = len(a:cur_text) |
||||
endif |
||||
|
||||
return complete_pos |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_complete_words(complete_pos, complete_str) "{{{ |
||||
return s:get_glob_files(a:complete_str, '') |
||||
endfunction"}}} |
||||
|
||||
let s:cached_files = {} |
||||
|
||||
function! s:get_glob_files(complete_str, path) "{{{ |
||||
let path = ',,' . substitute(a:path, '\.\%(,\|$\)\|,,', '', 'g') |
||||
|
||||
let complete_str = neocomplcache#util#substitute_path_separator( |
||||
\ substitute(a:complete_str, '\\\(.\)', '\1', 'g')) |
||||
|
||||
let glob = (complete_str !~ '\*$')? |
||||
\ complete_str . '*' : complete_str |
||||
|
||||
if a:path == '' && complete_str !~ '/' |
||||
if !has_key(s:cached_files, getcwd()) |
||||
call s:caching_current_files() |
||||
endif |
||||
|
||||
let files = copy(s:cached_files[getcwd()]) |
||||
else |
||||
let ftype = getftype(glob) |
||||
if ftype != '' && ftype !=# 'dir' |
||||
" Note: If glob() device files, Vim may freeze! |
||||
return [] |
||||
endif |
||||
|
||||
if a:path == '' |
||||
let files = neocomplcache#util#glob(glob) |
||||
else |
||||
try |
||||
let globs = globpath(path, glob) |
||||
catch |
||||
return [] |
||||
endtry |
||||
let files = split(substitute(globs, '\\', '/', 'g'), '\n') |
||||
endif |
||||
endif |
||||
|
||||
let files = neocomplcache#keyword_filter(map( |
||||
\ files, '{ |
||||
\ "word" : fnamemodify(v:val, ":t"), |
||||
\ "orig" : v:val, |
||||
\ }'), |
||||
\ fnamemodify(complete_str, ':t')) |
||||
|
||||
if neocomplcache#is_auto_complete() |
||||
\ && len(files) > g:neocomplcache_max_list |
||||
let files = files[: g:neocomplcache_max_list - 1] |
||||
endif |
||||
|
||||
let files = map(files, '{ |
||||
\ "word" : substitute(v:val.orig, "//", "/", "g"), |
||||
\ }') |
||||
|
||||
if a:complete_str =~ '^\$\h\w*' |
||||
let env = matchstr(a:complete_str, '^\$\h\w*') |
||||
let env_ev = eval(env) |
||||
if neocomplcache#is_windows() |
||||
let env_ev = substitute(env_ev, '\\', '/', 'g') |
||||
endif |
||||
let len_env = len(env_ev) |
||||
else |
||||
let len_env = 0 |
||||
endif |
||||
|
||||
let home_pattern = '^'. |
||||
\ neocomplcache#util#substitute_path_separator( |
||||
\ expand('~')).'/' |
||||
let exts = escape(substitute($PATHEXT, ';', '\\|', 'g'), '.') |
||||
|
||||
let dir_list = [] |
||||
let file_list = [] |
||||
for dict in files |
||||
call add(isdirectory(dict.word) ? |
||||
\ dir_list : file_list, dict) |
||||
|
||||
let dict.orig = dict.word |
||||
|
||||
if len_env != 0 && dict.word[: len_env-1] == env_ev |
||||
let dict.word = env . dict.word[len_env :] |
||||
endif |
||||
|
||||
let abbr = dict.word |
||||
if isdirectory(dict.word) && dict.word !~ '/$' |
||||
let abbr .= '/' |
||||
if g:neocomplcache_enable_auto_delimiter |
||||
let dict.word .= '/' |
||||
endif |
||||
elseif neocomplcache#is_windows() |
||||
if '.'.fnamemodify(dict.word, ':e') =~ exts |
||||
let abbr .= '*' |
||||
endif |
||||
elseif executable(dict.word) |
||||
let abbr .= '*' |
||||
endif |
||||
let dict.abbr = abbr |
||||
|
||||
if a:complete_str =~ '^\~/' |
||||
let dict.word = substitute(dict.word, home_pattern, '\~/', '') |
||||
let dict.abbr = substitute(dict.abbr, home_pattern, '\~/', '') |
||||
endif |
||||
|
||||
" Escape word. |
||||
let dict.word = escape(dict.word, ' ;*?[]"={}''') |
||||
endfor |
||||
|
||||
return dir_list + file_list |
||||
endfunction"}}} |
||||
function! s:caching_current_files() "{{{ |
||||
let s:cached_files[getcwd()] = neocomplcache#util#glob('*') |
||||
if !exists('vimproc#readdir') |
||||
let s:cached_files[getcwd()] += neocomplcache#util#glob('.*') |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#filename_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#filename_complete#get_complete_words(complete_str, path) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return [] |
||||
endif |
||||
|
||||
return s:get_glob_files(a:complete_str, a:path) |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,238 @@
@@ -0,0 +1,238 @@
|
||||
"============================================================================= |
||||
" FILE: filename_include.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 29 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Global options definition. "{{{ |
||||
if !exists('g:neocomplcache_include_patterns') |
||||
let g:neocomplcache_include_patterns = {} |
||||
endif |
||||
if !exists('g:neocomplcache_include_exprs') |
||||
let g:neocomplcache_include_exprs = {} |
||||
endif |
||||
if !exists('g:neocomplcache_include_paths') |
||||
let g:neocomplcache_include_paths = {} |
||||
endif |
||||
if !exists('g:neocomplcache_include_suffixes') |
||||
let g:neocomplcache_include_suffixes = {} |
||||
endif |
||||
"}}} |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'filename_include', |
||||
\ 'kind' : 'manual', |
||||
\ 'mark' : '[FI]', |
||||
\ 'rank' : 10, |
||||
\ 'min_pattern_length' : |
||||
\ g:neocomplcache_auto_completion_start_length, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
" Initialize. |
||||
|
||||
" Initialize filename include expr. "{{{ |
||||
let g:neocomplcache_filename_include_exprs = |
||||
\ get(g:, 'neocomplcache_filename_include_exprs', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exprs', |
||||
\ 'perl', |
||||
\ 'fnamemodify(substitute(v:fname, "/", "::", "g"), ":r")') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exprs', |
||||
\ 'ruby,python,java,d', |
||||
\ 'fnamemodify(substitute(v:fname, "/", ".", "g"), ":r")') |
||||
"}}} |
||||
|
||||
" Initialize filename include extensions. "{{{ |
||||
let g:neocomplcache_filename_include_exts = |
||||
\ get(g:, 'neocomplcache_filename_include_exts', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exts', |
||||
\ 'c', ['h']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exts', |
||||
\ 'cpp', ['', 'h', 'hpp', 'hxx']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exts', |
||||
\ 'perl', ['pm']) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_filename_include_exts', |
||||
\ 'java', ['java']) |
||||
"}}} |
||||
endfunction"}}} |
||||
function! s:source.finalize() "{{{ |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_pos(cur_text) "{{{ |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
" Not Filename pattern. |
||||
if exists('g:neocomplcache_include_patterns') |
||||
let pattern = get(g:neocomplcache_include_patterns, filetype, |
||||
\ &l:include) |
||||
else |
||||
let pattern = '' |
||||
endif |
||||
if neocomplcache#is_auto_complete() |
||||
\ && (pattern == '' || a:cur_text !~ pattern) |
||||
\ && a:cur_text =~ '\*$\|\.\.\+$\|/c\%[ygdrive/]$' |
||||
" Skip filename completion. |
||||
return -1 |
||||
endif |
||||
|
||||
" Check include pattern. |
||||
let pattern = get(g:neocomplcache_include_patterns, filetype, |
||||
\ &l:include) |
||||
if pattern == '' || a:cur_text !~ pattern |
||||
return -1 |
||||
endif |
||||
|
||||
let match_end = matchend(a:cur_text, pattern) |
||||
let complete_str = matchstr(a:cur_text[match_end :], '\f\+') |
||||
|
||||
let expr = get(g:neocomplcache_include_exprs, filetype, |
||||
\ &l:includeexpr) |
||||
if expr != '' |
||||
let cur_text = |
||||
\ substitute(eval(substitute(expr, |
||||
\ 'v:fname', string(complete_str), 'g')), |
||||
\ '\.\w*$', '', '') |
||||
endif |
||||
|
||||
let complete_pos = len(a:cur_text) - len(complete_str) |
||||
if neocomplcache#is_sources_complete() && complete_pos < 0 |
||||
let complete_pos = len(a:cur_text) |
||||
endif |
||||
|
||||
return complete_pos |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_complete_words(complete_pos, complete_str) "{{{ |
||||
return s:get_include_files(a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! s:get_include_files(complete_str) "{{{ |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
|
||||
let path = neocomplcache#util#substitute_path_separator( |
||||
\ get(g:neocomplcache_include_paths, filetype, |
||||
\ &l:path)) |
||||
let pattern = get(g:neocomplcache_include_patterns, filetype, |
||||
\ &l:include) |
||||
let expr = get(g:neocomplcache_include_exprs, filetype, |
||||
\ &l:includeexpr) |
||||
let reverse_expr = get(g:neocomplcache_filename_include_exprs, filetype, |
||||
\ '') |
||||
let exts = get(g:neocomplcache_filename_include_exts, filetype, |
||||
\ []) |
||||
|
||||
let line = neocomplcache#get_cur_text() |
||||
if line =~ '^\s*\<require_relative\>' && &filetype =~# 'ruby' |
||||
" For require_relative. |
||||
let path = '.' |
||||
endif |
||||
|
||||
let match_end = matchend(line, pattern) |
||||
let complete_str = matchstr(line[match_end :], '\f\+') |
||||
if expr != '' |
||||
let complete_str = |
||||
\ substitute(eval(substitute(expr, |
||||
\ 'v:fname', string(complete_str), 'g')), '\.\w*$', '', '') |
||||
endif |
||||
|
||||
" Path search. |
||||
let glob = (complete_str !~ '\*$')? |
||||
\ complete_str . '*' : complete_str |
||||
let cwd = getcwd() |
||||
let bufdirectory = neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(expand('%'), ':p:h')) |
||||
let dir_list = [] |
||||
let file_list = s:get_default_include_files(filetype) |
||||
for subpath in split(path, '[,;]') |
||||
let dir = (subpath == '.') ? bufdirectory : subpath |
||||
if !isdirectory(dir) |
||||
continue |
||||
endif |
||||
|
||||
execute 'lcd' fnameescape(dir) |
||||
|
||||
for word in split( |
||||
\ neocomplcache#util#substitute_path_separator( |
||||
\ glob(glob)), '\n') |
||||
let dict = { 'word' : word } |
||||
|
||||
call add(isdirectory(word) ? dir_list : file_list, dict) |
||||
|
||||
let abbr = dict.word |
||||
if isdirectory(word) |
||||
let abbr .= '/' |
||||
if g:neocomplcache_enable_auto_delimiter |
||||
let dict.word .= '/' |
||||
endif |
||||
elseif !empty(exts) && |
||||
\ index(exts, fnamemodify(dict.word, ':e')) < 0 |
||||
" Skip. |
||||
continue |
||||
endif |
||||
let dict.abbr = abbr |
||||
|
||||
if reverse_expr != '' |
||||
" Convert filename. |
||||
let dict.word = eval(substitute(reverse_expr, |
||||
\ 'v:fname', string(dict.word), 'g')) |
||||
let dict.abbr = eval(substitute(reverse_expr, |
||||
\ 'v:fname', string(dict.abbr), 'g')) |
||||
else |
||||
" Escape word. |
||||
let dict.word = escape(dict.word, ' ;*?[]"={}''') |
||||
endif |
||||
endfor |
||||
endfor |
||||
execute 'lcd' fnameescape(cwd) |
||||
|
||||
return neocomplcache#keyword_filter(dir_list, a:complete_str) |
||||
\ + neocomplcache#keyword_filter(file_list, a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! s:get_default_include_files(filetype) "{{{ |
||||
let files = [] |
||||
|
||||
if a:filetype ==# 'python' || a:filetype ==# 'python3' |
||||
let files = ['sys'] |
||||
endif |
||||
|
||||
return map(files, "{ 'word' : v:val }") |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#filename_include#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,490 @@
@@ -0,0 +1,490 @@
|
||||
"============================================================================= |
||||
" FILE: include_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'include_complete', |
||||
\ 'kind' : 'keyword', |
||||
\ 'rank' : 8, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
call s:initialize_variables() |
||||
|
||||
if neocomplcache#has_vimproc() |
||||
augroup neocomplcache |
||||
" Caching events |
||||
autocmd BufWritePost * call s:check_buffer('', 0) |
||||
autocmd CursorHold * call s:check_cache() |
||||
augroup END |
||||
endif |
||||
|
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_include_max_processes', 20) |
||||
|
||||
" Create cache directory. |
||||
if !isdirectory(neocomplcache#get_temporary_directory() . '/include_cache') |
||||
call mkdir(neocomplcache#get_temporary_directory() |
||||
\ . '/include_cache', 'p') |
||||
endif |
||||
|
||||
if neocomplcache#exists_echodoc() |
||||
call echodoc#register('include_complete', s:doc_dict) |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:source.finalize() "{{{ |
||||
delcommand NeoComplCacheCachingInclude |
||||
|
||||
if neocomplcache#exists_echodoc() |
||||
call echodoc#unregister('include_complete') |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_list(complete_str) "{{{ |
||||
if neocomplcache#within_comment() |
||||
return [] |
||||
endif |
||||
|
||||
if !has_key(s:include_info, bufnr('%')) |
||||
" Auto caching. |
||||
call s:check_buffer('', 0) |
||||
endif |
||||
|
||||
let keyword_list = [] |
||||
|
||||
" Check caching. |
||||
for include in s:include_info[bufnr('%')].include_files |
||||
call neocomplcache#cache#check_cache( |
||||
\ 'include_cache', include, s:async_include_cache, s:include_cache) |
||||
if has_key(s:include_cache, include) |
||||
let s:cache_accessed_time[include] = localtime() |
||||
let keyword_list += neocomplcache#dictionary_filter( |
||||
\ s:include_cache[include], a:complete_str) |
||||
endif |
||||
endfor |
||||
|
||||
return neocomplcache#keyword_filter( |
||||
\ neocomplcache#dup_filter(keyword_list), a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#include_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#include_complete#get_include_files(bufnumber) "{{{ |
||||
if has_key(s:include_info, a:bufnumber) |
||||
return copy(s:include_info[a:bufnumber].include_files) |
||||
else |
||||
return s:get_buffer_include_files(a:bufnumber) |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#include_complete#get_include_tags(bufnumber) "{{{ |
||||
return filter(map( |
||||
\ neocomplcache#sources#include_complete#get_include_files(a:bufnumber), |
||||
\ "neocomplcache#cache#encode_name('tags_output', v:val)"), |
||||
\ 'filereadable(v:val)') |
||||
endfunction"}}} |
||||
|
||||
" For Debug. |
||||
function! neocomplcache#sources#include_complete#get_current_include_files() "{{{ |
||||
return s:get_buffer_include_files(bufnr('%')) |
||||
endfunction"}}} |
||||
|
||||
" For echodoc. "{{{ |
||||
let s:doc_dict = { |
||||
\ 'name' : 'include_complete', |
||||
\ 'rank' : 5, |
||||
\ 'filetypes' : {}, |
||||
\ } |
||||
function! s:doc_dict.search(cur_text) "{{{ |
||||
if &filetype ==# 'vim' || !has_key(s:include_info, bufnr('%')) |
||||
return [] |
||||
endif |
||||
|
||||
let completion_length = 2 |
||||
|
||||
" Collect words. |
||||
let words = [] |
||||
let i = 0 |
||||
while i >= 0 |
||||
let word = matchstr(a:cur_text, '\k\+', i) |
||||
if len(word) >= completion_length |
||||
call add(words, word) |
||||
endif |
||||
|
||||
let i = matchend(a:cur_text, '\k\+', i) |
||||
endwhile |
||||
|
||||
for word in reverse(words) |
||||
let key = tolower(word[: completion_length-1]) |
||||
|
||||
for include in filter(copy(s:include_info[bufnr('%')].include_files), |
||||
\ 'has_key(s:include_cache, v:val) && has_key(s:include_cache[v:val], key)') |
||||
for matched in filter(values(s:include_cache[include][key]), |
||||
\ 'v:val.word ==# word && has_key(v:val, "kind") && v:val.kind != ""') |
||||
let ret = [] |
||||
|
||||
let match = match(matched.abbr, neocomplcache#escape_match(word)) |
||||
if match > 0 |
||||
call add(ret, { 'text' : matched.abbr[ : match-1] }) |
||||
endif |
||||
|
||||
call add(ret, { 'text' : word, 'highlight' : 'Identifier' }) |
||||
call add(ret, { 'text' : matched.abbr[match+len(word) :] }) |
||||
|
||||
if match > 0 || len(ret[-1].text) > 0 |
||||
return ret |
||||
endif |
||||
endfor |
||||
endfor |
||||
endfor |
||||
|
||||
return [] |
||||
endfunction"}}} |
||||
"}}} |
||||
|
||||
function! s:check_buffer(bufnumber, is_force) "{{{ |
||||
if !neocomplcache#is_enabled_source('include_complete') |
||||
return |
||||
endif |
||||
|
||||
let bufnumber = (a:bufnumber == '') ? bufnr('%') : a:bufnumber |
||||
let filename = fnamemodify(bufname(bufnumber), ':p') |
||||
|
||||
if !has_key(s:include_info, bufnumber) |
||||
" Initialize. |
||||
let s:include_info[bufnumber] = { |
||||
\ 'include_files' : [], 'lines' : [], |
||||
\ 'async_files' : {}, |
||||
\ } |
||||
endif |
||||
|
||||
if !executable(g:neocomplcache_ctags_program) |
||||
\ || (!a:is_force && !neocomplcache#has_vimproc()) |
||||
return |
||||
endif |
||||
|
||||
let include_info = s:include_info[bufnumber] |
||||
|
||||
if a:is_force || include_info.lines !=# getbufline(bufnumber, 1, 100) |
||||
let include_info.lines = getbufline(bufnumber, 1, 100) |
||||
|
||||
" Check include files contained bufname. |
||||
let include_files = s:get_buffer_include_files(bufnumber) |
||||
|
||||
" Check include files from function. |
||||
let filetype = getbufvar(a:bufnumber, '&filetype') |
||||
let function = get(g:neocomplcache_include_functions, filetype, '') |
||||
if function != '' && getbufvar(bufnumber, '&buftype') !~ 'nofile' |
||||
let path = get(g:neocomplcache_include_paths, filetype, |
||||
\ getbufvar(a:bufnumber, '&path')) |
||||
let include_files += call(function, |
||||
\ [getbufline(bufnumber, 1, (a:is_force ? '$' : 1000)), path]) |
||||
endif |
||||
|
||||
if getbufvar(bufnumber, '&buftype') !~ 'nofile' |
||||
\ && filereadable(filename) |
||||
call add(include_files, filename) |
||||
endif |
||||
let include_info.include_files = neocomplcache#util#uniq(include_files) |
||||
endif |
||||
|
||||
if g:neocomplcache_include_max_processes <= 0 |
||||
return |
||||
endif |
||||
|
||||
let filetype = getbufvar(bufnumber, '&filetype') |
||||
if filetype == '' |
||||
let filetype = 'nothing' |
||||
endif |
||||
|
||||
for filename in include_info.include_files |
||||
if (a:is_force || !has_key(include_info.async_files, filename)) |
||||
\ && !has_key(s:include_cache, filename) |
||||
if !a:is_force && has_key(s:async_include_cache, filename) |
||||
\ && len(s:async_include_cache[filename]) |
||||
\ >= g:neocomplcache_include_max_processes |
||||
break |
||||
endif |
||||
|
||||
" Caching. |
||||
let s:async_include_cache[filename] |
||||
\ = [ s:initialize_include(filename, filetype) ] |
||||
let include_info.async_files[filename] = 1 |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
function! s:get_buffer_include_files(bufnumber) "{{{ |
||||
let filetype = getbufvar(a:bufnumber, '&filetype') |
||||
if filetype == '' |
||||
return [] |
||||
endif |
||||
|
||||
if (filetype ==# 'python' || filetype ==# 'python3') |
||||
\ && (executable('python') || executable('python3')) |
||||
" Initialize python path pattern. |
||||
|
||||
let path = '' |
||||
if executable('python3') |
||||
let path .= ',' . neocomplcache#system('python3 -', |
||||
\ 'import sys;sys.stdout.write(",".join(sys.path))') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_paths', 'python3', path) |
||||
endif |
||||
if executable('python') |
||||
let path .= ',' . neocomplcache#system('python -', |
||||
\ 'import sys;sys.stdout.write(",".join(sys.path))') |
||||
endif |
||||
let path = join(neocomplcache#util#uniq(filter( |
||||
\ split(path, ',', 1), "v:val != ''")), ',') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_paths', 'python', path) |
||||
elseif filetype ==# 'cpp' && isdirectory('/usr/include/c++') |
||||
" Add cpp path. |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_paths', 'cpp', |
||||
\ getbufvar(a:bufnumber, '&path') . |
||||
\ ','.join(split(glob('/usr/include/c++/*'), '\n'), ',')) |
||||
endif |
||||
|
||||
let pattern = get(g:neocomplcache_include_patterns, filetype, |
||||
\ getbufvar(a:bufnumber, '&include')) |
||||
if pattern == '' |
||||
return [] |
||||
endif |
||||
let path = get(g:neocomplcache_include_paths, filetype, |
||||
\ getbufvar(a:bufnumber, '&path')) |
||||
let expr = get(g:neocomplcache_include_exprs, filetype, |
||||
\ getbufvar(a:bufnumber, '&includeexpr')) |
||||
if has_key(g:neocomplcache_include_suffixes, filetype) |
||||
let suffixes = &l:suffixesadd |
||||
endif |
||||
|
||||
" Change current directory. |
||||
let cwd_save = getcwd() |
||||
let buffer_dir = fnamemodify(bufname(a:bufnumber), ':p:h') |
||||
if isdirectory(buffer_dir) |
||||
execute 'lcd' fnameescape(buffer_dir) |
||||
endif |
||||
|
||||
let include_files = s:get_include_files(0, |
||||
\ getbufline(a:bufnumber, 1, 100), filetype, pattern, path, expr) |
||||
|
||||
if isdirectory(buffer_dir) |
||||
execute 'lcd' fnameescape(cwd_save) |
||||
endif |
||||
|
||||
" Restore option. |
||||
if has_key(g:neocomplcache_include_suffixes, filetype) |
||||
let &l:suffixesadd = suffixes |
||||
endif |
||||
|
||||
return include_files |
||||
endfunction"}}} |
||||
function! s:get_include_files(nestlevel, lines, filetype, pattern, path, expr) "{{{ |
||||
let include_files = [] |
||||
for line in a:lines "{{{ |
||||
if line =~ a:pattern |
||||
let match_end = matchend(line, a:pattern) |
||||
if a:expr != '' |
||||
let eval = substitute(a:expr, 'v:fname', |
||||
\ string(matchstr(line[match_end :], '\f\+')), 'g') |
||||
let filename = fnamemodify(findfile(eval(eval), a:path), ':p') |
||||
else |
||||
let filename = fnamemodify(findfile( |
||||
\ matchstr(line[match_end :], '\f\+'), a:path), ':p') |
||||
endif |
||||
|
||||
if filereadable(filename) |
||||
call add(include_files, filename) |
||||
|
||||
if (a:filetype == 'c' || a:filetype == 'cpp') && a:nestlevel < 1 |
||||
let include_files += s:get_include_files( |
||||
\ a:nestlevel + 1, readfile(filename)[:100], |
||||
\ a:filetype, a:pattern, a:path, a:expr) |
||||
endif |
||||
elseif isdirectory(filename) && a:filetype ==# 'java' |
||||
" For Java import with *. |
||||
" Ex: import lejos.nxt.* |
||||
let include_files += |
||||
\ neocomplcache#util#glob(filename . '/*.java') |
||||
endif |
||||
endif |
||||
endfor"}}} |
||||
|
||||
return include_files |
||||
endfunction"}}} |
||||
|
||||
function! s:check_cache() "{{{ |
||||
if neocomplcache#is_disabled_source('include_complete') |
||||
return |
||||
endif |
||||
|
||||
let release_accessd_time = localtime() - g:neocomplcache_release_cache_time |
||||
|
||||
for key in keys(s:include_cache) |
||||
if has_key(s:cache_accessed_time, key) |
||||
\ && s:cache_accessed_time[key] < release_accessd_time |
||||
call remove(s:include_cache, key) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! s:initialize_include(filename, filetype) "{{{ |
||||
" Initialize include list from tags. |
||||
return { |
||||
\ 'filename' : a:filename, |
||||
\ 'cachename' : neocomplcache#cache#async_load_from_tags( |
||||
\ 'include_cache', a:filename, a:filetype, 'I', 1) |
||||
\ } |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#include_complete#caching_include(bufname) "{{{ |
||||
let bufnumber = (a:bufname == '') ? bufnr('%') : bufnr(a:bufname) |
||||
if has_key(s:async_include_cache, bufnumber) |
||||
\ && filereadable(s:async_include_cache[bufnumber].cache_name) |
||||
" Delete old cache. |
||||
call delete(s:async_include_cache[bufnumber].cache_name) |
||||
endif |
||||
|
||||
" Initialize. |
||||
if has_key(s:include_info, bufnumber) |
||||
call remove(s:include_info, bufnumber) |
||||
endif |
||||
|
||||
call s:check_buffer(bufnumber, 1) |
||||
endfunction"}}} |
||||
|
||||
" Analyze include files functions. |
||||
function! neocomplcache#sources#include_complete#analyze_vim_include_files(lines, path) "{{{ |
||||
let include_files = [] |
||||
let dup_check = {} |
||||
for line in a:lines |
||||
if line =~ '\<\h\w*#' && line !~ '\<function!\?\>' |
||||
let filename = 'autoload/' . substitute(matchstr(line, '\<\%(\h\w*#\)*\h\w*\ze#'), |
||||
\ '#', '/', 'g') . '.vim' |
||||
if filename == '' || has_key(dup_check, filename) |
||||
continue |
||||
endif |
||||
let dup_check[filename] = 1 |
||||
|
||||
let filename = fnamemodify(findfile(filename, &runtimepath), ':p') |
||||
if filereadable(filename) |
||||
call add(include_files, filename) |
||||
endif |
||||
endif |
||||
endfor |
||||
|
||||
return include_files |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#include_complete#analyze_ruby_include_files(lines, path) "{{{ |
||||
let include_files = [] |
||||
let dup_check = {} |
||||
for line in a:lines |
||||
if line =~ '\<autoload\>' |
||||
let args = split(line, ',') |
||||
if len(args) < 2 |
||||
continue |
||||
endif |
||||
let filename = substitute(matchstr(args[1], '["'']\zs\f\+\ze["'']'), |
||||
\ '\.', '/', 'g') . '.rb' |
||||
if filename == '' || has_key(dup_check, filename) |
||||
continue |
||||
endif |
||||
let dup_check[filename] = 1 |
||||
|
||||
let filename = fnamemodify(findfile(filename, a:path), ':p') |
||||
if filereadable(filename) |
||||
call add(include_files, filename) |
||||
endif |
||||
endif |
||||
endfor |
||||
|
||||
return include_files |
||||
endfunction"}}} |
||||
|
||||
function! s:initialize_variables() "{{{ |
||||
let s:include_info = {} |
||||
let s:include_cache = {} |
||||
let s:cache_accessed_time = {} |
||||
let s:async_include_cache = {} |
||||
let s:cached_pattern = {} |
||||
|
||||
" Initialize include pattern. "{{{ |
||||
let g:neocomplcache_include_patterns = |
||||
\ get(g:, 'neocomplcache_include_patterns', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_patterns', |
||||
\ 'java,haskell', '^\s*\<import') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_patterns', |
||||
\ 'cs', '^\s*\<using') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_patterns', |
||||
\ 'ruby', '^\s*\<\%(load\|require\|require_relative\)\>') |
||||
"}}} |
||||
" Initialize expr pattern. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_include_exprs', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_exprs', |
||||
\ 'haskell,cs', |
||||
\ "substitute(v:fname, '\\.', '/', 'g')") |
||||
"}}} |
||||
" Initialize path pattern. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_include_paths', {}) |
||||
"}}} |
||||
" Initialize include suffixes. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_include_suffixes', {}) |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_suffixes', |
||||
\ 'haskell', '.hs') |
||||
"}}} |
||||
" Initialize include functions. "{{{ |
||||
call neocomplcache#util#set_default( |
||||
\ 'g:neocomplcache_include_functions', {}) |
||||
" call neocomplcache#util#set_default_dictionary( |
||||
" \ 'g:neocomplcache_include_functions', 'vim', |
||||
" \ 'neocomplcache#sources#include_complete#analyze_vim_include_files') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_include_functions', 'ruby', |
||||
\ 'neocomplcache#sources#include_complete#analyze_ruby_include_files') |
||||
"}}} |
||||
endfunction"}}} |
||||
|
||||
if !exists('s:include_info') |
||||
call s:initialize_variables() |
||||
endif |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,247 @@
@@ -0,0 +1,247 @@
|
||||
"============================================================================= |
||||
" FILE: member_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 01 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Important variables. |
||||
if !exists('s:member_sources') |
||||
let s:member_sources = {} |
||||
endif |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'member_complete', |
||||
\ 'kind' : 'manual', |
||||
\ 'mark' : '[M]', |
||||
\ 'rank' : 5, |
||||
\ 'min_pattern_length' : 0, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
augroup neocomplcache "{{{ |
||||
" Caching events |
||||
autocmd CursorHold * call s:caching_current_buffer(line('.')-10, line('.')+10) |
||||
autocmd InsertEnter,InsertLeave * |
||||
\ call neocomplcache#sources#member_complete#caching_current_line() |
||||
augroup END"}}} |
||||
|
||||
" Initialize member prefix patterns. "{{{ |
||||
if !exists('g:neocomplcache_member_prefix_patterns') |
||||
let g:neocomplcache_member_prefix_patterns = {} |
||||
endif |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_member_prefix_patterns', |
||||
\ 'c,cpp,objc,objcpp', '\.\|->') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_member_prefix_patterns', |
||||
\ 'perl,php', '->') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_member_prefix_patterns', |
||||
\ 'cs,java,javascript,d,vim,ruby,python,perl6,scala,vb', '\.') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_member_prefix_patterns', |
||||
\ 'lua', '\.\|:') |
||||
"}}} |
||||
|
||||
" Initialize member patterns. "{{{ |
||||
if !exists('g:neocomplcache_member_patterns') |
||||
let g:neocomplcache_member_patterns = {} |
||||
endif |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\ 'g:neocomplcache_member_patterns', |
||||
\'default', '\h\w*\%(()\|\[\h\w*\]\)\?') |
||||
"}}} |
||||
|
||||
" Initialize script variables. "{{{ |
||||
let s:member_sources = {} |
||||
"}}} |
||||
endfunction |
||||
"}}} |
||||
|
||||
function! s:source.get_keyword_pos(cur_text) "{{{ |
||||
" Check member prefix pattern. |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
if !has_key(g:neocomplcache_member_prefix_patterns, filetype) |
||||
\ || g:neocomplcache_member_prefix_patterns[filetype] == '' |
||||
return -1 |
||||
endif |
||||
|
||||
let member = s:get_member_pattern(filetype) |
||||
let prefix = g:neocomplcache_member_prefix_patterns[filetype] |
||||
let complete_pos = matchend(a:cur_text, |
||||
\ '\%(' . member . '\%(' . prefix . '\m\)\)\+\ze\w*$') |
||||
return complete_pos |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_complete_words(complete_pos, complete_str) "{{{ |
||||
" Check member prefix pattern. |
||||
let filetype = neocomplcache#get_context_filetype() |
||||
if !has_key(g:neocomplcache_member_prefix_patterns, filetype) |
||||
\ || g:neocomplcache_member_prefix_patterns[filetype] == '' |
||||
return [] |
||||
endif |
||||
|
||||
let cur_text = neocomplcache#get_cur_text() |
||||
let var_name = matchstr(cur_text, |
||||
\ '\%(' . s:get_member_pattern(filetype) . '\%(' . |
||||
\ g:neocomplcache_member_prefix_patterns[filetype] . '\m\)\)\+\ze\w*$') |
||||
if var_name == '' |
||||
return [] |
||||
endif |
||||
|
||||
return neocomplcache#keyword_filter( |
||||
\ copy(s:get_member_list(cur_text, var_name)), a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#member_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#member_complete#caching_current_line() "{{{ |
||||
" Current line caching. |
||||
return s:caching_current_buffer(line('.')-1, line('.')+1) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#member_complete#caching_current_buffer() "{{{ |
||||
" Current line caching. |
||||
return s:caching_current_buffer(1, line('$')) |
||||
endfunction"}}} |
||||
function! s:caching_current_buffer(start, end) "{{{ |
||||
" Current line caching. |
||||
|
||||
if !has_key(s:member_sources, bufnr('%')) |
||||
call s:initialize_source(bufnr('%')) |
||||
endif |
||||
|
||||
let filetype = neocomplcache#get_context_filetype(1) |
||||
if !has_key(g:neocomplcache_member_prefix_patterns, filetype) |
||||
\ || g:neocomplcache_member_prefix_patterns[filetype] == '' |
||||
return |
||||
endif |
||||
|
||||
let source = s:member_sources[bufnr('%')] |
||||
let keyword_pattern = |
||||
\ '\%(' . s:get_member_pattern(filetype) . '\%(' |
||||
\ . g:neocomplcache_member_prefix_patterns[filetype] |
||||
\ . '\m\)\)\+' . s:get_member_pattern(filetype) |
||||
let keyword_pattern2 = '^'.keyword_pattern |
||||
let member_pattern = s:get_member_pattern(filetype) . '$' |
||||
|
||||
" Cache member pattern. |
||||
let [line_num, max_lines] = [a:start, a:end] |
||||
for line in getline(a:start, a:end) |
||||
let match = match(line, keyword_pattern) |
||||
|
||||
while match >= 0 "{{{ |
||||
let match_str = matchstr(line, keyword_pattern2, match) |
||||
|
||||
" Next match. |
||||
let match = matchend(line, keyword_pattern, match + len(match_str)) |
||||
|
||||
while match_str != '' |
||||
let member_name = matchstr(match_str, member_pattern) |
||||
if member_name == '' |
||||
break |
||||
endif |
||||
let var_name = match_str[ : -len(member_name)-1] |
||||
|
||||
if !has_key(source.member_cache, var_name) |
||||
let source.member_cache[var_name] = {} |
||||
endif |
||||
if !has_key(source.member_cache[var_name], member_name) |
||||
let source.member_cache[var_name][member_name] = member_name |
||||
endif |
||||
|
||||
let match_str = matchstr(var_name, keyword_pattern2) |
||||
endwhile |
||||
endwhile"}}} |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! s:get_member_list(cur_text, var_name) "{{{ |
||||
let keyword_list = [] |
||||
for [key, source] in filter(s:get_sources_list(), |
||||
\ 'has_key(v:val[1].member_cache, a:var_name)') |
||||
let keyword_list += |
||||
\ values(source.member_cache[a:var_name]) |
||||
endfor |
||||
|
||||
return keyword_list |
||||
endfunction"}}} |
||||
|
||||
function! s:get_sources_list() "{{{ |
||||
let sources_list = [] |
||||
|
||||
let filetypes_dict = {} |
||||
for filetype in neocomplcache#get_source_filetypes( |
||||
\ neocomplcache#get_context_filetype()) |
||||
let filetypes_dict[filetype] = 1 |
||||
endfor |
||||
|
||||
for [key, source] in items(s:member_sources) |
||||
if has_key(filetypes_dict, source.filetype) |
||||
\ || has_key(filetypes_dict, '_') |
||||
\ || bufnr('%') == key |
||||
\ || (bufname('%') ==# '[Command Line]' && bufnr('#') == key) |
||||
call add(sources_list, [key, source]) |
||||
endif |
||||
endfor |
||||
|
||||
return sources_list |
||||
endfunction"}}} |
||||
|
||||
function! s:initialize_source(srcname) "{{{ |
||||
let path = fnamemodify(bufname(a:srcname), ':p') |
||||
let filename = fnamemodify(path, ':t') |
||||
if filename == '' |
||||
let filename = '[No Name]' |
||||
let path .= '/[No Name]' |
||||
endif |
||||
|
||||
" Set cache line count. |
||||
let buflines = getbufline(a:srcname, 1, '$') |
||||
let end_line = len(buflines) |
||||
|
||||
let ft = getbufvar(a:srcname, '&filetype') |
||||
if ft == '' |
||||
let ft = 'nothing' |
||||
endif |
||||
|
||||
let s:member_sources[a:srcname] = { |
||||
\ 'member_cache' : {}, 'filetype' : ft, |
||||
\ 'keyword_pattern' : neocomplcache#get_keyword_pattern(ft), |
||||
\} |
||||
endfunction"}}} |
||||
|
||||
function! s:get_member_pattern(filetype) "{{{ |
||||
return has_key(g:neocomplcache_member_patterns, a:filetype) ? |
||||
\ g:neocomplcache_member_patterns[a:filetype] : |
||||
\ g:neocomplcache_member_patterns['default'] |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,303 @@
@@ -0,0 +1,303 @@
|
||||
"============================================================================= |
||||
" FILE: omni_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 29 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'omni_complete', |
||||
\ 'kind' : 'manual', |
||||
\ 'compare_func' : 'neocomplcache#compare_nothing', |
||||
\ 'mark' : '[O]', |
||||
\ 'rank' : 50, |
||||
\} |
||||
|
||||
let s:List = vital#of('neocomplcache').import('Data.List') |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
" Initialize omni completion pattern. "{{{ |
||||
if !exists('g:neocomplcache_omni_patterns') |
||||
let g:neocomplcache_omni_patterns = {} |
||||
endif |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'html,xhtml,xml,markdown', |
||||
\'<[^>]*') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'css,scss,sass', |
||||
\'^\s\+\w\+\|\w\+[):;]\?\s\+\w*\|[@!]') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'javascript', |
||||
\'[^. \t]\.\%(\h\w*\)\?') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'actionscript', |
||||
\'[^. \t][.:]\h\w*') |
||||
"call neocomplcache#util#set_default_dictionary( |
||||
"\'g:neocomplcache_omni_patterns', |
||||
"\'php', |
||||
"\'[^. \t]->\h\w*\|\h\w*::') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'java', |
||||
\'\%(\h\w*\|)\)\.') |
||||
"call neocomplcache#util#set_default_dictionary( |
||||
"\'g:neocomplcache_omni_patterns', |
||||
"\'perl', |
||||
"\'\h\w*->\h\w*\|\h\w*::') |
||||
"call neocomplcache#util#set_default_dictionary( |
||||
"\'g:neocomplcache_omni_patterns', |
||||
"\'c', |
||||
"\'[^.[:digit:] *\t]\%(\.\|->\)' |
||||
"call neocomplcache#util#set_default_dictionary( |
||||
"\'g:neocomplcache_omni_patterns', |
||||
"\'cpp', |
||||
"\'[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'objc', |
||||
\'[^.[:digit:] *\t]\%(\.\|->\)') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'objj', |
||||
\'[\[ \.]\w\+$\|:\w*$') |
||||
|
||||
" External language interface check. |
||||
if has('ruby') |
||||
" call neocomplcache#util#set_default_dictionary( |
||||
"\'g:neocomplcache_omni_patterns', 'ruby', |
||||
"\'[^. *\t]\.\h\w*\|\h\w*::') |
||||
endif |
||||
if has('python/dyn') || has('python3/dyn') |
||||
\ || has('python') || has('python3') |
||||
call neocomplcache#util#set_default_dictionary( |
||||
\'g:neocomplcache_omni_patterns', |
||||
\'python', '[^. \t]\.\w*') |
||||
endif |
||||
"}}} |
||||
endfunction"}}} |
||||
function! s:source.finalize() "{{{ |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_pos(cur_text) "{{{ |
||||
let syn_name = neocomplcache#helper#get_syn_name(1) |
||||
if syn_name ==# 'Comment' || syn_name ==# 'String' |
||||
" Skip omni_complete in string literal. |
||||
return -1 |
||||
endif |
||||
|
||||
let filetype = neocomplcache#get_context_filetype() |
||||
let s:complete_results = s:set_complete_results_pos( |
||||
\ s:get_omni_funcs(filetype), a:cur_text) |
||||
|
||||
return s:get_complete_pos(s:complete_results) |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_complete_words(complete_pos, complete_str) "{{{ |
||||
return s:get_candidates( |
||||
\ s:set_complete_results_words(s:complete_results), |
||||
\ a:complete_pos, a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#omni_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! s:get_omni_funcs(filetype) "{{{ |
||||
let funcs = [] |
||||
for ft in insert(split(a:filetype, '\.'), '_') |
||||
if has_key(g:neocomplcache_omni_functions, ft) |
||||
let omnifuncs = |
||||
\ (type(g:neocomplcache_omni_functions[ft]) == type([])) ? |
||||
\ g:neocomplcache_omni_functions[ft] : |
||||
\ [g:neocomplcache_omni_functions[ft]] |
||||
else |
||||
let omnifuncs = [&l:omnifunc] |
||||
endif |
||||
|
||||
for omnifunc in omnifuncs |
||||
if neocomplcache#check_invalid_omnifunc(omnifunc) |
||||
" omnifunc is irregal. |
||||
continue |
||||
endif |
||||
|
||||
if get(g:neocomplcache_omni_patterns, omnifunc, '') != '' |
||||
let pattern = g:neocomplcache_omni_patterns[omnifunc] |
||||
elseif get(g:neocomplcache_omni_patterns, ft, '') != '' |
||||
let pattern = g:neocomplcache_omni_patterns[ft] |
||||
else |
||||
let pattern = '' |
||||
endif |
||||
|
||||
if pattern == '' |
||||
continue |
||||
endif |
||||
|
||||
call add(funcs, [omnifunc, pattern]) |
||||
endfor |
||||
endfor |
||||
|
||||
return s:List.uniq(funcs) |
||||
endfunction"}}} |
||||
function! s:get_omni_list(list) "{{{ |
||||
let omni_list = [] |
||||
|
||||
" Convert string list. |
||||
for val in deepcopy(a:list) |
||||
let dict = (type(val) == type('') ? |
||||
\ { 'word' : val } : val) |
||||
let dict.menu = '[O]' . get(dict, 'menu', '') |
||||
call add(omni_list, dict) |
||||
|
||||
unlet val |
||||
endfor |
||||
|
||||
return omni_list |
||||
endfunction"}}} |
||||
|
||||
function! s:set_complete_results_pos(funcs, cur_text) "{{{ |
||||
" Try omnifunc completion. "{{{ |
||||
let complete_results = {} |
||||
for [omnifunc, pattern] in a:funcs |
||||
if neocomplcache#is_auto_complete() |
||||
\ && a:cur_text !~ '\%(' . pattern . '\m\)$' |
||||
continue |
||||
endif |
||||
|
||||
" Save pos. |
||||
let pos = getpos('.') |
||||
|
||||
try |
||||
let complete_pos = call(omnifunc, [1, '']) |
||||
catch |
||||
call neocomplcache#print_error( |
||||
\ 'Error occured calling omnifunction: ' . omnifunc) |
||||
call neocomplcache#print_error(v:throwpoint) |
||||
call neocomplcache#print_error(v:exception) |
||||
let complete_pos = -1 |
||||
finally |
||||
if getpos('.') != pos |
||||
call setpos('.', pos) |
||||
endif |
||||
endtry |
||||
|
||||
if complete_pos < 0 |
||||
continue |
||||
endif |
||||
|
||||
let complete_str = a:cur_text[complete_pos :] |
||||
|
||||
let complete_results[omnifunc] = { |
||||
\ 'candidates' : [], |
||||
\ 'complete_pos' : complete_pos, |
||||
\ 'complete_str' : complete_str, |
||||
\ 'omnifunc' : omnifunc, |
||||
\} |
||||
endfor |
||||
"}}} |
||||
|
||||
return complete_results |
||||
endfunction"}}} |
||||
function! s:set_complete_results_words(complete_results) "{{{ |
||||
" Try source completion. |
||||
for [omnifunc, result] in items(a:complete_results) |
||||
if neocomplcache#complete_check() |
||||
return a:complete_results |
||||
endif |
||||
|
||||
let pos = getpos('.') |
||||
|
||||
" Note: For rubycomplete problem. |
||||
let complete_str = |
||||
\ (omnifunc == 'rubycomplete#Complete') ? |
||||
\ '' : result.complete_str |
||||
|
||||
try |
||||
let list = call(omnifunc, [0, complete_str]) |
||||
catch |
||||
call neocomplcache#print_error( |
||||
\ 'Error occured calling omnifunction: ' . omnifunc) |
||||
call neocomplcache#print_error(v:throwpoint) |
||||
call neocomplcache#print_error(v:exception) |
||||
let list = [] |
||||
finally |
||||
if getpos('.') != pos |
||||
call setpos('.', pos) |
||||
endif |
||||
endtry |
||||
|
||||
if type(list) != type([]) |
||||
" Error. |
||||
return a:complete_results |
||||
endif |
||||
|
||||
let list = s:get_omni_list(list) |
||||
|
||||
let result.candidates = list |
||||
endfor |
||||
|
||||
return a:complete_results |
||||
endfunction"}}} |
||||
function! s:get_complete_pos(complete_results) "{{{ |
||||
if empty(a:complete_results) |
||||
return -1 |
||||
endif |
||||
|
||||
let complete_pos = col('.') |
||||
for result in values(a:complete_results) |
||||
if complete_pos > result.complete_pos |
||||
let complete_pos = result.complete_pos |
||||
endif |
||||
endfor |
||||
|
||||
return complete_pos |
||||
endfunction"}}} |
||||
function! s:get_candidates(complete_results, complete_pos, complete_str) "{{{ |
||||
" Append prefix. |
||||
let candidates = [] |
||||
let len_words = 0 |
||||
for [source_name, result] in items(a:complete_results) |
||||
if result.complete_pos > a:complete_pos |
||||
let prefix = a:complete_str[: result.complete_pos |
||||
\ - a:complete_pos - 1] |
||||
|
||||
for keyword in result.candidates |
||||
let keyword.word = prefix . keyword.word |
||||
endfor |
||||
endif |
||||
|
||||
let candidates += result.candidates |
||||
endfor |
||||
|
||||
return candidates |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,322 @@
@@ -0,0 +1,322 @@
|
||||
"============================================================================= |
||||
" FILE: syntax_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 05 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Important variables. |
||||
if !exists('s:syntax_list') |
||||
let s:syntax_list = {} |
||||
endif |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'syntax_complete', |
||||
\ 'kind' : 'keyword', |
||||
\ 'mark' : '[S]', |
||||
\ 'rank' : 4, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
" Set caching event. |
||||
autocmd neocomplcache Syntax * call s:caching() |
||||
|
||||
" Create cache directory. |
||||
if !isdirectory(neocomplcache#get_temporary_directory() . '/syntax_cache') |
||||
call mkdir(neocomplcache#get_temporary_directory() . '/syntax_cache') |
||||
endif |
||||
|
||||
" Initialize check. |
||||
call s:caching() |
||||
endfunction"}}} |
||||
|
||||
function! s:source.finalize() "{{{ |
||||
delcommand NeoComplCacheCachingSyntax |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_list(complete_str) "{{{ |
||||
let list = [] |
||||
|
||||
let filetype = neocomplcache#get_context_filetype() |
||||
if !has_key(s:syntax_list, filetype) |
||||
call s:caching() |
||||
endif |
||||
|
||||
for syntax in neocomplcache#get_sources_list( |
||||
\ s:syntax_list, filetype) |
||||
let list += neocomplcache#dictionary_filter(syntax, a:complete_str) |
||||
endfor |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#syntax_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! s:caching() "{{{ |
||||
if &filetype == '' || &filetype ==# 'vim' |
||||
return |
||||
endif |
||||
|
||||
for filetype in neocomplcache#get_source_filetypes(&filetype) |
||||
if !has_key(s:syntax_list, filetype) |
||||
" Check old cache. |
||||
let cache_name = neocomplcache#cache#encode_name('syntax_cache', &filetype) |
||||
let syntax_files = split( |
||||
\ globpath(&runtimepath, 'syntax/'.&filetype.'.vim'), '\n') |
||||
if getftime(cache_name) < 0 || (!empty(syntax_files) |
||||
\ && getftime(cache_name) <= getftime(syntax_files[0])) |
||||
if filetype ==# &filetype |
||||
" Caching from syn list. |
||||
let s:syntax_list[filetype] = s:caching_from_syn(filetype) |
||||
endif |
||||
else |
||||
let s:syntax_list[filetype] = neocomplcache#cache#index_load_from_cache( |
||||
\ 'syntax_cache', filetype, 1) |
||||
endif |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#syntax_complete#recaching(filetype) "{{{ |
||||
if a:filetype == '' |
||||
let filetype = &filetype |
||||
else |
||||
let filetype = a:filetype |
||||
endif |
||||
|
||||
" Caching. |
||||
let s:syntax_list[filetype] = s:caching_from_syn(filetype) |
||||
endfunction"}}} |
||||
|
||||
function! s:caching_from_syn(filetype) "{{{ |
||||
call neocomplcache#print_caching( |
||||
\ 'Caching syntax "' . a:filetype . '"... please wait.') |
||||
|
||||
" Get current syntax list. |
||||
redir => syntax_list |
||||
silent! syntax list |
||||
redir END |
||||
|
||||
if syntax_list =~ '^E\d\+' || syntax_list =~ '^No Syntax items' |
||||
return [] |
||||
endif |
||||
|
||||
let group_name = '' |
||||
let keyword_pattern = neocomplcache#get_keyword_pattern(a:filetype) |
||||
|
||||
let dup_check = {} |
||||
|
||||
let filetype_pattern = tolower(a:filetype) |
||||
|
||||
let keyword_lists = {} |
||||
for line in split(syntax_list, '\n') |
||||
if line =~ '^\h\w\+' |
||||
" Change syntax group name. |
||||
let group_name = matchstr(line, '^\S\+') |
||||
let line = substitute(line, '^\S\+\s*xxx', '', '') |
||||
endif |
||||
|
||||
if line =~ 'Syntax items' || line =~ '^\s*links to' || |
||||
\ line =~ '^\s*nextgroup=' || |
||||
\ strridx(tolower(group_name), filetype_pattern) != 0 |
||||
" Next line. |
||||
continue |
||||
endif |
||||
|
||||
let line = substitute(line, 'contained\|skipwhite\|skipnl\|oneline', '', 'g') |
||||
let line = substitute(line, '^\s*nextgroup=.*\ze\s', '', '') |
||||
|
||||
if line =~ '^\s*match' |
||||
let line = s:substitute_candidate(matchstr(line, '/\zs[^/]\+\ze/')) |
||||
elseif line =~ '^\s*start=' |
||||
let line = |
||||
\s:substitute_candidate(matchstr(line, 'start=/\zs[^/]\+\ze/')) . ' ' . |
||||
\s:substitute_candidate(matchstr(line, 'end=/zs[^/]\+\ze/')) |
||||
endif |
||||
|
||||
" Add keywords. |
||||
let match_num = 0 |
||||
let completion_length = 2 |
||||
let match_str = matchstr(line, keyword_pattern, match_num) |
||||
while match_str != '' |
||||
" Ignore too short keyword. |
||||
if len(match_str) >= g:neocomplcache_min_syntax_length |
||||
\ && !has_key(dup_check, match_str) |
||||
\&& match_str =~ '^[[:print:]]\+$' |
||||
let key = tolower(match_str[: completion_length-1]) |
||||
if !has_key(keyword_lists, key) |
||||
let keyword_lists[key] = [] |
||||
endif |
||||
call add(keyword_lists[key], match_str) |
||||
|
||||
let dup_check[match_str] = 1 |
||||
endif |
||||
|
||||
let match_num += len(match_str) |
||||
|
||||
let match_str = matchstr(line, keyword_pattern, match_num) |
||||
endwhile |
||||
endfor |
||||
|
||||
" Save syntax cache. |
||||
let unpack_lists = neocomplcache#unpack_dictionary(keyword_lists) |
||||
if !empty(unpack_lists) |
||||
call neocomplcache#cache#save_cache('syntax_cache', &filetype, unpack_lists) |
||||
endif |
||||
|
||||
call neocomplcache#print_caching('') |
||||
|
||||
return keyword_lists |
||||
endfunction"}}} |
||||
|
||||
function! s:substitute_candidate(candidate) "{{{ |
||||
let candidate = a:candidate |
||||
|
||||
" Collection. |
||||
let candidate = substitute(candidate, |
||||
\'\\\@<!\[[^\]]*\]', ' ', 'g') |
||||
|
||||
" Delete. |
||||
let candidate = substitute(candidate, |
||||
\'\\\@<!\%(\\[=?+]\|\\%[\|\\s\*\)', '', 'g') |
||||
" Space. |
||||
let candidate = substitute(candidate, |
||||
\'\\\@<!\%(\\[<>{}]\|[$^]\|\\z\?\a\)', ' ', 'g') |
||||
|
||||
if candidate =~ '\\%\?(' |
||||
let candidate = join(s:split_pattern(candidate)) |
||||
endif |
||||
|
||||
" \ |
||||
let candidate = substitute(candidate, '\\\\', '\\', 'g') |
||||
" * |
||||
let candidate = substitute(candidate, '\\\*', '*', 'g') |
||||
return candidate |
||||
endfunction"}}} |
||||
|
||||
function! s:split_pattern(keyword_pattern) "{{{ |
||||
let original_pattern = a:keyword_pattern |
||||
let result_patterns = [] |
||||
let analyzing_patterns = [ '' ] |
||||
|
||||
let i = 0 |
||||
let max = len(original_pattern) |
||||
while i < max |
||||
if match(original_pattern, '^\\%\?(', i) >= 0 |
||||
" Grouping. |
||||
let end = s:match_pair(original_pattern, '\\%\?(', '\\)', i) |
||||
if end < 0 |
||||
"call neocomplcache#print_error('Unmatched (.') |
||||
return [ a:keyword_pattern ] |
||||
endif |
||||
|
||||
let save_pattern = analyzing_patterns |
||||
let analyzing_patterns = [] |
||||
for keyword in split(original_pattern[matchend(original_pattern, '^\\%\?(', i) : end], '\\|') |
||||
for prefix in save_pattern |
||||
call add(analyzing_patterns, prefix . keyword) |
||||
endfor |
||||
endfor |
||||
|
||||
let i = end + 1 |
||||
elseif match(original_pattern, '^\\|', i) >= 0 |
||||
" Select. |
||||
let result_patterns += analyzing_patterns |
||||
let analyzing_patterns = [ '' ] |
||||
let original_pattern = original_pattern[i+2 :] |
||||
let max = len(original_pattern) |
||||
|
||||
let i = 0 |
||||
elseif original_pattern[i] == '\' && i+1 < max |
||||
let save_pattern = analyzing_patterns |
||||
let analyzing_patterns = [] |
||||
for prefix in save_pattern |
||||
call add(analyzing_patterns, prefix . original_pattern[i] . original_pattern[i+1]) |
||||
endfor |
||||
|
||||
" Escape. |
||||
let i += 2 |
||||
else |
||||
let save_pattern = analyzing_patterns |
||||
let analyzing_patterns = [] |
||||
for prefix in save_pattern |
||||
call add(analyzing_patterns, prefix . original_pattern[i]) |
||||
endfor |
||||
|
||||
let i += 1 |
||||
endif |
||||
endwhile |
||||
|
||||
let result_patterns += analyzing_patterns |
||||
return result_patterns |
||||
endfunction"}}} |
||||
|
||||
function! s:match_pair(string, start_pattern, end_pattern, start_cnt) "{{{ |
||||
let end = -1 |
||||
let start_pattern = '\%(' . a:start_pattern . '\)' |
||||
let end_pattern = '\%(' . a:end_pattern . '\)' |
||||
|
||||
let i = a:start_cnt |
||||
let max = len(a:string) |
||||
let nest_level = 0 |
||||
while i < max |
||||
let start = match(a:string, start_pattern, i) |
||||
let end = match(a:string, end_pattern, i) |
||||
|
||||
if start >= 0 && (end < 0 || start < end) |
||||
let i = matchend(a:string, start_pattern, i) |
||||
let nest_level += 1 |
||||
elseif end >= 0 && (start < 0 || end < start) |
||||
let nest_level -= 1 |
||||
|
||||
if nest_level == 0 |
||||
return end |
||||
endif |
||||
|
||||
let i = matchend(a:string, end_pattern, i) |
||||
else |
||||
break |
||||
endif |
||||
endwhile |
||||
|
||||
if nest_level != 0 |
||||
return -1 |
||||
else |
||||
return end |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
" Global options definition. "{{{ |
||||
if !exists('g:neocomplcache_min_syntax_length') |
||||
let g:neocomplcache_min_syntax_length = 4 |
||||
endif |
||||
"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,113 @@
@@ -0,0 +1,113 @@
|
||||
"============================================================================= |
||||
" FILE: tags_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" Important variables. |
||||
if !exists('s:tags_list') |
||||
let s:tags_list = {} |
||||
let s:async_tags_list = {} |
||||
endif |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'tags_complete', |
||||
\ 'kind' : 'keyword', |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
let g:neocomplcache_tags_caching_limit_file_size = |
||||
\ get(g:, 'neocomplcache_tags_caching_limit_file_size', 500000) |
||||
|
||||
" Create cache directory. |
||||
if !isdirectory(neocomplcache#get_temporary_directory() . '/tags_cache') |
||||
call mkdir(neocomplcache#get_temporary_directory() . '/tags_cache', 'p') |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:source.finalize() "{{{ |
||||
delcommand NeoComplCacheCachingTags |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#tags_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_list(complete_str) "{{{ |
||||
if !has_key(s:async_tags_list, bufnr('%')) |
||||
\ && !has_key(s:tags_list, bufnr('%')) |
||||
call neocomplcache#sources#tags_complete#caching_tags(0) |
||||
endif |
||||
|
||||
if neocomplcache#within_comment() |
||||
return [] |
||||
endif |
||||
|
||||
call neocomplcache#cache#check_cache( |
||||
\ 'tags_cache', bufnr('%'), s:async_tags_list, s:tags_list) |
||||
|
||||
if !has_key(s:tags_list, bufnr('%')) |
||||
return [] |
||||
endif |
||||
let keyword_list = neocomplcache#dictionary_filter( |
||||
\ s:tags_list[bufnr('%')], a:complete_str) |
||||
|
||||
return neocomplcache#keyword_filter(keyword_list, a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! s:initialize_tags(filename) "{{{ |
||||
" Initialize tags list. |
||||
let ft = &filetype |
||||
if ft == '' |
||||
let ft = 'nothing' |
||||
endif |
||||
|
||||
return { |
||||
\ 'filename' : a:filename, |
||||
\ 'cachename' : neocomplcache#cache#async_load_from_tags( |
||||
\ 'tags_cache', a:filename, ft, 'T', 0) |
||||
\ } |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#tags_complete#caching_tags(force) "{{{ |
||||
let bufnumber = bufnr('%') |
||||
|
||||
let s:async_tags_list[bufnumber] = [] |
||||
for tags in map(filter(tagfiles(), 'getfsize(v:val) > 0'), |
||||
\ "neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(v:val, ':p'))") |
||||
if tags !~? '/doc/tags\%(-\w\+\)\?$' && |
||||
\ (a:force || getfsize(tags) |
||||
\ < g:neocomplcache_tags_caching_limit_file_size) |
||||
call add(s:async_tags_list[bufnumber], |
||||
\ s:initialize_tags(tags)) |
||||
endif |
||||
endfor |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,198 @@
@@ -0,0 +1,198 @@
|
||||
"============================================================================= |
||||
" FILE: vim_complete.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Jun 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'vim_complete', |
||||
\ 'kind' : 'manual', |
||||
\ 'filetypes' : { 'vim' : 1, 'vimconsole' : 1, }, |
||||
\ 'mark' : '[vim]', |
||||
\ 'rank' : 300, |
||||
\} |
||||
|
||||
function! s:source.initialize() "{{{ |
||||
" Initialize. |
||||
|
||||
" Initialize complete function list. "{{{ |
||||
if !exists('g:neocomplcache_vim_completefuncs') |
||||
let g:neocomplcache_vim_completefuncs = {} |
||||
endif |
||||
"}}} |
||||
|
||||
" Call caching event. |
||||
autocmd neocomplcache FileType * |
||||
\ call neocomplcache#sources#vim_complete#helper#on_filetype() |
||||
|
||||
" Initialize check. |
||||
call neocomplcache#sources#vim_complete#helper#on_filetype() |
||||
|
||||
" Add command. |
||||
command! -nargs=? -complete=buffer NeoComplCacheCachingVim |
||||
\ call neocomplcache#sources#vim_complete#helper#recaching(<q-args>) |
||||
endfunction"}}} |
||||
|
||||
function! s:source.finalize() "{{{ |
||||
delcommand NeoComplCacheCachingVim |
||||
|
||||
if neocomplcache#exists_echodoc() |
||||
call echodoc#unregister('vim_complete') |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_keyword_pos(cur_text) "{{{ |
||||
let cur_text = neocomplcache#sources#vim_complete#get_cur_text() |
||||
|
||||
if cur_text =~ '^\s*"' |
||||
" Comment. |
||||
return -1 |
||||
endif |
||||
|
||||
let pattern = '\.\%(\h\w*\)\?$\|' . |
||||
\ neocomplcache#get_keyword_pattern_end('vim') |
||||
if cur_text != '' && cur_text !~ |
||||
\ '^[[:digit:],[:space:][:tab:]$''<>]*\h\w*$' |
||||
let command_completion = |
||||
\ neocomplcache#sources#vim_complete#helper#get_completion_name( |
||||
\ neocomplcache#sources#vim_complete#get_command(cur_text)) |
||||
if command_completion =~ '\%(dir\|file\|shellcmd\)' |
||||
let pattern = neocomplcache#get_keyword_pattern_end('filename') |
||||
endif |
||||
endif |
||||
|
||||
let [complete_pos, complete_str] = |
||||
\ neocomplcache#match_word(a:cur_text, pattern) |
||||
if complete_pos < 0 |
||||
" Use args pattern. |
||||
let [complete_pos, complete_str] = |
||||
\ neocomplcache#match_word(a:cur_text, '\S\+$') |
||||
endif |
||||
|
||||
if a:cur_text !~ '\.\%(\h\w*\)\?$' && neocomplcache#is_auto_complete() |
||||
\ && bufname('%') !=# '[Command Line]' |
||||
\ && neocomplcache#util#mb_strlen(complete_str) |
||||
\ < g:neocomplcache_auto_completion_start_length |
||||
return -1 |
||||
endif |
||||
|
||||
return complete_pos |
||||
endfunction"}}} |
||||
|
||||
function! s:source.get_complete_words(complete_pos, complete_str) "{{{ |
||||
let cur_text = neocomplcache#sources#vim_complete#get_cur_text() |
||||
if neocomplcache#is_auto_complete() && cur_text !~ '\h\w*\.\%(\h\w*\)\?$' |
||||
\ && len(a:complete_str) < g:neocomplcache_auto_completion_start_length |
||||
\ && bufname('%') !=# '[Command Line]' |
||||
return [] |
||||
endif |
||||
|
||||
if cur_text =~ '\h\w*\.\%(\h\w*\)\?$' |
||||
" Dictionary. |
||||
let complete_str = matchstr(cur_text, '.\%(\h\w*\)\?$') |
||||
let list = neocomplcache#sources#vim_complete#helper#var_dictionary( |
||||
\ cur_text, complete_str) |
||||
return neocomplcache#keyword_filter(list, complete_str) |
||||
elseif a:complete_str =~# '^&\%([gl]:\)\?' |
||||
" Options. |
||||
let prefix = matchstr(a:complete_str, '&\%([gl]:\)\?') |
||||
let list = deepcopy( |
||||
\ neocomplcache#sources#vim_complete#helper#option( |
||||
\ cur_text, a:complete_str)) |
||||
for keyword in list |
||||
let keyword.word = |
||||
\ prefix . keyword.word |
||||
let keyword.abbr = prefix . |
||||
\ get(keyword, 'abbr', keyword.word) |
||||
endfor |
||||
elseif a:complete_str =~? '^\c<sid>' |
||||
" SID functions. |
||||
let prefix = matchstr(a:complete_str, '^\c<sid>') |
||||
let complete_str = substitute(a:complete_str, '^\c<sid>', 's:', '') |
||||
let list = deepcopy( |
||||
\ neocomplcache#sources#vim_complete#helper#function( |
||||
\ cur_text, complete_str)) |
||||
for keyword in list |
||||
let keyword.word = prefix . keyword.word[2:] |
||||
let keyword.abbr = prefix . |
||||
\ get(keyword, 'abbr', keyword.word)[2:] |
||||
endfor |
||||
elseif cur_text =~# '\<has([''"]\w*$' |
||||
" Features. |
||||
let list = neocomplcache#sources#vim_complete#helper#feature( |
||||
\ cur_text, a:complete_str) |
||||
elseif cur_text =~# '\<expand([''"][<>[:alnum:]]*$' |
||||
" Expand. |
||||
let list = neocomplcache#sources#vim_complete#helper#expand( |
||||
\ cur_text, a:complete_str) |
||||
elseif a:complete_str =~ '^\$' |
||||
" Environment. |
||||
let list = neocomplcache#sources#vim_complete#helper#environment( |
||||
\ cur_text, a:complete_str) |
||||
elseif cur_text =~ '^[[:digit:],[:space:][:tab:]$''<>]*!\s*\f\+$' |
||||
" Shell commands. |
||||
let list = neocomplcache#sources#vim_complete#helper#shellcmd( |
||||
\ cur_text, a:complete_str) |
||||
else |
||||
" Commands. |
||||
let list = neocomplcache#sources#vim_complete#helper#command( |
||||
\ cur_text, a:complete_str) |
||||
endif |
||||
|
||||
return neocomplcache#keyword_filter(copy(list), a:complete_str) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#vim_complete#define() "{{{ |
||||
return s:source |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#vim_complete#get_cur_text() "{{{ |
||||
let cur_text = neocomplcache#get_cur_text(1) |
||||
if &filetype == 'vimshell' && exists('*vimshell#get_secondary_prompt') |
||||
\ && empty(b:vimshell.continuation) |
||||
return cur_text[len(vimshell#get_secondary_prompt()) :] |
||||
endif |
||||
|
||||
let line = line('.') |
||||
let cnt = 0 |
||||
while cur_text =~ '^\s*\\' && line > 1 && cnt < 5 |
||||
let cur_text = getline(line - 1) . |
||||
\ substitute(cur_text, '^\s*\\', '', '') |
||||
let line -= 1 |
||||
let cnt += 1 |
||||
endwhile |
||||
|
||||
return split(cur_text, '\s\+|\s\+\|<bar>', 1)[-1] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#get_command(cur_text) "{{{ |
||||
return matchstr(a:cur_text, '\<\%(\d\+\)\?\zs\h\w*\ze!\?\|'. |
||||
\ '\<\%([[:digit:],[:space:]$''<>]\+\)\?\zs\h\w*\ze/.*') |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
BufNewFile ; starting to edit a file that doesn't exist |
||||
BufReadPre ; starting to edit a new buffer, before reading the file |
||||
BufRead ; starting to edit a new buffer, after reading the file |
||||
BufReadPost ; starting to edit a new buffer, after reading the file |
||||
BufReadCmd ; before starting to edit a new buffer |Cmd-event| |
||||
FileReadPre ; before reading a file with a ":read" command |
||||
FileReadPost ; after reading a file with a ":read" command |
||||
FileReadCmd ; before reading a file with a ":read" command |Cmd-event| |
||||
FilterReadPre ; before reading a file from a filter command |
||||
FilterReadPost ; after reading a file from a filter command |
||||
StdinReadPre ; before reading from stdin into the buffer |
||||
StdinReadPost ; After reading from the stdin into the buffer |
||||
BufWrite ; starting to write the whole buffer to a file |
||||
BufWritePre ; starting to write the whole buffer to a file |
||||
BufWritePost ; after writing the whole buffer to a file |
||||
BufWriteCmd ; before writing the whole buffer to a file |Cmd-event| |
||||
FileWritePre ; starting to write part of a buffer to a file |
||||
FileWritePost ; after writing part of a buffer to a file |
||||
FileWriteCmd ; starting to append to a file |
||||
FileAppendPre ; after appending to a file |
||||
FileAppendPost ; before appending to a file |Cmd-event| |
||||
FileAppendCmd ; starting to write a file for a filter command or diff |
||||
FilterWritePre ; after writing a file for a filter command or diff |
||||
FilterWritePost ; just after adding a buffer to the buffer list |
||||
BufAdd ; just after adding a buffer to the buffer list |
||||
BufCreate ; just after adding a buffer to the buffer list |
||||
BufDelete ; before deleting a buffer from the buffer list |
||||
BufWipeout ; before completely deleting a buffer |
||||
BufFilePre ; before changing the name of the current buffer |
||||
BufFilePost ; after changing the name of the current buffer |
||||
BufEnter ; after entering a buffer |
||||
BufLeave ; before leaving to another buffer |
||||
BufWinEnter ; after a buffer is displayed in a window |
||||
BufWinLeave ; before a buffer is removed from a window |
||||
BufUnload ; before unloading a buffer |
||||
BufHidden ; just after a buffer has become hidden |
||||
BufNew ; just after creating a new buffer |
||||
SwapExists ; detected an existing swap file |
||||
FileType ; when the 'filetype' option has been set |
||||
Syntax ; when the 'syntax' option has been set |
||||
EncodingChanged ; after the 'encoding' option has been changed |
||||
TermChanged ; after the value of 'term' has changed |
||||
VimEnter ; after doing all the startup stuff |
||||
GUIEnter ; after starting the GUI successfully |
||||
TermResponse ; after the terminal response to |t_RV| is received |
||||
VimLeavePre ; before exiting Vim, before writing the viminfo file |
||||
VimLeave ; before exiting Vim, after writing the viminfo file |
||||
FileChangedShell ; Vim notices that a file changed since editing started |
||||
FileChangedShellPost ; After handling a file changed since editing started |
||||
FileChangedRO ; before making the first change to a read-only file |
||||
ShellCmdPost ; after executing a shell command |
||||
ShellFilterPost ; after filtering with a shell command |
||||
FuncUndefined ; a user function is used but it isn't defined |
||||
SpellFileMissing ; a spell file is used but it can't be found |
||||
SourcePre ; before sourcing a Vim script |
||||
SourceCmd ; before sourcing a Vim script |Cmd-event| |
||||
VimResized ; after the Vim window size changed |
||||
FocusGained ; Vim got input focus |
||||
FocusLost ; Vim lost input focus |
||||
CursorHold ; the user doesn't press a key for a while |
||||
CursorHoldI ; the user doesn't press a key for a while in Insert mode |
||||
CursorMoved ; the cursor was moved in Normal mode |
||||
CursorMovedI ; the cursor was moved in Insert mode |
||||
WinEnter ; after entering another window |
||||
WinLeave ; before leaving a window |
||||
TabEnter ; after entering another tab page |
||||
TabLeave ; before leaving a tab page |
||||
CmdwinEnter ; after entering the command-line window |
||||
CmdwinLeave ; before leaving the command-line window |
||||
InsertEnter ; starting Insert mode |
||||
InsertChange ; when typing <Insert> while in Insert or Replace mode |
||||
InsertLeave ; when leaving Insert mode |
||||
ColorScheme ; after loading a color scheme |
||||
CompleteDone ; after Insert mode completion is done |
||||
RemoteReply ; a reply from a server Vim was received |
||||
QuickFixCmdPre ; before a quickfix command is run |
||||
QuickFixCmdPost ; after a quickfix command is run |
||||
SessionLoadPost ; after loading a session file |
||||
MenuPopup ; just before showing the popup menu |
||||
User ; to be used in combination with ":doautocmd" |
||||
<buffer> ; buffer-local autocommands |
||||
<afile> ; for the file name that is being |
||||
<abuf> ; for the buffer name that is being |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
-bang ; the command can take a ! modifier (like :q or :w) |
||||
-bar ; the command can be followed by a "|" and another command |
||||
-buffer ; the command will only be available in the current buffer |
||||
-complete=augroup ; autocmd groups |
||||
-complete=behave ; :behave suboptions |
||||
-complete=buffer ; buffer names |
||||
-complete=color ; color schemes |
||||
-complete=command ; Ex command (and arguments) |
||||
-complete=compiler ; compilers |
||||
-complete=cscope ; :cscope suboptions |
||||
-complete=custom,{func} ; custom completion, defined via {func} |
||||
-complete=customlist,{func} ; custom completion, defined via {func} |
||||
-complete=dir ; directory names |
||||
-complete=environment ; environment variable names |
||||
-complete=event ; autocommand events |
||||
-complete=expression ; Vim expression |
||||
-complete=file ; file and directory names |
||||
-complete=file_in_path ; file and directory names in 'path' |
||||
-complete=filetype ; filetype names 'filetype' |
||||
-complete=function ; function name |
||||
-complete=help ; help subjects |
||||
-complete=highlight ; highlight groups |
||||
-complete=history ; :history suboptions |
||||
-complete=locale ; locale names (as output of locale -a) |
||||
-complete=mapping ; mapping name |
||||
-complete=menu ; menus |
||||
-complete=option ; options |
||||
-complete=shellcmd ; Shell command |
||||
-complete=sign ; :sign suboptions |
||||
-complete=syntax ; syntax file names |'syntax'| |
||||
-complete=tag ; tags |
||||
-complete=tag_list ; tags, file names are shown when CTRL-D is hit |
||||
-complete=tag_listfiles ; tags, file names are shown when CTRL-D is hit |
||||
-complete=var ; user variables |
||||
-count= ; a count (default N) in the line or as an initial argument |
||||
-nargs=* ; any number of arguments are allowed (0, 1, or many) |
||||
-nargs=+ ; arguments must be supplied, but any number are allowed |
||||
-nargs=0 ; no arguments are allowed (the default) |
||||
-nargs=1 ; exactly one argument is required |
||||
-nargs=? ; 0 or 1 arguments are allowed |
||||
-range ; range allowed, default is current line |
||||
-range= ; a count (default N) which is specified in the line |
||||
-range=% ; range allowed, default is whole file (1,$) |
||||
-register ; the first argument to the command can be an optional register name |
@ -0,0 +1,498 @@
@@ -0,0 +1,498 @@
|
||||
N[ext] |
||||
P[rint] |
||||
a[ppend] |
||||
ab[breviate] abbreviation |
||||
abc[lear] |
||||
abo[veleft] command |
||||
al[l] |
||||
am[enu] |
||||
an[oremenu] menu |
||||
ar[gs] file |
||||
arga[dd] file |
||||
argd[elete] file |
||||
argdo command |
||||
arge[dit] file |
||||
argg[lobal] file |
||||
argl[ocal] file |
||||
argu[ment] |
||||
as[cii] |
||||
au[tocmd] autocmd_args |
||||
aug[roup] augroup |
||||
aun[menu] menu |
||||
bN[ext] |
||||
b[uffer] buffer |
||||
ba[ll] |
||||
bad[d] file |
||||
bd[elete] buffer |
||||
be[have] |
||||
bel[owright] command |
||||
bf[irst] |
||||
bl[ast] |
||||
bm[odified] |
||||
bn[ext] |
||||
bo[tright] command |
||||
bp[revious] |
||||
br[ewind] |
||||
brea[k] |
||||
breaka[dd] function |
||||
breakd[el] |
||||
breakl[ist] |
||||
bro[wse] command |
||||
bufdo command |
||||
buffers |
||||
bun[load] buffer |
||||
bw[ipeout] buffer |
||||
cN[ext] |
||||
cNf[ile] |
||||
c[hange] |
||||
ca[bbrev] abbreviation |
||||
cabc[lear] |
||||
cad[dexpr] expression |
||||
caddb[uffer] |
||||
caddf[ile] file |
||||
cal[l] function |
||||
cat[ch] |
||||
cb[uffer] |
||||
cc |
||||
ccl[ose] |
||||
cd dir |
||||
ce[nter] |
||||
cex[pr] expression |
||||
cf[ile] file |
||||
cfir[st] |
||||
cg[etfile] file |
||||
cgetb[uffer] |
||||
cgete[xpr] expression |
||||
changes |
||||
chd[ir] dir |
||||
che[ckpath] |
||||
checkt[ime] |
||||
cl[ist] |
||||
cla[st] |
||||
clo[se] |
||||
cm[ap] mapping |
||||
cmapc[lear] |
||||
cme[nu] menu |
||||
cn[ext] |
||||
cnew[er] |
||||
cnf[ile] |
||||
cno[remap] mapping |
||||
cnorea[bbrev] abbreviation |
||||
cnoreme[nu] menu |
||||
co[py] |
||||
col[der] |
||||
colo[rscheme] colorscheme_args |
||||
com[mand] command_args |
||||
comc[lear] |
||||
comp[iler] compiler_args |
||||
con[tinue] |
||||
conf[irm] command |
||||
cope[n] |
||||
cp[revious] |
||||
cpf[ile] |
||||
cq[uit] |
||||
cr[ewind] |
||||
cs[cope] cscope_args |
||||
cst[ag] |
||||
cu[nmap] mapping |
||||
cuna[bbrev] abbreviation |
||||
cunme[nu] menu |
||||
cw[indow] |
||||
d[elete] |
||||
deb[ug] command |
||||
debugg[reedy] |
||||
del[command] command |
||||
delf[unction] function |
||||
delm[arks] |
||||
di[splay] |
||||
diffg[et] |
||||
diffo[ff] |
||||
diffp[atch] file |
||||
diffpu[t] |
||||
diffs[plit] file |
||||
diffthis |
||||
diffu[pdate] |
||||
dig[raphs] |
||||
dj[ump] |
||||
dl[ist] |
||||
do[autocmd] autocmd_args |
||||
doautoa[ll] autocmd_args |
||||
dr[op] file |
||||
ds[earch] |
||||
dsp[lit] |
||||
e[dit] file |
||||
ea[rlier] |
||||
ec[ho] expression |
||||
echoe[rr] expression |
||||
echoh[l] expression |
||||
echom[sg] expression |
||||
echon expression |
||||
el[se] |
||||
elsei[f] expression |
||||
em[enu] menu |
||||
en[dif] |
||||
endf[unction] |
||||
endfo[r] |
||||
endt[ry] |
||||
endw[hile] |
||||
ene[w] |
||||
ex file |
||||
exe[cute] execute |
||||
exi[t] file |
||||
exu[sage] |
||||
f[ile] |
||||
files |
||||
filet[ype] |
||||
fin[d] file |
||||
fina[lly] |
||||
fini[sh] |
||||
fir[st] |
||||
fix[del] |
||||
fo[ld] |
||||
foldc[lose] |
||||
foldd[oopen] command |
||||
folddoc[losed] command |
||||
foldo[pen] |
||||
for expression |
||||
fu[nction] function_args |
||||
go[to] |
||||
gr[ep] file |
||||
grepa[dd] file |
||||
gu[i] file |
||||
gv[im] file |
||||
h[elp] help |
||||
ha[rdcopy] |
||||
helpf[ind] |
||||
helpg[rep] |
||||
helpt[ags] dir |
||||
hi[ghlight] highlight |
||||
hid[e] command |
||||
his[tory] |
||||
i[nsert] |
||||
ia[bbrev] abbreviation |
||||
iabc[lear] |
||||
if expression |
||||
ij[ump] |
||||
il[ist] |
||||
im[ap] mapping |
||||
imapc[lear] |
||||
imenu menu |
||||
ino[remap] mapping |
||||
inorea[bbrev] mapping |
||||
inoreme[nu] menu |
||||
int[ro] |
||||
is[earch] |
||||
isp[lit] |
||||
iu[nmap] mapping |
||||
iuna[bbrev] abbreviation |
||||
iunme[nu] menu |
||||
j[oin] |
||||
ju[mps] |
||||
kee[pmarks] command |
||||
keep[jumps] command |
||||
keepa[lt] command |
||||
lN[ext] |
||||
lNf[ile] |
||||
l[ist] |
||||
la[st] |
||||
lad[dexpr] expr |
||||
laddb[uffer] |
||||
laddf[ile] file |
||||
lan[guage] language_args |
||||
lat[er] |
||||
lb[uffer] |
||||
lc[d] dir |
||||
lch[dir] dir |
||||
lcl[ose] |
||||
lcs[cope] cscope_args |
||||
le[ft] |
||||
lefta[bove] command |
||||
let let |
||||
lex[pr] expression |
||||
lf[ile] file |
||||
lfir[st] |
||||
lg[etfile] file |
||||
lgetb[uffer] |
||||
lgete[xpr] expression |
||||
lgr[ep] file |
||||
lgrepa[dd] file |
||||
lh[elpgrep] |
||||
ll |
||||
lla[st] |
||||
lli[st] |
||||
lm[ap] mapping |
||||
lmak[e] file |
||||
lmapc[lear] |
||||
ln[oremap] mapping |
||||
lne[xt] |
||||
lnew[er] |
||||
lnf[ile] |
||||
lo[adview] |
||||
loadk[eymap] |
||||
loc[kmarks] command |
||||
lockv[ar] var |
||||
lol[der] |
||||
lop[en] |
||||
lp[revious] |
||||
lpf[ile] |
||||
lr[ewind] |
||||
ls |
||||
lt[ag] |
||||
lu[nmap] mapping |
||||
lua |
||||
luado |
||||
luafile file |
||||
lv[imgrep] file |
||||
lvimgrepadd file |
||||
lwindow |
||||
m[ove] |
||||
ma[rk] |
||||
mak[e] file |
||||
map mapping |
||||
mapc[lear] |
||||
marks |
||||
match |
||||
menu menu |
||||
menut[ranslate] menutranslate_args |
||||
mes[sages] |
||||
mk[exrc] file |
||||
mks[ession] file |
||||
mksp[ell] file |
||||
mkv[imrc] file |
||||
mkvie[w] file |
||||
mod[e] |
||||
mz[scheme] file |
||||
mzf[ile] file |
||||
n[ext] |
||||
nb[key] |
||||
new |
||||
nm[ap] mapping |
||||
nmapc[lear] |
||||
nmenu menu |
||||
nno[remap] mapping |
||||
nnoreme[nu] menu |
||||
no[remap] mapping |
||||
noa[utocmd] command |
||||
noh[lsearch] |
||||
norea[bbrev] abbreviation |
||||
noreme[nu] menu |
||||
norm[al] |
||||
nu[mber] |
||||
nun[map] mapping |
||||
nunme[nu] menu |
||||
o[pen] |
||||
ol[dfiles] |
||||
om[ap] mapping |
||||
omapc[lear] |
||||
ome[nu] menu |
||||
on[ly] |
||||
ono[remap] mapping |
||||
onoreme[nu] menu |
||||
opt[ions] |
||||
ou[nmap] lhs |
||||
ounmenu menu |
||||
ownsyntax syntax_args |
||||
p[rint] |
||||
pc[lose] |
||||
pe[rl] |
||||
ped[it] file |
||||
perld[o] |
||||
po[p] |
||||
popu[p] |
||||
pp[op] |
||||
pre[serve] |
||||
prev[ious] |
||||
prof[ile] profile_args |
||||
profd[el] |
||||
promptf[ind] |
||||
promptr[epl] |
||||
ps[earch] |
||||
ptN[ext] |
||||
pta[g] tag |
||||
ptf[irst] |
||||
ptj[ump] |
||||
ptl[ast] |
||||
ptn[ext] |
||||
ptp[revious] |
||||
ptr[ewind] |
||||
pts[elect] tag |
||||
pu[t] |
||||
pw[d] |
||||
py3f[ile] file |
||||
py[thon] |
||||
pyf[ile] file |
||||
python3 |
||||
q[uit] |
||||
qa[ll] |
||||
quita[ll] |
||||
r[ead] |
||||
rec[over] file |
||||
red[o] |
||||
redi[r] |
||||
redr[aw] |
||||
redraws[tatus] |
||||
reg[isters] |
||||
res[ize] |
||||
ret[ab] |
||||
retu[rn] expression |
||||
rew[ind] |
||||
ri[ght] |
||||
rightb[elow] command |
||||
rub[y] |
||||
rubyd[o] |
||||
rubyf[ile] file |
||||
runtime file |
||||
rv[iminfo] file |
||||
sN[ext] |
||||
s[ubstitute] |
||||
sa[rgument] |
||||
sal[l] |
||||
san[dbox] command |
||||
sav[eas] file |
||||
sbN[ext] |
||||
sb[uffer] buffer |
||||
sba[ll] |
||||
sbf[irst] |
||||
sbl[ast] |
||||
sbm[odified] |
||||
sbn[ext] |
||||
sbp[revious] |
||||
sbr[ewind] |
||||
scrip[tnames] |
||||
scripte[ncoding] encoding |
||||
scscope cscope_args |
||||
se[t] option |
||||
setf[iletype] filetype |
||||
setg[lobal] option |
||||
setl[ocal] option |
||||
sf[ind] file |
||||
sfir[st] |
||||
sh[ell] |
||||
sig[n] sign_args |
||||
sil[ent] command |
||||
sim[alt] |
||||
sl[eep] |
||||
sla[st] |
||||
sm[agic] |
||||
sm[ap] mapping |
||||
smapc[lear] |
||||
sme[nu] menu |
||||
sn[ext] file |
||||
sni[ff] |
||||
sno[remap] mapping |
||||
snoreme[nu] menu |
||||
so[urce] file |
||||
sor[t] |
||||
sp[lit] |
||||
spe[llgood] |
||||
spelld[ump] |
||||
spelli[nfo] |
||||
spellr[epall] |
||||
spellu[ndo] |
||||
spellw[rong] |
||||
spr[evious] |
||||
sre[wind] |
||||
st[op] |
||||
sta[g] tag |
||||
star[tinsert] |
||||
startg[replace] |
||||
startr[eplace] |
||||
stj[ump] tag |
||||
stopi[nsert] |
||||
sts[elect] tag |
||||
sun[hide] |
||||
sunm[ap] mapping |
||||
sunme[nu] menu |
||||
sus[pend] |
||||
sv[iew] file |
||||
sw[apname] |
||||
sy[ntax] syntax_args |
||||
sync[bind] |
||||
t |
||||
tN[ext] |
||||
ta[g] tag |
||||
tab command |
||||
tabN[ext] |
||||
tabc[lose] |
||||
tabd[o] command |
||||
tabe[dit] file |
||||
tabf[ind] file |
||||
tabfir[st] |
||||
tabl[ast] |
||||
tabm[ove] |
||||
tabn[ext] |
||||
tabnew file |
||||
tabo[nly] |
||||
tabp[revious] |
||||
tabr[ewind] |
||||
tabs |
||||
tags |
||||
tc[l] |
||||
tcld[o] |
||||
tclf[ile] file |
||||
te[aroff] menu |
||||
tf[irst] |
||||
th[row] expression |
||||
tj[ump] tag |
||||
tl[ast] |
||||
tm[enu] menu |
||||
tn[ext] |
||||
to[pleft] command |
||||
tp[revious] |
||||
tr[ewind] |
||||
try |
||||
tselect |
||||
tu[nmenu] menu |
||||
u[ndo] |
||||
una[bbreviate] abbreviation |
||||
undoj[oin] |
||||
undol[ist] |
||||
unh[ide] |
||||
unl[et] var |
||||
unlo[ckvar] var |
||||
unm[ap] mapping |
||||
unme[nu] menu |
||||
uns[ilent] command |
||||
up[date] file |
||||
ve[rsion] |
||||
verb[ose] command |
||||
vert[ical] command |
||||
vg[lobal] |
||||
vi[sual] file |
||||
vie[w] file |
||||
vim[grep] file |
||||
vimgrepa[dd] file |
||||
viu[sage] |
||||
vm[ap] mapping |
||||
vmapc[lear] |
||||
vmenu menu |
||||
vn[oremap] mapping |
||||
vne[w] file |
||||
vnoremenu menu |
||||
vsp[lit] file |
||||
vu[nmap] mapping |
||||
vunmenu menu |
||||
wN[ext] file |
||||
w[rite] file |
||||
wa[ll] |
||||
wh[ile] expression |
||||
win[size] |
||||
winc[md] |
||||
windo command |
||||
winp[os] |
||||
wn[ext] |
||||
wp[revious] file |
||||
wq |
||||
wqa[ll] |
||||
ws[verb] |
||||
wv[iminfo] file |
||||
x[it] file |
||||
xa[ll] |
||||
xm[ap] mapping |
||||
xmapc[lear] |
||||
xmenu menu |
||||
xn[oremap] mapping |
||||
xnoremenu menu |
||||
xu[nmap] mapping |
||||
xunmenu menu |
||||
y[ank] |
@ -0,0 +1,498 @@
@@ -0,0 +1,498 @@
|
||||
N[ext] [count] [++opt] [+cmd] |
||||
P[rint] [count] [flags] |
||||
a[ppend] |
||||
ab[breviate] |
||||
abc[lear] |
||||
abo[veleft] {cmd} |
||||
al[l] [N] |
||||
am[enu] |
||||
an[oremenu] {menu} |
||||
ar[gs] |
||||
arga[dd] {name} .. |
||||
argd[elete] {pattern} .. |
||||
argdo {cmd} |
||||
arge[dit] [++opt] [+cmd] {name} |
||||
argg[lobal] [++opt] [+cmd] {arglist} |
||||
argl[ocal] [++opt] [+cmd] {arglist} |
||||
argu[ment] [count] [++opt] [+cmd] |
||||
as[cii] |
||||
au[tocmd] [group] {event} {pat} [nested] {cmd} |
||||
aug[roup] {name} |
||||
aun[menu] {menu} |
||||
bN[ext] [N] |
||||
b[uffer] {bufname} |
||||
ba[ll] [N] |
||||
bad[d] [+lnum] {fname} |
||||
bd[elete] {bufname} |
||||
be[have] {model} |
||||
bel[owright] {cmd} |
||||
bf[irst] |
||||
bl[ast] |
||||
bm[odified] [N] |
||||
bn[ext] [N] |
||||
bo[tright] {cmd} |
||||
bp[revious] [N] |
||||
br[ewind] |
||||
brea[k] |
||||
breaka[dd] func [lnum] {name} |
||||
breakd[el] {nr} |
||||
breakl[ist] |
||||
bro[wse] {command} |
||||
bufdo {cmd} |
||||
buffers |
||||
bun[load] {bufname} |
||||
bw[ipeout] {bufname} |
||||
cN[ext] |
||||
cNf[ile] |
||||
c[hange] |
||||
ca[bbrev] [<expr>] [lhs] [rhs] |
||||
cabc[lear] |
||||
cad[dexpr] {expr} |
||||
caddb[uffer] [bufnr] |
||||
caddf[ile] [errorfile] |
||||
cal[l] {name}([arguments]) |
||||
cat[ch] /{pattern}/ |
||||
cb[uffer] [bufnr] |
||||
cc [nr] |
||||
ccl[ose] |
||||
cd {path} |
||||
ce[nter] [width] |
||||
cex[pr] {expr} |
||||
cf[ile] [errorfile] |
||||
cfir[st] [nr] |
||||
cg[etfile] [errorfile] |
||||
cgetb[uffer] [bufnr] |
||||
cgete[xpr] {expr} |
||||
changes |
||||
chd[ir] [path] |
||||
che[ckpath] |
||||
checkt[ime] |
||||
cl[ist] [from] [, [to]] |
||||
cla[st] [nr] |
||||
clo[se] |
||||
cm[ap] {lhs} {rhs} |
||||
cmapc[lear] |
||||
cme[nu] {menu} |
||||
cn[ext] |
||||
cnew[er] [count] |
||||
cnf[ile] |
||||
cno[remap] {lhs} {rhs} |
||||
cnorea[bbrev] [<expr>] [lhs] [rhs] |
||||
cnoreme[nu] {menu} |
||||
co[py] {address} |
||||
col[der] [count] |
||||
colo[rscheme] {name} |
||||
com[mand] [-bang -complete= -nargs=...] {cmdname} {call function(<args>)} | {rep} |
||||
comc[lear] |
||||
comp[iler] {name} |
||||
con[tinue] |
||||
conf[irm] {command} |
||||
cope[n] [height] |
||||
cp[revious] |
||||
cpf[ile] |
||||
cq[uit] |
||||
cr[ewind] [nr] |
||||
cs[cope] add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show |
||||
cst[ag] |
||||
cu[nmap] {lhs} |
||||
cuna[bbrev] {lhs} |
||||
cunme[nu] {menu} |
||||
cw[indow] [height] |
||||
d[elete] [x] |
||||
deb[ug] {cmd} |
||||
debugg[reedy] |
||||
del[command] {cmd} |
||||
delf[unction] {name} |
||||
delm[arks] {marks} |
||||
di[splay] [arg] |
||||
diffg[et] [bufspec] |
||||
diffo[ff] |
||||
diffp[atch] {patchfile} |
||||
diffpu[t] [bufspec] |
||||
diffs[plit] {filename} |
||||
diffthis |
||||
diffu[pdate] |
||||
dig[raphs] {char1}{char2} {number} ... |
||||
dj[ump] [count] [/]string[/] |
||||
dl[ist] [/]string[/] |
||||
do[autocmd] [group] {event} [fname] |
||||
doautoa[ll] [group] {event} [fname] |
||||
dr[op] [++opt] [+cmd] {file} .. |
||||
ds[earch] [count] [/]string[/] |
||||
dsp[lit] [count] [/]string[/] |
||||
e[dit] [++opt] [+cmd] {file} |
||||
ea[rlier] {count} | {N}s | {N}h |
||||
ec[ho] {expr1} .. |
||||
echoe[rr] {expr1} .. |
||||
echoh[l] {expr1} .. |
||||
echom[sg] {expr1} .. |
||||
echon {expr1} .. |
||||
el[se] |
||||
elsei[f] {expr1} |
||||
em[enu] {menu} |
||||
en[dif] |
||||
endf[unction] |
||||
endfo[r] |
||||
endt[ry] |
||||
endw[hile] |
||||
ene[w] |
||||
ex [++opt] [+cmd] [file] |
||||
exe[cute] {expr1} .. |
||||
exi[t] [++opt] [file] |
||||
exu[sage] |
||||
f[ile] |
||||
files |
||||
filet[ype] |
||||
fin[d] [++opt] [+cmd] {file} |
||||
fina[lly] |
||||
fini[sh] |
||||
fir[st] [++opt] [+cmd] |
||||
fix[del] |
||||
fo[ld] |
||||
foldc[lose] |
||||
foldd[oopen] {cmd} |
||||
folddoc[losed] {cmd} |
||||
foldo[pen] |
||||
for {var} in {list} |
||||
fu[nction] {name}([arguments]) [range] [abort] [dict] |
||||
go[to] [count] |
||||
gr[ep] [arguments] |
||||
grepa[dd] [arguments] |
||||
gu[i] [++opt] [+cmd] [-f|-b] [files...] |
||||
gv[im] [++opt] [+cmd] [-f|-b] [files...] |
||||
h[elp] {subject} |
||||
ha[rdcopy] [arguments] |
||||
helpf[ind] |
||||
helpg[rep] {pattern}[@xx] |
||||
helpt[ags] [++t] {dir} |
||||
hi[ghlight] [default] {group-name} {key}={arg} .. |
||||
hid[e] {cmd} |
||||
his[tory] [{name}] [{first}][, [{last}]] |
||||
i[nsert] |
||||
ia[bbrev] [<expr>] [lhs] [rhs] |
||||
iabc[lear] |
||||
if {expr1} |
||||
ij[ump] [count] [/]pattern[/] |
||||
il[ist] [/]pattern[/] |
||||
im[ap] {lhs} {rhs} |
||||
imapc[lear] |
||||
imenu {menu} |
||||
ino[remap] {lhs} {rhs} |
||||
inorea[bbrev] [<expr>] [lhs] [rhs] |
||||
inoreme[nu] {menu} |
||||
int[ro] |
||||
is[earch] [count] [/]pattern[/] |
||||
isp[lit] [count] [/]pattern[/] |
||||
iu[nmap] {lhs} |
||||
iuna[bbrev] {lhs} |
||||
iunme[nu] {menu} |
||||
j[oin] {count} [flags] |
||||
ju[mps] |
||||
kee[pmarks] {command} |
||||
keep[jumps] {command} |
||||
keepa[lt] {cmd} |
||||
lN[ext] |
||||
lNf[ile] |
||||
l[ist] [count] [flags] |
||||
la[st] [++opt] [+cmd] |
||||
lad[dexpr] {expr} |
||||
laddb[uffer] [bufnr] |
||||
laddf[ile] [errorfile] |
||||
lan[guage] {name} | mes[sages] {name} | cty[pe] {name} | tim[e] {name} |
||||
lat[er] {count} | {N}s | {N}m | {N}h |
||||
lb[uffer] [bufnr] |
||||
lc[d] {path} |
||||
lch[dir] {path} |
||||
lcl[ose] |
||||
lcs[cope] add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show |
||||
le[ft] [indent] |
||||
lefta[bove] {cmd} |
||||
let {var-name} = {expr1} |
||||
lex[pr] {expr} |
||||
lf[ile] [errorfile] |
||||
lfir[st] [nr] |
||||
lg[etfile] [errorfile] |
||||
lgetb[uffer] [bufnr] |
||||
lgete[xpr] {expr} |
||||
lgr[ep] [arguments] |
||||
lgrepa[dd] [arguments] |
||||
lh[elpgrep] {pattern}[@xx] |
||||
ll [nr] |
||||
lla[st] [nr] |
||||
lli[st] [from] [, [to]] |
||||
lm[ap] {lhs} {rhs} |
||||
lmak[e] [arguments] |
||||
lmapc[lear] |
||||
ln[oremap] {lhs} {rhs} |
||||
lne[xt] |
||||
lnew[er] [count] |
||||
lnf[ile] |
||||
lo[adview] [nr] |
||||
loadk[eymap] |
||||
loc[kmarks] {command} |
||||
lockv[ar] [depth] {name} ... |
||||
lol[der] [count] |
||||
lop[en] [height] |
||||
lp[revious] |
||||
lpf[ile] |
||||
lr[ewind] [nr] |
||||
ls |
||||
lt[ag] [ident] |
||||
lua {chunk} | << {endmarker} |
||||
luado {body} |
||||
luafile {file} |
||||
lu[nmap] {lhs} |
||||
lv[imgrep] /{pattern}/[g][j] {file} ... | {pattern} {file} ... |
||||
lvimgrepadd /{pattern}/[g][j] {file} ... | {pattern} {file} ... |
||||
lwindow [height] |
||||
m[ove] {address} |
||||
ma[rk] {a-zA-z'} |
||||
mak[e] [arguments] |
||||
map {lhs} {rhs} |
||||
mapc[lear] |
||||
marks |
||||
match {group} /{pattern}/ |
||||
menu {menu} |
||||
menut[ranslate] clear | {english} {mylang} |
||||
mes[sages] |
||||
mk[exrc] [file] |
||||
mks[ession] [file] |
||||
mksp[ell] [-ascii] {outname} {inname} ... |
||||
mkv[imrc] [file] |
||||
mkvie[w] [file] |
||||
mod[e] [mode] |
||||
mz[scheme] {stmt} | << {endmarker} {script} {endmarker} | {file} |
||||
mzf[ile] {file} |
||||
n[ext] [++opt] [+cmd] |
||||
nb[key] key |
||||
new |
||||
nm[ap] {lhs} {rhs} |
||||
nmapc[lear] |
||||
nmenu {menu} |
||||
nno[remap] {lhs} {rhs} |
||||
nnoreme[nu] {menu} |
||||
no[remap] {lhs} {rhs} |
||||
noa[utocmd] {cmd} |
||||
noh[lsearch] |
||||
norea[bbrev] [<expr>] [lhs] [rhs] |
||||
noreme[nu] {menu} |
||||
norm[al] {commands} |
||||
nu[mber] [count] [flags] |
||||
nun[map] {lhs} |
||||
nunme[nu] {menu} |
||||
o[pen] /pattern/ |
||||
ol[dfiles] |
||||
om[ap] {lhs} {rhs} |
||||
omapc[lear] |
||||
ome[nu] {menu} |
||||
on[ly] |
||||
ono[remap] {lhs} {rhs} |
||||
onoreme[nu] {menu} |
||||
opt[ions] |
||||
ou[nmap] {lhs} |
||||
ounmenu {menu} |
||||
ownsyntax list {group-name} | list @{cluster-name} |
||||
p[rint] {count} [flags] |
||||
pc[lose] |
||||
pe[rl] {cmd} | << {endpattern} {script} {endpattern} |
||||
ped[it] [++opt] [+cmd] {file} |
||||
perld[o] {cmd} |
||||
po[p] |
||||
popu[p] {name} |
||||
pp[op] |
||||
pre[serve] |
||||
prev[ious] [count] [++opt] [+cmd] |
||||
prof[ile] start {fname} | pause | continue | func {pattern} | file {pattern} |
||||
profd[el] ... |
||||
promptf[ind] [string] |
||||
promptr[epl] [string] |
||||
ps[earch] [count] [/]pattern[/] |
||||
ptN[ext] |
||||
pta[g] [tagname] |
||||
ptf[irst] |
||||
ptj[ump] |
||||
ptl[ast] |
||||
ptn[ext] |
||||
ptp[revious] |
||||
ptr[ewind] |
||||
pts[elect] [ident] |
||||
pu[t] [x] |
||||
pw[d] |
||||
py[thon] {stmt} | << {endmarker} {script} {endmarker} |
||||
python3 {stmt} | << {endmarker} {script} {endmarker} |
||||
pyf[ile] {file} |
||||
py3f[ile] {file} |
||||
q[uit] |
||||
qa[ll] |
||||
quita[ll] |
||||
r[ead] [++opt] [name] |
||||
rec[over] [file] |
||||
red[o] |
||||
redi[r] > {file} | >> {file} | @{a-zA-Z} | => {var} | END |
||||
redr[aw] |
||||
redraws[tatus] |
||||
reg[isters] {arg} |
||||
res[ize] |
||||
ret[ab] [new_tabstop] |
||||
retu[rn] [expr] |
||||
rew[ind] [++opt] [+cmd] |
||||
ri[ght] [width] |
||||
rightb[elow] {cmd} |
||||
rub[y] {cmd} | << {endpattern} {script} {endpattern} |
||||
rubyd[o] {cmd} |
||||
rubyf[ile] {file} |
||||
runtime {file} .. |
||||
rv[iminfo] [file] |
||||
sN[ext] [++opt] [+cmd] [N] |
||||
s[ubstitute] /{pattern}/{string}/[flags] [count] |
||||
sa[rgument] [++opt] [+cmd] [N] |
||||
sal[l] |
||||
san[dbox] {cmd} |
||||
sav[eas] [++opt] {file} |
||||
sbN[ext] [N] |
||||
sb[uffer] {bufname} |
||||
sba[ll] [N] |
||||
sbf[irst] |
||||
sbl[ast] |
||||
sbm[odified] [N] |
||||
sbn[ext] [N] |
||||
sbp[revious] [N] |
||||
sbr[ewind] |
||||
scrip[tnames] |
||||
scripte[ncoding] [encoging] |
||||
scscope add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show |
||||
se[t] {option}={value} {option}? | {option} | {option}& |
||||
setf[iletype] {filetype} |
||||
setg[lobal] ... |
||||
setl[ocal] ... |
||||
sf[ind] [++opt] [+cmd] {file} |
||||
sfir[st] [++opt] [+cmd] |
||||
sh[ell] |
||||
sig[n] define {name} {argument}... | icon={pixmap} | linehl={group} | text={text} | texthl={group} |
||||
sil[ent] {command} |
||||
sim[alt] {key} |
||||
sl[eep] [N] [m] |
||||
sla[st] [++opt] [+cmd] |
||||
sm[agic] ... |
||||
sm[ap] {lhs} {rhs} |
||||
smapc[lear] |
||||
sme[nu] {menu} |
||||
sn[ext] [++opt] [+cmd] [file ..] |
||||
sni[ff] request [symbol] |
||||
sno[remap] {lhs} {rhs} |
||||
snoreme[nu] {menu} |
||||
so[urce] {file} |
||||
sor[t] [i][u][r][n][x][o] [/{pattern}/] |
||||
sp[lit] [++opt] [+cmd] |
||||
spe[llgood] {word} |
||||
spelld[ump] |
||||
spelli[nfo] |
||||
spellr[epall] |
||||
spellu[ndo] {word} |
||||
spellw[rong] {word} |
||||
spr[evious] [++opt] [+cmd] [N] |
||||
sre[wind] [++opt] [+cmd] |
||||
st[op] |
||||
sta[g] [tagname] |
||||
star[tinsert] |
||||
startg[replace] |
||||
startr[eplace] |
||||
stj[ump] [ident] |
||||
stopi[nsert] |
||||
sts[elect] [ident] |
||||
sun[hide] [N] |
||||
sunm[ap] {lhs} |
||||
sunme[nu] {menu} |
||||
sus[pend] |
||||
sv[iew] [++opt] [+cmd] {file} |
||||
sw[apname] |
||||
sy[ntax] list {group-name} | list @{cluster-name} |
||||
sync[bind] |
||||
t |
||||
tN[ext] |
||||
ta[g] {ident} |
||||
tab {cmd} |
||||
tabN[ext] |
||||
tabc[lose] |
||||
tabd[o] {cmd} |
||||
tabe[dit] [++opt] [+cmd] {file} |
||||
tabf[ind] [++opt] [+cmd] {file} |
||||
tabfir[st] |
||||
tabl[ast] |
||||
tabm[ove] [N] |
||||
tabn[ext] |
||||
tabnew [++opt] [+cmd] {file} |
||||
tabo[nly] |
||||
tabp[revious] |
||||
tabr[ewind] |
||||
tabs |
||||
tags |
||||
tc[l] {cmd} | {endmarker} {script} {endmarker} |
||||
tcld[o] {cmd} |
||||
tclf[ile] {file} |
||||
te[aroff] {name} |
||||
tf[irst] |
||||
th[row] {expr1} |
||||
tj[ump] [ident] |
||||
tl[ast] |
||||
tm[enu] {menu} |
||||
tn[ext] |
||||
to[pleft] {cmd} |
||||
tp[revious] |
||||
tr[ewind] |
||||
try |
||||
tselect |
||||
tu[nmenu] {menu} |
||||
u[ndo] {N} |
||||
una[bbreviate] {lhs} |
||||
undoj[oin] |
||||
undol[ist] |
||||
unh[ide] [N] |
||||
unl[et] {name} ... |
||||
unlo[ckvar] [depth] {name} ... |
||||
unm[ap] {lhs} |
||||
unme[nu] {menu} |
||||
uns[ilent] {command} |
||||
up[date] [++opt] [>>] [file] |
||||
ve[rsion] |
||||
verb[ose] {command} |
||||
vert[ical] {cmd} |
||||
vg[lobal] /{pattern}/[cmd] |
||||
vi[sual] [++opt] [+cmd] [file] |
||||
vie[w] [++opt] [+cmd] file |
||||
vim[grep] /{pattern}/[g][j] {file} ... | {pattern} {file} ... |
||||
vimgrepa[dd] /{pattern}/[g][j] {file} ... | {pattern} {file} ... |
||||
viu[sage] |
||||
vm[ap] {lhs} {rhs} |
||||
vmapc[lear] |
||||
vmenu {menu} |
||||
vn[oremap] {lhs} {rhs} |
||||
vne[w] [++opt] [+cmd] [file] |
||||
vnoremenu {menu} |
||||
vsp[lit] [++opt] [+cmd] [file] |
||||
vu[nmap] {lhs} |
||||
vunmenu {menu} |
||||
wN[ext] [++opt] [file] |
||||
w[rite] [++opt] [file] |
||||
wa[ll] |
||||
wh[ile] {expr1} |
||||
win[size] {width} {height} |
||||
winc[md] {arg} |
||||
windo {cmd} |
||||
winp[os] {X} {Y} |
||||
wn[ext] [++opt] |
||||
wp[revious] [++opt] [file] |
||||
wq [++opt] |
||||
wqa[ll] [++opt] |
||||
ws[verb] verb |
||||
wv[iminfo] [file] |
||||
x[it] [++opt] [file] |
||||
xa[ll] [++opt] |
||||
xm[ap] {lhs} {rhs} |
||||
xmapc[lear] |
||||
xmenu {menu} |
||||
xn[oremap] {lhs} {rhs} |
||||
xnoremenu {menu} |
||||
xu[nmap] {lhs} |
||||
xunmenu {menu} |
||||
y[ank] [x] {count} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<line1> ; the starting line of the command range |
||||
<line2> ; the final line of the command range |
||||
<count> ; any count supplied (as described for the '-range' and '-count' attributes) |
||||
<bang> ; expands to a ! if the command was executed with a ! modifier |
||||
<reg> ; the optional register, if specified |
||||
<args> ; the command arguments, exactly as supplied |
||||
<lt> ; a single '<' (Less-Than) character |
||||
<q-args> ; the value is quoted in such a way as to make it a valid value for use in an expression |
||||
<f-args> ; splits the command arguments at spaces and tabs, quotes each argument individually |
||||
<sid> ; defining a user command in a script |
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
Next ; go to previous file in the argument list |
||||
Print ; print lines |
||||
abbreviate ; enter abbreviation |
||||
abclear ; remove all abbreviations |
||||
aboveleft ; make split window appear left or above |
||||
all ; open a window for each file in the argument list |
||||
amenu ; enter new menu item for all modes |
||||
anoremenu ; enter a new menu for all modes that will not be remapped |
||||
append ; append text |
||||
argadd ; add items to the argument list |
||||
argdelete ; delete items from the argument list |
||||
argdo ; do a command on all items in the argument list |
||||
argedit ; add item to the argument list and edit it |
||||
argglobal ; define the global argument list |
||||
arglocal ; define a local argument list |
||||
args ; print the argument list |
||||
argument ; go to specific file in the argument list |
||||
ascii ; print ascii value of character under the cursor |
||||
augroup ; select the autocommand group to use |
||||
aunmenu ; remove menu for all modes |
||||
autocmd ; enter or show autocommands |
||||
bNext ; go to previous buffer in the buffer list |
||||
badd ; add buffer to the buffer list |
||||
ball ; open a window for each buffer in the buffer list |
||||
bdelete ; remove a buffer from the buffer list |
||||
behave ; set mouse and selection behavior |
||||
belowright ; make split window appear right or below |
||||
bfirst ; go to first buffer in the buffer list |
||||
blast ; go to last buffer in the buffer list |
||||
bmodified ; go to next buffer in the buffer list that has been modified |
||||
bnext ; go to next buffer in the buffer list |
||||
botright ; make split window appear at bottom or far right |
||||
bprevious ; go to previous buffer in the buffer list |
||||
break ; break out of while loop |
||||
breakadd ; add a debugger breakpoint |
||||
breakdel ; delete a debugger breakpoint |
||||
breaklist ; list debugger breakpoints |
||||
brewind ; go to first buffer in the buffer list |
||||
browse ; use file selection dialog |
||||
bufdo ; execute command in each listed buffer |
||||
buffer ; go to specific buffer in the buffer list |
||||
buffers ; list all files in the buffer list |
||||
bunload ; unload a specific buffer |
||||
bwipeout ; really delete a buffer |
||||
cNext ; go to previous error |
||||
cNfile ; go to last error in previous file |
||||
cabbrev ; like "abbreviate" but for Command-line mode |
||||
cabclear ; clear all abbreviations for Command-line mode |
||||
caddbuffer ; add errors from buffer |
||||
caddexpr ; add errors from expr |
||||
caddfile ; add error message to current quickfix list |
||||
call ; call a function |
||||
catch ; part of a try command |
||||
cbuffer ; parse error messages and jump to first error |
||||
cclose ; close quickfix window |
||||
center ; format lines at the center |
||||
cexpr ; read errors from expr and jump to first |
||||
cfile ; read file with error messages and jump to first |
||||
cfirst ; go to the specified error, default first one |
||||
cgetbuffer ; get errors from buffer |
||||
cgetexpr ; get errors from expr |
||||
cgetfile ; read file with error messages |
||||
change ; replace a line or series of lines |
||||
changes ; print the change list |
||||
chdir ; change directory |
||||
checkpath ; list included files |
||||
checktime ; check timestamp of loaded buffers |
||||
clast ; go to the specified error, default last one |
||||
clist ; list all errors |
||||
close ; close current window |
||||
cmap ; like "map" but for Command-line mode |
||||
cmapclear ; clear all mappings for Command-line mode |
||||
cmenu ; add menu for Command-line mode |
||||
cnewer ; go to newer error list |
||||
cnext ; go to next error |
||||
cnfile ; go to first error in next file |
||||
cnoreabbrev ; like "noreabbrev" but for Command-line mode |
||||
cnoremap ; like "noremap" but for Command-line mode |
||||
cnoremenu ; like "noremenu" but for Command-line mode |
||||
colder ; go to older error list |
||||
colorscheme ; load a specific color scheme |
||||
comclear ; clear all user-defined commands |
||||
command ; create user-defined command |
||||
compiler ; do settings for a specific compiler |
||||
confirm ; prompt user when confirmation required |
||||
continue ; go back to while |
||||
copen ; open quickfix window |
||||
copy ; copy lines |
||||
cpfile ; go to last error in previous file |
||||
cprevious ; go to previous error |
||||
cquit ; quit Vim with an error code |
||||
crewind ; go to the specified error, default first one |
||||
cscope ; execute cscope command |
||||
cstag ; use cscope to jump to a tag |
||||
cunabbrev ; like "unabbrev" but for Command-line mode |
||||
cunmap ; like "unmap" but for Command-line mode |
||||
cunmenu ; remove menu for Command-line mode |
||||
cwindow ; open or close quickfix window |
||||
debug ; run a command in debugging mode |
||||
debuggreedy ; read debug mode commands from normal input |
||||
delcommand ; delete user-defined command |
||||
delete ; delete lines |
||||
delfunction ; delete a user function |
||||
delmarks ; delete marks |
||||
diffget ; remove differences in current buffer |
||||
diffoff ; switch off diff mode |
||||
diffpatch ; apply a patch and show differences |
||||
diffput ; remove differences in other buffer |
||||
diffsplit ; show differences with another file |
||||
diffthis ; make current window a diff window |
||||
diffupdate ; update 'diff' buffers |
||||
digraphs ; show or enter digraphs |
||||
display ; display registers |
||||
djump ; jump to #define |
||||
dlist ; list #defines |
||||
doautoall ; apply autocommands for all loaded buffers |
||||
doautocmd ; apply autocommands to current buffer |
||||
drop ; jump to window editing file or edit file in current window |
||||
dsearch ; list one #define |
||||
dsplit ; split window and jump to #define |
||||
earlier ; go to older change, undo |
||||
echo ; echoes the result of expressions |
||||
echoerr ; like echo, show like an error and use history |
||||
echohl ; set highlighting for echo commands |
||||
echomsg ; same as echo, put message in history |
||||
echon ; same as echo, but without <EOL> |
||||
edit ; edit a file |
||||
else ; part of an if command |
||||
elseif ; part of an if command |
||||
emenu ; execute a menu by name |
||||
endfor ; end previous for |
||||
endfunction ; end of a user function |
||||
endif ; end previous if |
||||
endtry ; end previous try |
||||
endwhile ; end previous while |
||||
enew ; edit a new, unnamed buffer |
||||
execute ; execute result of expressions |
||||
exit ; same as "xit" |
||||
exusage ; overview of Ex commands |
||||
file ; show or set the current file name |
||||
files ; list all files in the buffer list |
||||
filetype ; switch file type detection on/off |
||||
finally ; part of a try command |
||||
find ; find file in 'path' and edit it |
||||
finish ; quit sourcing a Vim script |
||||
first ; go to the first file in the argument list |
||||
fixdel ; set key code of <Del> |
||||
fold ; create a fold |
||||
foldclose ; close folds |
||||
folddoclosed ; execute command on lines in a closed fold |
||||
folddoopen ; execute command on lines not in a closed fold |
||||
foldopen ; open folds |
||||
for ; for loop |
||||
function ; define a user function |
||||
global ; execute commands for matching lines |
||||
goto ; go to byte in the buffer |
||||
grep ; run 'grepprg' and jump to first match |
||||
grepadd ; like grep, but append to current list |
||||
gui ; start the GUI |
||||
gvim ; start the GUI |
||||
hardcopy ; send text to the printer |
||||
help ; open a help window |
||||
helpfind ; dialog to open a help window |
||||
helpgrep ; like "grep" but searches help files |
||||
helptags ; generate help tags for a directory |
||||
hide ; hide current buffer for a command |
||||
highlight ; specify highlighting methods |
||||
history ; print a history list |
||||
iabbrev ; like "abbrev" but for Insert mode |
||||
iabclear ; like "abclear" but for Insert mode |
||||
ijump ; jump to definition of identifier |
||||
ilist ; list lines where identifier matches |
||||
imap ; like "map" but for Insert mode |
||||
imapclear ; like "mapclear" but for Insert mode |
||||
imenu ; add menu for Insert mode |
||||
inoreabbrev ; like "noreabbrev" but for Insert mode |
||||
inoremap ; like "noremap" but for Insert mode |
||||
inoremenu ; like "noremenu" but for Insert mode |
||||
insert ; insert text |
||||
intro ; print the introductory message |
||||
isearch ; list one line where identifier matches |
||||
isplit ; split window and jump to definition of identifier |
||||
iunabbrev ; like "unabbrev" but for Insert mode |
||||
iunmap ; like "unmap" but for Insert mode |
||||
iunmenu ; remove menu for Insert mode |
||||
join ; join lines |
||||
jumps ; print the jump list |
||||
keepalt ; following command keeps the alternate file |
||||
keepjumps ; following command keeps jumplist and marks |
||||
keepmarks ; following command keeps marks where they are |
||||
lNext ; go to previous entry in location list |
||||
lNfile ; go to last entry in previous file |
||||
laddbuffer ; add locations from buffer |
||||
laddexpr ; add locations from expr |
||||
laddfile ; add locations to current location list |
||||
language ; set the language (locale) |
||||
last ; go to the last file in the argument list |
||||
later ; go to newer change, redo |
||||
lbuffer ; parse locations and jump to first location |
||||
lcd ; change directory locally |
||||
lchdir ; change directory locally |
||||
lclose ; close location window |
||||
lcscope ; like "cscope" but uses location list |
||||
left ; left align lines |
||||
leftabove ; make split window appear left or above |
||||
let ; assign a value to a variable or option |
||||
lexpr ; read locations from expr and jump to first |
||||
lfile ; read file with locations and jump to first |
||||
lfirst ; go to the specified location, default first one |
||||
lgetbuffer ; get locations from buffer |
||||
lgetexpr ; get locations from expr |
||||
lgetfile ; read file with locations |
||||
lgrep ; run 'grepprg' and jump to first match |
||||
lgrepadd ; like grep, but append to current list |
||||
lhelpgrep ; like "helpgrep" but uses location list |
||||
list ; print lines |
||||
llast ; go to the specified location, default last one |
||||
llist ; list all locations |
||||
lmake ; execute external command 'makeprg' and parse error messages |
||||
lmap ; like "map!" but includes Lang-Arg mode |
||||
lmapclear ; like "mapclear!" but includes Lang-Arg mode |
||||
lnewer ; go to newer location list |
||||
lnext ; go to next location |
||||
lnfile ; go to first location in next file |
||||
lnoremap ; like "noremap!" but includes Lang-Arg mode |
||||
loadkeymap ; load the following keymaps until EOF |
||||
loadview ; load view for current window from a file |
||||
lockmarks ; following command keeps marks where they are |
||||
lockvar ; lock variables |
||||
lolder ; go to older location list |
||||
lopen ; open location window |
||||
lpfile ; go to last location in previous file |
||||
lprevious ; go to previous location |
||||
lrewind ; go to the specified location, default first one |
||||
ltag ; jump to tag and add matching tags to the location list |
||||
lua ; execute Lua chunk. |
||||
luado ; execute Lua function. |
||||
luafile ; execute Lua script in file. |
||||
lunmap ; like "unmap!" but includes Lang-Arg mode |
||||
lvimgrep ; search for pattern in files |
||||
lvimgrepadd ; like vimgrep, but append to current list |
||||
lwindow ; open or close location window |
||||
make ; execute external command 'makeprg' and parse error messages |
||||
map ; show or enter a mapping |
||||
mapclear ; clear all mappings for Normal and Visual mode |
||||
mark ; set a mark |
||||
marks ; list all marks |
||||
match ; define a match to highlight |
||||
menu ; enter a new menu item |
||||
menutranslate ; add a menu translation item |
||||
messages ; view previously displayed messages |
||||
mkexrc ; write current mappings and settings to a file |
||||
mksession ; write session info to a file |
||||
mkspell ; produce .spl spell file |
||||
mkview ; write view of current window to a file |
||||
mkvimrc ; write current mappings and settings to a file |
||||
mode ; show or change the screen mode |
||||
move ; move lines |
||||
mzfile ; execute MzScheme script file |
||||
mzscheme ; execute MzScheme command |
||||
nbkey ; pass a key to Netbeans |
||||
new ; create a new empty window |
||||
next ; go to next file in the argument list |
||||
nmap ; like "map" but for Normal mode |
||||
nmapclear ; clear all mappings for Normal mode |
||||
nmenu ; add menu for Normal mode |
||||
nnoremap ; like "noremap" but for Normal mode |
||||
nnoremenu ; like "noremenu" but for Normal mode |
||||
noautocmd ; following command don't trigger autocommands |
||||
nohlsearch ; suspend 'hlsearch' highlighting |
||||
noreabbrev ; enter an abbreviation that will not be remapped |
||||
noremap ; enter a mapping that will not be remapped |
||||
noremenu ; enter a menu that will not be remapped |
||||
normal ; execute Normal mode commands |
||||
number ; print lines with line number |
||||
nunmap ; like "unmap" but for Normal mode |
||||
nunmenu ; remove menu for Normal mode |
||||
oldfiles ; list files that have marks in the viminfo file |
||||
omap ; like "map" but for Operator-pending mode |
||||
omapclear ; remove all mappings for Operator-pending mode |
||||
omenu ; add menu for Operator-pending mode |
||||
only ; close all windows except the current one |
||||
onoremap ; like "noremap" but for Operator-pending mode |
||||
onoremenu ; like "noremenu" but for Operator-pending mode |
||||
open ; start open mode (not implemented) |
||||
options ; open the options-window |
||||
ounmap ; like "unmap" but for Operator-pending mode |
||||
ounmenu ; remove menu for Operator-pending mode |
||||
ownsyntax ; define Window-local syntax |
||||
pclose ; close preview window |
||||
pedit ; edit file in the preview window |
||||
perl ; execute Perl command |
||||
perldo ; execute Perl command for each line |
||||
pop ; jump to older entry in tag stack |
||||
popup ; popup a menu by name |
||||
ppop ; "pop" in preview window |
||||
preserve ; write all text to swap file |
||||
previous ; go to previous file in argument list |
||||
print ; print lines |
||||
profdel ; stop profiling a function or script |
||||
profile ; profiling functions and scripts |
||||
promptfind ; open GUI dialog for searching |
||||
promptrepl ; open GUI dialog for search/replace |
||||
psearch ; like "ijump" but shows match in preview window |
||||
ptNext ; tNext in preview window |
||||
ptag ; show tag in preview window |
||||
ptfirst ; trewind in preview window |
||||
ptjump ; tjump and show tag in preview window |
||||
ptlast ; tlast in preview window |
||||
ptnext ; tnext in preview window |
||||
ptprevious ; tprevious in preview window |
||||
ptrewind ; trewind in preview window |
||||
ptselect ; tselect and show tag in preview window |
||||
put ; insert contents of register in the text |
||||
pwd ; print current directory |
||||
py3file ; execute Python3 script file |
||||
pyfile ; execute Python script file |
||||
python ; execute Python command |
||||
python3 ; execute Python3 command |
||||
qall ; quit Vim |
||||
quit ; quit current window (when one window quit Vim) |
||||
quitall ; quit Vim |
||||
read ; read file into the text |
||||
recover ; recover a file from a swap file |
||||
redir ; redirect messages to a file or register |
||||
redo ; redo one undone change |
||||
redraw ; force a redraw of the display |
||||
redrawstatus ; force a redraw of the status line(s) |
||||
registers ; display the contents of registers |
||||
resize ; change current window height |
||||
retab ; change tab size |
||||
return ; return from a user function |
||||
rewind ; go to the first file in the argument list |
||||
right ; right align text |
||||
rightbelow ; make split window appear right or below |
||||
ruby ; execute Ruby command |
||||
rubydo ; execute Ruby command for each line |
||||
rubyfile ; execute Ruby script file |
||||
runtime ; source vim scripts in 'runtimepath' |
||||
rviminfo ; read from viminfo file |
||||
sNext ; split window and go to previous file in argument list |
||||
sall ; open a window for each file in argument list |
||||
sandbox ; execute a command in the sandbox |
||||
sargument ; split window and go to specific file in argument list |
||||
saveas ; save file under another name. |
||||
sbNext ; split window and go to previous file in the buffer list |
||||
sball ; open a window for each file in the buffer list |
||||
sbfirst ; split window and go to first file in the buffer list |
||||
sblast ; split window and go to last file in buffer list |
||||
sbmodified ; split window and go to modified file in the buffer list |
||||
sbnext ; split window and go to next file in the buffer list |
||||
sbprevious ; split window and go to previous file in the buffer list |
||||
sbrewind ; split window and go to first file in the buffer list |
||||
sbuffer ; split window and go to specific file in the buffer list |
||||
scriptencoding ; encoding used in sourced Vim script |
||||
scriptnames ; list names of all sourced Vim scripts |
||||
scscope ; split window and execute cscope command |
||||
set ; show or set options |
||||
setfiletype ; set 'filetype', unless it was set already |
||||
setglobal ; show global values of options |
||||
setlocal ; show or set options locally |
||||
sfind ; split current window and edit file in 'path' |
||||
sfirst ; split window and go to first file in the argument list |
||||
shell ; escape to a shell |
||||
sign ; manipulate signs |
||||
silent ; run a command silently |
||||
simalt ; Win32 GUI simulate Windows ALT key |
||||
slast ; split window and go to last file in the argument list |
||||
sleep ; do nothing for a few seconds |
||||
smagic ; substitute with 'magic' |
||||
smap ; like "map" but for Select mode |
||||
smapclear ; remove all mappings for Select mode |
||||
smenu ; add menu for Select mode |
||||
snext ; split window and go to next file in the argument list |
||||
sniff ; send request to sniff |
||||
snomagic ; substitute with 'nomagic' |
||||
snoremap ; like "noremap" but for Select mode |
||||
snoremenu ; like "noremenu" but for Select mode |
||||
sort ; sort lines |
||||
source ; read Vim or Ex commands from a file |
||||
spelldump ; split window and fill with all correct words |
||||
spellgood ; add good word for spelling |
||||
spellinfo ; show info about loaded spell files |
||||
spellrepall ; replace all bad words like last z= |
||||
spellundo ; remove good or bad word |
||||
spellwrong ; add spelling mistake |
||||
split ; split current window |
||||
sprevious ; split window and go to previous file in the argument list |
||||
srewind ; split window and go to first file in the argument list |
||||
stag ; split window and jump to a tag |
||||
startgreplace ; start Virtual Replace mode |
||||
startinsert ; start Insert mode |
||||
startreplace ; start Replace mode |
||||
stjump ; do "tjump" and split window |
||||
stop ; suspend the editor or escape to a shell |
||||
stopinsert ; stop Insert mode |
||||
stselect ; do "tselect" and split window |
||||
substitute ; find and replace text |
||||
sunhide ; same as "unhide" |
||||
sunmap ; like "unmap" but for Select mode |
||||
sunmenu ; remove menu for Select mode |
||||
suspend ; same as "stop" |
||||
sview ; split window and edit file read-only |
||||
swapname ; show the name of the current swap file |
||||
syncbind ; sync scroll binding |
||||
syntax ; syntax highlighting |
||||
tNext ; jump to previous matching tag |
||||
tab ; create new tab when opening new window |
||||
tabNext ; go to previous tab page |
||||
tabclose ; close current tab page |
||||
tabdo ; execute command in each tab page |
||||
tabedit ; edit a file in a new tab page |
||||
tabfind ; find file in 'path', edit it in a new tab page |
||||
tabfirst ; got to first tab page |
||||
tablast ; got to last tab page |
||||
tabmove ; move tab page to other position |
||||
tabnew ; edit a file in a new tab page |
||||
tabnext ; go to next tab page |
||||
tabonly ; close all tab pages except the current one |
||||
tabprevious ; go to previous tab page |
||||
tabrewind ; got to first tab page |
||||
tabs ; list the tab pages and what they contain |
||||
tag ; jump to tag |
||||
tags ; show the contents of the tag stack |
||||
tcl ; execute Tcl command |
||||
tcldo ; execute Tcl command for each line |
||||
tclfile ; execute Tcl script file |
||||
tearoff ; tear-off a menu |
||||
tfirst ; jump to first matching tag |
||||
throw ; throw an exception |
||||
tjump ; like "tselect", but jump directly when there is only one match |
||||
tlast ; jump to last matching tag |
||||
tmenu ; define menu tooltip |
||||
tnext ; jump to next matching tag |
||||
topleft ; make split window appear at top or far left |
||||
tprevious ; jump to previous matching tag |
||||
trewind ; jump to first matching tag |
||||
try ; execute commands, abort on error or exception |
||||
tselect ; list matching tags and select one |
||||
tunmenu ; remove menu tooltip |
||||
unabbreviate ; remove abbreviation |
||||
undo ; undo last change(s) |
||||
undojoin ; join next change with previous undo block |
||||
undolist ; list leafs of the undo tree |
||||
unhide ; open a window for each loaded file in the buffer list |
||||
unlet ; delete variable |
||||
unlockvar ; unlock variables |
||||
unmap ; remove mapping |
||||
unmenu ; remove menu |
||||
unsilent ; run a command not silently |
||||
update ; write buffer if modified |
||||
verbose ; execute command with 'verbose' set |
||||
version ; print version number and other info |
||||
vertical ; make following command split vertically |
||||
vglobal ; execute commands for not matching lines |
||||
view ; edit a file read-only |
||||
vimgrep ; search for pattern in files |
||||
vimgrepadd ; like vimgrep, but append to current list |
||||
visual ; same as "edit", but turns off "Ex" mode |
||||
viusage ; overview of Normal mode commands |
||||
vmap ; like "map" but for Visual+Select mode |
||||
vmapclear ; remove all mappings for Visual+Select mode |
||||
vmenu ; add menu for Visual+Select mode |
||||
vnew ; create a new empty window, vertically split |
||||
vnoremap ; like "noremap" but for Visual+Select mode |
||||
vnoremenu ; like "noremenu" but for Visual+Select mode |
||||
vsplit ; split current window vertically |
||||
vunmap ; like "unmap" but for Visual+Select mode |
||||
vunmenu ; remove menu for Visual+Select mode |
||||
wNext ; write to a file and go to previous file in argument list |
||||
wall ; write all (changed) buffers |
||||
while ; execute loop for as long as condition met |
||||
wincmd ; execute a Window (CTRL-W) command |
||||
windo ; execute command in each window |
||||
winpos ; get or set window position |
||||
winsize ; get or set window size (obsolete) |
||||
wnext ; write to a file and go to next file in argument list |
||||
wprevious ; write to a file and go to previous file in argument list |
||||
wqall ; write all changed buffers and quit Vim |
||||
write ; write to a file |
||||
wsverb ; pass the verb to workshop over IPC |
||||
wviminfo ; write to viminfo file |
||||
xall ; same as "wqall" |
||||
xit ; write if buffer changed and quit window or Vim |
||||
xmap ; like "map" but for Visual mode |
||||
xmapclear ; remove all mappings for Visual mode |
||||
xmenu ; add menu for Visual mode |
||||
xnoremap ; like "noremap" but for Visual mode |
||||
xnoremenu ; like "noremenu" but for Visual mode |
||||
xunmap ; like "unmap" but for Visual mode |
||||
xunmenu ; remove menu for Visual mode |
||||
yank ; yank lines into a register |
@ -0,0 +1,153 @@
@@ -0,0 +1,153 @@
|
||||
all_builtin_terms ; Compiled with all builtin terminals enabled. |
||||
amiga ; Amiga version of Vim. |
||||
arabic ; Compiled with Arabic support |Arabic|. |
||||
arp ; Compiled with ARP support (Amiga). |
||||
autocmd ; Compiled with autocommand support. |autocommand| |
||||
balloon_eval ; Compiled with |balloon-eval| support. |
||||
balloon_multiline ; GUI supports multiline balloons. |
||||
beos ; BeOS version of Vim. |
||||
browse ; Compiled with |:browse| support, and browse() will work. |
||||
builtin_terms ; Compiled with some builtin terminals. |
||||
byte_offset ; Compiled with support for 'o' in 'statusline' |
||||
cindent ; Compiled with 'cindent' support. |
||||
clientserver ; Compiled with remote invocation support |clientserver|. |
||||
clipboard ; Compiled with 'clipboard' support. |
||||
cmdline_compl ; Compiled with |cmdline-completion| support. |
||||
cmdline_hist ; Compiled with |cmdline-history| support. |
||||
cmdline_info ; Compiled with 'showcmd' and 'ruler' support. |
||||
comments ; Compiled with |'comments'| support. |
||||
compatible ; Compiled to be very Vi compatible. |
||||
cryptv ; Compiled with encryption support |encryption|. |
||||
cscope ; Compiled with |cscope| support. |
||||
debug ; Compiled with "DEBUG" defined. |
||||
dialog_con ; Compiled with console dialog support. |
||||
dialog_gui ; Compiled with GUI dialog support. |
||||
diff ; Compiled with |vimdiff| and 'diff' support. |
||||
digraphs ; Compiled with support for digraphs. |
||||
dnd ; Compiled with support for the "~ register |quote_~|. |
||||
dos16 ; 16 bits DOS version of Vim. |
||||
dos32 ; 32 bits DOS (DJGPP) version of Vim. |
||||
ebcdic ; Compiled on a machine with ebcdic character set. |
||||
emacs_tags ; Compiled with support for Emacs tags. |
||||
eval ; Compiled with expression evaluation support. Always true, of course! |
||||
ex_extra ; Compiled with extra Ex commands |+ex_extra|. |
||||
extra_search ; Compiled with support for |'incsearch'| and |'hlsearch'| |
||||
farsi ; Compiled with Farsi support |farsi|. |
||||
file_in_path ; Compiled with support for |gf| and |<cfile>| |
||||
filterpipe ; When 'shelltemp' is off pipes are used for shell read/write/filter commands |
||||
find_in_path ; Compiled with support for include file searches |+find_in_path|. |
||||
float ; Compiled with support for |Float|. |
||||
fname_case ; Case in file names matters (for Amiga, MS-DOS, and Windows this is not present). |
||||
folding ; Compiled with |folding| support. |
||||
footer ; Compiled with GUI footer support. |gui-footer| |
||||
fork ; Compiled to use fork()/exec() instead of system(). |
||||
gettext ; Compiled with message translation |multi-lang| |
||||
gui ; Compiled with GUI enabled. |
||||
gui_athena ; Compiled with Athena GUI. |
||||
gui_gnome ; Compiled with Gnome support (gui_gtk is also defined). |
||||
gui_gtk ; Compiled with GTK+ GUI (any version). |
||||
gui_gtk2 ; Compiled with GTK+ 2 GUI (gui_gtk is also defined). |
||||
gui_mac ; Compiled with Macintosh GUI. |
||||
gui_motif ; Compiled with Motif GUI. |
||||
gui_photon ; Compiled with Photon GUI. |
||||
gui_running ; Vim is running in the GUI, or it will start soon. |
||||
gui_win32 ; Compiled with MS Windows Win32 GUI. |
||||
gui_win32s ; idem, and Win32s system being used (Windows 3.1) |
||||
hangul_input ; Compiled with Hangul input support. |hangul| |
||||
iconv ; Can use iconv() for conversion. |
||||
insert_expand ; Compiled with support for CTRL-X expansion commands in Insert mode. |
||||
jumplist ; Compiled with |jumplist| support. |
||||
keymap ; Compiled with 'keymap' support. |
||||
langmap ; Compiled with 'langmap' support. |
||||
libcall ; Compiled with |libcall()| support. |
||||
linebreak ; Compiled with 'linebreak', 'breakat' and 'showbreak' support. |
||||
lispindent ; Compiled with support for lisp indenting. |
||||
listcmds ; Compiled with commands for the buffer list |:files| and the argument list |arglist|. |
||||
localmap ; Compiled with local mappings and abbr. |:map-local| |
||||
lua ; Compiled with Lua interface |Lua|. |
||||
mac ; Macintosh version of Vim. |
||||
macunix ; Macintosh version of Vim, using Unix files (OS-X). |
||||
menu ; Compiled with support for |:menu|. |
||||
mksession ; Compiled with support for |:mksession|. |
||||
modify_fname ; Compiled with file name modifiers. |filename-modifiers| |
||||
mouse ; Compiled with support mouse. |
||||
mouse_dec ; Compiled with support for Dec terminal mouse. |
||||
mouse_gpm ; Compiled with support for gpm (Linux console mouse) |
||||
mouse_netterm ; Compiled with support for netterm mouse. |
||||
mouse_pterm ; Compiled with support for qnx pterm mouse. |
||||
mouse_sysmouse ; Compiled with support for sysmouse (*BSD console mouse) |
||||
mouse_xterm ; Compiled with support for xterm mouse. |
||||
mouseshape ; Compiled with support for 'mouseshape'. |
||||
multi_byte ; Compiled with support for 'encoding' |
||||
multi_byte_encoding ; 'encoding' is set to a multi-byte encoding. |
||||
multi_byte_ime ; Compiled with support for IME input method. |
||||
multi_lang ; Compiled with support for multiple languages. |
||||
mzscheme ; Compiled with MzScheme interface |mzscheme|. |
||||
netbeans_enabled ; Compiled with support for |netbeans| and it's used. |
||||
netbeans_intg ; Compiled with support for |netbeans|. |
||||
ole ; Compiled with OLE automation support for Win32. |
||||
os2 ; OS/2 version of Vim. |
||||
osfiletype ; Compiled with support for osfiletypes |+osfiletype| |
||||
path_extra ; Compiled with up/downwards search in 'path' and 'tags' |
||||
perl ; Compiled with Perl interface. |
||||
persistent_undo ; Compiled with support for persistent undo history. |
||||
postscript ; Compiled with PostScript file printing. |
||||
printer ; Compiled with |:hardcopy| support. |
||||
profile ; Compiled with |:profile| support. |
||||
python ; Compiled with Python interface. |
||||
python3 ; Compiled with Python3 interface. |
||||
qnx ; QNX version of Vim. |
||||
quickfix ; Compiled with |quickfix| support. |
||||
reltime ; Compiled with |reltime()| support. |
||||
rightleft ; Compiled with 'rightleft' support. |
||||
ruby ; Compiled with Ruby interface |ruby|. |
||||
scrollbind ; Compiled with 'scrollbind' support. |
||||
showcmd ; Compiled with 'showcmd' support. |
||||
signs ; Compiled with |:sign| support. |
||||
smartindent ; Compiled with 'smartindent' support. |
||||
sniff ; Compiled with SNiFF interface support. |
||||
spell ; Compiled with spell checking support |spell|. |
||||
statusline ; Compiled with |--startuptime| support. |
||||
sun_workshop ; Compiled with support for Sun |workshop|. |
||||
syntax ; Compiled with syntax highlighting support |syntax|. |
||||
syntax_items ; There are active syntax highlighting items for the current buffer. |
||||
system ; Compiled to use system() instead of fork()/exec(). |
||||
tag_any_white ; Compiled with support for any white characters in tags files |tag-any-white|. |
||||
tag_binary ; Compiled with binary searching in tags files |tag-binary-search|. |
||||
tag_old_static ; Compiled with support for old static tags |tag-old-static|. |
||||
tcl ; Compiled with Tcl interface. |
||||
terminfo ; Compiled with terminfo instead of termcap. |
||||
termresponse ; Compiled with support for |t_RV| and |v:termresponse|. |
||||
textobjects ; Compiled with support for |text-objects|. |
||||
tgetent ; Compiled with tgetent support, able to use a termcap or terminfo file. |
||||
title ; Compiled with window title support |'title'|. |
||||
toolbar ; Compiled with support for |gui-toolbar|. |
||||
unix ; Unix version of Vim. |
||||
unnamedplus ; Usable '+' register instead of '*' register. |
||||
user_commands ; User-defined commands. |
||||
vertsplit ; Compiled with vertically split windows |:vsplit|. |
||||
vim_starting ; True while initial source'ing takes place. |
||||
viminfo ; Compiled with viminfo support. |
||||
virtualedit ; Compiled with 'virtualedit' option. |
||||
visual ; Compiled with Visual mode. |
||||
visualextra ; Compiled with extra Visual mode commands. |
||||
vms ; VMS version of Vim. |
||||
vreplace ; Compiled with |gR| and |gr| commands. |
||||
wildignore ; Compiled with 'wildignore' option. |
||||
wildmenu ; Compiled with 'wildmenu' option. |
||||
win16 ; Win16 version of Vim (MS-Windows 3.1). |
||||
win32 ; Win32 version of Vim (MS-Windows 95/98/ME/NT/2000/XP). |
||||
win32unix ; Win32 version of Vim, using Unix files (Cygwin) |
||||
win64 ; Win64 version of Vim (MS-Windows 64 bit). |
||||
win95 ; Win32 version for MS-Windows 95/98/ME. |
||||
winaltkeys ; Compiled with 'winaltkeys' option. |
||||
windows ; Compiled with support for more than one window. |
||||
writebackup ; Compiled with 'writebackup' default on. |
||||
x11 ; Compiled with X11 support. |
||||
xfontset ; Compiled with X fontset support |xfontset|. |
||||
xim ; Compiled with X input method support |xim|. |
||||
xpm_w32 ; Compiled with pixmap support for Win32. |
||||
xsmp ; Compiled with X session management support. |
||||
xsmp_interact ; Compiled with interactive X session management support. |
||||
xterm_clipboard ; Compiled with support for xterm clipboard. |
||||
xterm_save ; Compiled with support for saving and restoring the xterm screen. |
@ -0,0 +1,252 @@
@@ -0,0 +1,252 @@
|
||||
abs({expr}) |
||||
acos({expr}) |
||||
add({list}, {item}) |
||||
append({lnum}, {list}) |
||||
append({lnum}, {string}) |
||||
argc() |
||||
argidx() |
||||
argv() |
||||
argv({nr}) |
||||
asin({expr}) |
||||
atan({expr}) |
||||
atan2({expr1}, {expr2}) |
||||
browse({save}, {title}, {initdir}, {default}) |
||||
browsedir({title}, {initdir}) |
||||
bufexists({expr}) |
||||
buflisted({expr}) |
||||
bufloaded({expr}) |
||||
bufname({expr}) |
||||
bufnr({expr}) |
||||
bufwinnr({expr}) |
||||
byte2line({byte}) |
||||
byteidx({expr}, {nr}) |
||||
call({func}, {arglist} [, {dict}]) |
||||
ceil({expr}) |
||||
changenr() |
||||
char2nr({expr}) |
||||
cindent({lnum}) |
||||
clearmatches() |
||||
col({expr}) |
||||
complete({startcol}, {matches}) |
||||
complete_add({expr}) |
||||
complete_check() |
||||
confirm({msg} [, {choices} [, {default} [, {type}]]]) |
||||
copy({expr}) |
||||
cos({expr}) |
||||
cosh({expr}) |
||||
count({list}, {expr} [, {start} [, {ic}]]) |
||||
cscope_connection([{num} , {dbpath} [, {prepend}]]) |
||||
cursor({list}) |
||||
cursor({lnum}, {col} [, {coladd}]) |
||||
deepcopy({expr}) |
||||
delete({fname}) |
||||
did_filetype() |
||||
diff_filler({lnum}) |
||||
diff_hlID({lnum}, {col}) |
||||
empty({expr}) |
||||
escape({string}, {chars}) |
||||
eval({string}) |
||||
eventhandler() |
||||
executable({expr}) |
||||
exists({expr}) |
||||
exp({expr}) |
||||
expand({expr} [, {flag}]) |
||||
extend({expr1}, {expr2} [, {expr3}]) |
||||
feedkeys({string} [, {mode}]) |
||||
filereadable({file}) |
||||
filewritable({file}) |
||||
filter({expr}, {string}) |
||||
finddir({name}[, {path}[, {count}]]) |
||||
findfile({name}[, {path}[, {count}]]) |
||||
float2nr({expr}) |
||||
floor({expr}) |
||||
fmod({expr1}, {expr2}) |
||||
fnameescape({fname}) |
||||
fnamemodify({fname}, {mods}) |
||||
foldclosed({lnum}) |
||||
foldclosedend({lnum}) |
||||
foldlevel({lnum}) |
||||
foldtext() |
||||
foldtextresult({lnum}) |
||||
foreground() |
||||
function({name}) |
||||
garbagecollect([at_exit]) |
||||
get({dict}, {key} [, {def}]) |
||||
get({list}, {idx} [, {def}]) |
||||
getbufline({expr}, {lnum} [, {end}]) |
||||
getbufvar({expr}, {varname}) |
||||
getchar([expr]) |
||||
getcharmod() |
||||
getcmdline() |
||||
getcmdpos() |
||||
getcmdtype() |
||||
getcwd() |
||||
getfontname([{name}]) |
||||
getfperm({fname}) |
||||
getfsize({fname}) |
||||
getftime({fname}) |
||||
getftype({fname}) |
||||
getline({lnum}) |
||||
getline({lnum}, {end}) |
||||
getloclist({nr}) |
||||
getmatches() |
||||
getpid() |
||||
getpos({expr}) |
||||
getqflist() |
||||
getreg([{regname} [, 1]]) |
||||
getregtype([{regname}]) |
||||
gettabvar({tabnr}, {varname}) |
||||
gettabwinvar({tabnr}, {winnr}, {name}) |
||||
getwinposx() |
||||
getwinposy() |
||||
getwinvar({nr}, {varname}) |
||||
glob({expr} [, {flag}]) |
||||
globpath({path}, {expr} [, {flag}]) |
||||
has({feature}) |
||||
has_key({dict}, {key}) |
||||
haslocaldir() |
||||
hasmapto({what} [, {mode} [, {abbr}]]) |
||||
histadd({history},{item}) |
||||
histdel({history} [, {item}]) |
||||
histget({history} [, {index}]) |
||||
histnr({history}) |
||||
hlID({name}) |
||||
hlexists({name}) |
||||
hostname() |
||||
iconv({expr}, {from}, {to}) |
||||
indent({lnum}) |
||||
index({list}, {expr} [, {start} [, {ic}]]) |
||||
input({prompt} [, {text} [, {completion}]]) |
||||
inputdialog({p} [, {t} [, {c}]]) |
||||
inputlist({textlist}) |
||||
inputrestore() |
||||
inputsave() |
||||
inputsecret({prompt} [, {text}]) |
||||
insert({list}, {item} [, {idx}]) |
||||
isdirectory({directory}) |
||||
islocked({expr}) |
||||
items({dict}) |
||||
join({list} [, {sep}]) |
||||
keys({dict}) |
||||
len({expr}) |
||||
libcall({lib}, {func}, {arg}) |
||||
libcallnr({lib}, {func}, {arg}) |
||||
line({expr}) |
||||
line2byte({lnum}) |
||||
lispindent({lnum}) |
||||
localtime() |
||||
log({expr}) |
||||
log10({expr}) |
||||
map({expr}, {string}) |
||||
maparg({name}[, {mode} [, {abbr}]]) |
||||
mapcheck({name}[, {mode} [, {abbr}]]) |
||||
match({expr}, {pat}[, {start}[, {count}]]) |
||||
matchadd({group}, {pattern}[, {priority}[, {id}]]) |
||||
matcharg({nr}) |
||||
matchdelete({id}) |
||||
matchend({expr}, {pat}[, {start}[, {count}]]) |
||||
matchlist({expr}, {pat}[, {start}[, {count}]]) |
||||
matchstr({expr}, {pat}[, {start}[, {count}]]) |
||||
max({list}) |
||||
min({list}) |
||||
mkdir({name} [, {path} [, {prot}]]) |
||||
mode([expr]) |
||||
nextnonblank({lnum}) |
||||
nr2char({expr}) |
||||
pathshorten({expr}) |
||||
pow({x}, {y}) |
||||
prevnonblank({lnum}) |
||||
printf({fmt}, {expr1}...) |
||||
pumvisible() |
||||
range({expr} [, {max} [, {stride}]]) |
||||
readfile({fname} [, {binary} [, {max}]]) |
||||
reltime([{start} [, {end}]]) |
||||
reltimestr({time}) |
||||
remote_expr({server}, {string} [, {idvar}]) |
||||
remote_foreground({server}) |
||||
remote_peek({serverid} [, {retvar}]) |
||||
remote_read({serverid}) |
||||
remote_send({server}, {string} [, {idvar}]) |
||||
remove({dict}, {key}) |
||||
remove({list}, {idx} [, {end}]) |
||||
rename({from}, {to}) |
||||
repeat({expr}, {count}) |
||||
resolve({filename}) |
||||
reverse({list}) |
||||
round({expr}) |
||||
search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) |
||||
searchdecl({name} [, {global} [, {thisblock}]]) |
||||
searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) |
||||
searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) |
||||
searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) |
||||
server2client({clientid}, {string}) |
||||
serverlist() |
||||
setbufvar({expr}, {varname}, {val}) |
||||
setcmdpos({pos}) |
||||
setline({lnum}, {line}) |
||||
setloclist({nr}, {list}[, {action}]) |
||||
setmatches({list}) |
||||
setpos({expr}, {list}) |
||||
setqflist({list}[, {action}]) |
||||
setreg({n}, {v}[, {opt}]) |
||||
settabvar({tabnr}, {varname}, {val}) |
||||
settabwinvar({tabnr}, {winnr}, {varname}, {val}) |
||||
setwinvar({nr}, {varname}, {val}) |
||||
shellescape({string} [, {special}]) |
||||
simplify({filename}) |
||||
sin({expr}) |
||||
sinh({expr}) |
||||
sort({list} [, {func}]) |
||||
soundfold({word}) |
||||
spellbadword() |
||||
spellsuggest({word} [, {max} [, {capital}]]) |
||||
split({expr} [, {pat} [, {keepempty}]]) |
||||
sqrt({expr}) |
||||
str2float({expr}) |
||||
str2nr({expr} [, {base}]) |
||||
strchars({expr}) |
||||
strdisplaywidth({expr}[, {col}]) |
||||
strftime({format}[, {time}]) |
||||
stridx({haystack}, {needle}[, {start}]) |
||||
string({expr}) |
||||
strlen({expr}) |
||||
strpart({src}, {start}[, {len}]) |
||||
strridx({haystack}, {needle} [, {start}]) |
||||
strtrans({expr}) |
||||
strwidth({expr}) |
||||
submatch({nr}) |
||||
substitute({expr}, {pat}, {sub}, {flags}) |
||||
synID({lnum}, {col}, {trans}) |
||||
synIDattr({synID}, {what} [, {mode}]) |
||||
synIDtrans({synID}) |
||||
synconcealed({lnum}, {col}) |
||||
synstack({lnum}, {col}) |
||||
system({expr} [, {input}]) |
||||
tabpagebuflist([{arg}]) |
||||
tabpagenr([{arg}]) |
||||
tabpagewinnr({tabarg}[, {arg}]) |
||||
tagfiles() |
||||
taglist({expr}) |
||||
tan({expr}) |
||||
tanh({expr}) |
||||
tempname() |
||||
tolower({expr}) |
||||
toupper({expr}) |
||||
tr({src}, {fromstr}, {tostr}) |
||||
trunc({expr} |
||||
type({name}) |
||||
undofile({name}) |
||||
undotree() |
||||
values({dict}) |
||||
virtcol({expr}) |
||||
visualmode([expr]) |
||||
winbufnr({nr}) |
||||
wincol() |
||||
winheight({nr}) |
||||
winline() |
||||
winnr([{expr}]) |
||||
winrestcmd() |
||||
winrestview({dict}) |
||||
winsaveview() |
||||
winwidth({nr}) |
||||
writefile({list}, {fname} [, {binary}]) |
@ -0,0 +1,964 @@
@@ -0,0 +1,964 @@
|
||||
"============================================================================= |
||||
" FILE: helper.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 24 Apr 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
if !exists('s:internal_candidates_list') |
||||
let s:internal_candidates_list = {} |
||||
let s:global_candidates_list = { 'dictionary_variables' : {} } |
||||
let s:script_candidates_list = {} |
||||
let s:local_candidates_list = {} |
||||
endif |
||||
|
||||
function! neocomplcache#sources#vim_complete#helper#on_filetype() "{{{ |
||||
" Caching script candidates. |
||||
let bufnumber = 1 |
||||
|
||||
" Check buffer. |
||||
while bufnumber <= bufnr('$') |
||||
if getbufvar(bufnumber, '&filetype') == 'vim' && bufloaded(bufnumber) |
||||
\&& !has_key(s:script_candidates_list, bufnumber) |
||||
let s:script_candidates_list[bufnumber] = s:get_script_candidates(bufnumber) |
||||
endif |
||||
|
||||
let bufnumber += 1 |
||||
endwhile |
||||
|
||||
if neocomplcache#exists_echodoc() |
||||
call echodoc#register('vim_complete', s:doc_dict) |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#vim_complete#helper#recaching(bufname) "{{{ |
||||
" Caching script candidates. |
||||
let bufnumber = a:bufname != '' ? bufnr(a:bufname) : bufnr('%') |
||||
|
||||
if getbufvar(bufnumber, '&filetype') == 'vim' && bufloaded(bufnumber) |
||||
let s:script_candidates_list[bufnumber] = s:get_script_candidates(bufnumber) |
||||
endif |
||||
let s:global_candidates_list = { 'dictionary_variables' : {} } |
||||
endfunction"}}} |
||||
|
||||
" For echodoc. "{{{ |
||||
let s:doc_dict = { |
||||
\ 'name' : 'vim_complete', |
||||
\ 'rank' : 10, |
||||
\ 'filetypes' : { 'vim' : 1 }, |
||||
\ } |
||||
function! s:doc_dict.search(cur_text) "{{{ |
||||
let cur_text = a:cur_text |
||||
|
||||
" Echo prototype. |
||||
let script_candidates_list = s:get_cached_script_candidates() |
||||
|
||||
let prototype_name = matchstr(cur_text, |
||||
\'\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\s*(\ze\%([^(]\|(.\{-})\)*$') |
||||
let ret = [] |
||||
if prototype_name != '' |
||||
if !has_key(s:internal_candidates_list, 'function_prototypes') |
||||
" No cache. |
||||
return [] |
||||
endif |
||||
|
||||
" Search function name. |
||||
call add(ret, { 'text' : prototype_name, 'highlight' : 'Identifier' }) |
||||
if has_key(s:internal_candidates_list.function_prototypes, prototype_name) |
||||
call add(ret, { 'text' : s:internal_candidates_list.function_prototypes[prototype_name] }) |
||||
elseif has_key(s:global_candidates_list.function_prototypes, prototype_name) |
||||
call add(ret, { 'text' : s:global_candidates_list.function_prototypes[prototype_name] }) |
||||
elseif has_key(script_candidates_list.function_prototypes, prototype_name) |
||||
call add(ret, { 'text' : script_candidates_list.function_prototypes[prototype_name] }) |
||||
else |
||||
" No prototypes. |
||||
return [] |
||||
endif |
||||
else |
||||
if !has_key(s:internal_candidates_list, 'command_prototypes') |
||||
" No cache. |
||||
return [] |
||||
endif |
||||
|
||||
" Search command name. |
||||
" Skip head digits. |
||||
let prototype_name = neocomplcache#sources#vim_complete#get_command(cur_text) |
||||
call add(ret, { 'text' : prototype_name, 'highlight' : 'Statement' }) |
||||
if has_key(s:internal_candidates_list.command_prototypes, prototype_name) |
||||
call add(ret, { 'text' : s:internal_candidates_list.command_prototypes[prototype_name] }) |
||||
elseif has_key(s:global_candidates_list.command_prototypes, prototype_name) |
||||
call add(ret, { 'text' : s:global_candidates_list.command_prototypes[prototype_name] }) |
||||
else |
||||
" No prototypes. |
||||
return [] |
||||
endif |
||||
endif |
||||
|
||||
return ret |
||||
endfunction"}}} |
||||
"}}} |
||||
|
||||
function! neocomplcache#sources#vim_complete#helper#get_command_completion(command_name, cur_text, complete_str) "{{{ |
||||
let completion_name = |
||||
\ neocomplcache#sources#vim_complete#helper#get_completion_name(a:command_name) |
||||
if completion_name == '' |
||||
" Not found. |
||||
return [] |
||||
endif |
||||
|
||||
let args = (completion_name ==# 'custom' || completion_name ==# 'customlist')? |
||||
\ [a:command_name, a:cur_text, a:complete_str] : [a:cur_text, a:complete_str] |
||||
return call('neocomplcache#sources#vim_complete#helper#'.completion_name, args) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#get_completion_name(command_name) "{{{ |
||||
if !has_key(s:internal_candidates_list, 'command_completions') |
||||
let s:internal_candidates_list.command_completions = |
||||
\ s:caching_completion_from_dict('command_completions') |
||||
endif |
||||
if !has_key(s:global_candidates_list, 'command_completions') |
||||
let s:global_candidates_list.commands = |
||||
\ neocomplcache#pack_dictionary(s:get_cmdlist()) |
||||
endif |
||||
|
||||
if has_key(s:internal_candidates_list.command_completions, a:command_name) |
||||
\&& exists('*neocomplcache#sources#vim_complete#helper#' |
||||
\ .s:internal_candidates_list.command_completions[a:command_name]) |
||||
return s:internal_candidates_list.command_completions[a:command_name] |
||||
elseif has_key(s:global_candidates_list.command_completions, a:command_name) |
||||
\&& exists('*neocomplcache#sources#vim_complete#helper#' |
||||
\ .s:global_candidates_list.command_completions[a:command_name]) |
||||
return s:global_candidates_list.command_completions[a:command_name] |
||||
else |
||||
return '' |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#sources#vim_complete#helper#autocmd_args(cur_text, complete_str) "{{{ |
||||
let args = s:split_args(a:cur_text, a:complete_str) |
||||
if len(args) < 2 |
||||
return [] |
||||
endif |
||||
|
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'augroups') |
||||
let s:global_candidates_list.augroups = s:get_augrouplist() |
||||
endif |
||||
if !has_key(s:internal_candidates_list, 'autocmds') |
||||
let s:internal_candidates_list.autocmds = s:caching_from_dict('autocmds', '') |
||||
endif |
||||
|
||||
let list = [] |
||||
if len(args) == 2 |
||||
let list += s:global_candidates_list.augroups + s:internal_candidates_list.autocmds |
||||
elseif len(args) == 3 |
||||
if args[1] ==# 'FileType' |
||||
" Filetype completion. |
||||
let list += neocomplcache#sources#vim_complete#helper#filetype(a:cur_text, a:complete_str) |
||||
endif |
||||
|
||||
let list += s:internal_candidates_list.autocmds |
||||
elseif len(args) == 4 |
||||
if args[2] ==# 'FileType' |
||||
" Filetype completion. |
||||
let list += neocomplcache#sources#vim_complete#helper#filetype( |
||||
\ a:cur_text, a:complete_str) |
||||
endif |
||||
|
||||
let list += neocomplcache#sources#vim_complete#helper#command( |
||||
\ args[3], a:complete_str) |
||||
let list += s:make_completion_list(['nested'], '') |
||||
else |
||||
let command = args[3] =~ '^*' ? |
||||
\ join(args[4:]) : join(args[3:]) |
||||
let list += neocomplcache#sources#vim_complete#helper#command( |
||||
\ command, a:complete_str) |
||||
let list += s:make_completion_list(['nested'], '') |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#augroup(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'augroups') |
||||
let s:global_candidates_list.augroups = s:get_augrouplist() |
||||
endif |
||||
|
||||
return s:global_candidates_list.augroups |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#buffer(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#colorscheme_args(cur_text, complete_str) "{{{ |
||||
return s:make_completion_list(filter(map(split( |
||||
\ globpath(&runtimepath, 'colors/*.vim'), '\n'), |
||||
\ 'fnamemodify(v:val, ":t:r")'), |
||||
\ 'stridx(v:val, a:complete_str) == 0'), '') |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#command(cur_text, complete_str) "{{{ |
||||
if a:cur_text == '' || |
||||
\ a:cur_text =~ '^[[:digit:],[:space:][:tab:]$''<>]*\h\w*$' |
||||
" Commands. |
||||
|
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'commands') |
||||
let s:global_candidates_list.commands = |
||||
\ neocomplcache#pack_dictionary(s:get_cmdlist()) |
||||
endif |
||||
if !has_key(s:internal_candidates_list, 'commands') |
||||
let s:internal_candidates_list.command_prototypes = |
||||
\ s:caching_prototype_from_dict('command_prototypes') |
||||
let commands = s:caching_from_dict('commands', 'c') |
||||
for command in commands |
||||
if has_key(s:internal_candidates_list.command_prototypes, command.word) |
||||
let command.description = command.word . |
||||
\ s:internal_candidates_list.command_prototypes[command.word] |
||||
endif |
||||
endfor |
||||
|
||||
let s:internal_candidates_list.commands = |
||||
\ neocomplcache#pack_dictionary(commands) |
||||
endif |
||||
|
||||
" echomsg string(s:internal_candidates_list.commands)[: 1000] |
||||
" echomsg string(s:global_candidates_list.commands)[: 1000] |
||||
let list = neocomplcache#dictionary_filter( |
||||
\ s:internal_candidates_list.commands, a:complete_str) |
||||
\ + neocomplcache#dictionary_filter( |
||||
\ s:global_candidates_list.commands, a:complete_str) |
||||
else |
||||
" Commands args. |
||||
let command = neocomplcache#sources#vim_complete#get_command(a:cur_text) |
||||
let completion_name = |
||||
\ neocomplcache#sources#vim_complete#helper#get_completion_name(command) |
||||
|
||||
" Prevent infinite loop. |
||||
let cur_text = completion_name ==# 'command' ? |
||||
\ a:cur_text[len(command):] : a:cur_text |
||||
|
||||
let list = neocomplcache#sources#vim_complete#helper#get_command_completion( |
||||
\ command, cur_text, a:complete_str) |
||||
|
||||
if a:cur_text =~ |
||||
\'[[(,{]\|`=[^`]*$' |
||||
" Expression. |
||||
let list += neocomplcache#sources#vim_complete#helper#expression( |
||||
\ a:cur_text, a:complete_str) |
||||
endif |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#command_args(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:internal_candidates_list, 'command_args') |
||||
let s:internal_candidates_list.command_args = |
||||
\ s:caching_from_dict('command_args', '') |
||||
let s:internal_candidates_list.command_replaces = |
||||
\ s:caching_from_dict('command_replaces', '') |
||||
endif |
||||
|
||||
return s:internal_candidates_list.command_args + |
||||
\ s:internal_candidates_list.command_replaces |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#custom(command_name, cur_text, complete_str) "{{{ |
||||
if !has_key(g:neocomplcache_vim_completefuncs, a:command_name) |
||||
return [] |
||||
endif |
||||
|
||||
return s:make_completion_list(split( |
||||
\ call(g:neocomplcache_vim_completefuncs[a:command_name], |
||||
\ [a:complete_str, getline('.'), len(a:cur_text)]), '\n'), '') |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#customlist(command_name, cur_text, complete_str) "{{{ |
||||
if !has_key(g:neocomplcache_vim_completefuncs, a:command_name) |
||||
return [] |
||||
endif |
||||
|
||||
return s:make_completion_list( |
||||
\ call(g:neocomplcache_vim_completefuncs[a:command_name], |
||||
\ [a:complete_str, getline('.'), len(a:cur_text)]), '') |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#dir(cur_text, complete_str) "{{{ |
||||
return filter(neocomplcache#sources#filename_complete#get_complete_words( |
||||
\ a:complete_str, '.'), 'isdirectory(v:val.word)') |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#environment(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'environments') |
||||
let s:global_candidates_list.environments = s:get_envlist() |
||||
endif |
||||
|
||||
return s:global_candidates_list.environments |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#event(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#execute(cur_text, complete_str) "{{{ |
||||
if a:cur_text =~ '["''][^"'']*$' |
||||
let command = matchstr(a:cur_text, '["'']\zs[^"'']*$') |
||||
return neocomplcache#sources#vim_complete#helper#command(command, a:complete_str) |
||||
else |
||||
return neocomplcache#sources#vim_complete#helper#expression(a:cur_text, a:complete_str) |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#expression(cur_text, complete_str) "{{{ |
||||
return neocomplcache#sources#vim_complete#helper#function(a:cur_text, a:complete_str) |
||||
\+ neocomplcache#sources#vim_complete#helper#var(a:cur_text, a:complete_str) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#feature(cur_text, complete_str) "{{{ |
||||
if !has_key(s:internal_candidates_list, 'features') |
||||
let s:internal_candidates_list.features = s:caching_from_dict('features', '') |
||||
endif |
||||
return s:internal_candidates_list.features |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#file(cur_text, complete_str) "{{{ |
||||
return neocomplcache#sources#filename_complete#get_complete_words( |
||||
\ a:complete_str, '.') |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#filetype(cur_text, complete_str) "{{{ |
||||
if !has_key(s:internal_candidates_list, 'filetypes') |
||||
let s:internal_candidates_list.filetypes = |
||||
\ neocomplcache#pack_dictionary(s:make_completion_list(map( |
||||
\ split(globpath(&runtimepath, 'syntax/*.vim'), '\n') + |
||||
\ split(globpath(&runtimepath, 'indent/*.vim'), '\n') + |
||||
\ split(globpath(&runtimepath, 'ftplugin/*.vim'), '\n') |
||||
\ , "matchstr(fnamemodify(v:val, ':t:r'), '^[[:alnum:]-]*')"), '')) |
||||
endif |
||||
|
||||
return neocomplcache#dictionary_filter( |
||||
\ s:internal_candidates_list.filetypes, a:complete_str) |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#function(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'functions') |
||||
let s:global_candidates_list.functions = |
||||
\ neocomplcache#pack_dictionary(s:get_functionlist()) |
||||
endif |
||||
if !has_key(s:internal_candidates_list, 'functions') |
||||
let s:internal_candidates_list.function_prototypes = |
||||
\ s:caching_prototype_from_dict('functions') |
||||
|
||||
let functions = s:caching_from_dict('functions', 'f') |
||||
for function in functions |
||||
if has_key(s:internal_candidates_list.function_prototypes, function.word) |
||||
let function.description = function.word |
||||
\ . s:internal_candidates_list.function_prototypes[function.word] |
||||
endif |
||||
endfor |
||||
|
||||
let s:internal_candidates_list.functions = |
||||
\ neocomplcache#pack_dictionary(functions) |
||||
endif |
||||
|
||||
let script_candidates_list = s:get_cached_script_candidates() |
||||
if a:complete_str =~ '^s:' |
||||
let list = values(script_candidates_list.functions) |
||||
elseif a:complete_str =~ '^\a:' |
||||
let functions = deepcopy(values(script_candidates_list.functions)) |
||||
for keyword in functions |
||||
let keyword.word = '<SID>' . keyword.word[2:] |
||||
let keyword.abbr = '<SID>' . keyword.abbr[2:] |
||||
endfor |
||||
let list = functions |
||||
else |
||||
let list = neocomplcache#dictionary_filter( |
||||
\ s:internal_candidates_list.functions, a:complete_str) |
||||
\ + neocomplcache#dictionary_filter( |
||||
\ s:global_candidates_list.functions, a:complete_str) |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#help(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#highlight(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#let(cur_text, complete_str) "{{{ |
||||
if a:cur_text !~ '=' |
||||
return neocomplcache#sources#vim_complete#helper#var(a:cur_text, a:complete_str) |
||||
elseif a:cur_text =~# '\<let\s\+&\%([lg]:\)\?filetype\s*=\s*' |
||||
" FileType. |
||||
return neocomplcache#sources#vim_complete#helper#filetype(a:cur_text, a:complete_str) |
||||
else |
||||
return neocomplcache#sources#vim_complete#helper#expression(a:cur_text, a:complete_str) |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#mapping(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'mappings') |
||||
let s:global_candidates_list.mappings = s:get_mappinglist() |
||||
endif |
||||
if !has_key(s:internal_candidates_list, 'mappings') |
||||
let s:internal_candidates_list.mappings = s:caching_from_dict('mappings', '') |
||||
endif |
||||
|
||||
let list = s:internal_candidates_list.mappings + s:global_candidates_list.mappings |
||||
|
||||
if a:cur_text =~ '<expr>' |
||||
let list += neocomplcache#sources#vim_complete#helper#expression(a:cur_text, a:complete_str) |
||||
elseif a:cur_text =~ ':<C-u>\?' |
||||
let command = matchstr(a:cur_text, ':<C-u>\?\zs.*$') |
||||
let list += neocomplcache#sources#vim_complete#helper#command(command, a:complete_str) |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#menu(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#option(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:internal_candidates_list, 'options') |
||||
let s:internal_candidates_list.options = s:caching_from_dict('options', 'o') |
||||
|
||||
for keyword in deepcopy(s:internal_candidates_list.options) |
||||
let keyword.word = 'no' . keyword.word |
||||
let keyword.abbr = 'no' . keyword.abbr |
||||
call add(s:internal_candidates_list.options, keyword) |
||||
endfor |
||||
endif |
||||
|
||||
if a:cur_text =~ '\<set\%[local]\s\+\%(filetype\|ft\)=' |
||||
return neocomplcache#sources#vim_complete#helper#filetype(a:cur_text, a:complete_str) |
||||
else |
||||
return s:internal_candidates_list.options |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#shellcmd(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#tag(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#tag_listfiles(cur_text, complete_str) "{{{ |
||||
return [] |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#var_dictionary(cur_text, complete_str) "{{{ |
||||
let var_name = matchstr(a:cur_text, |
||||
\'\%(\a:\)\?\h\w*\ze\.\%(\h\w*\%(()\?\)\?\)\?$') |
||||
let list = [] |
||||
if a:cur_text =~ '[btwg]:\h\w*\.\%(\h\w*\%(()\?\)\?\)\?$' |
||||
let list = has_key(s:global_candidates_list.dictionary_variables, var_name) ? |
||||
\ values(s:global_candidates_list.dictionary_variables[var_name]) : [] |
||||
elseif a:cur_text =~ 's:\h\w*\.\%(\h\w*\%(()\?\)\?\)\?$' |
||||
let list = values(get(s:get_cached_script_candidates().dictionary_variables, |
||||
\ var_name, {})) |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#var(cur_text, complete_str) "{{{ |
||||
" Caching. |
||||
if !has_key(s:global_candidates_list, 'variables') |
||||
let s:global_candidates_list.variables = |
||||
\ neocomplcache#pack_dictionary( |
||||
\ s:get_variablelist(g:, 'g:') + s:get_variablelist(v:, 'v:')) |
||||
endif |
||||
|
||||
if a:complete_str =~ '^[swtb]:' |
||||
let list = values(s:get_cached_script_candidates().variables) |
||||
if a:complete_str !~ '^s:' |
||||
let prefix = matchstr(a:complete_str, '^[swtb]:') |
||||
let list += s:get_variablelist(eval(prefix), prefix) |
||||
endif |
||||
elseif a:complete_str =~ '^[vg]:' |
||||
let list = neocomplcache#dictionary_filter( |
||||
\ s:global_candidates_list.variables, a:complete_str) |
||||
else |
||||
let list = s:get_local_variables() |
||||
endif |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! neocomplcache#sources#vim_complete#helper#expand(cur_text, complete_str) "{{{ |
||||
return s:make_completion_list( |
||||
\ ['<cfile>', '<afile>', '<abuf>', '<amatch>', |
||||
\ '<sfile>', '<cword>', '<cWORD>', '<client>'], '') |
||||
endfunction"}}} |
||||
|
||||
function! s:get_local_variables() "{{{ |
||||
" Get local variable list. |
||||
|
||||
let keyword_dict = {} |
||||
" Search function. |
||||
let line_num = line('.') - 1 |
||||
let end_line = (line('.') > 100) ? line('.') - 100 : 1 |
||||
while line_num >= end_line |
||||
let line = getline(line_num) |
||||
if line =~ '\<endf\%[unction]\>' |
||||
break |
||||
elseif line =~ '\<fu\%[nction]!\?\s\+' |
||||
" Get function arguments. |
||||
call s:analyze_variable_line(line, keyword_dict) |
||||
break |
||||
endif |
||||
|
||||
let line_num -= 1 |
||||
endwhile |
||||
let line_num += 1 |
||||
|
||||
let end_line = line('.') - 1 |
||||
while line_num <= end_line |
||||
let line = getline(line_num) |
||||
|
||||
if line =~ '\<\%(let\|for\)\s\+' |
||||
if line =~ '\<\%(let\|for\)\s\+s:' && |
||||
\ has_key(s:script_candidates_list, bufnr('%')) |
||||
\ && has_key(s:script_candidates_list[bufnr('%')], 'variables') |
||||
let candidates_list = s:script_candidates_list[bufnr('%')].variables |
||||
else |
||||
let candidates_list = keyword_dict |
||||
endif |
||||
|
||||
call s:analyze_variable_line(line, candidates_list) |
||||
endif |
||||
|
||||
let line_num += 1 |
||||
endwhile |
||||
|
||||
return values(keyword_dict) |
||||
endfunction"}}} |
||||
|
||||
function! s:get_cached_script_candidates() "{{{ |
||||
return has_key(s:script_candidates_list, bufnr('%')) && v:version > 700 ? |
||||
\ s:script_candidates_list[bufnr('%')] : { |
||||
\ 'functions' : {}, 'variables' : {}, 'function_prototypes' : {}, 'dictionary_variables' : {} } |
||||
endfunction"}}} |
||||
function! s:get_script_candidates(bufnumber) "{{{ |
||||
" Get script candidate list. |
||||
|
||||
let function_dict = {} |
||||
let variable_dict = {} |
||||
let dictionary_variable_dict = {} |
||||
let function_prototypes = {} |
||||
let var_pattern = '\a:[[:alnum:]_:]*\.\h\w*\%(()\?\)\?' |
||||
|
||||
for line in getbufline(a:bufnumber, 1, '$') |
||||
if line =~ '\<fu\%[nction]!\?\s\+s:' |
||||
call s:analyze_function_line(line, function_dict, function_prototypes) |
||||
elseif line =~ '\<let\s\+' |
||||
" Get script variable. |
||||
call s:analyze_variable_line(line, variable_dict) |
||||
elseif line =~ var_pattern |
||||
while line =~ var_pattern |
||||
let var_name = matchstr(line, '\a:[[:alnum:]_:]*\ze\.\h\w*') |
||||
let candidates_dict = dictionary_variable_dict |
||||
if !has_key(candidates_dict, var_name) |
||||
let candidates_dict[var_name] = {} |
||||
endif |
||||
|
||||
call s:analyze_dictionary_variable_line(line, candidates_dict[var_name], var_name) |
||||
|
||||
let line = line[matchend(line, var_pattern) :] |
||||
endwhile |
||||
endif |
||||
endfor |
||||
|
||||
return { 'functions' : function_dict, 'variables' : variable_dict, |
||||
\ 'function_prototypes' : function_prototypes, |
||||
\ 'dictionary_variables' : dictionary_variable_dict } |
||||
endfunction"}}} |
||||
|
||||
function! s:caching_from_dict(dict_name, kind) "{{{ |
||||
let dict_files = split(globpath(&runtimepath, |
||||
\ 'autoload/neocomplcache/sources/vim_complete/'.a:dict_name.'.dict'), '\n') |
||||
if empty(dict_files) |
||||
return [] |
||||
endif |
||||
|
||||
let keyword_pattern = |
||||
\'^\%(-\h\w*\%(=\%(\h\w*\|[01*?+%]\)\?\)\?'. |
||||
\'\|<\h[[:alnum:]_-]*>\?\|\h[[:alnum:]_:#\[]*\%([!\]]\+\|()\?\)\?\)' |
||||
let keyword_list = [] |
||||
for line in readfile(dict_files[0]) |
||||
call add(keyword_list, { |
||||
\ 'word' : substitute(matchstr( |
||||
\ line, keyword_pattern), '[\[\]]', '', 'g'), |
||||
\ 'kind' : a:kind, 'abbr' : line |
||||
\}) |
||||
endfor |
||||
|
||||
return keyword_list |
||||
endfunction"}}} |
||||
function! s:caching_completion_from_dict(dict_name) "{{{ |
||||
let dict_files = split(globpath(&runtimepath, |
||||
\ 'autoload/neocomplcache/sources/vim_complete/'.a:dict_name.'.dict'), '\n') |
||||
if empty(dict_files) |
||||
return {} |
||||
endif |
||||
|
||||
let keyword_dict = {} |
||||
for line in readfile(dict_files[0]) |
||||
let word = matchstr(line, '^[[:alnum:]_\[\]]\+') |
||||
let completion = matchstr(line[len(word):], '\h\w*') |
||||
if completion != '' |
||||
if word =~ '\[' |
||||
let [word_head, word_tail] = split(word, '\[') |
||||
let word_tail = ' ' . substitute(word_tail, '\]', '', '') |
||||
else |
||||
let word_head = word |
||||
let word_tail = ' ' |
||||
endif |
||||
|
||||
for i in range(len(word_tail)) |
||||
let keyword_dict[word_head . word_tail[1:i]] = completion |
||||
endfor |
||||
endif |
||||
endfor |
||||
|
||||
return keyword_dict |
||||
endfunction"}}} |
||||
function! s:caching_prototype_from_dict(dict_name) "{{{ |
||||
let dict_files = split(globpath(&runtimepath, |
||||
\ 'autoload/neocomplcache/sources/vim_complete/'.a:dict_name.'.dict'), '\n') |
||||
if empty(dict_files) |
||||
return {} |
||||
endif |
||||
if a:dict_name == 'functions' |
||||
let pattern = '^[[:alnum:]_]\+(' |
||||
else |
||||
let pattern = '^[[:alnum:]_\[\](]\+' |
||||
endif |
||||
|
||||
let keyword_dict = {} |
||||
for line in readfile(dict_files[0]) |
||||
let word = matchstr(line, pattern) |
||||
let rest = line[len(word):] |
||||
if word =~ '\[' |
||||
let [word_head, word_tail] = split(word, '\[') |
||||
let word_tail = ' ' . substitute(word_tail, '\]', '', '') |
||||
else |
||||
let word_head = word |
||||
let word_tail = ' ' |
||||
endif |
||||
|
||||
for i in range(len(word_tail)) |
||||
let keyword_dict[word_head . word_tail[1:i]] = rest |
||||
endfor |
||||
endfor |
||||
|
||||
return keyword_dict |
||||
endfunction"}}} |
||||
|
||||
function! s:get_cmdlist() "{{{ |
||||
" Get command list. |
||||
redir => redir |
||||
silent! command |
||||
redir END |
||||
|
||||
let keyword_list = [] |
||||
let completions = [ 'augroup', 'buffer', 'behave', |
||||
\ 'color', 'command', 'compiler', 'cscope', |
||||
\ 'dir', 'environment', 'event', 'expression', |
||||
\ 'file', 'file_in_path', 'filetype', 'function', |
||||
\ 'help', 'highlight', 'history', 'locale', |
||||
\ 'mapping', 'menu', 'option', 'shellcmd', 'sign', |
||||
\ 'syntax', 'tag', 'tag_listfiles', |
||||
\ 'var', 'custom', 'customlist' ] |
||||
let command_prototypes = {} |
||||
let command_completions = {} |
||||
for line in split(redir, '\n')[1:] |
||||
let word = matchstr(line, '\a\w*') |
||||
|
||||
" Analyze prototype. |
||||
let end = matchend(line, '\a\w*') |
||||
let args = matchstr(line, '[[:digit:]?+*]', end) |
||||
if args != '0' |
||||
let prototype = matchstr(line, '\a\w*', end) |
||||
let found = 0 |
||||
for comp in completions |
||||
if comp == prototype |
||||
let command_completions[word] = prototype |
||||
let found = 1 |
||||
|
||||
break |
||||
endif |
||||
endfor |
||||
|
||||
if !found |
||||
let prototype = 'arg' |
||||
endif |
||||
|
||||
if args == '*' |
||||
let prototype = '[' . prototype . '] ...' |
||||
elseif args == '?' |
||||
let prototype = '[' . prototype . ']' |
||||
elseif args == '+' |
||||
let prototype = prototype . ' ...' |
||||
endif |
||||
|
||||
let command_prototypes[word] = ' ' . repeat(' ', 16 - len(word)) . prototype |
||||
else |
||||
let command_prototypes[word] = '' |
||||
endif |
||||
let prototype = command_prototypes[word] |
||||
|
||||
call add(keyword_list, { |
||||
\ 'word' : word, 'abbr' : word . prototype, |
||||
\ 'description' : word . prototype, 'kind' : 'c' |
||||
\}) |
||||
endfor |
||||
let s:global_candidates_list.command_prototypes = command_prototypes |
||||
let s:global_candidates_list.command_completions = command_completions |
||||
|
||||
return keyword_list |
||||
endfunction"}}} |
||||
function! s:get_variablelist(dict, prefix) "{{{ |
||||
let kind_dict = ['0', '""', '()', '[]', '{}', '.'] |
||||
return values(map(copy(a:dict), "{ |
||||
\ 'word' : a:prefix.v:key, |
||||
\ 'kind' : kind_dict[type(v:val)], |
||||
\}")) |
||||
endfunction"}}} |
||||
function! s:get_functionlist() "{{{ |
||||
" Get function list. |
||||
redir => redir |
||||
silent! function |
||||
redir END |
||||
|
||||
let keyword_dict = {} |
||||
let function_prototypes = {} |
||||
for line in split(redir, '\n') |
||||
let line = line[9:] |
||||
if line =~ '^<SNR>' |
||||
continue |
||||
endif |
||||
let orig_line = line |
||||
|
||||
let word = matchstr(line, '\h[[:alnum:]_:#.]*()\?') |
||||
if word != '' |
||||
let keyword_dict[word] = { |
||||
\ 'word' : word, 'abbr' : line, |
||||
\ 'description' : line, |
||||
\} |
||||
|
||||
let function_prototypes[word] = orig_line[len(word):] |
||||
endif |
||||
endfor |
||||
|
||||
let s:global_candidates_list.function_prototypes = function_prototypes |
||||
|
||||
return values(keyword_dict) |
||||
endfunction"}}} |
||||
function! s:get_augrouplist() "{{{ |
||||
" Get augroup list. |
||||
redir => redir |
||||
silent! augroup |
||||
redir END |
||||
|
||||
let keyword_list = [] |
||||
for group in split(redir . ' END', '\s\|\n') |
||||
call add(keyword_list, { 'word' : group }) |
||||
endfor |
||||
return keyword_list |
||||
endfunction"}}} |
||||
function! s:get_mappinglist() "{{{ |
||||
" Get mapping list. |
||||
redir => redir |
||||
silent! map |
||||
redir END |
||||
|
||||
let keyword_list = [] |
||||
for line in split(redir, '\n') |
||||
let map = matchstr(line, '^\a*\s*\zs\S\+') |
||||
if map !~ '^<' || map =~ '^<SNR>' |
||||
continue |
||||
endif |
||||
call add(keyword_list, { 'word' : map }) |
||||
endfor |
||||
return keyword_list |
||||
endfunction"}}} |
||||
function! s:get_envlist() "{{{ |
||||
" Get environment variable list. |
||||
|
||||
let keyword_list = [] |
||||
for line in split(system('set'), '\n') |
||||
let word = '$' . toupper(matchstr(line, '^\h\w*')) |
||||
call add(keyword_list, { 'word' : word, 'kind' : 'e' }) |
||||
endfor |
||||
return keyword_list |
||||
endfunction"}}} |
||||
function! s:make_completion_list(list, kind) "{{{ |
||||
let list = [] |
||||
for item in a:list |
||||
call add(list, { 'word' : item, 'kind' : a:kind }) |
||||
endfor |
||||
|
||||
return list |
||||
endfunction"}}} |
||||
function! s:analyze_function_line(line, keyword_dict, prototype) "{{{ |
||||
" Get script function. |
||||
let line = substitute(matchstr(a:line, '\<fu\%[nction]!\?\s\+\zs.*)'), '".*$', '', '') |
||||
let orig_line = line |
||||
let word = matchstr(line, '^\h[[:alnum:]_:#.]*()\?') |
||||
if word != '' && !has_key(a:keyword_dict, word) |
||||
let a:keyword_dict[word] = { |
||||
\ 'word' : word, 'abbr' : line, 'kind' : 'f' |
||||
\} |
||||
let a:prototype[word] = orig_line[len(word):] |
||||
endif |
||||
endfunction"}}} |
||||
function! s:analyze_variable_line(line, keyword_dict) "{{{ |
||||
if a:line =~ '\<\%(let\|for\)\s\+\a[[:alnum:]_:]*' |
||||
" let var = pattern. |
||||
let word = matchstr(a:line, '\<\%(let\|for\)\s\+\zs\a[[:alnum:]_:]*') |
||||
let expression = matchstr(a:line, '\<let\s\+\a[[:alnum:]_:]*\s*=\s*\zs.*$') |
||||
if !has_key(a:keyword_dict, word) |
||||
let a:keyword_dict[word] = { |
||||
\ 'word' : word, |
||||
\ 'kind' : s:get_variable_type(expression) |
||||
\} |
||||
elseif expression != '' && a:keyword_dict[word].kind == '' |
||||
" Update kind. |
||||
let a:keyword_dict[word].kind = s:get_variable_type(expression) |
||||
endif |
||||
elseif a:line =~ '\<\%(let\|for\)\s\+\[.\{-}\]' |
||||
" let [var1, var2] = pattern. |
||||
let words = split(matchstr(a:line, |
||||
\'\<\%(let\|for\)\s\+\[\zs.\{-}\ze\]'), '[,[:space:]]\+') |
||||
let expressions = split(matchstr(a:line, |
||||
\'\<let\s\+\[.\{-}\]\s*=\s*\[\zs.\{-}\ze\]$'), '[,[:space:];]\+') |
||||
|
||||
let i = 0 |
||||
while i < len(words) |
||||
let expression = get(expressions, i, '') |
||||
let word = words[i] |
||||
|
||||
if !has_key(a:keyword_dict, word) |
||||
let a:keyword_dict[word] = { |
||||
\ 'word' : word, |
||||
\ 'kind' : s:get_variable_type(expression) |
||||
\} |
||||
elseif expression != '' && a:keyword_dict[word].kind == '' |
||||
" Update kind. |
||||
let a:keyword_dict[word].kind = s:get_variable_type(expression) |
||||
endif |
||||
|
||||
let i += 1 |
||||
endwhile |
||||
elseif a:line =~ '\<fu\%[nction]!\?\s\+' |
||||
" Get function arguments. |
||||
for arg in split(matchstr(a:line, '^[^(]*(\zs[^)]*'), '\s*,\s*') |
||||
let word = 'a:' . (arg == '...' ? '000' : arg) |
||||
let a:keyword_dict[word] = { |
||||
\ 'word' : word, |
||||
\ 'kind' : (arg == '...' ? '[]' : '') |
||||
\} |
||||
|
||||
endfor |
||||
if a:line =~ '\.\.\.)' |
||||
" Extra arguments. |
||||
for arg in range(5) |
||||
let word = 'a:' . arg |
||||
let a:keyword_dict[word] = { |
||||
\ 'word' : word, |
||||
\ 'kind' : (arg == 0 ? '0' : '') |
||||
\} |
||||
endfor |
||||
endif |
||||
endif |
||||
endfunction"}}} |
||||
function! s:analyze_dictionary_variable_line(line, keyword_dict, var_name) "{{{ |
||||
let var_pattern = a:var_name.'\.\h\w*\%(()\?\)\?' |
||||
let let_pattern = '\<let\s\+'.a:var_name.'\.\h\w*' |
||||
let call_pattern = '\<call\s\+'.a:var_name.'\.\h\w*()\?' |
||||
|
||||
if a:line =~ let_pattern |
||||
let word = matchstr(a:line, a:var_name.'\zs\.\h\w*') |
||||
let expression = matchstr(a:line, let_pattern.'\s*=\zs.*$') |
||||
let kind = '' |
||||
elseif a:line =~ call_pattern |
||||
let word = matchstr(a:line, a:var_name.'\zs\.\h\w*()\?') |
||||
let kind = '()' |
||||
else |
||||
let word = matchstr(a:line, a:var_name.'\zs.\h\w*\%(()\?\)\?') |
||||
let kind = s:get_variable_type(matchstr(a:line, a:var_name.'\.\h\w*\zs.*$')) |
||||
endif |
||||
|
||||
if !has_key(a:keyword_dict, word) |
||||
let a:keyword_dict[word] = { 'word' : word, 'kind' : kind } |
||||
elseif kind != '' && a:keyword_dict[word].kind == '' |
||||
" Update kind. |
||||
let a:keyword_dict[word].kind = kind |
||||
endif |
||||
endfunction"}}} |
||||
function! s:split_args(cur_text, complete_str) "{{{ |
||||
let args = split(a:cur_text) |
||||
if a:complete_str == '' |
||||
call add(args, '') |
||||
endif |
||||
|
||||
return args |
||||
endfunction"}}} |
||||
|
||||
" Initialize return types. "{{{ |
||||
function! s:set_dictionary_helper(variable, keys, value) "{{{ |
||||
for key in split(a:keys, ',') |
||||
let a:variable[key] = a:value |
||||
endfor |
||||
endfunction"}}} |
||||
let s:function_return_types = {} |
||||
call neocomplcache#util#set_dictionary_helper( |
||||
\ s:function_return_types, |
||||
\ 'len,match,matchend', |
||||
\ '0') |
||||
call neocomplcache#util#set_dictionary_helper( |
||||
\ s:function_return_types, |
||||
\ 'input,matchstr', |
||||
\ '""') |
||||
call neocomplcache#util#set_dictionary_helper( |
||||
\ s:function_return_types, |
||||
\ 'expand,filter,sort,split', |
||||
\ '[]') |
||||
"}}} |
||||
function! s:get_variable_type(expression) "{{{ |
||||
" Analyze variable type. |
||||
if a:expression =~ '^\%(\s*+\)\?\s*\d\+\.\d\+' |
||||
return '.' |
||||
elseif a:expression =~ '^\%(\s*+\)\?\s*\d\+' |
||||
return '0' |
||||
elseif a:expression =~ '^\%(\s*\.\)\?\s*["'']' |
||||
return '""' |
||||
elseif a:expression =~ '\<function(' |
||||
return '()' |
||||
elseif a:expression =~ '^\%(\s*+\)\?\s*\[' |
||||
return '[]' |
||||
elseif a:expression =~ '^\s*{\|^\.\h[[:alnum:]_:]*' |
||||
return '{}' |
||||
elseif a:expression =~ '\<\h\w*(' |
||||
" Function. |
||||
let func_name = matchstr(a:expression, '\<\zs\h\w*\ze(') |
||||
return has_key(s:function_return_types, func_name) ? s:function_return_types[func_name] : '' |
||||
else |
||||
return '' |
||||
endif |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
<buffer> ; the mapping will be effective in the current buffer only |
||||
<expr> ; the argument is an expression evaluated to obtain the {rhs} that is used |
||||
<Leader> ; define a mapping which uses the "mapleader" variable |
||||
<LocalLeader> ; just like <Leader>, except that it uses "maplocalleader" instead of "mapleader" |
||||
<Plug> ; used for an internal mapping, which is not to be matched with any key sequence |
||||
<script> ; the mapping will only remap characters in the {rhs} using mappings that were defined local to a script |
||||
<SID> ; unique mapping for the script |
||||
<unique> ; the command will fail if the mapping or abbreviation already exists |
||||
<silent> ; define a mapping which will not be echoed on the command line |
||||
<Nul> ; zero |
||||
<Nop> ; no operation |
||||
<BS> ; backspace |
||||
<Tab> ; tab |
||||
<NL> ; linefeed |
||||
<FF> ; formfeed |
||||
<CR> ; carriage return |
||||
<Return> ; same as <CR> |
||||
<Enter> ; same as <CR> |
||||
<Esc> ; escape |
||||
<Space> ; space |
||||
<lt> ; less-than < |
||||
<Bslash> ; backslash \ |
||||
<Bar> ; vertical bar | |
||||
<Del> ; delete |
||||
<CSI> ; command sequence intro ALT-Esc |
||||
<xCSI> ; CSI when typed in the GUI |
||||
<EOL> ; end-of-line (can be <CR>, <LF> or <CR><LF>, depends on system and 'fileformat') |
||||
<Up> ; cursor-up |
||||
<Down> ; cursor-down |
||||
<Left> ; cursor-left |
||||
<Right> ; cursor-right |
||||
<S-Up> ; shift-cursor-up |
||||
<S-Down> ; shift-cursor-down |
||||
<S-Left> ; shift-cursor-left |
||||
<S-Right> ; shift-cursor-right |
||||
<C-Left> ; control-cursor-left |
||||
<C-Right> ; control-cursor-right |
||||
<Help> ; help key |
||||
<Undo> ; undo key |
||||
<Insert> ; insert key |
||||
<Home> ; home |
||||
<End> ; end |
||||
<PageUp> ; page-up |
||||
<PageDown> ; page-down |
||||
<kHome> ; keypad home (upper left) |
||||
<kEnd> ; keypad end (lower left) |
||||
<kPageUp> ; keypad page-up (upper right) |
||||
<kPageDown> ; keypad page-down (lower right) |
||||
<kPlus> ; keypad + |
||||
<kMinus> ; keypad - |
||||
<kMultiply> ; keypad * |
||||
<kDivide> ; keypad / |
||||
<kEnter> ; keypad Enter |
||||
<kPoint> ; keypad Decimal point |
||||
<LeftMouse> ; Left mouse click |
||||
<A-LeftMouse> ; Left mouse click with Alt |
||||
<C-LeftMouse> ; Left mouse click with Ctrl |
||||
<S-LeftMouse> ; Left mouse click with Shift |
||||
<2-LeftMouse> ; Double left mouse click |
||||
<3-LeftMouse> ; Triple left mouse click |
||||
<4-LeftMouse> ; Quad left mouse click |
||||
<LeftDrag> ; Left mouse drag |
||||
<LeftRelease> ; Left mouse release |
||||
<MiddleMouse> ; Middle mouse click |
||||
<MiddleDrag> ; Middle mouse drag |
||||
<MiddleRelease> ; Middle mouse drag |
||||
<RightMouse> ; Right mouse click |
||||
<A-RightMouse> ; Right mouse click with Alt |
||||
<S-RightMouse> ; Right mouse click with Shift |
||||
<C-RightMouse> ; Right mouse click with Ctrl |
||||
<RightDrag> ; Right mouse drag |
||||
<RightRelease> ; Right mouse release |
@ -0,0 +1,354 @@
@@ -0,0 +1,354 @@
|
||||
aleph ; ASCII code of the letter Aleph (Hebrew) |
||||
allowrevins ; allow CTRL-_ in Insert and Command-line mode |
||||
altkeymap ; for default second language (Farsi/Hebrew) |
||||
ambiwidth ; what to do with Unicode chars of ambiguous width |
||||
antialias ; Mac OS X: use smooth, antialiased fonts |
||||
arabic ; for Arabic as a default second language |
||||
arabicshape ; do shaping for Arabic characters |
||||
autochdir ; change directory to the file in the current window |
||||
autoindent ; take indent for new line from previous line |
||||
autoread ; autom. read file when changed outside of Vim |
||||
autowrite ; automatically write file if changed |
||||
autowriteall ; as 'autowrite', but works with more commands |
||||
background ; "dark" or "light", used for highlight colors |
||||
backspace ; how backspace works at start of line |
||||
backup ; keep backup file after overwriting a file |
||||
backupcopy ; make backup as a copy, don't rename the file |
||||
backupdir ; list of directories for the backup file |
||||
backupext ; extension used for the backup file |
||||
backupskip ; no backup for files that match these patterns |
||||
balloondelay ; delay in mS before a balloon may pop up |
||||
ballooneval ; switch on balloon evaluation |
||||
balloonexpr ; expression to show in balloon |
||||
binary ; read/write/edit file in binary mode |
||||
bioskey ; MS-DOS: use bios calls for input characters |
||||
bomb ; prepend a Byte Order Mark to the file |
||||
breakat ; characters that may cause a line break |
||||
browsedir ; which directory to start browsing in |
||||
bufhidden ; what to do when buffer is no longer in window |
||||
buflisted ; whether the buffer shows up in the buffer list |
||||
buftype ; special type of buffer |
||||
casemap ; specifies how case of letters is changed |
||||
cdpath ; list of directories searched with ":cd" |
||||
cedit ; key used to open the command-line window |
||||
charconvert ; expression for character encoding conversion |
||||
cindent ; do C program indenting |
||||
cinkeys ; keys that trigger indent when 'cindent' is set |
||||
cinoptions ; how to do indenting when 'cindent' is set |
||||
cinwords ; words where 'si' and 'cin' add an indent |
||||
clipboard ; use the clipboard as the unnamed register |
||||
cmdheight ; number of lines to use for the command-line |
||||
cmdwinheight ; height of the command-line window |
||||
colorcolumn ; screen columns that are highlighted with ColorColumn |
||||
columns ; number of columns in the display |
||||
comments ; patterns that can start a comment line |
||||
commentstring ; template for comments; used for fold marker |
||||
compatible ; behave Vi-compatible as much as possible |
||||
complete ; specify how Insert mode completion works |
||||
completefunc ; function to be used for Insert mode completion |
||||
completeopt ; options for Insert mode completion |
||||
concealcursor ; sets the modes in which text in the cursor line can also be concealed |
||||
conceallevel ; how text with the "conceal" syntax attribute |
||||
confirm ; ask what to do about unsaved/read-only files |
||||
conskey ; get keys directly from console (MS-DOS only) |
||||
copyindent ; make 'autoindent' use existing indent structure |
||||
cpoptions ; flags for Vi-compatible behavior |
||||
cryptmethod ; method used for encryption when the buffer is written to a file |
||||
cscopepathcomp ; how many components of the path to show |
||||
cscopeprg ; command to execute cscope |
||||
cscopequickfix ; use quickfix window for cscope results |
||||
cscopetag ; use cscope for tag commands |
||||
cscopetagorder ; determines ":cstag" search order |
||||
cscopeverbose ; give messages when adding a cscope database |
||||
cursorcolumn ; highlight the screen column of the cursor |
||||
cursorline ; highlight the screen line of the cursor |
||||
debug ; set to "msg" to see all error messages |
||||
define ; pattern to be used to find a macro definition |
||||
delcombine ; delete combining characters on their own |
||||
dictionary ; list of file names used for keyword completion |
||||
diff ; use diff mode for the current window |
||||
diffexpr ; expression used to obtain a diff file |
||||
diffopt ; options for using diff mode |
||||
digraph ; enable the entering of digraphs in Insert mode |
||||
directory ; list of directory names for the swap file |
||||
display ; list of flags for how to display text |
||||
eadirection ; in which direction 'equalalways' works |
||||
edcompatible ; toggle flags of ":substitute" command |
||||
encoding ; encoding used internally |
||||
endofline ; write <EOL> for last line in file |
||||
equalalways ; windows are automatically made the same size |
||||
equalprg ; external program to use for "=" command |
||||
errorbells ; ring the bell for error messages |
||||
errorfile ; name of the errorfile for the QuickFix mode |
||||
errorformat ; description of the lines in the error file |
||||
esckeys ; recognize function keys in Insert mode |
||||
eventignore ; autocommand events that are ignored |
||||
expandtab ; use spaces when <Tab> is inserted |
||||
exrc ; read .vimrc and .exrc in the current directory |
||||
fileencoding ; file encoding for multi-byte text |
||||
fileencodings ; automatically detected character encodings |
||||
fileformat ; file format used for file I/O |
||||
fileformats ; automatically detected values for 'fileformat' |
||||
filetype ; type of file, used for autocommands |
||||
fillchars ; characters to use for displaying special items |
||||
fkmap ; Farsi keyboard mapping |
||||
foldclose ; close a fold when the cursor leaves it |
||||
foldcolumn ; width of the column used to indicate folds |
||||
foldenable ; set to display all folds open |
||||
foldexpr ; expression used when 'foldmethod' is "expr" |
||||
foldignore ; ignore lines when 'foldmethod' is "indent" |
||||
foldlevel ; close folds with a level higher than this |
||||
foldlevelstart ; 'foldlevel' when starting to edit a file |
||||
foldmarker ; markers used when 'foldmethod' is "marker" |
||||
foldmethod ; folding type |
||||
foldminlines ; minimum number of lines for a fold to be closed |
||||
foldnestmax ; maximum fold depth |
||||
foldopen ; for which commands a fold will be opened |
||||
foldtext ; expression used to display for a closed fold |
||||
formatexpr ; expression used with "gq" command |
||||
formatlistpat ; pattern used to recognize a list header |
||||
formatoptions ; how automatic formatting is to be done |
||||
formatprg ; name of external program used with "gq" command |
||||
fsync ; whether to invoke fsync() after file write |
||||
gdefault ; the ":substitute" flag 'g' is default on |
||||
grepformat ; format of 'grepprg' output |
||||
grepprg ; program to use for ":grep" |
||||
guicursor ; GUI: settings for cursor shape and blinking |
||||
guifont ; GUI: Name(s) of font(s) to be used |
||||
guifontset ; GUI: Names of multi-byte fonts to be used |
||||
guifontwide ; list of font names for double-wide characters |
||||
guiheadroom ; GUI: pixels room for window decorations |
||||
guioptions ; GUI: Which components and options are used |
||||
guipty ; GUI: try to use a pseudo-tty for ":!" commands |
||||
guitablabel ; GUI: custom label for a tab page |
||||
guitabtooltip ; GUI: custom tooltip for a tab page |
||||
helpfile ; full path name of the main help file |
||||
helpheight ; minimum height of a new help window |
||||
helplang ; preferred help languages |
||||
hidden ; don't unload buffer when it is abandoned |
||||
highlight ; sets highlighting mode for various occasions |
||||
history ; number of command-lines that are remembered |
||||
hkmap ; Hebrew keyboard mapping |
||||
hkmapp ; phonetic Hebrew keyboard mapping |
||||
hlsearch ; highlight matches with last search pattern |
||||
icon ; let Vim set the text of the window icon |
||||
iconstring ; string to use for the Vim icon text |
||||
ignorecase ; ignore case in search patterns |
||||
imactivatekey ; key that activates the X input method |
||||
imcmdline ; use IM when starting to edit a command line |
||||
imdisable ; do not use the IM in any mode |
||||
iminsert ; use :lmap or IM in Insert mode |
||||
imsearch ; use :lmap or IM when typing a search pattern |
||||
include ; pattern to be used to find an include file |
||||
includeexpr ; expression used to process an include line |
||||
incsearch ; highlight match while typing search pattern |
||||
indentexpr ; expression used to obtain the indent of a line |
||||
indentkeys ; keys that trigger indenting with 'indentexpr' |
||||
infercase ; adjust case of match for keyword completion |
||||
insertmode ; start the edit of a file in Insert mode |
||||
isfname ; characters included in file names and pathnames |
||||
isident ; characters included in identifiers |
||||
iskeyword ; characters included in keywords |
||||
isprint ; printable characters |
||||
joinspaces ; two spaces after a period with a join command |
||||
key ; encryption key |
||||
key ; for encrypting and decrypting the current buffer |
||||
keymap ; name of a keyboard mapping |
||||
keymodel ; enable starting/stopping selection with keys |
||||
keywordprg ; program to use for the "K" command |
||||
langmap ; alphabetic characters for other language mode |
||||
langmenu ; language to be used for the menus |
||||
laststatus ; tells when last window has status lines |
||||
lazyredraw ; don't redraw while executing macros |
||||
linebreak ; wrap long lines at a blank |
||||
lines ; number of lines in the display |
||||
linespace ; number of pixel lines to use between characters |
||||
lisp ; automatic indenting for Lisp |
||||
lispwords ; words that change how lisp indenting works |
||||
list ; show <Tab> and <EOL> |
||||
listchars ; characters for displaying in list mode |
||||
loadplugins ; load plugin scripts when starting up |
||||
macatsui ; Mac GUI: use ATSUI text drawing |
||||
magic ; changes special characters in search patterns |
||||
makeef ; name of the errorfile for ":make" |
||||
makeprg ; program to use for the ":make" command |
||||
matchpairs ; pairs of characters that "%" can match |
||||
matchtime ; tenths of a second to show matching paren |
||||
maxcombine ; maximum nr of combining characters displayed |
||||
maxfuncdepth ; maximum recursive depth for user functions |
||||
maxmapdepth ; maximum recursive depth for mapping |
||||
maxmem ; maximum memory (in Kbyte) used for one buffer |
||||
maxmempattern ; maximum memory (in Kbyte) used for pattern search |
||||
maxmemtot ; maximum memory (in Kbyte) used for all buffers |
||||
menuitems ; maximum number of items in a menu |
||||
mkspellmem ; memory used before :mkspell compresses the tree |
||||
modeline ; recognize modelines at start or end of file |
||||
modelines ; number of lines checked for modelines |
||||
modifiable ; changes to the text are not possible |
||||
modified ; buffer has been modified |
||||
more ; pause listings when the whole screen is filled |
||||
mouse ; enable the use of mouse clicks |
||||
mousefocus ; keyboard focus follows the mouse |
||||
mousehide ; hide mouse pointer while typing |
||||
mousemodel ; changes meaning of mouse buttons |
||||
mouseshape ; shape of the mouse pointer in different modes |
||||
mousetime ; max time between mouse double-click |
||||
mzquantum ; the interval between polls for MzScheme threads |
||||
nrformats ; number formats recognized for CTRL-A command |
||||
number ; print the line number in front of each line |
||||
numberwidth ; number of columns used for the line number |
||||
omnifunc ; function for filetype-specific completion |
||||
opendevice ; allow reading/writing devices on MS-Windows |
||||
operatorfunc ; function to be called for g@ operator |
||||
osfiletype ; operating system-specific filetype information |
||||
paragraphs ; nroff macros that separate paragraphs |
||||
paste ; allow pasting text |
||||
pastetoggle ; key code that causes 'paste' to toggle |
||||
patchexpr ; expression used to patch a file |
||||
patchmode ; keep the oldest version of a file |
||||
path ; list of directories searched with "gf" et.al. |
||||
preserveindent ; preserve the indent structure when reindenting |
||||
previewheight ; height of the preview window |
||||
previewwindow ; identifies the preview window |
||||
printdevice ; name of the printer to be used for :hardcopy |
||||
printencoding ; encoding to be used for printing |
||||
printexpr ; expression used to print PostScript for :hardcopy |
||||
printfont ; name of the font to be used for :hardcopy |
||||
printheader ; format of the header used for :hardcopy |
||||
printmbcharset ; CJK character set to be used for :hardcopy |
||||
printmbfont ; font names to be used for CJK output of :hardcopy |
||||
printoptions ; controls the format of :hardcopy output |
||||
pumheight ; maximum height of the popup menu |
||||
quoteescape ; escape characters used in a string |
||||
readonly ; disallow writing the buffer |
||||
redrawtime ; timeout for 'hlsearch' and :match highlighting |
||||
relativenumber ; show the line number relative to the line with the cursor in front of each line |
||||
remap ; allow mappings to work recursively |
||||
report ; threshold for reporting nr. of lines changed |
||||
restorescreen ; Win32: restore screen when exiting |
||||
revins ; inserting characters will work backwards |
||||
rightleft ; window is right-to-left oriented |
||||
rightleftcmd ; commands for which editing works right-to-left |
||||
ruler ; show cursor line and column in the status line |
||||
rulerformat ; custom format for the ruler |
||||
runtimepath ; list of directories used for runtime files |
||||
scroll ; lines to scroll with CTRL-U and CTRL-D |
||||
scrollbind ; scroll in window as other windows scroll |
||||
scrolljump ; minimum number of lines to scroll |
||||
scrolloff ; minimum nr. of lines above and below cursor |
||||
scrollopt ; how 'scrollbind' should behave |
||||
sections ; nroff macros that separate sections |
||||
secure ; secure mode for reading .vimrc in current dir |
||||
selection ; what type of selection to use |
||||
selectmode ; when to use Select mode instead of Visual mode |
||||
sessionoptions ; options for :mksession |
||||
shell ; name of shell to use for external commands |
||||
shellcmdflag ; flag to shell to execute one command |
||||
shellpipe ; string to put output of ":make" in error file |
||||
shellquote ; quote character(s) for around shell command |
||||
shellredir ; string to put output of filter in a temp file |
||||
shellslash ; use forward slash for shell file names |
||||
shelltemp ; whether to use a temp file for shell commands |
||||
shelltype ; Amiga: influences how to use a shell |
||||
shellxquote ; like 'shellquote', but include redirection |
||||
shiftround ; round indent to multiple of shiftwidth |
||||
shiftwidth ; number of spaces to use for (auto)indent step |
||||
shortmess ; list of flags, reduce length of messages |
||||
shortname ; non-MS-DOS: Filenames assumed to be 8.3 chars |
||||
showbreak ; string to use at the start of wrapped lines |
||||
showcmd ; show (partial) command in status line |
||||
showfulltag ; show full tag pattern when completing tag |
||||
showmatch ; briefly jump to matching bracket if insert one |
||||
showmode ; message on status line to show current mode |
||||
showtabline ; tells when the tab pages line is displayed |
||||
sidescroll ; minimum number of columns to scroll horizontal |
||||
sidescrolloff ; min. nr. of columns to left and right of cursor |
||||
smartcase ; no ignore case when pattern has uppercase |
||||
smartindent ; smart autoindenting for C programs |
||||
smarttab ; use 'shiftwidth' when inserting <Tab> |
||||
softtabstop ; number of spaces that <Tab> uses while editing |
||||
spell ; enable spell checking |
||||
spellcapcheck ; pattern to locate end of a sentence |
||||
spellfile ; files where zg and zw store words |
||||
spelllang ; language(s) to do spell checking for |
||||
spellsuggest ; method(s) used to suggest spelling corrections |
||||
splitbelow ; new window from split is below the current one |
||||
splitright ; new window is put right of the current one |
||||
startofline ; commands move cursor to first non-blank in line |
||||
statusline ; custom format for the status line |
||||
suffixes ; suffixes that are ignored with multiple match |
||||
suffixesadd ; suffixes added when searching for a file |
||||
swapfile ; whether to use a swapfile for a buffer |
||||
swapsync ; how to sync the swap file |
||||
switchbuf ; sets behavior when switching to another buffer |
||||
synmaxcol ; maximum column to find syntax items |
||||
syntax ; syntax to be loaded for current buffer |
||||
tabline ; custom format for the console tab pages line |
||||
tabpagemax ; maximum number of tab pages for -p and "tab all" |
||||
tabstop ; number of spaces that <Tab> in file uses |
||||
tagbsearch ; use binary searching in tags files |
||||
taglength ; number of significant characters for a tag |
||||
tagrelative ; file names in tag file are relative |
||||
tags ; list of file names used by the tag command |
||||
tagstack ; push tags onto the tag stack |
||||
term ; name of the terminal |
||||
termbidi ; terminal takes care of bi-directionality |
||||
termencoding ; character encoding used by the terminal |
||||
terse ; shorten some messages |
||||
textauto ; obsolete, use 'fileformats' |
||||
textmode ; obsolete, use 'fileformat' |
||||
textwidth ; maximum width of text that is being inserted |
||||
thesaurus ; list of thesaurus files for keyword completion |
||||
tildeop ; tilde command "~" behaves like an operator |
||||
timeout ; time out on mappings and key codes |
||||
timeoutlen ; time out time in milliseconds |
||||
title ; let Vim set the title of the window |
||||
titlelen ; percentage of 'columns' used for window title |
||||
titleold ; old title, restored when exiting |
||||
titlestring ; string to use for the Vim window title |
||||
toolbar ; GUI: which items to show in the toolbar |
||||
toolbariconsize ; size of the toolbar icons (for GTK 2 only) |
||||
transparency ; GUI: set transparency percentage (max: 255) |
||||
ttimeout ; time out on mappings |
||||
ttimeoutlen ; time out time for key codes in milliseconds |
||||
ttybuiltin ; use built-in termcap before external termcap |
||||
ttyfast ; indicates a fast terminal connection |
||||
ttymouse ; type of mouse codes generated |
||||
ttyscroll ; maximum number of lines for a scroll |
||||
ttytype ; alias for 'term' |
||||
undodir ; list of directory names for undo files |
||||
undofile ; automatically saves undo history to an undo file |
||||
undolevels ; maximum number of changes that can be undone |
||||
undoreload ; save the whole buffer for undo when reloading it |
||||
updatecount ; after this many characters flush swap file |
||||
updatetime ; after this many milliseconds flush swap file |
||||
verbose ; give informative messages |
||||
verbosefile ; file to write messages in |
||||
viewdir ; directory where to store files with :mkview |
||||
viewoptions ; specifies what to save for :mkview |
||||
viminfo ; use .viminfo file upon startup and exiting |
||||
virtualedit ; when to use virtual editing |
||||
visualbell ; use visual bell instead of beeping |
||||
warn ; warn for shell command when buffer was changed |
||||
weirdinvert ; for terminals that have weird inversion method |
||||
whichwrap ; allow specified keys to cross line boundaries |
||||
wildchar ; command-line character for wildcard expansion |
||||
wildcharm ; like 'wildchar' but also works when mapped |
||||
wildignore ; files matching these patterns are not completed |
||||
wildmenu ; use menu for command line completion |
||||
wildmode ; mode for 'wildchar' command-line expansion |
||||
wildoptions ; specifies how command line completion is done. |
||||
winaltkeys ; when the windows system handles ALT keys |
||||
winfixheight ; keep window height when opening/closing windows |
||||
winfixwidth ; keep window width when opening/closing windows |
||||
winheight ; minimum number of lines for the current window |
||||
winminheight ; minimum number of lines for any window |
||||
winminwidth ; minimal number of columns for any window |
||||
winwidth ; minimal number of columns for current window |
||||
wrap ; long lines wrap and continue on the next line |
||||
wrapmargin ; chars from the right where wrapping starts |
||||
wrapscan ; searches wrap around the end of the file |
||||
write ; writing to a file is allowed |
||||
writeany ; write to file with no need for "!" override |
||||
writebackup ; make a backup before overwriting a file |
||||
writedelay ; delay this many msec for each char (for debug) |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
v:beval_col ; the number of the column, over which the mouse pointer is |
||||
v:beval_bufnr ; the number of the buffer, over which the mouse pointer is |
||||
v:beval_lnum ; the number of the line, over which the mouse pointer is |
||||
v:beval_text ; the text under or after the mouse pointer |
||||
v:beval_winnr ; the number of the window, over which the mouse pointer is |
||||
v:char ; argument for evaluating 'formatexpr' and used for the typed character when using <expr> in an abbreviation |
||||
v:charconvert_from ; the name of the character encoding of a file to be converted |
||||
v:charconvert_to ; the name of the character encoding of a file after conversion |
||||
v:cmdarg ; the extra arguments given to a file read/write command |
||||
v:cmdbang ; when a "!" was used the value is 1, otherwise it is 0 |
||||
v:count ; the count given for the last Normal mode command |
||||
v:count1 ; Just like "v:count", but defaults to one when no count is used |
||||
v:ctype ; the current locale setting for characters of the runtime environment |
||||
v:dying ; normally zero, when a deadly signal is caught it's set to one |
||||
v:errmsg ; last given error message |
||||
v:exception ; the value of the exception most recently caught and not finished |
||||
v:fcs_reason ; the reason why the FileChangedShell event was triggered. |
||||
v:fcs_choice ; what should happen after a FileChangedShell event was triggered |
||||
v:fname_in ; the name of the input file |
||||
v:fname_out ; the name of the output file |
||||
v:fname_new ; the name of the new version of the file |
||||
v:fname_diff ; the name of the diff (patch) file |
||||
v:folddashes ; dashes representing foldlevel of a closed fold |
||||
v:foldlevel ; foldlevel of closed fold |
||||
v:foldend ; last line of closed fold |
||||
v:foldstart ; first line of closed fold |
||||
v:insertmode ; i: Insert mode r: Replace mode v: Virtual Replace mode |
||||
v:key ; key of the current item of a Dictionary |
||||
v:lang ; the current locale setting for messages of the runtime environment |
||||
v:lc_time ; the current locale setting for time messages of the runtime environment |
||||
v:lnum ; line number for the 'foldexpr' fold-expr and 'indentexpr' expressions |
||||
v:mouse_win ; window number for a mouse click obtained with getchar() |
||||
v:mouse_lnum ; line number for a mouse click obtained with getchar() |
||||
v:mouse_col ; column number for a mouse click obtained with getchar() |
||||
v:oldfiles ; list of file names that is loaded from the viminfo file on startup |
||||
v:operator ; the last operator given in Normal mode |
||||
v:prevcount ; the count given for the last but one Normal mode command |
||||
v:profiling ; normally zero. set to one after using ":profile start" |
||||
v:progname ; contains the name (with path removed) with which Vim was invoked |
||||
v:register ; the name of the register supplied to the last normal mode command |
||||
v:scrollstart ; string describing the script or function that caused the screen to scroll up |
||||
v:servername ; the resulting registered x11-clientserver name if any |
||||
v:searchforward ; search direction: 1 after a forward search, 0 after a backward search |
||||
v:shell_error ; result of the last shell command |
||||
v:statusmsg ; last given status message |
||||
v:swapname ; name of the swap file found |
||||
v:swapchoice ; SwapExists autocommands can set this to the selected choice |
||||
v:swapcommand ; normal mode command to be executed after a file has been opened |
||||
v:termresponse ; the escape sequence returned by the terminal for the t_RV termcap entry |
||||
v:this_session ; full filename of the last loaded or saved session file |
||||
v:throwpoint ; the point where the exception most recently caught and not finished was thrown |
||||
v:val ; value of the current item of a List or Dictionary |
||||
v:version ; version number of Vim: Major version*100+minor version |
||||
v:warningmsg ; last given warning message |
@ -0,0 +1,228 @@
@@ -0,0 +1,228 @@
|
||||
"============================================================================= |
||||
" FILE: util.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 25 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
let s:V = vital#of('neocomplcache') |
||||
let s:List = vital#of('neocomplcache').import('Data.List') |
||||
let s:String = vital#of('neocomplcache').import('Data.String') |
||||
|
||||
function! neocomplcache#util#truncate_smart(...) "{{{ |
||||
return call(s:V.truncate_smart, a:000) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#truncate(...) "{{{ |
||||
return call(s:V.truncate, a:000) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#strchars(...) "{{{ |
||||
return call(s:String.strchars, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#wcswidth(...) "{{{ |
||||
return call(s:V.wcswidth, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#strwidthpart(...) "{{{ |
||||
return call(s:V.strwidthpart, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#strwidthpart_reverse(...) "{{{ |
||||
return call(s:V.strwidthpart_reverse, a:000) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#substitute_path_separator(...) "{{{ |
||||
return call(s:V.substitute_path_separator, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#mb_strlen(...) "{{{ |
||||
return call(s:String.strchars, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#uniq(list) "{{{ |
||||
let dict = {} |
||||
for item in a:list |
||||
if !has_key(dict, item) |
||||
let dict[item] = item |
||||
endif |
||||
endfor |
||||
|
||||
return values(dict) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#system(...) "{{{ |
||||
return call(s:V.system, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#has_vimproc(...) "{{{ |
||||
return call(s:V.has_vimproc, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#has_lua() "{{{ |
||||
" Note: Disabled if_lua feature if less than 7.3.885. |
||||
" Because if_lua has double free problem. |
||||
return has('lua') && (v:version > 703 || v:version == 703 && has('patch885')) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#is_windows(...) "{{{ |
||||
return call(s:V.is_windows, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#is_mac(...) "{{{ |
||||
return call(s:V.is_mac, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#get_last_status(...) "{{{ |
||||
return call(s:V.get_last_status, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#escape_pattern(...) "{{{ |
||||
return call(s:V.escape_pattern, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#iconv(...) "{{{ |
||||
return call(s:V.iconv, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#uniq(...) "{{{ |
||||
return call(s:List.uniq, a:000) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#sort_by(...) |
||||
return call(s:List.sort_by, a:000) |
||||
endfunction |
||||
|
||||
function! neocomplcache#util#glob(pattern, ...) "{{{ |
||||
if a:pattern =~ "'" |
||||
" Use glob('*'). |
||||
let cwd = getcwd() |
||||
let base = neocomplcache#util#substitute_path_separator( |
||||
\ fnamemodify(a:pattern, ':h')) |
||||
execute 'lcd' fnameescape(base) |
||||
|
||||
let files = map(split(neocomplcache#util#substitute_path_separator( |
||||
\ glob('*')), '\n'), "base . '/' . v:val") |
||||
|
||||
execute 'lcd' fnameescape(cwd) |
||||
|
||||
return files |
||||
endif |
||||
|
||||
" let is_force_glob = get(a:000, 0, 0) |
||||
let is_force_glob = get(a:000, 0, 1) |
||||
|
||||
if !is_force_glob && a:pattern =~ '^[^\\*]\+/\*' |
||||
\ && neocomplcache#util#has_vimproc() && exists('*vimproc#readdir') |
||||
return filter(vimproc#readdir(a:pattern[: -2]), 'v:val !~ "/\\.\\.\\?$"') |
||||
else |
||||
" Escape [. |
||||
if neocomplcache#util#is_windows() |
||||
let glob = substitute(a:pattern, '\[', '\\[[]', 'g') |
||||
else |
||||
let glob = escape(a:pattern, '[') |
||||
endif |
||||
|
||||
return split(neocomplcache#util#substitute_path_separator(glob(glob)), '\n') |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#util#expand(path) "{{{ |
||||
return expand(escape(a:path, '*?[]"={}'), 1) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#set_default(var, val, ...) "{{{ |
||||
if !exists(a:var) || type({a:var}) != type(a:val) |
||||
let alternate_var = get(a:000, 0, '') |
||||
|
||||
let {a:var} = exists(alternate_var) ? |
||||
\ {alternate_var} : a:val |
||||
endif |
||||
endfunction"}}} |
||||
function! neocomplcache#util#set_dictionary_helper(...) "{{{ |
||||
return call(s:V.set_dictionary_helper, a:000) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#set_default_dictionary(variable, keys, value) "{{{ |
||||
if !exists('s:disable_dictionaries') |
||||
let s:disable_dictionaries = {} |
||||
endif |
||||
|
||||
if has_key(s:disable_dictionaries, a:variable) |
||||
return |
||||
endif |
||||
|
||||
call neocomplcache#util#set_dictionary_helper({a:variable}, a:keys, a:value) |
||||
endfunction"}}} |
||||
function! neocomplcache#util#disable_default_dictionary(variable) "{{{ |
||||
if !exists('s:disable_dictionaries') |
||||
let s:disable_dictionaries = {} |
||||
endif |
||||
|
||||
let s:disable_dictionaries[a:variable] = 1 |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#split_rtp(...) "{{{ |
||||
let rtp = a:0 ? a:1 : &runtimepath |
||||
if type(rtp) == type([]) |
||||
return rtp |
||||
endif |
||||
|
||||
if rtp !~ '\\' |
||||
return split(rtp, ',') |
||||
endif |
||||
|
||||
let split = split(rtp, '\\\@<!\%(\\\\\)*\zs,') |
||||
return map(split,'substitute(v:val, ''\\\([\\,]\)'', "\\1", "g")') |
||||
endfunction"}}} |
||||
function! neocomplcache#util#join_rtp(list) "{{{ |
||||
return join(map(copy(a:list), 's:escape(v:val)'), ',') |
||||
endfunction"}}} |
||||
" Escape a path for runtimepath. |
||||
function! s:escape(path)"{{{ |
||||
return substitute(a:path, ',\|\\,\@=', '\\\0', 'g') |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#has_vimproc() "{{{ |
||||
" Initialize. |
||||
if !exists('g:neocomplcache_use_vimproc') |
||||
" Check vimproc. |
||||
try |
||||
call vimproc#version() |
||||
let exists_vimproc = 1 |
||||
catch |
||||
let exists_vimproc = 0 |
||||
endtry |
||||
|
||||
let g:neocomplcache_use_vimproc = exists_vimproc |
||||
endif |
||||
|
||||
return g:neocomplcache_use_vimproc |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#dup_filter(list) "{{{ |
||||
let dict = {} |
||||
for keyword in a:list |
||||
if !has_key(dict, keyword.word) |
||||
let dict[keyword.word] = keyword |
||||
endif |
||||
endfor |
||||
|
||||
return values(dict) |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#util#convert2list(expr) "{{{ |
||||
return type(a:expr) ==# type([]) ? a:expr : [a:expr] |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
"============================================================================= |
||||
" FILE: variables.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 01 May 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! neocomplcache#variables#get_frequencies() "{{{ |
||||
if !exists('s:filetype_frequencies') |
||||
let s:filetype_frequencies = {} |
||||
endif |
||||
let filetype = neocomplcache#context_filetype#get(&filetype) |
||||
if !has_key(s:filetype_frequencies, filetype) |
||||
let s:filetype_frequencies[filetype] = {} |
||||
endif |
||||
|
||||
let frequencies = s:filetype_frequencies[filetype] |
||||
|
||||
return frequencies |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#variables#get_sources() "{{{ |
||||
if !exists('s:sources') |
||||
let s:sources = {} |
||||
endif |
||||
return s:sources |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#variables#get_filters() "{{{ |
||||
if !exists('s:filters') |
||||
let s:filters = {} |
||||
endif |
||||
return s:filters |
||||
endfunction"}}} |
||||
|
||||
function! neocomplcache#variables#get_custom() "{{{ |
||||
if !exists('s:custom') |
||||
let s:custom = {} |
||||
let s:custom.sources = {} |
||||
let s:custom.sources._ = {} |
||||
endif |
||||
|
||||
return s:custom |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
"============================================================================= |
||||
" FILE: neocomplcache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" manga_osyo (Original) |
||||
" Last Modified: 19 Dec 2011. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! unite#sources#file_include#define() |
||||
return s:source |
||||
endfunction |
||||
|
||||
let s:source = { |
||||
\ 'name' : 'file_include', |
||||
\ 'description' : 'candidates from include files', |
||||
\ 'hooks' : {}, |
||||
\} |
||||
function! s:source.hooks.on_init(args, context) "{{{ |
||||
" From neocomplcache include files. |
||||
let a:context.source__include_files = |
||||
\ neocomplcache#sources#include_complete#get_include_files(bufnr('%')) |
||||
let a:context.source__path = &path |
||||
endfunction"}}} |
||||
|
||||
function! s:source.gather_candidates(args, context) "{{{ |
||||
let files = map(copy(a:context.source__include_files), '{ |
||||
\ "word" : neocomplcache#util#substitute_path_separator(v:val), |
||||
\ "abbr" : neocomplcache#util#substitute_path_separator(v:val), |
||||
\ "source" : "file_include", |
||||
\ "kind" : "file", |
||||
\ "action__path" : v:val |
||||
\ }') |
||||
|
||||
for word in files |
||||
" Path search. |
||||
for path in map(split(a:context.source__path, ','), |
||||
\ 'neocomplcache#util#substitute_path_separator(v:val)') |
||||
if path != '' && neocomplcache#head_match(word.word, path . '/') |
||||
let word.abbr = word.abbr[len(path)+1 : ] |
||||
break |
||||
endif |
||||
endfor |
||||
endfor |
||||
|
||||
return files |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,131 @@
@@ -0,0 +1,131 @@
|
||||
"============================================================================= |
||||
" FILE: neocomplcache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 27 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
"============================================================================= |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! unite#sources#neocomplcache#define() "{{{ |
||||
return s:neocomplcache_source |
||||
endfunction "}}} |
||||
|
||||
" neocomplcache unite source. |
||||
let s:neocomplcache_source = { |
||||
\ 'name': 'neocomplcache', |
||||
\ 'hooks' : {}, |
||||
\ } |
||||
|
||||
function! s:neocomplcache_source.hooks.on_init(args, context) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
let a:context.source__complete_pos = -1 |
||||
let a:context.source__candidates = [] |
||||
return |
||||
endif |
||||
|
||||
" Save options. |
||||
let max_list_save = g:neocomplcache_max_list |
||||
let max_keyword_width_save = g:neocomplcache_max_keyword_width |
||||
let manual_start_length = g:neocomplcache_manual_completion_start_length |
||||
|
||||
try |
||||
let g:neocomplcache_max_list = -1 |
||||
let g:neocomplcache_max_keyword_width = -1 |
||||
let g:neocomplcache_manual_completion_start_length = 0 |
||||
let &l:completefunc = 'neocomplcache#complete#unite_complete' |
||||
|
||||
let cur_text = neocomplcache#get_cur_text(1) |
||||
let complete_results = neocomplcache#complete#_get_results(cur_text) |
||||
let a:context.source__complete_pos = |
||||
\ neocomplcache#complete#_get_complete_pos(complete_results) |
||||
let a:context.source__candidates = neocomplcache#complete#_get_words( |
||||
\ complete_results, a:context.source__complete_pos, |
||||
\ cur_text[a:context.source__complete_pos :]) |
||||
finally |
||||
" Restore options. |
||||
let g:neocomplcache_max_list = max_list_save |
||||
let g:neocomplcache_max_keyword_width = max_keyword_width_save |
||||
let &l:completefunc = 'neocomplcache#complete#auto_complete' |
||||
let g:neocomplcache_manual_completion_start_length = manual_start_length |
||||
endtry |
||||
endfunction"}}} |
||||
|
||||
function! s:neocomplcache_source.gather_candidates(args, context) "{{{ |
||||
let keyword_pos = a:context.source__complete_pos |
||||
let list = [] |
||||
for keyword in a:context.source__candidates |
||||
let dict = { |
||||
\ 'word' : keyword.word, |
||||
\ 'abbr' : printf('%-50s', get(keyword, 'abbr', keyword.word)), |
||||
\ 'kind': 'completion', |
||||
\ 'action__complete_word' : keyword.word, |
||||
\ 'action__complete_pos' : keyword_pos, |
||||
\ } |
||||
if has_key(keyword, 'kind') |
||||
let dict.abbr .= ' ' . keyword.kind |
||||
endif |
||||
if has_key(keyword, 'menu') |
||||
let dict.abbr .= ' ' . keyword.menu |
||||
endif |
||||
if has_key(keyword, 'description') |
||||
if type(keyword.description) ==# type(function('tr')) |
||||
let dict.action__complete_info_lazy = keyword.description |
||||
else |
||||
let dict.action__complete_info = keyword.description |
||||
endif |
||||
endif |
||||
|
||||
call add(list, dict) |
||||
endfor |
||||
|
||||
return list |
||||
endfunction "}}} |
||||
|
||||
function! unite#sources#neocomplcache#start_complete() "{{{ |
||||
return s:start_complete(0) |
||||
endfunction "}}} |
||||
|
||||
function! unite#sources#neocomplcache#start_quick_match() "{{{ |
||||
return s:start_complete(1) |
||||
endfunction "}}} |
||||
|
||||
function! s:start_complete(is_quick_match) "{{{ |
||||
if !neocomplcache#is_enabled() |
||||
return '' |
||||
endif |
||||
if !exists(':Unite') |
||||
echoerr 'unite.vim is not installed.' |
||||
return '' |
||||
endif |
||||
|
||||
return unite#start_complete(['neocomplcache'], { |
||||
\ 'auto_preview' : 1, 'quick_match' : a:is_quick_match, |
||||
\ 'input' : neocomplcache#get_cur_text(1), |
||||
\ }) |
||||
endfunction"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
function! vital#of(name) |
||||
let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital') |
||||
let file = split(files, "\n") |
||||
if empty(file) |
||||
throw 'vital: version file not found: ' . a:name |
||||
endif |
||||
let ver = readfile(file[0], 'b') |
||||
if empty(ver) |
||||
throw 'vital: invalid version file: ' . a:name |
||||
endif |
||||
return vital#_{substitute(ver[0], '\W', '', 'g')}#new() |
||||
endfunction |
@ -0,0 +1,177 @@
@@ -0,0 +1,177 @@
|
||||
let s:self_version = expand('<sfile>:t:r') |
||||
|
||||
let s:loaded = {} |
||||
|
||||
function! s:import(name, ...) |
||||
let target = {} |
||||
let functions = [] |
||||
for a in a:000 |
||||
if type(a) == type({}) |
||||
let target = a |
||||
elseif type(a) == type([]) |
||||
let functions = a |
||||
endif |
||||
unlet a |
||||
endfor |
||||
let module = s:_import(a:name, s:_scripts()) |
||||
if empty(functions) |
||||
call extend(target, module, 'keep') |
||||
else |
||||
for f in functions |
||||
if has_key(module, f) && !has_key(target, f) |
||||
let target[f] = module[f] |
||||
endif |
||||
endfor |
||||
endif |
||||
return target |
||||
endfunction |
||||
|
||||
function! s:load(...) dict |
||||
let scripts = s:_scripts() |
||||
for arg in a:000 |
||||
let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg] |
||||
let target = split(join(as, ''), '\W\+') |
||||
let dict = self |
||||
while 1 <= len(target) |
||||
let ns = remove(target, 0) |
||||
if !has_key(dict, ns) |
||||
let dict[ns] = {} |
||||
endif |
||||
if type(dict[ns]) == type({}) |
||||
let dict = dict[ns] |
||||
else |
||||
unlet dict |
||||
break |
||||
endif |
||||
endwhile |
||||
|
||||
if exists('dict') |
||||
call extend(dict, s:_import(name, scripts)) |
||||
endif |
||||
unlet arg |
||||
endfor |
||||
return self |
||||
endfunction |
||||
|
||||
function! s:unload() |
||||
let s:loaded = {} |
||||
endfunction |
||||
|
||||
function! s:_import(name, scripts) |
||||
if type(a:name) == type(0) |
||||
return s:_build_module(a:name) |
||||
endif |
||||
let path = s:_get_module_path(a:name) |
||||
if path ==# '' |
||||
throw 'vital: module not found: ' . a:name |
||||
endif |
||||
let sid = get(a:scripts, path, 0) |
||||
if !sid |
||||
try |
||||
execute 'source' fnameescape(path) |
||||
catch /^Vim\%((\a\+)\)\?:E484/ |
||||
throw 'vital: module not found: ' . a:name |
||||
catch /^Vim\%((\a\+)\)\?:E127/ |
||||
" Ignore. |
||||
endtry |
||||
|
||||
let sid = len(a:scripts) + 1 " We expect that the file newly read is +1. |
||||
let a:scripts[path] = sid |
||||
endif |
||||
return s:_build_module(sid) |
||||
endfunction |
||||
|
||||
function! s:_get_module_path(name) |
||||
if filereadable(a:name) |
||||
return s:_unify_path(a:name) |
||||
endif |
||||
if a:name ==# '' |
||||
let tailpath = printf('autoload/vital/%s.vim', s:self_version) |
||||
elseif a:name =~# '\v^\u\w*%(\.\u\w*)*$' |
||||
let target = '/' . substitute(a:name, '\W\+', '/', 'g') |
||||
let tailpath = printf('autoload/vital/%s%s.vim', s:self_version, target) |
||||
else |
||||
let tailpath = a:name |
||||
endif |
||||
|
||||
" Note: The extra argument to globpath() was added in Patch 7.2.051. |
||||
if v:version > 702 || v:version == 702 && has('patch51') |
||||
let paths = split(globpath(&runtimepath, tailpath, 1), "\n") |
||||
else |
||||
let paths = split(globpath(&runtimepath, tailpath), "\n") |
||||
endif |
||||
call filter(paths, 'filereadable(v:val)') |
||||
return s:_unify_path(get(paths, 0, '')) |
||||
endfunction |
||||
|
||||
function! s:_scripts() |
||||
let scripts = {} |
||||
for line in split(s:_redir('scriptnames'), "\n") |
||||
let list = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$') |
||||
if !empty(list) |
||||
let scripts[s:_unify_path(list[2])] = list[1] - 0 |
||||
endif |
||||
endfor |
||||
return scripts |
||||
endfunction |
||||
|
||||
if filereadable(expand('<sfile>:r') . '.VIM') |
||||
function! s:_unify_path(path) |
||||
" Note: On windows, vim can't expand path names from 8.3 formats. |
||||
" So if getting full path via <sfile> and $HOME was set as 8.3 format, |
||||
" vital load duplicated scripts. Below's :~ avoid this issue. |
||||
return tolower(fnamemodify(resolve(fnamemodify( |
||||
\ a:path, ':p:gs?[\\/]\+?/?')), ':~')) |
||||
endfunction |
||||
else |
||||
function! s:_unify_path(path) |
||||
return resolve(fnamemodify(a:path, ':p:gs?[\\/]\+?/?')) |
||||
endfunction |
||||
endif |
||||
|
||||
function! s:_build_module(sid) |
||||
if has_key(s:loaded, a:sid) |
||||
return copy(s:loaded[a:sid]) |
||||
endif |
||||
let prefix = '<SNR>' . a:sid . '_' |
||||
let funcs = s:_redir('function') |
||||
let filter_pat = '^\s*function ' . prefix |
||||
let map_pat = prefix . '\zs\w\+' |
||||
let functions = map(filter(split(funcs, "\n"), 'v:val =~# filter_pat'), |
||||
\ 'matchstr(v:val, map_pat)') |
||||
|
||||
let module = {} |
||||
for func in functions |
||||
let module[func] = function(prefix . func) |
||||
endfor |
||||
if has_key(module, '_vital_loaded') |
||||
let V = vital#{s:self_version}#new() |
||||
if has_key(module, '_vital_depends') |
||||
call call(V.load, module._vital_depends(), V) |
||||
endif |
||||
try |
||||
call module._vital_loaded(V) |
||||
catch |
||||
" FIXME: Show an error message for debug. |
||||
endtry |
||||
endif |
||||
if !get(g:, 'vital_debug', 0) |
||||
call filter(module, 'v:key =~# "^\\a"') |
||||
endif |
||||
let s:loaded[a:sid] = module |
||||
return copy(module) |
||||
endfunction |
||||
|
||||
function! s:_redir(cmd) |
||||
let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] |
||||
set verbose=0 verbosefile= |
||||
redir => res |
||||
silent! execute a:cmd |
||||
redir END |
||||
let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] |
||||
return res |
||||
endfunction |
||||
|
||||
function! vital#{s:self_version}#new() |
||||
return s:_import('', s:_scripts()).load(['Prelude', '']) |
||||
endfunction |
@ -0,0 +1,244 @@
@@ -0,0 +1,244 @@
|
||||
" Utilities for list. |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! s:pop(list) |
||||
return remove(a:list, -1) |
||||
endfunction |
||||
|
||||
function! s:push(list, val) |
||||
call add(a:list, a:val) |
||||
return a:list |
||||
endfunction |
||||
|
||||
function! s:shift(list) |
||||
return remove(a:list, 0) |
||||
endfunction |
||||
|
||||
function! s:unshift(list, val) |
||||
return insert(a:list, a:val) |
||||
endfunction |
||||
|
||||
" Removes duplicates from a list. |
||||
function! s:uniq(list, ...) |
||||
let list = a:0 ? map(copy(a:list), printf('[v:val, %s]', a:1)) : copy(a:list) |
||||
let i = 0 |
||||
let seen = {} |
||||
while i < len(list) |
||||
let key = string(a:0 ? list[i][1] : list[i]) |
||||
if has_key(seen, key) |
||||
call remove(list, i) |
||||
else |
||||
let seen[key] = 1 |
||||
let i += 1 |
||||
endif |
||||
endwhile |
||||
return a:0 ? map(list, 'v:val[0]') : list |
||||
endfunction |
||||
|
||||
function! s:clear(list) |
||||
if !empty(a:list) |
||||
unlet! a:list[0 : len(a:list) - 1] |
||||
endif |
||||
return a:list |
||||
endfunction |
||||
|
||||
" Concatenates a list of lists. |
||||
" XXX: Should we verify the input? |
||||
function! s:concat(list) |
||||
let list = [] |
||||
for Value in a:list |
||||
let list += Value |
||||
endfor |
||||
return list |
||||
endfunction |
||||
|
||||
" Flattens a list. |
||||
function! s:flatten(list, ...) |
||||
let limit = a:0 > 0 ? a:1 : -1 |
||||
let list = [] |
||||
if limit == 0 |
||||
return a:list |
||||
endif |
||||
let limit -= 1 |
||||
for Value in a:list |
||||
if type(Value) == type([]) |
||||
let list += s:flatten(Value, limit) |
||||
else |
||||
call add(list, Value) |
||||
endif |
||||
unlet! Value |
||||
endfor |
||||
return list |
||||
endfunction |
||||
|
||||
" Sorts a list with expression to compare each two values. |
||||
" a:a and a:b can be used in {expr}. |
||||
function! s:sort(list, expr) |
||||
if type(a:expr) == type(function('function')) |
||||
return sort(a:list, a:expr) |
||||
endif |
||||
let s:expr = a:expr |
||||
return sort(a:list, 's:_compare') |
||||
endfunction |
||||
|
||||
function! s:_compare(a, b) |
||||
return eval(s:expr) |
||||
endfunction |
||||
|
||||
" Sorts a list using a set of keys generated by mapping the values in the list |
||||
" through the given expr. |
||||
" v:val is used in {expr} |
||||
function! s:sort_by(list, expr) |
||||
let pairs = map(a:list, printf('[v:val, %s]', a:expr)) |
||||
return map(s:sort(pairs, |
||||
\ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'), 'v:val[0]') |
||||
endfunction |
||||
|
||||
" Returns a maximum value in {list} through given {expr}. |
||||
" Returns 0 if {list} is empty. |
||||
" v:val is used in {expr} |
||||
function! s:max(list, expr) |
||||
if empty(a:list) |
||||
return 0 |
||||
endif |
||||
let list = map(copy(a:list), a:expr) |
||||
return a:list[index(list, max(list))] |
||||
endfunction |
||||
|
||||
" Returns a minimum value in {list} through given {expr}. |
||||
" Returns 0 if {list} is empty. |
||||
" v:val is used in {expr} |
||||
" FIXME: -0x80000000 == 0x80000000 |
||||
function! s:min(list, expr) |
||||
return s:max(a:list, '-(' . a:expr . ')') |
||||
endfunction |
||||
|
||||
" Returns List of character sequence between [a:from, a:to] |
||||
" e.g.: s:char_range('a', 'c') returns ['a', 'b', 'c'] |
||||
function! s:char_range(from, to) |
||||
return map( |
||||
\ range(char2nr(a:from), char2nr(a:to)), |
||||
\ 'nr2char(v:val)' |
||||
\) |
||||
endfunction |
||||
|
||||
" Returns true if a:list has a:Value. |
||||
" Returns false otherwise. |
||||
function! s:has(list, Value) |
||||
return index(a:list, a:Value) isnot -1 |
||||
endfunction |
||||
|
||||
" Returns true if a:list[a:index] exists. |
||||
" Returns false otherwise. |
||||
" NOTE: Returns false when a:index is negative number. |
||||
function! s:has_index(list, index) |
||||
" Return true when negative index? |
||||
" let index = a:index >= 0 ? a:index : len(a:list) + a:index |
||||
return 0 <= a:index && a:index < len(a:list) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Data.List.span |
||||
function! s:span(f, xs) |
||||
let border = len(a:xs) |
||||
for i in range(len(a:xs)) |
||||
if !eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g')) |
||||
let border = i |
||||
break |
||||
endif |
||||
endfor |
||||
return border == 0 ? [[], copy(a:xs)] : [a:xs[: border - 1], a:xs[border :]] |
||||
endfunction |
||||
|
||||
" similar to Haskell's Data.List.break |
||||
function! s:break(f, xs) |
||||
return s:span(printf('!(%s)', a:f), a:xs) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Data.List.takeWhile |
||||
function! s:take_while(f, xs) |
||||
return s:span(a:f, a:xs)[0] |
||||
endfunction |
||||
|
||||
" similar to Haskell's Data.List.partition |
||||
function! s:partition(f, xs) |
||||
return [filter(copy(a:xs), a:f), filter(copy(a:xs), '!(' . a:f . ')')] |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.all |
||||
function! s:all(f, xs) |
||||
return !s:any(printf('!(%s)', a:f), a:xs) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.any |
||||
function! s:any(f, xs) |
||||
return !empty(filter(map(copy(a:xs), a:f), 'v:val')) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.and |
||||
function! s:and(xs) |
||||
return s:all('v:val', a:xs) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.or |
||||
function! s:or(xs) |
||||
return s:any('v:val', a:xs) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.foldl |
||||
function! s:foldl(f, init, xs) |
||||
let memo = a:init |
||||
for x in a:xs |
||||
let expr = substitute(a:f, 'v:val', string(x), 'g') |
||||
let expr = substitute(expr, 'v:memo', string(memo), 'g') |
||||
unlet memo |
||||
let memo = eval(expr) |
||||
endfor |
||||
return memo |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.foldl1 |
||||
function! s:foldl1(f, xs) |
||||
if len(a:xs) == 0 |
||||
throw 'foldl1' |
||||
endif |
||||
return s:foldl(a:f, a:xs[0], a:xs[1:]) |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.foldr |
||||
function! s:foldr(f, init, xs) |
||||
let memo = a:init |
||||
for i in reverse(range(0, len(a:xs) - 1)) |
||||
let x = a:xs[i] |
||||
let expr = substitute(a:f, 'v:val', string(x), 'g') |
||||
let expr = substitute(expr, 'v:memo', string(memo), 'g') |
||||
unlet memo |
||||
let memo = eval(expr) |
||||
endfor |
||||
return memo |
||||
endfunction |
||||
|
||||
" similar to Haskell's Prelude.fold11 |
||||
function! s:foldr1(f, xs) |
||||
if len(a:xs) == 0 |
||||
throw 'foldr1' |
||||
endif |
||||
return s:foldr(a:f, a:xs[-1], a:xs[0:-2]) |
||||
endfunction |
||||
|
||||
" similar to python's zip() |
||||
function! s:zip(...) |
||||
return map(range(min(map(copy(a:000), 'len(v:val)'))), "map(copy(a:000), 'v:val['.v:val.']')") |
||||
endfunction |
||||
|
||||
" Inspired by Ruby's with_index method. |
||||
function! s:with_index(list, ...) |
||||
let base = a:0 > 0 ? a:1 : 0 |
||||
return s:zip(a:list, range(base, len(a:list)+base-1)) |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim:set et ts=2 sts=2 sw=2 tw=0: |
@ -0,0 +1,256 @@
@@ -0,0 +1,256 @@
|
||||
" Utilities for string. |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! s:_vital_loaded(V) |
||||
let s:V = a:V |
||||
let s:L = s:V.import('Data.List') |
||||
endfunction |
||||
|
||||
function! s:_vital_depends() |
||||
return ['Data.List'] |
||||
endfunction |
||||
|
||||
" Substitute a:from => a:to by string. |
||||
" To substitute by pattern, use substitute() instead. |
||||
function! s:replace(str, from, to) |
||||
if a:str ==# '' || a:from ==# '' |
||||
return a:str |
||||
endif |
||||
let str = a:str |
||||
let idx = stridx(str, a:from) |
||||
while idx !=# -1 |
||||
let left = idx ==# 0 ? '' : str[: idx - 1] |
||||
let right = str[idx + strlen(a:from) :] |
||||
let str = left . a:to . right |
||||
let idx = stridx(str, a:from, idx + strlen(a:to)) |
||||
endwhile |
||||
return str |
||||
endfunction |
||||
|
||||
" Substitute a:from => a:to only once. |
||||
" cf. s:replace() |
||||
function! s:replace_once(str, from, to) |
||||
if a:str ==# '' || a:from ==# '' |
||||
return a:str |
||||
endif |
||||
let idx = stridx(a:str, a:from) |
||||
if idx ==# -1 |
||||
return a:str |
||||
else |
||||
let left = idx ==# 0 ? '' : a:str[: idx - 1] |
||||
let right = a:str[idx + strlen(a:from) :] |
||||
return left . a:to . right |
||||
endif |
||||
endfunction |
||||
|
||||
function! s:scan(str, pattern) |
||||
let list = [] |
||||
let pos = 0 |
||||
let len = len(a:str) |
||||
while 0 <= pos && pos < len |
||||
let matched = matchstr(a:str, a:pattern, pos) |
||||
let pos = matchend(a:str, a:pattern, pos) |
||||
if !empty(matched) |
||||
call add(list, matched) |
||||
endif |
||||
endwhile |
||||
return list |
||||
endfunction |
||||
|
||||
function! s:reverse(str) |
||||
return join(reverse(split(a:str, '.\zs')), '') |
||||
endfunction |
||||
|
||||
function! s:common_head(strs) |
||||
if empty(a:strs) |
||||
return '' |
||||
endif |
||||
let head = a:strs[0] |
||||
for str in a:strs[1 :] |
||||
let pat = substitute(str, '.', '[\0]', 'g') |
||||
let head = matchstr(head, '^\%[' . pat . ']') |
||||
if head ==# '' |
||||
break |
||||
endif |
||||
endfor |
||||
return head |
||||
endfunction |
||||
|
||||
" Split to two elements of List. ([left, right]) |
||||
" e.g.: s:split3('neocomplcache', 'compl') returns ['neo', 'compl', 'cache'] |
||||
function! s:split_leftright(expr, pattern) |
||||
let [left, _, right] = s:split3(a:expr, a:pattern) |
||||
return [left, right] |
||||
endfunction |
||||
|
||||
function! s:split3(expr, pattern) |
||||
let ERROR = ['', '', ''] |
||||
if a:expr ==# '' || a:pattern ==# '' |
||||
return ERROR |
||||
endif |
||||
let begin = match(a:expr, a:pattern) |
||||
if begin is -1 |
||||
return ERROR |
||||
endif |
||||
let end = matchend(a:expr, a:pattern) |
||||
let left = begin <=# 0 ? '' : a:expr[: begin - 1] |
||||
let right = a:expr[end :] |
||||
return [left, a:expr[begin : end-1], right] |
||||
endfunction |
||||
|
||||
" Slices into strings determines the number of substrings. |
||||
" e.g.: s:splitn("neo compl cache", 2, '\s') returns ['neo', 'compl cache'] |
||||
function! s:nsplit(expr, n, ...) |
||||
let pattern = get(a:000, 0, '\s') |
||||
let keepempty = get(a:000, 1, 1) |
||||
let ret = [] |
||||
let expr = a:expr |
||||
if a:n <= 1 |
||||
return [expr] |
||||
endif |
||||
while 1 |
||||
let pos = match(expr, pattern) |
||||
if pos == -1 |
||||
if expr !~ pattern || keepempty |
||||
call add(ret, expr) |
||||
endif |
||||
break |
||||
elseif pos >= 0 |
||||
let left = pos > 0 ? expr[:pos-1] : '' |
||||
if pos > 0 || keepempty |
||||
call add(ret, left) |
||||
endif |
||||
let ml = len(matchstr(expr, pattern)) |
||||
if pos == 0 && ml == 0 |
||||
let pos = 1 |
||||
endif |
||||
let expr = expr[pos+ml :] |
||||
endif |
||||
if len(expr) == 0 |
||||
break |
||||
endif |
||||
if len(ret) == a:n - 1 |
||||
call add(ret, expr) |
||||
break |
||||
endif |
||||
endwhile |
||||
return ret |
||||
endfunction |
||||
|
||||
" Returns the number of character in a:str. |
||||
" NOTE: This returns proper value |
||||
" even if a:str contains multibyte character(s). |
||||
" s:strchars(str) {{{ |
||||
if exists('*strchars') |
||||
function! s:strchars(str) |
||||
return strchars(a:str) |
||||
endfunction |
||||
else |
||||
function! s:strchars(str) |
||||
return strlen(substitute(copy(a:str), '.', 'x', 'g')) |
||||
endfunction |
||||
endif "}}} |
||||
|
||||
" Remove last character from a:str. |
||||
" NOTE: This returns proper value |
||||
" even if a:str contains multibyte character(s). |
||||
function! s:chop(str) "{{{ |
||||
return substitute(a:str, '.$', '', '') |
||||
endfunction "}}} |
||||
|
||||
" Remove last \r,\n,\r\n from a:str. |
||||
function! s:chomp(str) "{{{ |
||||
return substitute(a:str, '\%(\r\n\|[\r\n]\)$', '', '') |
||||
endfunction "}}} |
||||
|
||||
" wrap() and its internal functions |
||||
" * _split_by_wcswidth_once() |
||||
" * _split_by_wcswidth() |
||||
" * _concat() |
||||
" * wrap() |
||||
" |
||||
" NOTE _concat() is just a copy of Data.List.concat(). |
||||
" FIXME don't repeat yourself |
||||
function! s:_split_by_wcswidth_once(body, x) |
||||
let fst = s:V.strwidthpart(a:body, a:x) |
||||
let snd = s:V.strwidthpart_reverse(a:body, s:V.wcswidth(a:body) - s:V.wcswidth(fst)) |
||||
return [fst, snd] |
||||
endfunction |
||||
|
||||
function! s:_split_by_wcswidth(body, x) |
||||
let memo = [] |
||||
let body = a:body |
||||
while s:V.wcswidth(body) > a:x |
||||
let [tmp, body] = s:_split_by_wcswidth_once(body, a:x) |
||||
call add(memo, tmp) |
||||
endwhile |
||||
call add(memo, body) |
||||
return memo |
||||
endfunction |
||||
|
||||
function! s:trim(str) |
||||
return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') |
||||
endfunction |
||||
|
||||
function! s:wrap(str,...) |
||||
let _columns = a:0 > 0 ? a:1 : &columns |
||||
return s:L.concat( |
||||
\ map(split(a:str, '\r\?\n'), 's:_split_by_wcswidth(v:val, _columns - 1)')) |
||||
endfunction |
||||
|
||||
function! s:nr2byte(nr) |
||||
if a:nr < 0x80 |
||||
return nr2char(a:nr) |
||||
elseif a:nr < 0x800 |
||||
return nr2char(a:nr/64+192).nr2char(a:nr%64+128) |
||||
else |
||||
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128) |
||||
endif |
||||
endfunction |
||||
|
||||
function! s:nr2enc_char(charcode) |
||||
if &encoding == 'utf-8' |
||||
return nr2char(a:charcode) |
||||
endif |
||||
let char = s:nr2byte(a:charcode) |
||||
if strlen(char) > 1 |
||||
let char = strtrans(iconv(char, 'utf-8', &encoding)) |
||||
endif |
||||
return char |
||||
endfunction |
||||
|
||||
function! s:nr2hex(nr) |
||||
let n = a:nr |
||||
let r = "" |
||||
while n |
||||
let r = '0123456789ABCDEF'[n % 16] . r |
||||
let n = n / 16 |
||||
endwhile |
||||
return r |
||||
endfunction |
||||
|
||||
" If a ==# b, returns -1. |
||||
" If a !=# b, returns first index of diffrent character. |
||||
function! s:diffidx(a, b) |
||||
let [a, b] = [split(a:a, '\zs'), split(a:b, '\zs')] |
||||
let [al, bl] = [len(a), len(b)] |
||||
let l = max([al, bl]) |
||||
for i in range(l) |
||||
" if `i` is out of range, a[i] returns empty string. |
||||
if i >= al || i >= bl || a[i] !=# b[i] |
||||
return i > 0 ? strlen(join(a[:i-1], '')) : 0 |
||||
endif |
||||
endfor |
||||
return -1 |
||||
endfunction |
||||
|
||||
function! s:substitute_last(expr, pat, sub) |
||||
return substitute(a:expr, printf('.*\zs%s', a:pat), a:sub, '') |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim:set et ts=2 sts=2 sw=2 tw=0: |
@ -0,0 +1,404 @@
@@ -0,0 +1,404 @@
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
" glob() wrapper which returns List |
||||
" and 'wildignore' does not affect |
||||
" this function's return value. |
||||
if v:version ># 703 || |
||||
\ (v:version is 703 && has('patch465')) |
||||
function! s:glob(expr) |
||||
return glob(a:expr, 1, 1) |
||||
endfunction |
||||
else |
||||
function! s:glob(expr) |
||||
let R = glob(a:expr, 1) |
||||
return split(R, '\n') |
||||
endfunction |
||||
endif |
||||
|
||||
" globpath() wrapper which returns List |
||||
" and 'suffixes' and 'wildignore' does not affect |
||||
" this function's return value. |
||||
function! s:globpath(path, expr) |
||||
let R = globpath(a:path, a:expr, 1) |
||||
return split(R, '\n') |
||||
endfunction |
||||
|
||||
" Wrapper functions for type(). |
||||
let [ |
||||
\ s:__TYPE_NUMBER, |
||||
\ s:__TYPE_STRING, |
||||
\ s:__TYPE_FUNCREF, |
||||
\ s:__TYPE_LIST, |
||||
\ s:__TYPE_DICT, |
||||
\ s:__TYPE_FLOAT] = [ |
||||
\ type(3), |
||||
\ type(""), |
||||
\ type(function('tr')), |
||||
\ type([]), |
||||
\ type({}), |
||||
\ has('float') ? type(str2float('0')) : -1] |
||||
" __TYPE_FLOAT = -1 when -float |
||||
" This doesn't match to anything. |
||||
|
||||
" Number or Float |
||||
function! s:is_numeric(Value) |
||||
let _ = type(a:Value) |
||||
return _ ==# s:__TYPE_NUMBER |
||||
\ || _ ==# s:__TYPE_FLOAT |
||||
endfunction |
||||
|
||||
" Number |
||||
function! s:is_integer(Value) |
||||
echoerr 'Prelude.is_integer() is obsolete. Use its is_number() instead; they are equivalent.' |
||||
return s:is_number(a:Value) |
||||
endfunction |
||||
|
||||
function! s:is_number(Value) |
||||
return type(a:Value) ==# s:__TYPE_NUMBER |
||||
endfunction |
||||
|
||||
" Float |
||||
function! s:is_float(Value) |
||||
return type(a:Value) ==# s:__TYPE_FLOAT |
||||
endfunction |
||||
" String |
||||
function! s:is_string(Value) |
||||
return type(a:Value) ==# s:__TYPE_STRING |
||||
endfunction |
||||
" Funcref |
||||
function! s:is_funcref(Value) |
||||
return type(a:Value) ==# s:__TYPE_FUNCREF |
||||
endfunction |
||||
" List |
||||
function! s:is_list(Value) |
||||
return type(a:Value) ==# s:__TYPE_LIST |
||||
endfunction |
||||
" Dictionary |
||||
function! s:is_dict(Value) |
||||
return type(a:Value) ==# s:__TYPE_DICT |
||||
endfunction |
||||
|
||||
function! s:truncate_smart(str, max, footer_width, separator) |
||||
let width = s:wcswidth(a:str) |
||||
if width <= a:max |
||||
let ret = a:str |
||||
else |
||||
let header_width = a:max - s:wcswidth(a:separator) - a:footer_width |
||||
let ret = s:strwidthpart(a:str, header_width) . a:separator |
||||
\ . s:strwidthpart_reverse(a:str, a:footer_width) |
||||
endif |
||||
|
||||
return s:truncate(ret, a:max) |
||||
endfunction |
||||
|
||||
function! s:truncate(str, width) |
||||
" Original function is from mattn. |
||||
" http://github.com/mattn/googlereader-vim/tree/master |
||||
|
||||
if a:str =~# '^[\x00-\x7f]*$' |
||||
return len(a:str) < a:width ? |
||||
\ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width) |
||||
endif |
||||
|
||||
let ret = a:str |
||||
let width = s:wcswidth(a:str) |
||||
if width > a:width |
||||
let ret = s:strwidthpart(ret, a:width) |
||||
let width = s:wcswidth(ret) |
||||
endif |
||||
|
||||
if width < a:width |
||||
let ret .= repeat(' ', a:width - width) |
||||
endif |
||||
|
||||
return ret |
||||
endfunction |
||||
|
||||
function! s:strwidthpart(str, width) |
||||
if a:width <= 0 |
||||
return '' |
||||
endif |
||||
let ret = a:str |
||||
let width = s:wcswidth(a:str) |
||||
while width > a:width |
||||
let char = matchstr(ret, '.$') |
||||
let ret = ret[: -1 - len(char)] |
||||
let width -= s:wcswidth(char) |
||||
endwhile |
||||
|
||||
return ret |
||||
endfunction |
||||
function! s:strwidthpart_reverse(str, width) |
||||
if a:width <= 0 |
||||
return '' |
||||
endif |
||||
let ret = a:str |
||||
let width = s:wcswidth(a:str) |
||||
while width > a:width |
||||
let char = matchstr(ret, '^.') |
||||
let ret = ret[len(char) :] |
||||
let width -= s:wcswidth(char) |
||||
endwhile |
||||
|
||||
return ret |
||||
endfunction |
||||
|
||||
if v:version >= 703 |
||||
" Use builtin function. |
||||
function! s:wcswidth(str) |
||||
return strwidth(a:str) |
||||
endfunction |
||||
else |
||||
function! s:wcswidth(str) |
||||
if a:str =~# '^[\x00-\x7f]*$' |
||||
return strlen(a:str) |
||||
end |
||||
|
||||
let mx_first = '^\(.\)' |
||||
let str = a:str |
||||
let width = 0 |
||||
while 1 |
||||
let ucs = char2nr(substitute(str, mx_first, '\1', '')) |
||||
if ucs == 0 |
||||
break |
||||
endif |
||||
let width += s:_wcwidth(ucs) |
||||
let str = substitute(str, mx_first, '', '') |
||||
endwhile |
||||
return width |
||||
endfunction |
||||
|
||||
" UTF-8 only. |
||||
function! s:_wcwidth(ucs) |
||||
let ucs = a:ucs |
||||
if (ucs >= 0x1100 |
||||
\ && (ucs <= 0x115f |
||||
\ || ucs == 0x2329 |
||||
\ || ucs == 0x232a |
||||
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf |
||||
\ && ucs != 0x303f) |
||||
\ || (ucs >= 0xac00 && ucs <= 0xd7a3) |
||||
\ || (ucs >= 0xf900 && ucs <= 0xfaff) |
||||
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f) |
||||
\ || (ucs >= 0xff00 && ucs <= 0xff60) |
||||
\ || (ucs >= 0xffe0 && ucs <= 0xffe6) |
||||
\ || (ucs >= 0x20000 && ucs <= 0x2fffd) |
||||
\ || (ucs >= 0x30000 && ucs <= 0x3fffd) |
||||
\ )) |
||||
return 2 |
||||
endif |
||||
return 1 |
||||
endfunction |
||||
endif |
||||
|
||||
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95') |
||||
let s:is_cygwin = has('win32unix') |
||||
let s:is_mac = !s:is_windows && !s:is_cygwin |
||||
\ && (has('mac') || has('macunix') || has('gui_macvim') || |
||||
\ (!isdirectory('/proc') && executable('sw_vers'))) |
||||
let s:is_unix = has('unix') |
||||
|
||||
function! s:is_windows() |
||||
return s:is_windows |
||||
endfunction |
||||
|
||||
function! s:is_cygwin() |
||||
return s:is_cygwin |
||||
endfunction |
||||
|
||||
function! s:is_mac() |
||||
return s:is_mac |
||||
endfunction |
||||
|
||||
function! s:is_unix() |
||||
return s:is_unix |
||||
endfunction |
||||
|
||||
function! s:print_error(message) |
||||
echohl ErrorMsg |
||||
for m in split(a:message, "\n") |
||||
echomsg m |
||||
endfor |
||||
echohl None |
||||
endfunction |
||||
|
||||
function! s:smart_execute_command(action, word) |
||||
execute a:action . ' ' . (a:word == '' ? '' : '`=a:word`') |
||||
endfunction |
||||
|
||||
function! s:escape_file_searching(buffer_name) |
||||
return escape(a:buffer_name, '*[]?{}, ') |
||||
endfunction |
||||
|
||||
function! s:escape_pattern(str) |
||||
return escape(a:str, '~"\.^$[]*') |
||||
endfunction |
||||
|
||||
" iconv() wrapper for safety. |
||||
function! s:iconv(expr, from, to) |
||||
if a:from == '' || a:to == '' || a:from ==? a:to |
||||
return a:expr |
||||
endif |
||||
let result = iconv(a:expr, a:from, a:to) |
||||
return result != '' ? result : a:expr |
||||
endfunction |
||||
|
||||
" Like builtin getchar() but returns string always. |
||||
function! s:getchar(...) |
||||
let c = call('getchar', a:000) |
||||
return type(c) == type(0) ? nr2char(c) : c |
||||
endfunction |
||||
|
||||
" Like builtin getchar() but returns string always. |
||||
" and do inputsave()/inputrestore() before/after getchar(). |
||||
function! s:getchar_safe(...) |
||||
let c = s:input_helper('getchar', a:000) |
||||
return type(c) == type("") ? c : nr2char(c) |
||||
endfunction |
||||
|
||||
" Like builtin getchar() but |
||||
" do inputsave()/inputrestore() before/after input(). |
||||
function! s:input_safe(...) |
||||
return s:input_helper('input', a:000) |
||||
endfunction |
||||
|
||||
" Do inputsave()/inputrestore() before/after calling a:funcname. |
||||
function! s:input_helper(funcname, args) |
||||
let success = 0 |
||||
if inputsave() !=# success |
||||
throw 'inputsave() failed' |
||||
endif |
||||
try |
||||
return call(a:funcname, a:args) |
||||
finally |
||||
if inputrestore() !=# success |
||||
throw 'inputrestore() failed' |
||||
endif |
||||
endtry |
||||
endfunction |
||||
|
||||
function! s:set_default(var, val) |
||||
if !exists(a:var) || type({a:var}) != type(a:val) |
||||
let {a:var} = a:val |
||||
endif |
||||
endfunction |
||||
|
||||
function! s:set_dictionary_helper(variable, keys, pattern) |
||||
for key in split(a:keys, '\s*,\s*') |
||||
if !has_key(a:variable, key) |
||||
let a:variable[key] = a:pattern |
||||
endif |
||||
endfor |
||||
endfunction |
||||
|
||||
function! s:substitute_path_separator(path) |
||||
return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path |
||||
endfunction |
||||
|
||||
function! s:path2directory(path) |
||||
return s:substitute_path_separator(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':p:h')) |
||||
endfunction |
||||
|
||||
function! s:path2project_directory(path, ...) |
||||
let is_allow_empty = get(a:000, 0, 0) |
||||
let search_directory = s:path2directory(a:path) |
||||
let directory = '' |
||||
|
||||
" Search VCS directory. |
||||
for vcs in ['.git', '.bzr', '.hg', '.svn'] |
||||
let find_directory = s:escape_file_searching(search_directory) |
||||
let d = finddir(vcs, find_directory . ';') |
||||
if d == '' |
||||
continue |
||||
endif |
||||
|
||||
let directory = fnamemodify(d, ':p:h:h') |
||||
|
||||
if vcs ==# '.svn' |
||||
" Search parent directories. |
||||
let parent_directory = s:path2directory( |
||||
\ fnamemodify(directory, ':h')) |
||||
|
||||
if parent_directory != '' |
||||
let d = finddir(vcs, parent_directory . ';') |
||||
if d != '' |
||||
let directory = s:path2project_directory(parent_directory) |
||||
endif |
||||
endif |
||||
endif |
||||
endfor |
||||
|
||||
" Search project file. |
||||
if directory == '' |
||||
for d in ['build.xml', 'prj.el', '.project', 'pom.xml', |
||||
\ 'Makefile', 'configure', 'Rakefile', 'NAnt.build', 'tags', 'gtags'] |
||||
let d = findfile(d, s:escape_file_searching(search_directory) . ';') |
||||
if d != '' |
||||
let directory = fnamemodify(d, ':p:h') |
||||
break |
||||
endif |
||||
endfor |
||||
endif |
||||
|
||||
if directory == '' |
||||
" Search /src/ directory. |
||||
let base = s:substitute_path_separator(search_directory) |
||||
if base =~# '/src/' |
||||
let directory = base[: strridx(base, '/src/') + 3] |
||||
endif |
||||
endif |
||||
|
||||
if directory == '' && !is_allow_empty |
||||
" Use original path. |
||||
let directory = search_directory |
||||
endif |
||||
|
||||
return s:substitute_path_separator(directory) |
||||
endfunction |
||||
|
||||
" Check vimproc. |
||||
function! s:has_vimproc() |
||||
if !exists('s:exists_vimproc') |
||||
try |
||||
call vimproc#version() |
||||
let s:exists_vimproc = 1 |
||||
catch |
||||
let s:exists_vimproc = 0 |
||||
endtry |
||||
endif |
||||
return s:exists_vimproc |
||||
endfunction |
||||
|
||||
function! s:system(str, ...) |
||||
let command = a:str |
||||
let input = a:0 >= 1 ? a:1 : '' |
||||
let command = s:iconv(command, &encoding, 'char') |
||||
let input = s:iconv(input, &encoding, 'char') |
||||
|
||||
if a:0 == 0 |
||||
let output = s:has_vimproc() ? |
||||
\ vimproc#system(command) : system(command) |
||||
elseif a:0 == 1 |
||||
let output = s:has_vimproc() ? |
||||
\ vimproc#system(command, input) : system(command, input) |
||||
else |
||||
" ignores 3rd argument unless you have vimproc. |
||||
let output = s:has_vimproc() ? |
||||
\ vimproc#system(command, input, a:2) : system(command, input) |
||||
endif |
||||
|
||||
let output = s:iconv(output, 'char', &encoding) |
||||
|
||||
return output |
||||
endfunction |
||||
|
||||
function! s:get_last_status() |
||||
return s:has_vimproc() ? |
||||
\ vimproc#get_last_status() : v:shell_error |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim:set et ts=2 sts=2 sw=2 tw=0: |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
" Utilities for output cache. |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
function! s:getfilename(cache_dir, filename) |
||||
return s:_encode_name(a:cache_dir, a:filename) |
||||
endfunction |
||||
|
||||
function! s:filereadable(cache_dir, filename) |
||||
let cache_name = s:_encode_name(a:cache_dir, a:filename) |
||||
return filereadable(cache_name) |
||||
endfunction |
||||
|
||||
function! s:readfile(cache_dir, filename) |
||||
let cache_name = s:_encode_name(a:cache_dir, a:filename) |
||||
return filereadable(cache_name) ? readfile(cache_name) : [] |
||||
endfunction |
||||
|
||||
function! s:writefile(cache_dir, filename, list) |
||||
let cache_name = s:_encode_name(a:cache_dir, a:filename) |
||||
|
||||
call writefile(a:list, cache_name) |
||||
endfunction |
||||
|
||||
function! s:delete(cache_dir, filename) |
||||
echoerr 'System.Cache.delete() is obsolete. Use its deletefile() instead.' |
||||
return call('s:deletefile', a:cache_dir, a:filename) |
||||
endfunction |
||||
|
||||
function! s:deletefile(cache_dir, filename) |
||||
let cache_name = s:_encode_name(a:cache_dir, a:filename) |
||||
return delete(cache_name) |
||||
endfunction |
||||
|
||||
function! s:_encode_name(cache_dir, filename) |
||||
" Check cache directory. |
||||
if !isdirectory(a:cache_dir) |
||||
call mkdir(a:cache_dir, 'p') |
||||
endif |
||||
let cache_dir = a:cache_dir |
||||
if cache_dir !~ '/$' |
||||
let cache_dir .= '/' |
||||
endif |
||||
|
||||
return cache_dir . s:_create_hash(cache_dir, a:filename) |
||||
endfunction |
||||
|
||||
function! s:check_old_cache(cache_dir, filename) |
||||
" Check old cache file. |
||||
let cache_name = s:_encode_name(a:cache_dir, a:filename) |
||||
let ret = getftime(cache_name) == -1 |
||||
\ || getftime(cache_name) <= getftime(a:filename) |
||||
if ret && filereadable(cache_name) |
||||
" Delete old cache. |
||||
call delete(cache_name) |
||||
endif |
||||
|
||||
return ret |
||||
endfunction |
||||
|
||||
" Check md5. |
||||
try |
||||
call md5#md5() |
||||
let s:exists_md5 = 1 |
||||
catch |
||||
let s:exists_md5 = 0 |
||||
endtry |
||||
|
||||
function! s:_create_hash(dir, str) |
||||
if len(a:dir) + len(a:str) < 150 |
||||
let hash = substitute(substitute( |
||||
\ a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g') |
||||
elseif s:exists_md5 |
||||
" Use md5.vim. |
||||
let hash = md5#md5(a:str) |
||||
else |
||||
" Use simple hash. |
||||
let sum = 0 |
||||
for i in range(len(a:str)) |
||||
let sum += char2nr(a:str[i]) * (i + 1) |
||||
endfor |
||||
|
||||
let hash = printf('%x', sum) |
||||
endif |
||||
|
||||
return hash |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim:set et ts=2 sts=2 sw=2 tw=0: |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
a20a988 |
||||
|
||||
Data.String |
||||
Data.List |
||||
System.Cache |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,204 @@
@@ -0,0 +1,204 @@
|
||||
"============================================================================= |
||||
" FILE: neocomplcache.vim |
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> |
||||
" Last Modified: 11 Jul 2013. |
||||
" License: MIT license {{{ |
||||
" Permission is hereby granted, free of charge, to any person obtaining |
||||
" a copy of this software and associated documentation files (the |
||||
" "Software"), to deal in the Software without restriction, including |
||||
" without limitation the rights to use, copy, modify, merge, publish, |
||||
" distribute, sublicense, and/or sell copies of the Software, and to |
||||
" permit persons to whom the Software is furnished to do so, subject to |
||||
" the following conditions: |
||||
" |
||||
" The above copyright notice and this permission notice shall be included |
||||
" in all copies or substantial portions of the Software. |
||||
" |
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
" }}} |
||||
" GetLatestVimScripts: 2620 1 :AutoInstall: neocomplcache |
||||
"============================================================================= |
||||
|
||||
if exists('g:loaded_neocomplcache') |
||||
finish |
||||
endif |
||||
let g:loaded_neocomplcache = 1 |
||||
|
||||
let s:save_cpo = &cpo |
||||
set cpo&vim |
||||
|
||||
if v:version < 702 |
||||
echohl Error |
||||
echomsg 'neocomplcache does not work this version of Vim (' . v:version . ').' |
||||
echohl None |
||||
finish |
||||
elseif $SUDO_USER != '' && $USER !=# $SUDO_USER |
||||
\ && $HOME !=# expand('~'.$USER) |
||||
\ && $HOME ==# expand('~'.$SUDO_USER) |
||||
echohl Error |
||||
echomsg 'neocomplcache disabled: "sudo vim" is detected and $HOME is set to ' |
||||
\.'your user''s home. ' |
||||
\.'You may want to use the sudo.vim plugin, the "-H" option ' |
||||
\.'with "sudo" or set always_set_home in /etc/sudoers instead.' |
||||
echohl None |
||||
finish |
||||
endif |
||||
|
||||
command! -nargs=0 -bar NeoComplCacheEnable |
||||
\ call neocomplcache#init#enable() |
||||
command! -nargs=0 -bar NeoComplCacheDisable |
||||
\ call neocomplcache#init#disable() |
||||
command! -nargs=0 -bar NeoComplCacheLock |
||||
\ call neocomplcache#commands#_lock() |
||||
command! -nargs=0 -bar NeoComplCacheUnlock |
||||
\ call neocomplcache#commands#_unlock() |
||||
command! -nargs=0 -bar NeoComplCacheToggle |
||||
\ call neocomplcache#commands#_toggle_lock() |
||||
command! -nargs=1 -bar NeoComplCacheLockSource |
||||
\ call neocomplcache#commands#_lock_source(<q-args>) |
||||
command! -nargs=1 -bar NeoComplCacheUnlockSource |
||||
\ call neocomplcache#commands#_unlock_source(<q-args>) |
||||
if v:version >= 703 |
||||
command! -nargs=1 -bar -complete=filetype NeoComplCacheSetFileType |
||||
\ call neocomplcache#commands#_set_file_type(<q-args>) |
||||
else |
||||
command! -nargs=1 -bar NeoComplCacheSetFileType |
||||
\ call neocomplcache#commands#_set_file_type(<q-args>) |
||||
endif |
||||
command! -nargs=0 -bar NeoComplCacheClean |
||||
\ call neocomplcache#commands#_clean() |
||||
|
||||
" Warning if using obsolute mappings. "{{{ |
||||
silent! inoremap <unique> <Plug>(neocomplcache_snippets_expand) |
||||
\ <C-o>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! snoremap <unique> <Plug>(neocomplcache_snippets_expand) |
||||
\ :<C-u>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! inoremap <unique> <Plug>(neocomplcache_snippets_jump) |
||||
\ <C-o>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! snoremap <unique> <Plug>(neocomplcache_snippets_jump) |
||||
\ :<C-u>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! inoremap <unique> <Plug>(neocomplcache_snippets_force_expand) |
||||
\ <C-o>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! snoremap <unique> <Plug>(neocomplcache_snippets_force_expand) |
||||
\ :<C-u>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! inoremap <unique> <Plug>(neocomplcache_snippets_force_jump) |
||||
\ <C-o>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
silent! snoremap <unique> <Plug>(neocomplcache_snippets_force_jump) |
||||
\ :<C-u>:echoerr <SID>print_snippets_complete_error()<CR> |
||||
function! s:print_snippets_complete_error() |
||||
return 'Warning: neocomplcache snippets source was splitted!' |
||||
\ .' You should install neosnippet from' |
||||
\ .' "https://github.com/Shougo/neosnippet.vim"' |
||||
endfunction"}}} |
||||
|
||||
" Global options definition. "{{{ |
||||
let g:neocomplcache_max_list = |
||||
\ get(g:, 'neocomplcache_max_list', 100) |
||||
let g:neocomplcache_max_keyword_width = |
||||
\ get(g:, 'neocomplcache_max_keyword_width', 80) |
||||
let g:neocomplcache_max_menu_width = |
||||
\ get(g:, 'neocomplcache_max_menu_width', 15) |
||||
let g:neocomplcache_auto_completion_start_length = |
||||
\ get(g:, 'neocomplcache_auto_completion_start_length', 2) |
||||
let g:neocomplcache_manual_completion_start_length = |
||||
\ get(g:, 'neocomplcache_manual_completion_start_length', 0) |
||||
let g:neocomplcache_min_keyword_length = |
||||
\ get(g:, 'neocomplcache_min_keyword_length', 4) |
||||
let g:neocomplcache_enable_ignore_case = |
||||
\ get(g:, 'neocomplcache_enable_ignore_case', &ignorecase) |
||||
let g:neocomplcache_enable_smart_case = |
||||
\ get(g:, 'neocomplcache_enable_smart_case', &infercase) |
||||
let g:neocomplcache_disable_auto_complete = |
||||
\ get(g:, 'neocomplcache_disable_auto_complete', 0) |
||||
let g:neocomplcache_enable_wildcard = |
||||
\ get(g:, 'neocomplcache_enable_wildcard', 1) |
||||
let g:neocomplcache_enable_camel_case_completion = |
||||
\ get(g:, 'neocomplcache_enable_camel_case_completion', 0) |
||||
let g:neocomplcache_enable_underbar_completion = |
||||
\ get(g:, 'neocomplcache_enable_underbar_completion', 0) |
||||
let g:neocomplcache_enable_fuzzy_completion = |
||||
\ get(g:, 'neocomplcache_enable_fuzzy_completion', 0) |
||||
let g:neocomplcache_fuzzy_completion_start_length = |
||||
\ get(g:, 'neocomplcache_fuzzy_completion_start_length', 3) |
||||
let g:neocomplcache_enable_caching_message = |
||||
\ get(g:, 'neocomplcache_enable_caching_message', 1) |
||||
let g:neocomplcache_enable_insert_char_pre = |
||||
\ get(g:, 'neocomplcache_enable_insert_char_pre', 0) |
||||
let g:neocomplcache_enable_cursor_hold_i = |
||||
\ get(g:, 'neocomplcache_enable_cursor_hold_i', 0) |
||||
let g:neocomplcache_cursor_hold_i_time = |
||||
\ get(g:, 'neocomplcache_cursor_hold_i_time', 300) |
||||
let g:neocomplcache_enable_auto_select = |
||||
\ get(g:, 'neocomplcache_enable_auto_select', 0) |
||||
let g:neocomplcache_enable_auto_delimiter = |
||||
\ get(g:, 'neocomplcache_enable_auto_delimiter', 0) |
||||
let g:neocomplcache_caching_limit_file_size = |
||||
\ get(g:, 'neocomplcache_caching_limit_file_size', 500000) |
||||
let g:neocomplcache_disable_caching_file_path_pattern = |
||||
\ get(g:, 'neocomplcache_disable_caching_file_path_pattern', '') |
||||
let g:neocomplcache_lock_buffer_name_pattern = |
||||
\ get(g:, 'neocomplcache_lock_buffer_name_pattern', '') |
||||
let g:neocomplcache_ctags_program = |
||||
\ get(g:, 'neocomplcache_ctags_program', 'ctags') |
||||
let g:neocomplcache_force_overwrite_completefunc = |
||||
\ get(g:, 'neocomplcache_force_overwrite_completefunc', 0) |
||||
let g:neocomplcache_enable_prefetch = |
||||
\ get(g:, 'neocomplcache_enable_prefetch', |
||||
\ !(v:version > 703 || v:version == 703 && has('patch519')) |
||||
\ || (has('gui_running') && has('xim')) |
||||
\ ) |
||||
let g:neocomplcache_lock_iminsert = |
||||
\ get(g:, 'neocomplcache_lock_iminsert', 0) |
||||
let g:neocomplcache_release_cache_time = |
||||
\ get(g:, 'neocomplcache_release_cache_time', 900) |
||||
let g:neocomplcache_wildcard_characters = |
||||
\ get(g:, 'neocomplcache_wildcard_characters', { |
||||
\ '_' : '*' }) |
||||
let g:neocomplcache_skip_auto_completion_time = |
||||
\ get(g:, 'neocomplcache_skip_auto_completion_time', '0.3') |
||||
let g:neocomplcache_enable_auto_close_preview = |
||||
\ get(g:, 'neocomplcache_enable_auto_close_preview', 1) |
||||
|
||||
let g:neocomplcache_sources_list = |
||||
\ get(g:, 'neocomplcache_sources_list', {}) |
||||
let g:neocomplcache_disabled_sources_list = |
||||
\ get(g:, 'neocomplcache_disabled_sources_list', {}) |
||||
if exists('g:neocomplcache_source_disable') |
||||
let g:neocomplcache_disabled_sources_list._ = |
||||
\ keys(filter(copy(g:neocomplcache_source_disable), 'v:val')) |
||||
endif |
||||
|
||||
if exists('g:neocomplcache_plugin_completion_length') |
||||
let g:neocomplcache_source_completion_length = |
||||
\ g:neocomplcache_plugin_completion_length |
||||
endif |
||||
let g:neocomplcache_source_completion_length = |
||||
\ get(g:, 'neocomplcache_source_completion_length', {}) |
||||
if exists('g:neocomplcache_plugin_rank') |
||||
let g:neocomplcache_source_rank = g:neocomplcache_plugin_rank |
||||
endif |
||||
let g:neocomplcache_source_rank = |
||||
\ get(g:, 'neocomplcache_source_rank', {}) |
||||
|
||||
let g:neocomplcache_temporary_dir = |
||||
\ get(g:, 'neocomplcache_temporary_dir', expand('~/.neocomplcache')) |
||||
let g:neocomplcache_enable_debug = |
||||
\ get(g:, 'neocomplcache_enable_debug', 0) |
||||
if get(g:, 'neocomplcache_enable_at_startup', 0) |
||||
augroup neocomplcache |
||||
" Enable startup. |
||||
autocmd CursorHold,CursorMovedI |
||||
\ * call neocomplcache#init#lazy() |
||||
augroup END |
||||
endif"}}} |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
||||
" vim: foldmethod=marker |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue