mirror of
https://github.com/preservim/tagbar.git
synced 2024-11-22 20:54:03 +08:00
Display nice unicode fold icons if possible
This commit is contained in:
parent
0c39715fa7
commit
d256c9976b
|
@ -74,6 +74,14 @@ if !exists('g:tagbar_foldlevel')
|
|||
let g:tagbar_foldlevel = 99
|
||||
endif
|
||||
|
||||
if has('multi_byte') && &encoding == 'utf-8'
|
||||
let s:icon_closed = '▶'
|
||||
let s:icon_open = '▼'
|
||||
else
|
||||
let s:icon_closed = '+'
|
||||
let s:icon_open = '-'
|
||||
endif
|
||||
|
||||
let s:type_init_done = 0
|
||||
let s:autocommands_done = 0
|
||||
let s:window_expanded = 0
|
||||
|
@ -1619,9 +1627,9 @@ function! s:PrintKinds(typeinfo, fileinfo)
|
|||
else
|
||||
" Non-scoped tags
|
||||
if a:fileinfo.kindfolds[kind.short]
|
||||
let foldmarker = '+'
|
||||
let foldmarker = s:icon_closed
|
||||
else
|
||||
let foldmarker = '-'
|
||||
let foldmarker = s:icon_open
|
||||
endif
|
||||
|
||||
if g:tagbar_compact && first_kind && s:short_help
|
||||
|
@ -1703,9 +1711,9 @@ endfunction
|
|||
function! s:GetPrefix(tag, fileinfo)
|
||||
if has_key(a:tag, 'children') && !empty(a:tag.children)
|
||||
if a:fileinfo.tagfolds[a:tag.fields.kind][a:tag.fullpath]
|
||||
let prefix = '+'
|
||||
let prefix = s:icon_closed
|
||||
else
|
||||
let prefix = '-'
|
||||
let prefix = s:icon_open
|
||||
endif
|
||||
else
|
||||
let prefix = ' '
|
||||
|
@ -1839,7 +1847,8 @@ function! s:HighlightTag()
|
|||
" Make sure the tag is visible in the window
|
||||
call winline()
|
||||
|
||||
let pattern = '/^\%' . tagline . 'l\s*[-+ ][-+# ]\zs[^( ]\+\ze/'
|
||||
let foldpat = '[' . s:icon_open . s:icon_closed . ' ]'
|
||||
let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\zs[^( ]\+\ze/'
|
||||
execute 'match Search ' . pattern
|
||||
|
||||
execute prevwinnr . 'wincmd w'
|
||||
|
@ -2217,12 +2226,12 @@ endfunction
|
|||
|
||||
" s:CheckMouseClick() {{{2
|
||||
function! s:CheckMouseClick()
|
||||
let curchar = strpart(getline('.'), col('.') - 1, 1)
|
||||
let nextchar = strpart(getline('.'), col('.'), 1)
|
||||
let line = getline('.')
|
||||
let curcol = col('.')
|
||||
|
||||
if curchar =~# '-' && nextchar =~# '[-+ ]'
|
||||
if (match(line, s:icon_open . '[-+ ]') + 1) == curcol
|
||||
call s:CloseFold()
|
||||
elseif curchar =~# '+' && nextchar =~# '[-+ ]'
|
||||
elseif (match(line, s:icon_closed . '[-+ ]') + 1) == curcol
|
||||
call s:OpenFold()
|
||||
endif
|
||||
endfunction
|
||||
|
|
|
@ -9,20 +9,31 @@ if exists("b:current_syntax")
|
|||
finish
|
||||
endif
|
||||
|
||||
syntax match TagbarComment '^".*'
|
||||
if has('multi_byte') && &encoding == 'utf-8'
|
||||
syntax match TagbarKind '\([▶▼][-+ ]\)\@<=[^-+: ]\+[^:]\+$'
|
||||
syntax match TagbarScope '[^-+#▶▼(* ]\+\(\*\? :\)\@='
|
||||
|
||||
syntax match TagbarKind '\([-+][-+ ]\)\@<=[^-+: ]\+[^:]\+$'
|
||||
syntax match TagbarScope '[^-+#(* ]\+\(\*\? :\)\@='
|
||||
syntax match TagbarFoldIcon '[▶▼]\([-+# ]\)\@='
|
||||
|
||||
syntax match TagbarAccessPublic '\([▶▼ ]\)\@<=+\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessProtected '\([▶▼ ]\)\@<=#\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessPrivate '\([▶▼ ]\)\@<=-\([^-+# ]\)\@='
|
||||
else
|
||||
syntax match TagbarKind '\([-+][-+ ]\)\@<=[^-+: ]\+[^:]\+$'
|
||||
syntax match TagbarScope '[^-+#(* ]\+\(\*\? :\)\@='
|
||||
|
||||
syntax match TagbarFoldIcon '[-+]\([-+# ]\)\@='
|
||||
|
||||
syntax match TagbarAccessPublic '\([-+ ]\)\@<=+\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessProtected '\([-+ ]\)\@<=#\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessPrivate '\([-+ ]\)\@<=-\([^-+# ]\)\@='
|
||||
endif
|
||||
|
||||
syntax match TagbarComment '^".*'
|
||||
syntax match TagbarScopeType ' : \zs.*'
|
||||
syntax match TagbarSignature '(.*)'
|
||||
syntax match TagbarPseudoID '\*\ze :'
|
||||
|
||||
syntax match TagbarFoldIcon '[-+]\([-+# ]\)\@='
|
||||
|
||||
syntax match TagbarAccessPublic '\([-+ ]\)\@<=+\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessProtected '\([-+ ]\)\@<=#\([^-+# ]\)\@='
|
||||
syntax match TagbarAccessPrivate '\([-+ ]\)\@<=-\([^-+# ]\)\@='
|
||||
|
||||
highlight default link TagbarComment Comment
|
||||
highlight default link TagbarKind Identifier
|
||||
highlight default link TagbarScope Title
|
||||
|
|
Loading…
Reference in New Issue
Block a user