Yggdroot / indentLine

A vim plugin to display the indention levels with thin vertical lines
MIT License
4.14k stars 227 forks source link

Add feature to conceal characters #327

Open chinwobble opened 3 years ago

chinwobble commented 3 years ago

Great plugin!

I would like to add the option for this plugin to collapse indents.

Some code bases I work on use 4 spaces per indent. However I have limited screen space (90 character width). This means if there is 4 levels of indent, over a quarter of the screen is already consumed.

I think this can be achieved with the following code.

for i in range(space, space * g:indentLine_indentLevel + 1, space)
            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',
                        \'^'
                        \.repeat(' ',i)
                        \.'\zs'
                        \.repeat(' ',space),
                        \0, -1, {'conceal': char}))
        endfor

The output looks like this. image

Would you accept a PR to accept an option like this?