mirror of
https://github.com/Yggdroot/indentLine.git
synced 2025-12-08 21:14:45 +08:00
fix issue #106
This commit is contained in:
@@ -75,10 +75,15 @@ function! s:SetConcealOption()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"{{{1 function! s:SetIndentLine()
|
"{{{1 function! s:IndentLinesEnable()
|
||||||
function! s:SetIndentLine()
|
function! s:IndentLinesEnable()
|
||||||
|
if exists("b:indentLine_enabled") && b:indentLine_enabled
|
||||||
|
return
|
||||||
|
else
|
||||||
|
let b:indentLine_enabled = 1
|
||||||
|
endif
|
||||||
call s:SetConcealOption()
|
call s:SetConcealOption()
|
||||||
let b:indentLine_enabled = 1
|
|
||||||
let space = &l:shiftwidth is 0 ? &l:tabstop : &l:shiftwidth
|
let space = &l:shiftwidth is 0 ? &l:tabstop : &l:shiftwidth
|
||||||
|
|
||||||
if g:indentLine_showFirstIndentLevel
|
if g:indentLine_showFirstIndentLevel
|
||||||
@@ -97,28 +102,12 @@ function! s:SetIndentLine()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"{{{1 function! s:ResetWidth(...)
|
|
||||||
function! s:ResetWidth(...)
|
|
||||||
if 0 < a:0
|
|
||||||
let &l:shiftwidth = a:1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists("b:indentLine_enabled") && b:indentLine_enabled
|
|
||||||
syntax clear IndentLine
|
|
||||||
endif
|
|
||||||
call s:SetIndentLine()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"{{{1 function! s:IndentLinesEnable()
|
|
||||||
function! s:IndentLinesEnable()
|
|
||||||
call s:SetIndentLine()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"{{{1 function! s:IndentLinesDisable()
|
"{{{1 function! s:IndentLinesDisable()
|
||||||
function! s:IndentLinesDisable()
|
function! s:IndentLinesDisable()
|
||||||
let b:indentLine_enabled = 0
|
let b:indentLine_enabled = 0
|
||||||
try
|
try
|
||||||
syntax clear IndentLine
|
syntax clear IndentLine
|
||||||
|
syntax clear IndentLineSpace
|
||||||
catch /^Vim\%((\a\+)\)\=:E28/ " catch error E28
|
catch /^Vim\%((\a\+)\)\=:E28/ " catch error E28
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
@@ -132,6 +121,16 @@ function! s:IndentLinesToggle()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"{{{1 function! s:ResetWidth(...)
|
||||||
|
function! s:ResetWidth(...)
|
||||||
|
if 0 < a:0
|
||||||
|
let &l:shiftwidth = a:1
|
||||||
|
endif
|
||||||
|
|
||||||
|
call s:IndentLinesDisable()
|
||||||
|
call s:IndentLinesEnable()
|
||||||
|
endfunction
|
||||||
|
|
||||||
"{{{1 function! s:Setup()
|
"{{{1 function! s:Setup()
|
||||||
function! s:Setup()
|
function! s:Setup()
|
||||||
if index(g:indentLine_fileTypeExclude, &filetype) isnot -1
|
if index(g:indentLine_fileTypeExclude, &filetype) isnot -1
|
||||||
@@ -160,31 +159,23 @@ function! s:Setup()
|
|||||||
call s:InitColor()
|
call s:InitColor()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ! exists("b:indentLine_enabled")
|
if g:indentLine_enabled
|
||||||
let b:indentLine_enabled = g:indentLine_enabled
|
call s:IndentLinesEnable()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ! exists("b:indentLine_leadingSpaceEnabled")
|
if g:indentLine_leadingSpaceEnabled
|
||||||
let b:indentLine_leadingSpaceEnabled = g:indentLine_leadingSpaceEnabled
|
|
||||||
endif
|
|
||||||
|
|
||||||
if b:indentLine_enabled
|
|
||||||
call s:SetIndentLine()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if b:indentLine_leadingSpaceEnabled
|
|
||||||
call s:LeadingSpaceEnable()
|
call s:LeadingSpaceEnable()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"{{{1 function! s:LeadingSpaceEnable()
|
"{{{1 function! s:LeadingSpaceEnable()
|
||||||
function! s:LeadingSpaceEnable()
|
function! s:LeadingSpaceEnable()
|
||||||
call s:SetConcealOption()
|
|
||||||
if g:indentLine_faster
|
if g:indentLine_faster
|
||||||
echoerr 'LeadingSpace can not be shown when g:indentLine_faster == 1'
|
echoerr 'LeadingSpace can not be shown when g:indentLine_faster == 1'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let b:indentLine_leadingSpaceEnabled = 1
|
let b:indentLine_leadingSpaceEnabled = 1
|
||||||
|
call s:SetConcealOption()
|
||||||
execute 'syntax match IndentLineLeadingSpace /\%(^\s*\)\@<= / containedin=ALLBUT,IndentLine conceal cchar=' . g:indentLine_leadingSpaceChar
|
execute 'syntax match IndentLineLeadingSpace /\%(^\s*\)\@<= / containedin=ALLBUT,IndentLine conceal cchar=' . g:indentLine_leadingSpaceChar
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user