From c1cacf2e461aae0defd523a66c0770f2564f2fdb Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 5 Mar 2020 13:24:52 -0800 Subject: [PATCH] Enable auto redraw indentLines Trigger redraw after set shiftwidth or tabstop --- after/plugin/indentLine.vim | 24 +++++++++++++++++++++++- doc/indentLine.txt | 14 ++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/after/plugin/indentLine.vim b/after/plugin/indentLine.vim index 03188f0..3b919e7 100644 --- a/after/plugin/indentLine.vim +++ b/after/plugin/indentLine.vim @@ -254,7 +254,7 @@ endfunction "{{{1 function! s:ResetWidth(...) function! s:ResetWidth(...) if 0 < a:0 - let &l:shiftwidth = a:1 + noautocmd let &l:shiftwidth = a:1 endif let b:indentLine_enabled = 1 @@ -262,6 +262,26 @@ function! s:ResetWidth(...) call s:IndentLinesEnable() 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() function! s:Filter() if index(g:indentLine_fileTypeExclude, &filetype) != -1 @@ -400,6 +420,7 @@ augroup indentLine autocmd FileType * call s:Disable() if exists("##OptionSet") autocmd OptionSet diff call s:ToggleOnDiff() + autocmd OptionSet shiftwidth,tabstop noautocmd call s:AutoResetWidth() endif autocmd VimEnter * call s:VimEnter() else @@ -412,6 +433,7 @@ augroup indentLine autocmd FileChangedShellPost * doautocmd indentLine BufUnload | call s:Setup() if exists("##OptionSet") autocmd OptionSet diff call s:ToggleOnDiff() + autocmd OptionSet shiftwidth,tabstop noautocmd call s:AutoResetWidth() endif autocmd VimEnter * call s:VimEnter() endif diff --git a/doc/indentLine.txt b/doc/indentLine.txt index a56592f..ed58119 100644 --- a/doc/indentLine.txt +++ b/doc/indentLine.txt @@ -105,7 +105,7 @@ g:indentLine_fileTypeExclude *g:indentLine_fileTypeExclude* e.g. let g:indentLine_fileTypeExclude = ['text', 'sh'] Default value is [] which means no file types are excluded. -g:indentLine_bufTypeExclude *g:indentLine_bufTypeExclude* +g:indentLine_bufTypeExclude *g:indentLine_bufTypeExclude* This variable specify a list of buffer types. When opening these types of buffers, the plugin is disabled by default. @@ -136,14 +136,14 @@ g:indentLine_setConceal set this value to 0. Default value is 1. -g:indentLine_concealcursor *g:indentLine_concealcursor* +g:indentLine_concealcursor *g:indentLine_concealcursor* This variable toggles cursor lines behavior. If variable exists and is empty, that is, set to '', then the indentlines - will not show up in the cursorline. + will not show up in the cursorline. See *concealcursor*. Default value is 'inc'. -g:indentLine_conceallevel *g:indentLine_conceallevel* +g:indentLine_conceallevel *g:indentLine_conceallevel* This variable toggles the concealing behavior. See *conceallevel*. Default value is '2'. @@ -160,6 +160,12 @@ g:indentLine_leadingSpaceEnabled *g:indentLine_leadingSpaceEnable g:indentLine_defaultGroup *g:indentLine_defaultGroup* Specify a highlight group to use for default values 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*