Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

Commit 2911afb

Browse files
committed
Ensure syntax matches are loaded on buffer loads and scheme changes.
1 parent dd959f9 commit 2911afb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

plugin/workspace.vim

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,20 @@ function! s:SetUndoDir()
198198
endif
199199
endfunction
200200

201+
function! s:SetIndentGuideHighlights(user_initiated)
202+
if g:workspace_indentguides && index(g:workspace_indentguides_ignore, &filetype) == -1
203+
if !a:user_initiated
204+
silent! syntax clear IndentGuideSpaces
205+
silent! syntax clear IndentGuideDraw
206+
endif
207+
execute "highlight Conceal ctermfg=238 ctermbg=NONE guifg=Grey27 guibg=NONE"
208+
execute "highlight SpecialKey ctermfg=238 ctermbg=NONE guifg=Grey27 guibg=NONE"
209+
execute 'syntax match IndentGuideSpaces /^\ \+/ containedin=ALL contains=IndentGuideDraw keepend'
210+
execute printf('syntax match IndentGuideDraw /^\zs\ \ze\ \{%i}/ contained conceal cchar=┆', &l:shiftwidth - 1)
211+
execute printf('syntax match IndentGuideDraw /\ \{%i}\zs \ze/ contained conceal cchar=┆', &l:shiftwidth - 1)
212+
endif
213+
endfunction
214+
201215
function! s:ToggleIndentGuides(user_initiated)
202216
let b:toggle_indentguides = get(b:, 'toggle_indentguides', 1)
203217

@@ -208,10 +222,7 @@ function! s:ToggleIndentGuides(user_initiated)
208222
endif
209223

210224
if b:toggle_indentguides
211-
execute "highlight Conceal ctermfg=238 ctermbg=NONE guifg=Grey27 guibg=NONE"
212-
execute "highlight SpecialKey ctermfg=238 ctermbg=NONE guifg=Grey27 guibg=NONE"
213-
execute 'syntax match IndentGuideSpaces /^\ \+/ containedin=ALL contains=IndentGuideDraw keepend'
214-
execute printf('syntax match IndentGuideDraw /\(^\|\ \)\{%i}\zs / contained conceal cchar=┆', &l:shiftwidth - 1)
225+
call s:SetIndentGuideHighlights(a:user_initiated)
215226

216227
" TODO-TK: local and global listchars are the same, and s: variables are failing (??)
217228
let g:original_listchars = get(g:, 'original_listchars', &g:listchars)
@@ -239,6 +250,7 @@ function! s:PostLoadCleanup()
239250
endfunction
240251

241252
augroup Workspace
253+
au! BufRead,ColorScheme * call s:SetIndentGuideHighlights(0)
242254
au! BufWinEnter * call s:ToggleIndentGuides(0)
243255
au! VimEnter * nested call s:LoadWorkspace()
244256
au! VimLeave * call s:MakeWorkspace(0)

0 commit comments

Comments
 (0)