vim-pencil icon indicating copy to clipboard operation
vim-pencil copied to clipboard

Vim pencil hides/removes colorcolumn

Open Stratus3D opened this issue 7 years ago • 4 comments

In my vimrc I have:

set colorcolumn=80,120

Without vim-pencil turned on I see columns 80 and 120 highlighted as I would expect: Screenshot from 2019-03-29 21-49-17

But, after running :call pencil#init() the highlighting on the columns disappears: Screenshot from 2019-03-29 21-50-18

I can manually run :set colorcolumn=80,120 to restore the columns, but I'd rather not have to do that every time. In my vimrc I have:

autocmd FileType text,mkd.markdown,markdown,mkd call pencil#init()

But if I try setting colorcolum after pencil#init() it doesn't work:

autocmd FileType text,mkd.markdown,markdown,mkd call set colorcolumn=80,120

Any idea what I should do to ensure colorcolumns are always shown without manual intervention? Ideally it would be nice if vim-pencil did not affect them at all. Happy to contribute if there is something in vim-pencil that needs to be changed to accommodate this.

Stratus3D avatar Mar 30 '19 01:03 Stratus3D

This appears to be hard coded here:

https://github.com/reedes/vim-pencil/blob/236380f1afcc1df10ae78cbf2c6e958d29183eaa/autoload/pencil.vim#L266-L268

The logic seems to be that because there are extra characters added an the start of wrapped lines the color column does not actually correspond to that column in the actual text.

We could easily add some sort of preference toggle to not disable this, but before we do that maybe you can give some input on when this would be useful. Perhaps only disabling it in soft wrap mode and letting it alone in hard wrap mode would make sense. Thoughts?

alerque avatar Nov 16 '19 10:11 alerque

@alerque if it doesn't align as expected, would it be feasible to figure out the correct offset, and then adjust colorcolumn as necessary?

Stratus3D avatar Nov 27 '19 03:11 Stratus3D

As far as I know, no. The colorcolumn is set at the buffer/pane level and the problem is some individual lines don't align with their peers. I've never seen a "ragged" color column. I suppose it might be possible if you want to look into it, but my guess is it's going to be all or nothing.

alerque avatar Nov 27 '19 06:11 alerque

I ended up solving by using the Goyo callbacks to toggle vim-pencil - https://github.com/Stratus3D/dotfiles/commit/7b5657366a27e736a65a1001cf99b3af7a526a1e

Stratus3D avatar Aug 19 '20 02:08 Stratus3D