Enable auto redraw indentLines

Trigger redraw after set shiftwidth or tabstop
This commit is contained in:
Mike
2020-03-05 13:24:52 -08:00
parent dfc850b7e4
commit c1cacf2e46
2 changed files with 33 additions and 5 deletions

View File

@@ -254,7 +254,7 @@ endfunction
"{{{1 function! s:ResetWidth(...) "{{{1 function! s:ResetWidth(...)
function! s:ResetWidth(...) function! s:ResetWidth(...)
if 0 < a:0 if 0 < a:0
let &l:shiftwidth = a:1 noautocmd let &l:shiftwidth = a:1
endif endif
let b:indentLine_enabled = 1 let b:indentLine_enabled = 1
@@ -262,6 +262,26 @@ function! s:ResetWidth(...)
call s:IndentLinesEnable() call s:IndentLinesEnable()
endfunction endfunction
"{{{1 function! s:AutoResetWidth()
function! s:AutoResetWidth()
let l:enable = get(
\ b:,
\ 'indentLine_enabled',
\ get(g:, 'indentLine_enabled', 1)
\)
let g:indentLine_autoResetWidth = get(g:, 'indentLine_autoResetWidth', 1)
if l:enable != 1 || g:indentLine_autoResetWidth != 1
return
endif
let b:indentLine_enabled = l:enable
call s:IndentLinesDisable()
call s:IndentLinesEnable()
endfunction
"{{{1 function! s:Filter() "{{{1 function! s:Filter()
function! s:Filter() function! s:Filter()
if index(g:indentLine_fileTypeExclude, &filetype) != -1 if index(g:indentLine_fileTypeExclude, &filetype) != -1
@@ -400,6 +420,7 @@ augroup indentLine
autocmd FileType * call s:Disable() autocmd FileType * call s:Disable()
if exists("##OptionSet") if exists("##OptionSet")
autocmd OptionSet diff call s:ToggleOnDiff() autocmd OptionSet diff call s:ToggleOnDiff()
autocmd OptionSet shiftwidth,tabstop noautocmd call s:AutoResetWidth()
endif endif
autocmd VimEnter * call s:VimEnter() autocmd VimEnter * call s:VimEnter()
else else
@@ -412,6 +433,7 @@ augroup indentLine
autocmd FileChangedShellPost * doautocmd indentLine BufUnload | call s:Setup() autocmd FileChangedShellPost * doautocmd indentLine BufUnload | call s:Setup()
if exists("##OptionSet") if exists("##OptionSet")
autocmd OptionSet diff call s:ToggleOnDiff() autocmd OptionSet diff call s:ToggleOnDiff()
autocmd OptionSet shiftwidth,tabstop noautocmd call s:AutoResetWidth()
endif endif
autocmd VimEnter * call s:VimEnter() autocmd VimEnter * call s:VimEnter()
endif endif

View File

@@ -160,6 +160,12 @@ g:indentLine_leadingSpaceEnabled *g:indentLine_leadingSpaceEnable
g:indentLine_defaultGroup *g:indentLine_defaultGroup* g:indentLine_defaultGroup *g:indentLine_defaultGroup*
Specify a highlight group to use for default values Specify a highlight group to use for default values
of g:indentLine_[bg]color_(term|gui) of g:indentLine_[bg]color_(term|gui)
g:indentLine_autoResetWidth *g:indentLine_autoResetWidth*
Specify whether to auto redraw the indentLines after
'shiftwidth' or 'tabstop' change.
Default value is 1.
============================================================================== ==============================================================================
COMMANDS *indentLine-commands* COMMANDS *indentLine-commands*