Reorganize syntax stuff
This commit is contained in:
parent
c62259c201
commit
a14bbe0737
@ -712,9 +712,7 @@ endf
|
||||
fu! s:ToggleType(dir)
|
||||
let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0
|
||||
unl! g:ctrlp_nolimit
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal ctrlp#syntax()
|
||||
en
|
||||
cal ctrlp#setlines(s:walker(2 + ext, s:itemtype, a:dir))
|
||||
cal s:PrtSwitcher()
|
||||
endf
|
||||
@ -1213,9 +1211,8 @@ fu! ctrlp#setlcdir()
|
||||
endf
|
||||
" Highlighting {{{2
|
||||
fu! ctrlp#syntax()
|
||||
for [ke, va] in items(s:hlgrps) | if !hlexists('CtrlP'.ke)
|
||||
exe 'hi link CtrlP'.ke va
|
||||
en | endfo
|
||||
if ctrlp#nosy() | retu | en
|
||||
for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo
|
||||
if !hlexists('CtrlPLinePre')
|
||||
\ && synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$'
|
||||
sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg'
|
||||
@ -1510,6 +1507,11 @@ fu! s:openfile(cmd, fid, tail, ...)
|
||||
cal ctrlp#setlcdir()
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:settype(type)
|
||||
retu a:type < 0 ? exists('s:itemtype') ? s:itemtype
|
||||
\ : exists('g:CTRLP_LAST_MODE') ? g:CTRLP_LAST_MODE : 0 : a:type
|
||||
endf
|
||||
" Matching {{{2
|
||||
fu! s:matchfname(item, pat)
|
||||
retu match(split(a:item, s:lash)[-1], a:pat)
|
||||
@ -1603,6 +1605,16 @@ endf
|
||||
fu! ctrlp#switchtype(id)
|
||||
cal s:ToggleType(a:id - s:itemtype)
|
||||
endf
|
||||
|
||||
fu! ctrlp#nosy()
|
||||
retu !( has('syntax') && exists('g:syntax_on') )
|
||||
endf
|
||||
|
||||
fu! ctrlp#hicheck(grp, defgrp)
|
||||
if !hlexists(a:grp)
|
||||
exe 'hi link' a:grp a:defgrp
|
||||
en
|
||||
endf
|
||||
"}}}1
|
||||
" * Initialization {{{1
|
||||
fu! ctrlp#setlines(...)
|
||||
@ -1622,12 +1634,8 @@ fu! ctrlp#init(type, ...)
|
||||
cal s:SetWD(a:0 ? a:1 : '')
|
||||
cal s:SetDefTxt()
|
||||
cal s:MapKeys()
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal ctrlp#syntax()
|
||||
en
|
||||
let type = a:type < 0 ? exists('s:itemtype') ? s:itemtype
|
||||
\ : exists('g:CTRLP_LAST_MODE') ? g:CTRLP_LAST_MODE : 0 : a:type
|
||||
cal ctrlp#setlines(type)
|
||||
cal ctrlp#setlines(s:settype(a:type))
|
||||
cal s:BuildPrompt(1)
|
||||
endf
|
||||
" - Autocmds {{{1
|
||||
|
@ -199,15 +199,10 @@ fu! s:parseline(line)
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !hlexists('CtrlPTagKind')
|
||||
hi link CtrlPTagKind Title
|
||||
en
|
||||
if !hlexists('CtrlPBufName')
|
||||
hi link CtrlPBufName Directory
|
||||
en
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
if ctrlp#nosy() | retu | en
|
||||
cal ctrlp#hicheck('CtrlPTagKind', 'Title')
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
|
||||
sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind
|
||||
@ -223,9 +218,7 @@ fu! ctrlp#buffertag#init(fname)
|
||||
let tftype = get(split(getbufvar(bname, '&ft'), '\.'), 0, '')
|
||||
cal extend(lines, s:process(bname, tftype))
|
||||
endfo
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal s:syntax()
|
||||
en
|
||||
retu lines
|
||||
endf
|
||||
|
||||
|
@ -46,12 +46,9 @@ fu! s:process(clines, ...)
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !hlexists('CtrlPBufName')
|
||||
hi link CtrlPBufName Directory
|
||||
en
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
if ctrlp#nosy() | retu | en
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
|
||||
endf
|
||||
@ -72,10 +69,8 @@ fu! ctrlp#changes#init(original_bufnr, fname)
|
||||
sil! exe 'noa hid b' a:original_bufnr
|
||||
let &swb = swb
|
||||
let g:ctrlp_nolimit = 1
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal ctrlp#syntax()
|
||||
cal s:syntax()
|
||||
en
|
||||
retu lines
|
||||
endf
|
||||
|
||||
|
@ -35,9 +35,9 @@ fu! s:globdirs(dirs, depth)
|
||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
|
||||
cal extend(g:ctrlp_alldirs, dirs)
|
||||
if !empty(dirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles)
|
||||
\ && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(len(g:ctrlp_alldirs))
|
||||
let nr = len(g:ctrlp_alldirs)
|
||||
if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(nr)
|
||||
cal s:globdirs(join(dirs, ','), depth)
|
||||
en
|
||||
endf
|
||||
|
@ -24,12 +24,9 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:syntax()
|
||||
if !hlexists('CtrlPBufName')
|
||||
hi link CtrlPBufName Directory
|
||||
en
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
if ctrlp#nosy() | retu | en
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
|
||||
endf
|
||||
@ -48,9 +45,7 @@ fu! ctrlp#line#init()
|
||||
cal filter(from_file, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')
|
||||
cal extend(lines, from_file)
|
||||
endfo
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal s:syntax()
|
||||
en
|
||||
retu lines
|
||||
endf
|
||||
|
||||
|
@ -28,15 +28,17 @@ fu! s:lineout(dict)
|
||||
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
|
||||
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
|
||||
endf
|
||||
" Utilities {{{1
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
|
||||
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#quickfix#init()
|
||||
let g:ctrlp_nolimit = 1
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
if !hlexists('CtrlPqfLineCol')
|
||||
hi link CtrlPqfLineCol Search
|
||||
en
|
||||
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
||||
en
|
||||
cal s:syntax()
|
||||
retu map(getqflist(), 's:lineout(v:val)')
|
||||
endf
|
||||
|
||||
|
@ -57,6 +57,13 @@ fu! s:filter(tags)
|
||||
endw
|
||||
retu alltags
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#tag#init()
|
||||
if empty(s:tagfiles) | retu [] | en
|
||||
@ -66,12 +73,7 @@ fu! ctrlp#tag#init()
|
||||
let alltags = s:filter(ctrlp#utils#readfile(each))
|
||||
cal extend(g:ctrlp_alltags, alltags)
|
||||
endfo
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
en
|
||||
cal s:syntax()
|
||||
retu g:ctrlp_alltags
|
||||
endf
|
||||
|
||||
|
@ -82,11 +82,10 @@ fu! s:elapsed(nr)
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if ctrlp#nosy() | retu | en
|
||||
for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
|
||||
\ 'Sv': 'Comment', 'Po': 'Title'})
|
||||
if !hlexists('CtrlPUndo'.ke)
|
||||
exe 'hi link CtrlPUndo'.ke va
|
||||
en
|
||||
cal ctrlp#hicheck('CtrlPUndo'.ke, va)
|
||||
endfo
|
||||
sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
|
||||
sy match CtrlPUndoBr '\[\|\]'
|
||||
@ -121,9 +120,6 @@ endf
|
||||
fu! ctrlp#undo#init()
|
||||
let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
|
||||
if empty(entries) | retu [] | en
|
||||
if has('syntax') && exists('g:syntax_on')
|
||||
cal s:syntax()
|
||||
en
|
||||
let g:ctrlp_nolimit = 1
|
||||
if !exists('s:lines')
|
||||
if s:undos[0]
|
||||
@ -133,6 +129,7 @@ fu! ctrlp#undo#init()
|
||||
let s:lines = map(reverse(entries), 's:formatul(v:val)')
|
||||
en
|
||||
en
|
||||
cal s:syntax()
|
||||
retu s:lines
|
||||
endf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user