Updated plugins
This commit is contained in:
parent
879a7b6bd4
commit
a448b32309
|
@ -68,6 +68,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
|
|||
\ 'key_loop': ['s:keyloop', 0],
|
||||
\ 'lazy_update': ['s:lazy', 0],
|
||||
\ 'match_func': ['s:matcher', {}],
|
||||
\ 'match_window': ['s:mw', ''],
|
||||
\ 'match_window_bottom': ['s:mwbottom', 1],
|
||||
\ 'match_window_reversed': ['s:mwreverse', 1],
|
||||
\ 'max_depth': ['s:maxdepth', 40],
|
||||
|
@ -102,7 +103,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
|
|||
|
||||
" Global options
|
||||
let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
|
||||
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n',
|
||||
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'ttimeout': 0,
|
||||
\ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 }
|
||||
|
||||
" Keymaps
|
||||
|
@ -181,7 +182,7 @@ let s:hlgrps = {
|
|||
\ 'PrtText': 'Normal',
|
||||
\ 'PrtCursor': 'Constant',
|
||||
\ }
|
||||
" s:opts() {{{2
|
||||
" Get the options {{{2
|
||||
fu! s:opts(...)
|
||||
unl! s:usrign s:usrcmd s:urprtmaps
|
||||
for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each)
|
||||
|
@ -201,6 +202,9 @@ fu! s:opts(...)
|
|||
let {va} = {s:bpref.ke}
|
||||
en
|
||||
endfo
|
||||
" Match window options
|
||||
cal s:match_window_opts()
|
||||
" One-time values
|
||||
if a:0 && a:1 != {}
|
||||
unl va
|
||||
for [ke, va] in items(a:1)
|
||||
|
@ -217,7 +221,6 @@ fu! s:opts(...)
|
|||
en | endfo
|
||||
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
||||
let s:maxdepth = min([s:maxdepth, 100])
|
||||
let s:mxheight = max([s:mxheight, 1])
|
||||
let s:glob = s:showhidden ? '.*\|*' : '*'
|
||||
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
|
||||
let s:lash = ctrlp#utils#lash()
|
||||
|
@ -238,13 +241,32 @@ fu! s:opts(...)
|
|||
cal extend(s:prtmaps, s:urprtmaps)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:match_window_opts()
|
||||
let s:mw_pos =
|
||||
\ s:mw =~ 'top\|bottom' ? matchstr(s:mw, 'top\|bottom') :
|
||||
\ exists('g:ctrlp_match_window_bottom') ? ( s:mwbottom ? 'bottom' : 'top' )
|
||||
\ : 'bottom'
|
||||
let s:mw_order =
|
||||
\ s:mw =~ 'order:[^,]\+' ? matchstr(s:mw, 'order:\zs[^,]\+') :
|
||||
\ exists('g:ctrlp_match_window_reversed') ? ( s:mwreverse ? 'btt' : 'ttb' )
|
||||
\ : 'btt'
|
||||
let s:mw_max =
|
||||
\ s:mw =~ 'max:[^,]\+' ? str2nr(matchstr(s:mw, 'max:\zs\d\+')) :
|
||||
\ exists('g:ctrlp_max_height') ? s:mxheight
|
||||
\ : 10
|
||||
let s:mw_min =
|
||||
\ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
|
||||
let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
|
||||
let s:mw_min = min([s:mw_min, s:mw_max])
|
||||
endf
|
||||
"}}}1
|
||||
" * Open & Close {{{1
|
||||
fu! s:Open()
|
||||
cal s:log(1)
|
||||
cal s:getenv()
|
||||
cal s:execextvar('enter')
|
||||
sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
|
||||
sil! exe 'keepa' ( s:mw_pos == 'top' ? 'to' : 'bo' ) '1new ControlP'
|
||||
cal s:buffunc(1)
|
||||
let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)]
|
||||
let [s:focus, s:prompt] = [1, ['', '', '']]
|
||||
|
@ -297,7 +319,7 @@ fu! ctrlp#clra()
|
|||
if isdirectory(cadir)
|
||||
let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n")
|
||||
let eval = '!isdirectory(v:val) && v:val !~ ''\v[\/]cache[.a-z]+$|\.log$'''
|
||||
sil! cal map(filter(cafiles, eval), 'delete(v:val)')
|
||||
sil! cal map(s:ifilter(cafiles, eval), 'delete(v:val)')
|
||||
en
|
||||
cal ctrlp#clr()
|
||||
endf
|
||||
|
@ -362,7 +384,7 @@ fu! s:UserCmd(lscmd)
|
|||
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
|
||||
en
|
||||
if has('win32') || has('win64')
|
||||
let lscmd = substitute(lscmd, '\v(^|&&\s*)\zscd (/d)@!', 'cd /d ', '')
|
||||
let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
|
||||
en
|
||||
let path = exists('*shellescape') ? shellescape(path) : path
|
||||
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
|
||||
|
@ -433,7 +455,7 @@ endf
|
|||
fu! s:MatchIt(items, pat, limit, exc)
|
||||
let [lines, id] = [[], 0]
|
||||
let pat =
|
||||
\ s:byfname ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
|
||||
\ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
|
||||
\ : s:martcs.a:pat
|
||||
for item in a:items
|
||||
let id += 1
|
||||
|
@ -450,7 +472,16 @@ fu! s:MatchedItems(items, pat, limit)
|
|||
let exc = exists('s:crfilerel') ? s:crfilerel : ''
|
||||
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
|
||||
if s:matcher != {}
|
||||
let argms = [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
|
||||
let argms =
|
||||
\ has_key(s:matcher, 'arg_type') && s:matcher['arg_type'] == 'dict' ? [{
|
||||
\ 'items': items,
|
||||
\ 'str': a:pat,
|
||||
\ 'limit': a:limit,
|
||||
\ 'mmode': s:mmode(),
|
||||
\ 'ispath': s:ispath,
|
||||
\ 'crfile': exc,
|
||||
\ 'regex': s:regexp,
|
||||
\ }] : [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
|
||||
let lines = call(s:matcher['match'], argms, s:matcher)
|
||||
el
|
||||
let lines = s:MatchIt(items, a:pat, a:limit, exc)
|
||||
|
@ -480,7 +511,7 @@ fu! s:SplitPattern(str)
|
|||
if exists('lst')
|
||||
let pat = ''
|
||||
if !empty(lst)
|
||||
if s:byfname && index(lst, ';') > 0
|
||||
if s:byfname() && index(lst, ';') > 0
|
||||
let fbar = index(lst, ';')
|
||||
let lst_1 = s:sublist(lst, 0, fbar - 1)
|
||||
let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : ['']
|
||||
|
@ -494,15 +525,19 @@ fu! s:SplitPattern(str)
|
|||
endf
|
||||
" * BuildPrompt() {{{1
|
||||
fu! s:Render(lines, pat)
|
||||
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
|
||||
let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
|
||||
let [&ma, lines, s:res_count] = [1, a:lines, len(a:lines)]
|
||||
let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
|
||||
let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
|
||||
let cur_cmd = 'keepj norm! '.( s:mw_order == 'btt' ? 'G' : 'gg' ).'1|'
|
||||
" Setup the match window
|
||||
sil! exe '%d _ | res' s:height
|
||||
sil! exe '%d _ | res' height
|
||||
" Print the new items
|
||||
if empty(lines)
|
||||
let [s:matched, s:lines] = [[], []]
|
||||
cal setline(1, ' == NO ENTRIES ==')
|
||||
let lines = [' == NO ENTRIES ==']
|
||||
cal setline(1, s:offset(lines, height - 1))
|
||||
setl noma nocul
|
||||
exe cur_cmd
|
||||
cal s:unmarksigns()
|
||||
if s:dohighlight() | cal clearmatches() | en
|
||||
retu
|
||||
|
@ -514,12 +549,12 @@ fu! s:Render(lines, pat)
|
|||
cal sort(lines, 's:mixedsort')
|
||||
unl s:compat
|
||||
en
|
||||
if s:mwreverse | cal reverse(lines) | en
|
||||
if s:mw_order == 'btt' | cal reverse(lines) | en
|
||||
let s:lines = copy(lines)
|
||||
cal map(lines, 's:formatline(v:val)')
|
||||
cal setline(1, lines)
|
||||
cal setline(1, s:offset(lines, height))
|
||||
setl noma cul
|
||||
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|'
|
||||
exe cur_cmd
|
||||
cal s:unmarksigns()
|
||||
cal s:remarksigns()
|
||||
if exists('s:cline') && s:nolim != 1
|
||||
|
@ -541,7 +576,7 @@ fu! s:Update(str)
|
|||
let s:martcs = &scs && str =~ '\u' ? '\C' : ''
|
||||
let pat = s:matcher == {} ? s:SplitPattern(str) : str
|
||||
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
|
||||
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winh)
|
||||
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winmaxh)
|
||||
cal s:Render(lines, pat)
|
||||
endf
|
||||
|
||||
|
@ -550,7 +585,7 @@ fu! s:ForceUpdate()
|
|||
endf
|
||||
|
||||
fu! s:BuildPrompt(upd)
|
||||
let base = ( s:regexp ? 'r' : '>' ).( s:byfname ? 'd' : '>' ).'> '
|
||||
let base = ( s:regexp ? 'r' : '>' ).( s:byfname() ? 'd' : '>' ).'> '
|
||||
let str = escape(s:getinput(), '\')
|
||||
let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy
|
||||
if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp')
|
||||
|
@ -581,11 +616,8 @@ fu! s:SetDefTxt()
|
|||
if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
|
||||
let txt = s:deftxt
|
||||
if !type(txt)
|
||||
let txt = txt && !stridx(s:crfpath, s:dyncwd)
|
||||
\ ? ctrlp#rmbasedir([s:crfpath])[0] : ''
|
||||
let txt = txt != '' ? txt.s:lash(s:crfpath) : ''
|
||||
el
|
||||
let txt = expand(txt, 1)
|
||||
let path = s:crfpath.s:lash(s:crfpath)
|
||||
let txt = txt && !stridx(path, s:dyncwd) ? ctrlp#rmbasedir([path])[0] : ''
|
||||
en
|
||||
let s:prompt[0] = txt
|
||||
endf
|
||||
|
@ -735,7 +767,7 @@ endf
|
|||
|
||||
fu! s:PrtSelectJump(char)
|
||||
let lines = copy(s:lines)
|
||||
if s:byfname
|
||||
if s:byfname()
|
||||
cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]')
|
||||
en
|
||||
" Cycle through matches, use s:jmpchr to store last jump
|
||||
|
@ -904,6 +936,11 @@ fu! s:ToggleKeyLoop()
|
|||
en
|
||||
endf
|
||||
|
||||
fu! s:ToggleMRURelative()
|
||||
cal ctrlp#mrufiles#tgrel()
|
||||
cal s:PrtClearCache()
|
||||
endf
|
||||
|
||||
fu! s:PrtSwitcher()
|
||||
let [s:force, s:matches] = [1, 1]
|
||||
cal s:BuildPrompt(1)
|
||||
|
@ -937,14 +974,21 @@ fu! s:SetWD(args)
|
|||
en
|
||||
endf
|
||||
" * AcceptSelection() {{{1
|
||||
fu! ctrlp#acceptfile(mode, line, ...)
|
||||
let [md, useb] = [a:mode, 0]
|
||||
if !type(a:line)
|
||||
let [filpath, bufnr, useb] = [a:line, a:line, 1]
|
||||
fu! ctrlp#acceptfile(...)
|
||||
let useb = 0
|
||||
if a:0 == 1 && type(a:1) == 4
|
||||
let [md, line] = [a:1['action'], a:1['line']]
|
||||
let atl = has_key(a:1, 'tail') ? a:1['tail'] : ''
|
||||
el
|
||||
let filpath = fnamemodify(a:line, ':p')
|
||||
if s:nonamecond(a:line, filpath)
|
||||
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
|
||||
let [md, line] = [a:1, a:2]
|
||||
let atl = a:0 > 2 ? a:3 : ''
|
||||
en
|
||||
if !type(line)
|
||||
let [filpath, bufnr, useb] = [line, line, 1]
|
||||
el
|
||||
let filpath = fnamemodify(line, ':p')
|
||||
if s:nonamecond(line, filpath)
|
||||
let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
|
||||
let [filpath, useb] = [bufnr, 1]
|
||||
el
|
||||
let bufnr = bufnr('^'.filpath.'$')
|
||||
|
@ -952,7 +996,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
|
|||
en
|
||||
cal s:PrtExit()
|
||||
let tail = s:tail()
|
||||
let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$')
|
||||
let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
|
||||
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
|
||||
\ && !( md == 'e' && bufnr == bufnr('%') )
|
||||
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
|
||||
|
@ -980,7 +1024,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
|
|||
" Reset &switchbuf option
|
||||
let [swb, &swb] = [&swb, '']
|
||||
" Open new window/buffer
|
||||
let [fid, tail] = [( useb ? bufnr : filpath ), ( a:0 ? ' +'.a:1 : tail )]
|
||||
let [fid, tail] = [( useb ? bufnr : filpath ), ( atl != '' ? ' +'.atl : tail )]
|
||||
let args = [cmd, fid, tail, 1, [useb, j2l]]
|
||||
cal call('s:openfile', args)
|
||||
let &swb = swb
|
||||
|
@ -1011,24 +1055,34 @@ fu! s:SpecInputs(str)
|
|||
retu 0
|
||||
endf
|
||||
|
||||
fu! s:AcceptSelection(mode)
|
||||
if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en
|
||||
fu! s:AcceptSelection(action)
|
||||
let [md, icr] = [a:action[0], match(a:action, 'r') >= 0]
|
||||
let subm = icr || ( !icr && md == 'e' )
|
||||
if !subm && s:OpenMulti(md) != -1 | retu | en
|
||||
let str = s:getinput()
|
||||
if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en
|
||||
if subm | if s:SpecInputs(str) | retu | en | en
|
||||
" Get the selected line
|
||||
let line = ctrlp#getcline()
|
||||
if a:mode != 'e' && !s:itemtype && line == ''
|
||||
if !subm && !s:itemtype && line == '' && line('.') > s:offset
|
||||
\ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
|
||||
cal s:CreateNewFile(a:mode) | retu
|
||||
cal s:CreateNewFile(md) | retu
|
||||
en
|
||||
if empty(line) | retu | en
|
||||
" Do something with it
|
||||
if s:openfunc != {} && has_key(s:openfunc, s:ctype)
|
||||
let actfunc = s:openfunc[s:ctype]
|
||||
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
|
||||
el
|
||||
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept')
|
||||
if s:itemtype < 3
|
||||
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
|
||||
el
|
||||
let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
|
||||
let type = exttype == 'dict' ? exttype : 'list'
|
||||
en
|
||||
en
|
||||
cal call(actfunc, [a:mode, line])
|
||||
let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr }]
|
||||
\ : [md, line]
|
||||
cal call(actfunc, actargs)
|
||||
endf
|
||||
" - CreateNewFile() {{{1
|
||||
fu! s:CreateNewFile(...)
|
||||
|
@ -1187,7 +1241,10 @@ fu! s:OpenNoMarks(md, line)
|
|||
cal s:remarksigns()
|
||||
cal s:BuildPrompt(0)
|
||||
elsei a:md == 'x'
|
||||
cal call(s:openfunc[s:ctype], [a:md, a:line], s:openfunc)
|
||||
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict'
|
||||
let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }]
|
||||
\ : [a:md, a:line]
|
||||
cal call(s:openfunc[s:ctype], argms, s:openfunc)
|
||||
elsei a:md == 'd'
|
||||
let dir = fnamemodify(a:line, ':h')
|
||||
if isdirectory(dir)
|
||||
|
@ -1278,7 +1335,7 @@ fu! s:mixedsort(...)
|
|||
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
|
||||
if s:ispath
|
||||
let ms = []
|
||||
if s:height < 21
|
||||
if s:res_count < 21
|
||||
let ms += [s:compfnlen(a:1, a:2)]
|
||||
if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
|
||||
if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
|
||||
|
@ -1324,12 +1381,21 @@ fu! ctrlp#statusline()
|
|||
let prv = tps[s:walker(max, s:itemtype, -1)][1]
|
||||
let s:ctype = tps[s:itemtype][0]
|
||||
let focus = s:focus ? 'prt' : 'win'
|
||||
let byfname = s:byfname ? 'file' : 'path'
|
||||
let byfname = s:ispath ? s:byfname ? 'file' : 'path' : 'line'
|
||||
let marked = s:opmul != '0' ?
|
||||
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
|
||||
if s:status != {}
|
||||
let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
|
||||
let &l:stl = call(s:status['main'], args, s:status)
|
||||
let argms =
|
||||
\ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{
|
||||
\ 'focus': focus,
|
||||
\ 'byfname': byfname,
|
||||
\ 'regex': s:regexp,
|
||||
\ 'prev': prv,
|
||||
\ 'item': s:ctype,
|
||||
\ 'next': nxt,
|
||||
\ 'marked': marked,
|
||||
\ }] : [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
|
||||
let &l:stl = call(s:status['main'], argms, s:status)
|
||||
el
|
||||
let item = '%#CtrlPMode1# '.s:ctype.' %*'
|
||||
let focus = '%#CtrlPMode2# '.focus.' %*'
|
||||
|
@ -1349,8 +1415,13 @@ endf
|
|||
fu! ctrlp#progress(enum, ...)
|
||||
if has('macunix') || has('mac') | sl 1m | en
|
||||
let txt = a:0 ? '(press ctrl-c to abort)' : ''
|
||||
let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum], s:status)
|
||||
\ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
|
||||
if s:status != {}
|
||||
let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict'
|
||||
\ ? [{ 'str': a:enum }] : [a:enum]
|
||||
let &l:stl = call(s:status['prog'], argms, s:status)
|
||||
el
|
||||
let &l:stl = '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
|
||||
en
|
||||
redraws
|
||||
endf
|
||||
" *** Paths {{{2
|
||||
|
@ -1376,6 +1447,11 @@ fu! s:pathshorten(str)
|
|||
retu matchstr(a:str, '^.\{9}').'...'
|
||||
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
|
||||
endf
|
||||
|
||||
fu! s:offset(lines, height)
|
||||
let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0
|
||||
retu s:offset > 0 ? ( repeat([''], s:offset) + a:lines ) : a:lines
|
||||
endf
|
||||
" Directory completion {{{3
|
||||
fu! s:dircompl(be, sd)
|
||||
if a:sd == '' | retu [] | en
|
||||
|
@ -1464,7 +1540,7 @@ fu! s:samerootsyml(each, isfile, cwd)
|
|||
endf
|
||||
|
||||
fu! ctrlp#rmbasedir(items)
|
||||
let cwd = s:dyncwd.( s:dyncwd !~ '[\/]$' ? s:lash : '' )
|
||||
let cwd = s:dyncwd.s:lash()
|
||||
if a:items != [] && !stridx(a:items[0], cwd)
|
||||
let idx = strlen(cwd)
|
||||
retu map(a:items, 'strpart(v:val, idx)')
|
||||
|
@ -1599,6 +1675,18 @@ fu! s:dosigns()
|
|||
retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs')
|
||||
endf
|
||||
" Lists & Dictionaries {{{2
|
||||
fu! s:ifilter(list, str)
|
||||
let [rlist, estr] = [[], substitute(a:str, 'v:val', 'each', 'g')]
|
||||
for each in a:list
|
||||
try
|
||||
if eval(estr)
|
||||
cal add(rlist, each)
|
||||
en
|
||||
cat | con | endt
|
||||
endfo
|
||||
retu rlist
|
||||
endf
|
||||
|
||||
fu! s:dictindex(dict, expr)
|
||||
for key in keys(a:dict)
|
||||
if a:dict[key] == a:expr | retu key | en
|
||||
|
@ -1808,7 +1896,6 @@ endf
|
|||
fu! s:modevar()
|
||||
let s:matchtype = s:mtype()
|
||||
let s:ispath = s:ispathitem()
|
||||
if !s:ispath | let s:byfname = 0 | en
|
||||
let s:mfunc = s:mfunc()
|
||||
let s:nolim = s:getextvar('nolim')
|
||||
let s:dosort = s:getextvar('sort')
|
||||
|
@ -1820,6 +1907,10 @@ fu! s:nosort()
|
|||
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
|
||||
endf
|
||||
|
||||
fu! s:byfname()
|
||||
retu s:ispath && s:byfname
|
||||
endf
|
||||
|
||||
fu! s:narrowable()
|
||||
retu exists('s:act_add') && exists('s:matched') && s:matched != []
|
||||
\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
|
||||
|
@ -1834,7 +1925,7 @@ fu! s:getinput(...)
|
|||
if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k'
|
||||
retu join(prt, '')
|
||||
en
|
||||
let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
|
||||
let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
|
||||
for dict in s:abbrev['abbrevs']
|
||||
let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
|
||||
let pat = escape(dict['pattern'], '~')
|
||||
|
@ -1916,7 +2007,7 @@ fu! s:getenv()
|
|||
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
|
||||
let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)]
|
||||
let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')]
|
||||
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
|
||||
let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')]
|
||||
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
|
||||
let s:crfile = bufname('%') == ''
|
||||
\ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1)
|
||||
|
@ -1939,7 +2030,8 @@ endf
|
|||
fu! s:log(m)
|
||||
if exists('g:ctrlp_log') && g:ctrlp_log | if a:m
|
||||
let cadir = ctrlp#utils#cachedir()
|
||||
sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log'
|
||||
let apd = g:ctrlp_log > 1 ? '>' : ''
|
||||
sil! exe 'redi! >'.apd cadir.s:lash(cadir).'ctrlp.log'
|
||||
el
|
||||
sil! redi END
|
||||
en | en
|
||||
|
@ -2023,7 +2115,7 @@ endf
|
|||
|
||||
fu! s:mfunc()
|
||||
let mfunc = 'match'
|
||||
if s:byfname && s:ispath
|
||||
if s:byfname()
|
||||
let mfunc = 's:matchfname'
|
||||
elsei s:itemtype > 2
|
||||
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
||||
|
@ -2102,7 +2194,9 @@ fu! s:getextvar(key)
|
|||
endf
|
||||
|
||||
fu! ctrlp#getcline()
|
||||
retu !empty(s:lines) ? s:lines[line('.') - 1] : ''
|
||||
let [linenr, offset] = [line('.'), ( s:offset > 0 ? s:offset : 0 )]
|
||||
retu !empty(s:lines) && !( offset && linenr <= offset )
|
||||
\ ? s:lines[linenr - 1 - offset] : ''
|
||||
endf
|
||||
|
||||
fu! ctrlp#getmarkedlist()
|
||||
|
@ -2134,6 +2228,10 @@ endf
|
|||
fu! ctrlp#call(func, ...)
|
||||
retu call(a:func, a:000)
|
||||
endf
|
||||
|
||||
fu! ctrlp#getvar(var)
|
||||
retu {a:var}
|
||||
endf
|
||||
"}}}1
|
||||
" * Initialization {{{1
|
||||
fu! ctrlp#setlines(...)
|
||||
|
|
|
@ -248,7 +248,9 @@ endf
|
|||
fu! ctrlp#buffertag#cmd(mode, ...)
|
||||
let s:btmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:bufname = fnamemodify(a:1, ':p')
|
||||
let s:btmode = 0
|
||||
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
|
||||
let s:bufname = fnamemodify(bname, ':p')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
|
|
|
@ -83,7 +83,9 @@ endf
|
|||
fu! ctrlp#changes#cmd(mode, ...)
|
||||
let s:clmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
|
||||
let s:clmode = 0
|
||||
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
|
||||
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
|
|
|
@ -74,7 +74,7 @@ fu! ctrlp#dir#init(...)
|
|||
endf
|
||||
|
||||
fu! ctrlp#dir#accept(mode, str)
|
||||
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
|
||||
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
|
||||
if a:mode =~ 't\|v\|h'
|
||||
cal ctrlp#exit()
|
||||
en
|
||||
|
|
|
@ -11,7 +11,7 @@ en
|
|||
let g:loaded_ctrlp_line = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#line#init()',
|
||||
\ 'init': 'ctrlp#line#init(s:crbufnr)',
|
||||
\ 'accept': 'ctrlp#line#accept',
|
||||
\ 'lname': 'lines',
|
||||
\ 'sname': 'lns',
|
||||
|
@ -29,8 +29,9 @@ fu! s:syntax()
|
|||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#line#init()
|
||||
let [bufs, lines] = [ctrlp#buffers('id'), []]
|
||||
fu! ctrlp#line#init(bufnr)
|
||||
let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
|
||||
let bufs = exists('s:lnmode') && s:lnmode ? ctrlp#buffers('id') : [bufnr]
|
||||
for bufnr in bufs
|
||||
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
|
||||
if lfb == [] && bufn != ''
|
||||
|
@ -57,7 +58,13 @@ fu! ctrlp#line#accept(mode, str)
|
|||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#line#id()
|
||||
fu! ctrlp#line#cmd(mode, ...)
|
||||
let s:lnmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:lnmode = 0
|
||||
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
|
||||
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
|
|
@ -126,6 +126,10 @@ fu! ctrlp#mrufiles#bufs()
|
|||
retu s:mrbs
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#tgrel()
|
||||
let {s:re} = !{s:re}
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#cachefile()
|
||||
if !exists('s:cadir') || !exists('s:cafile')
|
||||
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
|
||||
|
|
|
@ -40,9 +40,7 @@ Overview:~
|
|||
|ctrlp_cmd|...................Default command used for the default mapping.
|
||||
|ctrlp_by_filename|...........Default to filename mode or not.
|
||||
|ctrlp_regexp|................Default to regexp mode or not.
|
||||
|ctrlp_match_window_bottom|...Where to show the match window.
|
||||
|ctrlp_match_window_reversed|.Sort order in the match window.
|
||||
|ctrlp_max_height|............Max height of the match window.
|
||||
|ctrlp_match_window|..........Order, height and position of the match window.
|
||||
|ctrlp_switch_buffer|.........Jump to an open buffer if already opened.
|
||||
|ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc).
|
||||
|ctrlp_tabpage_position|......Where to put the new tab page.
|
||||
|
@ -77,6 +75,11 @@ Overview:~
|
|||
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
|
||||
|ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
|
||||
|
||||
BufferTag mode: (to enable, see |ctrlp-extensions|)
|
||||
|g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
|
||||
|g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
|
||||
|g:ctrlp_buftag_types|........Add new filetypes and set the cmd arguments.
|
||||
|
||||
Advanced options:
|
||||
|ctrlp_open_func|.............Use custom file opening functions.
|
||||
|ctrlp_status_func|...........Change CtrlP's two statuslines.
|
||||
|
@ -114,21 +117,27 @@ Set this to 1 to set regexp search as the default: >
|
|||
<
|
||||
Can be toggled on/off by pressing <c-r> inside the prompt.
|
||||
|
||||
*'g:ctrlp_match_window_bottom'*
|
||||
Set this to 0 to show the match window at the top of the screen: >
|
||||
let g:ctrlp_match_window_bottom = 1
|
||||
*'g:ctrlp_match_window'*
|
||||
Change the postion, the listing order of results, the minimum and the maximum
|
||||
heights of the match window: >
|
||||
let g:ctrlp_match_window = ''
|
||||
<
|
||||
Example: >
|
||||
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10'
|
||||
<
|
||||
The position: (default: bottom)
|
||||
top - show the match window at the top of the screen.
|
||||
bottom - show the match window at the bottom of the screen.
|
||||
|
||||
*'g:ctrlp_match_window_reversed'*
|
||||
Change the listing order of the files in the match window. The default setting
|
||||
(1) is from bottom to top: >
|
||||
let g:ctrlp_match_window_reversed = 1
|
||||
<
|
||||
The listing order of results: (default: btt)
|
||||
order:ttb - from top to bottom.
|
||||
order:btt - from bottom to top.
|
||||
|
||||
*'g:ctrlp_max_height'*
|
||||
Set the maximum height of the match window: >
|
||||
let g:ctrlp_max_height = 10
|
||||
<
|
||||
The minimum and maximum heights:
|
||||
min:{n} - show minimum {n} lines (default: 1).
|
||||
max:{n} - show maximum {n} lines (default: 10).
|
||||
|
||||
Note: When a setting isn't set, its default value will be used.
|
||||
|
||||
*'g:ctrlp_switch_buffer'*
|
||||
When opening a file, if it's already open in a window somewhere, CtrlP will try
|
||||
|
@ -323,18 +332,21 @@ Some examples: >
|
|||
let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
|
||||
\ . 'do hg --cwd %s status -numac -I . %%a'] " Windows
|
||||
<
|
||||
Note #1: if the fallback_command is empty or the 'fallback' key is not defined,
|
||||
Note #1: in the |Dictionary| format, 'fallback' and 'ignore' are optional. In
|
||||
the |List| format, fallback_command is optional.
|
||||
|
||||
Note #2: if the fallback_command is empty or the 'fallback' key is not defined,
|
||||
|globpath()| will then be used when scanning outside of a repository.
|
||||
|
||||
Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set
|
||||
Note #3: unless the |Dictionary| format is used and 'ignore' is defined and set
|
||||
to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
|
||||
these custom commands are being used. When not present, 'ignore' is set to 0 by
|
||||
default to retain the performance advantage of using external commands.
|
||||
|
||||
Note #3: when changing the option's variable type, remember to |:unlet| it
|
||||
Note #4: when changing the option's variable type, remember to |:unlet| it
|
||||
first or restart Vim to avoid the "E706: Variable type mismatch" error.
|
||||
|
||||
Note #4: you can use a |b:var| to set this option on a per buffer basis.
|
||||
Note #5: you can use a |b:var| to set this option on a per buffer basis.
|
||||
|
||||
*'g:ctrlp_max_history'*
|
||||
The maximum number of input strings you want CtrlP to remember. The default
|
||||
|
@ -563,6 +575,9 @@ Example: >
|
|||
Set this to 1 to show only MRU files in the current working directory: >
|
||||
let g:ctrlp_mruf_relative = 0
|
||||
<
|
||||
Note: you can use a custom mapping to toggle this option inside the prompt: >
|
||||
let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': ['<F2>'] }
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_default_order'*
|
||||
Set this to 1 to disable sorting when searching in MRU mode: >
|
||||
|
@ -734,6 +749,27 @@ Structure of the function: >
|
|||
endfunction
|
||||
<
|
||||
|
||||
Note: you can extend any of the above options with { 'arg_type': 'dict' } to
|
||||
enable passing all the function arguments in a single Dictionary argument. Use
|
||||
the existing argument names as keys in this Dictionary.
|
||||
|
||||
Example: >
|
||||
let g:ctrlp_status_func = {
|
||||
\ 'arg_type' : 'dict',
|
||||
\ 'enter': 'Function_Name_1',
|
||||
\ 'exit': 'Function_Name_2',
|
||||
\ }
|
||||
|
||||
function! Function_Name_1(dict)
|
||||
" where dict == {
|
||||
" \ 'focus': value,
|
||||
" \ 'byfname': value,
|
||||
" \ 'regex': value,
|
||||
" \ ...
|
||||
" }
|
||||
endfunction
|
||||
<
|
||||
|
||||
===============================================================================
|
||||
COMMANDS *ctrlp-commands*
|
||||
|
||||
|
@ -1076,8 +1112,8 @@ Available extensions:~
|
|||
*:CtrlPLine*
|
||||
* Line mode:~
|
||||
- Name: 'line'
|
||||
- Command: ":CtrlPLine"
|
||||
- Search for a line in all listed buffers.
|
||||
- Command: ":CtrlPLine [buffer]"
|
||||
- Search for a line in all listed buffers or in the specified [buffer].
|
||||
|
||||
*:CtrlPChange*
|
||||
*:CtrlPChangeAll*
|
||||
|
@ -1164,7 +1200,7 @@ Highlighting:~
|
|||
|
||||
Statuslines:~
|
||||
* Highlight groups:
|
||||
CtrlPMode1 : 'file' or 'path', and the current mode (Character)
|
||||
CtrlPMode1 : 'file' or 'path' or 'line', and the current mode (Character)
|
||||
CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|)
|
||||
CtrlPStats : the scanning status (Function)
|
||||
|
||||
|
@ -1253,6 +1289,10 @@ Special thanks:~
|
|||
===============================================================================
|
||||
CHANGELOG *ctrlp-changelog*
|
||||
|
||||
+ Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and
|
||||
*g:ctrlp_max_height* into |g:ctrlp_match_window|.
|
||||
+ New option: |g:ctrlp_match_window|.
|
||||
|
||||
Before 2012/11/30~
|
||||
|
||||
+ New options: |g:ctrlp_abbrev|,
|
||||
|
|
|
@ -51,7 +51,9 @@ com! -n=? -com=buffer CtrlPBufTag
|
|||
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
||||
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
||||
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
|
||||
com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
|
||||
|
||||
com! -n=? -com=buffer CtrlPLine
|
||||
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
|
||||
|
||||
com! -n=? -com=buffer CtrlPChange
|
||||
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
|
||||
|
|
|
@ -76,8 +76,8 @@ syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+
|
|||
|
||||
syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic
|
||||
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic
|
||||
syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
|
||||
|
@ -86,7 +86,7 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end=
|
|||
|
||||
if main_syntax ==# 'markdown'
|
||||
for s:type in g:markdown_fenced_languages
|
||||
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
|
||||
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
|
||||
endfor
|
||||
unlet! s:type
|
||||
endif
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## 2.2 (06/10/2013)
|
||||
Bugfixes:
|
||||
- Fix plugin break in PASTE mode. This fixes #44.
|
||||
|
||||
## 2.1 (04/26/2013)
|
||||
|
||||
Bugfixes:
|
||||
|
|
|
@ -69,7 +69,7 @@ let g:multi_cursor_start_key='<F6>'
|
|||
|
||||
## Setting
|
||||
Currently there're two additional global settings one can tweak:
|
||||
### ```g:multi_cursor_exit_from_visual_mode``` (Defaut: 1)
|
||||
### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
|
||||
|
||||
If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
|
||||
|
||||
|
@ -87,7 +87,6 @@ highlight link multiple_cursors_visual Visual
|
|||
|
||||
## Issues
|
||||
- Multi key commands like `ciw` do not work at the moment
|
||||
- Insert mode can be slow. If you are using Neobundle and have many plugins, try switching to Vundle to see if it helps. See https://github.com/Shougo/neobundle.vim/issues/84 for additional info.
|
||||
- All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input.
|
||||
- Select mode is not implemented
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ endif
|
|||
" Internal Mappings
|
||||
"===============================================================================
|
||||
|
||||
inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_inut()<CR>
|
||||
nnoremap <silent> <Plug>(i) :call <SID>process_user_inut()<CR>
|
||||
xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_inut()<CR>
|
||||
inoremap <silent> <Plug>(i) <C-o>:call <SID>process_user_input()<CR>
|
||||
nnoremap <silent> <Plug>(i) :call <SID>process_user_input()<CR>
|
||||
xnoremap <silent> <Plug>(i) :<C-u>call <SID>process_user_input()<CR>
|
||||
|
||||
inoremap <silent> <Plug>(a) <C-o>:call <SID>apply_user_input_next('i')<CR>
|
||||
nnoremap <silent> <Plug>(a) :call <SID>apply_user_input_next('n')<CR>
|
||||
|
@ -97,8 +97,8 @@ endfunction
|
|||
" attempted to be created at the next occurrence of the visual selection
|
||||
function! multiple_cursors#new(mode)
|
||||
if a:mode ==# 'n'
|
||||
" Reset all existing cursors, don't restore view
|
||||
call s:cm.reset(0)
|
||||
" Reset all existing cursors, don't restore view and setting
|
||||
call s:cm.reset(0, 0)
|
||||
|
||||
" Select the word under cursor to set the '< and '> marks
|
||||
exec "normal! viw"
|
||||
|
@ -113,7 +113,7 @@ function! multiple_cursors#new(mode)
|
|||
let start = line("'<")
|
||||
let finish = line("'>")
|
||||
if start != finish
|
||||
call s:cm.reset(0)
|
||||
call s:cm.reset(0, 0)
|
||||
let col = col("'<")
|
||||
for line in range(line("'<"), line("'>"))
|
||||
let pos = [line, col]
|
||||
|
@ -124,7 +124,7 @@ function! multiple_cursors#new(mode)
|
|||
else
|
||||
" Came directly from visual mode
|
||||
if s:cm.is_empty()
|
||||
call s:cm.reset(0)
|
||||
call s:cm.reset(0, 0)
|
||||
|
||||
if visualmode() ==# 'V'
|
||||
let left = [line('.'), 1]
|
||||
|
@ -133,7 +133,7 @@ function! multiple_cursors#new(mode)
|
|||
return
|
||||
endif
|
||||
call s:cm.add(right, [left, right])
|
||||
else
|
||||
else
|
||||
call s:cm.add(s:pos("'>"), s:region("'<", "'>"))
|
||||
endif
|
||||
endif
|
||||
|
@ -219,7 +219,7 @@ function! multiple_cursors#find(start, end, pattern)
|
|||
call winrestview(s:cm.saved_winview)
|
||||
echohl ErrorMsg | echo 'No match found' | echohl None
|
||||
return
|
||||
else
|
||||
else
|
||||
echohl Normal | echo 'Added '.s:cm.size().' cursor'.(s:cm.size()>1?'s':'') | echohl None
|
||||
call s:wait_for_user_input('v')
|
||||
endif
|
||||
|
@ -318,6 +318,7 @@ function! s:CursorManager.new()
|
|||
\ 'virtualedit': &virtualedit,
|
||||
\ 'cursorline': &cursorline,
|
||||
\ 'lazyredraw': &lazyredraw,
|
||||
\ 'paste': &paste,
|
||||
\ }
|
||||
" We save the window view when multicursor mode is entered
|
||||
let obj.saved_winview = []
|
||||
|
@ -327,7 +328,7 @@ function! s:CursorManager.new()
|
|||
endfunction
|
||||
|
||||
" Clear all cursors and their highlights
|
||||
function! s:CursorManager.reset(restore_view) dict
|
||||
function! s:CursorManager.reset(restore_view, restore_setting) dict
|
||||
if a:restore_view
|
||||
" Return the view back to the beginning
|
||||
if !empty(self.saved_winview)
|
||||
|
@ -357,7 +358,9 @@ function! s:CursorManager.reset(restore_view) dict
|
|||
let self.saved_winview = []
|
||||
let self.start_from_find = 0
|
||||
let s:char = ''
|
||||
call self.restore_user_settings()
|
||||
if a:restore_setting
|
||||
call self.restore_user_settings()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns 0 if it's not managing any cursors at the moment
|
||||
|
@ -513,10 +516,17 @@ endfunction
|
|||
" where the real vim cursor is
|
||||
" lazyredraw needs to be turned on to prevent jerky screen behavior with many
|
||||
" cursors on screen
|
||||
" paste mode needs to be switched off since it turns off a bunch of features
|
||||
" that's critical for the plugin to function
|
||||
function! s:CursorManager.initialize() dict
|
||||
let self.saved_settings['virtualedit'] = &virtualedit
|
||||
let self.saved_settings['cursorline'] = &cursorline
|
||||
let self.saved_settings['lazyredraw'] = &lazyredraw
|
||||
let self.saved_settings['paste'] = &paste
|
||||
let &virtualedit = "onemore"
|
||||
let &cursorline = 0
|
||||
let &lazyredraw = 1
|
||||
let &paste = 0
|
||||
" We could have already saved the view from multiple_cursors#find
|
||||
if !self.start_from_find
|
||||
let self.saved_winview = winsaveview()
|
||||
|
@ -529,6 +539,7 @@ function! s:CursorManager.restore_user_settings() dict
|
|||
let &virtualedit = self.saved_settings['virtualedit']
|
||||
let &cursorline = self.saved_settings['cursorline']
|
||||
let &lazyredraw = self.saved_settings['lazyredraw']
|
||||
let &paste = self.saved_settings['paste']
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -742,7 +753,7 @@ function! s:feedkeys(keys)
|
|||
endfunction
|
||||
|
||||
" Take the user input and apply it at every cursor
|
||||
function! s:process_user_inut()
|
||||
function! s:process_user_input()
|
||||
" Grr this is frustrating. In Insert mode, between the feedkey call and here,
|
||||
" the current position could actually CHANGE for some odd reason. Forcing a
|
||||
" position reset here
|
||||
|
@ -876,7 +887,7 @@ function! s:exit()
|
|||
let exit = 1
|
||||
endif
|
||||
if exit
|
||||
call s:cm.reset(1)
|
||||
call s:cm.reset(1, 1)
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
|
@ -923,7 +934,7 @@ function! s:revert_highlight_fix()
|
|||
if type(s:saved_line) == 1
|
||||
if s:from_mode ==# 'i'
|
||||
silent! undojoin | call setline('.', s:saved_line)
|
||||
else
|
||||
else
|
||||
call setline('.', s:saved_line)
|
||||
endif
|
||||
endif
|
||||
|
@ -961,7 +972,7 @@ function! s:end_latency_measure()
|
|||
silent! echom "Starting latency debug at ".reltimestr(reltime())
|
||||
redir END
|
||||
endif
|
||||
|
||||
|
||||
if !s:skip_latency_measure
|
||||
exec 'redir >> '.s:latency_debug_file
|
||||
silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode
|
||||
|
@ -1000,7 +1011,7 @@ function! s:wait_for_user_input(mode)
|
|||
if s:exit()
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
" If the key is a special key and we're in the right mode, handle it
|
||||
if index(get(s:special_keys, s:from_mode, []), s:char) != -1
|
||||
call s:handle_special_key(s:char, s:from_mode)
|
||||
|
|
|
@ -160,7 +160,6 @@ like the following in your vimrc: >
|
|||
cursors is lost. This is a implementation decision to keep the input
|
||||
perfectly synced in all locations, at the cost of potentially losing user
|
||||
input.
|
||||
- Performance in terminal vim degrades significantly with more cursors
|
||||
- Select mode is not implemented
|
||||
|
||||
==============================================================================
|
||||
|
|
|
@ -270,4 +270,19 @@ describe "Multiple Cursors" do
|
|||
hello world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#set paste mode" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type ':set paste<CR><C-n><C-n>cworld<Esc>:set nopaste<CR>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -77,11 +77,10 @@ fun! snipMate#expandSnip(snip, col)
|
|||
endif
|
||||
endif
|
||||
|
||||
call setline(lnum, line.snipLines[0])
|
||||
|
||||
" Autoindent snippet according to previous indentation
|
||||
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
|
||||
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
|
||||
" Insert snippet with proper indentation
|
||||
let indent = indent(lnum) + 1
|
||||
call setline(lnum, line . snipLines[0])
|
||||
call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val"))
|
||||
|
||||
" Open any folds snippet expands into
|
||||
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
|
||||
|
@ -391,7 +390,8 @@ endf
|
|||
" if triggername is not set 'default' is assumed
|
||||
fun! snipMate#ReadSnippetsFile(file)
|
||||
let result = []
|
||||
if !filereadable(a:file) | return result | endif
|
||||
let new_scopes = []
|
||||
if !filereadable(a:file) | return [result, new_scopes] | endif
|
||||
let r_guard = '^guard\s\+\zs.*'
|
||||
let inSnip = 0
|
||||
let guard = 1
|
||||
|
@ -421,9 +421,12 @@ fun! snipMate#ReadSnippetsFile(file)
|
|||
let trigger = strpart(trigger, 0, space - 1)
|
||||
endif
|
||||
let content = ''
|
||||
elseif line[:6] == 'extends'
|
||||
call extend(new_scopes, map(split(strpart(line, 8)),
|
||||
\ "substitute(v:val, ',*$', '', '')"))
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
return [result, new_scopes]
|
||||
endf
|
||||
|
||||
" adds scope aliases to list.
|
||||
|
@ -448,7 +451,14 @@ fun! s:AddScopeAliases(list)
|
|||
endf
|
||||
|
||||
function! s:Glob(path, expr)
|
||||
return filter(split(globpath(a:path, a:expr), "\n"), 'filereadable(v:val)')
|
||||
let res = []
|
||||
for p in split(a:path, ',')
|
||||
let h = fnamemodify(a:expr, ':h')
|
||||
if isdirectory(p . '/' . h)
|
||||
call extend(res, split(glob(p . '/' . a:expr), "\n"))
|
||||
endif
|
||||
endfor
|
||||
return filter(res, 'filereadable(v:val)')
|
||||
endfunction
|
||||
|
||||
" returns dict of
|
||||
|
@ -467,7 +477,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
|
|||
let paths = join(funcref#Call(s:c.snippet_dirs), ',')
|
||||
let result = {}
|
||||
let scopes = s:AddScopeAliases(a:scopes)
|
||||
let trigger = escape(a:trigger, '{}*[]`')
|
||||
let trigger = escape(a:trigger, "*[]?{}`'$")
|
||||
|
||||
" collect existing files
|
||||
for scope in scopes
|
||||
|
@ -490,7 +500,7 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
|
|||
|
||||
if !a:mustExist
|
||||
for p in split(paths, ',')
|
||||
let p .= '/' . scope . '.snippets'
|
||||
let p .= '/snippets/' . scope . '.snippets'
|
||||
let result[p] = get(result, p, {'exists': 0, 'type': 'snippets'})
|
||||
endfor
|
||||
endif
|
||||
|
@ -514,21 +524,27 @@ endf
|
|||
" default triggers based on paths
|
||||
fun! snipMate#DefaultPool(scopes, trigger, result)
|
||||
let triggerR = substitute(a:trigger,'*','.*','g')
|
||||
let extra_scopes = []
|
||||
for [f,opts] in items(snipMate#GetSnippetFiles(1, a:scopes, a:trigger))
|
||||
let opts.name_prefix = matchstr(f, '\v[^/]+\ze/snippets') . ' ' . opts.name_prefix
|
||||
if opts.type == 'snippets'
|
||||
for [trigger, name, contents, guard] in cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
|
||||
let [snippets, extension] = cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
|
||||
for [trigger, name, contents, guard] in snippets
|
||||
if trigger !~ escape(triggerR,'~') | continue | endif
|
||||
if snipMate#EvalGuard(guard)
|
||||
call snipMate#SetByPath(a:result, [trigger, opts.name_prefix.' '.name], contents)
|
||||
endif
|
||||
endfor
|
||||
call extend(extra_scopes, extension)
|
||||
elseif opts.type == 'snippet'
|
||||
call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], funcref#Function('return readfile('.string(f).')'))
|
||||
else
|
||||
throw "unexpected"
|
||||
endif
|
||||
endfor
|
||||
if !empty(extra_scopes)
|
||||
call snipMate#DefaultPool(extra_scopes, a:trigger, a:result)
|
||||
endif
|
||||
endf
|
||||
|
||||
" return a dict of snippets found in runtimepath matching trigger
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
|
||||
|
||||
snipMate *snippet* *snippets* *snipMate*
|
||||
Last Change: December 27, 2009
|
||||
|
||||
|snipMate-installation| Installation
|
||||
|snipMate-description| Description
|
||||
|
@ -306,6 +305,15 @@ TextMates's functionality, use the |system()| function. E.g.: >
|
|||
will insert the current date, assuming you are on a Unix system. Note that you
|
||||
can also (and should) use |strftime()| for this example.
|
||||
|
||||
*snipMate-extends*
|
||||
Borrowing from UltiSnips, .snippets files can also contain an extends
|
||||
directive, for example: >
|
||||
|
||||
extends html, javascript, css
|
||||
|
||||
will tell SnipMate to also read html, javascript, and css snippets.
|
||||
|
||||
|
||||
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
|
||||
|
||||
Since the current filename is used often in snippets, a default function
|
||||
|
@ -420,6 +428,15 @@ Perhaps some of these features will be added in a later release.
|
|||
==============================================================================
|
||||
CHANGELOG *snipMate-changelog*
|
||||
|
||||
0.86 - 2013-06-15
|
||||
-----------------
|
||||
* Use more idiomatic <Plug> maps
|
||||
|
||||
* Fix disappearing variables bug (hpesoj)
|
||||
* Fix cursor position bug when a variable is on the same line as the stop
|
||||
* Fix undo point creation causing problems with Supertab
|
||||
* Fix bug where SnipMate would use a typed trigger as a regular expression
|
||||
|
||||
0.85 - 2013-04-03
|
||||
-----------------
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
" File: snipMate.vim
|
||||
" Author: Michael Sanders
|
||||
" Version: 0.85
|
||||
" Version: 0.86
|
||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||
" Vim. A snippet is a piece of often-typed text that you can
|
||||
" insert into your document using a trigger word followed by a "<tab>".
|
||||
|
@ -56,30 +56,15 @@ let s:snipMate['get_snippets'] = get(s:snipMate, 'get_snippets', funcref#Functio
|
|||
" snippets. You can replace it with your own implementation. Defaults to all
|
||||
" directories in &rtp/snippets/*
|
||||
let s:snipMate['snippet_dirs'] = get(s:snipMate, 'snippet_dirs', funcref#Function('return split(&runtimepath,",")'))
|
||||
if type(s:snipMate['snippet_dirs']) == type([])
|
||||
call map(s:snipMate['snippet_dirs'], 'expand(v:val)')
|
||||
endif
|
||||
|
||||
" _ is default scope added always
|
||||
"
|
||||
" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO
|
||||
let s:snipMate['get_scopes'] = get(s:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]'))
|
||||
|
||||
if !exists('snippets_dir')
|
||||
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
|
||||
endif
|
||||
|
||||
" Processes a single-snippet file; optionally add the name of the parent
|
||||
" directory for a snippet with multiple matches.
|
||||
fun! s:ProcessFile(file, ft, ...)
|
||||
let keyword = fnamemodify(a:file, ':t:r')
|
||||
if keyword == '' | return | endif
|
||||
try
|
||||
let text = join(readfile(a:file), "\n")
|
||||
catch /E484/
|
||||
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||
endtry
|
||||