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