From 47648734706fb2cd0e4d4350f12157d1e5f4c465 Mon Sep 17 00:00:00 2001 From: Yggdroot Date: Fri, 22 Feb 2019 14:50:21 +0800 Subject: [PATCH] fix issue #266 --- README.md | 6 ++++++ after/plugin/indentLine.vim | 11 ++++++++++- doc/indentLine.txt | 14 +++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 764f9e6..de1b5de 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ let g:indentLine_char = 'c' ``` where `'c'` can be any ASCII character. You can also use one of `¦`, `┆`, `│`, `⎸`, or `▏` to display more beautiful lines. However, these characters will only work with files whose encoding is UTF-8. +or +```vim +let g:indentLine_char_list = ['|', '¦', '┆', '┊'] +``` +each indent level has a distinct character. + **Change Conceal Behaviour** This plugin enables the Vim `conceal` feature which automatically hides stretches of text based on syntax highlighting. This setting will apply to all syntax items. diff --git a/after/plugin/indentLine.vim b/after/plugin/indentLine.vim index 7daff2d..fa9e7cc 100644 --- a/after/plugin/indentLine.vim +++ b/after/plugin/indentLine.vim @@ -13,6 +13,7 @@ let g:indentLine_loaded = 1 let g:indentLine_newVersion = get(g:,'indentLine_newVersion',v:version > 704 || v:version == 704 && has("patch792")) let g:indentLine_char = get(g:, 'indentLine_char', (&encoding ==# "utf-8" && &term isnot# "linux" ? '¦' : '|')) +let g:indentLine_char_list = get(g:, 'indentLine_char_list', []) let g:indentLine_first_char = get(g:, 'indentLine_first_char', (&encoding ==# "utf-8" && &term isnot# "linux" ? '¦' : '|')) let g:indentLine_indentLevel = get(g:, 'indentLine_indentLevel', 20) let g:indentLine_enabled = get(g:, 'indentLine_enabled', 1) @@ -139,8 +140,16 @@ function! s:IndentLinesEnable() endif let space = &l:shiftwidth == 0 ? &l:tabstop : &l:shiftwidth + let n = len(g:indentLine_char_list) + let level = 0 for i in range(space+1, space * g:indentLine_indentLevel + 1, space) - call add(w:indentLine_indentLineId, matchadd('Conceal', '^\s\+\zs\%'.i.'v ', 0, -1, {'conceal': g:indentLine_char})) + if n > 0 + let char = g:indentLine_char_list[level % n] + let level += 1 + else + let char = g:indentLine_char + endif + call add(w:indentLine_indentLineId, matchadd('Conceal', '^\s\+\zs\%'.i.'v ', 0, -1, {'conceal': char})) endfor return diff --git a/doc/indentLine.txt b/doc/indentLine.txt index e943da8..a56592f 100644 --- a/doc/indentLine.txt +++ b/doc/indentLine.txt @@ -20,16 +20,20 @@ CONFIG *indentLine-config* ============================================================================== VARIABLES *indentLine-variables* -g:indentLine_loaded *g:loaded_indentLine* - Whether load indentLine plugin. - Default value is 0. - g:indentLine_char *g:indentLine_char* - Specify a character to be used as indent line. + Specify a character to be used as indent line if + |g:indentLine_char_list| is not []. You also can use other characters: | ¦ ┆ │ Default value is "|". +g:indentLine_char_list *g:indentLine_char_list* + Specify a list of characters to be used as indent line for + each indent level. If the value is an empty list [], use + |g:indentLine_char| instead. + e.g., let g:indentLine_char_list = ['|', '¦', '┆', '┊'] + Default value is []. + g:indentLine_setColors *g:indentLine_setColors* By default, indentLine will overwrite 'conceal' color. If you want to highlight conceal with your