add choice for user to select better performance

This commit is contained in:
Yggdroot
2013-10-19 17:34:56 +08:00
parent 419b9a7012
commit 8f971fcb0c
2 changed files with 25 additions and 7 deletions

View File

@@ -56,6 +56,10 @@ if !exists("g:indentLine_maxLines")
let g:indentLine_maxLines = 3000 let g:indentLine_maxLines = 3000
endif endif
if !exists("g:indentLine_faster")
let g:indentLine_faster = 0
endif
if !exists("g:indentLine_noConcealCursor") if !exists("g:indentLine_noConcealCursor")
set concealcursor=inc set concealcursor=inc
endif endif
@@ -93,14 +97,21 @@ function! <SID>SetIndentLine()
let b:indentLine_enabled = 1 let b:indentLine_enabled = 1
let space = &l:shiftwidth == 0 ? &l:tabstop : &l:shiftwidth let space = &l:shiftwidth == 0 ? &l:tabstop : &l:shiftwidth
if g:indentLine_showFirstIndentLevel if g:indentLine_faster
exec 'syn match IndentLine /^ / containedin=ALL conceal cchar=' . g:indentLine_first_char exec 'syn match IndentLineSpace /^\s\+/ contains=IndentLine'
endif exec 'syn match IndentLine /^ / containedin=ALL contained conceal cchar=' . g:indentLine_char
exec 'syn match IndentLine / \{'.(space-1).'}\zs / containedin=ALL contained conceal cchar=' . g:indentLine_char
exec 'syn match IndentLine /\t\zs / containedin=ALL contained conceal cchar=' . g:indentLine_char
else
if g:indentLine_showFirstIndentLevel
exec 'syn match IndentLine /^ / containedin=ALL conceal cchar=' . g:indentLine_first_char
endif
let pattern = line('$') < g:indentLine_maxLines ? 'v' : 'c' let pattern = line('$') < g:indentLine_maxLines ? 'v' : 'c'
for i in range(space+1, space * g:indentLine_indentLevel + 1, space) for i in range(space+1, space * g:indentLine_indentLevel + 1, space)
exec 'syn match IndentLine /\%(^\s\+\)\@<=\%'.i.pattern.' / containedin=ALL conceal cchar=' . g:indentLine_char exec 'syn match IndentLine /\%(^\s\+\)\@<=\%'.i.pattern.' / containedin=ALL conceal cchar=' . g:indentLine_char
endfor endfor
endif
endfunction endfunction
"{{{1 function! <SID>ResetWidth(...) "{{{1 function! <SID>ResetWidth(...)
@@ -111,6 +122,7 @@ function! <SID>ResetWidth(...)
if exists("b:indentLine_enabled") if exists("b:indentLine_enabled")
syn clear IndentLine syn clear IndentLine
syn clear IndentLineSpace
endif endif
call <SID>SetIndentLine() call <SID>SetIndentLine()
endfunction endfunction
@@ -167,6 +179,7 @@ autocmd BufWinEnter * call <SID>Setup()
autocmd BufRead,BufNewFile,ColorScheme * call <SID>InitColor() autocmd BufRead,BufNewFile,ColorScheme * call <SID>InitColor()
autocmd Syntax * if exists("b:indentLine_set") | call <SID>InitColor() | call <SID>SetIndentLine() | endif autocmd Syntax * if exists("b:indentLine_set") | call <SID>InitColor() | call <SID>SetIndentLine() | endif
command! -nargs=? IndentLinesReset call <SID>ResetWidth(<f-args>) command! -nargs=? IndentLinesReset call <SID>ResetWidth(<f-args>)
command! IndentLinesToggle call <SID>IndentLinesToggle() command! IndentLinesToggle call <SID>IndentLinesToggle()

View File

@@ -90,6 +90,11 @@ g:indentLine_maxLines *g:indentLine_maxLines*
the performance better. the performance better.
Default value is 3000. Default value is 3000.
g:indentLine_faster *g:indentLine_faster*
If you want the performance better, you can set the value as
1, default value is 0. But better performance may bring little
issue with it.
g:indentLine_noConcealCursor *g:indentLine_noConcealCursor* g:indentLine_noConcealCursor *g:indentLine_noConcealCursor*
This variable toggles cursor lines behavior. If variable This variable toggles cursor lines behavior. If variable
exists, then cursorline will be above conceal chars. exists, then cursorline will be above conceal chars.