Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapped lines don't dim after 256 chars #2

Open
jtmkrueger opened this issue Feb 10, 2014 · 11 comments
Open

Wrapped lines don't dim after 256 chars #2

jtmkrueger opened this issue Feb 10, 2014 · 11 comments

Comments

@jtmkrueger
Copy link

Not a blocker, but it would be really nice if wrapped lines also dimmed.

@blueyed
Copy link
Owner

blueyed commented Feb 10, 2014

They should get dimmed - but only up to 256 chars by default.
Is that what you're seeing?
Try increasing g:diminactive_max_cols. You can use :DimInactiveRefresh to refresh/apply it.

Otherwise please provide a screenshot.

@jtmkrueger
Copy link
Author

I have let g:diminactive_max_cols = 1000 in my .vimrc, and performed a :DimInactiveRefresh in vim, and tried reloading vim as well. here's what I'm getting.

image

So somethings still not right.

@jtmkrueger
Copy link
Author

I'm wondering if this hack isn't doing what it's supposed to.

@blueyed
Copy link
Owner

blueyed commented Feb 10, 2014

From :h 'cc':

A maximum of 256 columns are highlighted.

That's why I had the 256 there initially.

blueyed added a commit that referenced this issue Feb 17, 2014
@SarahIluvatariel
Copy link

blueyed: You would be more than welcome to try to incorporate the following script I've written which will help combat (but not entirely fix) this issue:

if exists('+colorcolumn')
    function! InactivateWindow(inactivate)
        if a:inactivate == 1
            " using 0 as the third parameter lets me still see Search'd patterns in inactive windows.
            let w:inactiveWindowMatchId = matchadd("inactiveWindow", "\\%>0v", 0, 9999)
        else
            if exists("w:inactiveWindowMatchId")
                call matchdelete(w:inactiveWindowMatchId)
            endif
        endif
    endfunction
    augroup DimInactiveWindows
        au!
        " For some as-yet-unknown reason, my usage of the diminactive plugin by blueyed makes it
        " impossible for me to see search-highlighted text in inactive windows.  (Maybe my
        " colorscheme setup is at fault...)  This keeps my Search pattern visible (but only
        " changes the background of areas WITH text...).  As an added advantage, it highlights
        " text beyond the 256 char mark.
        au WinLeave * call InactivateWindow(1)
        au WinEnter * call InactivateWindow(0)
    augroup END
endif

My inactive window is on the left. Notice that I have highlighed the string "123". After the 256th character, you can see that the dark background continues for the left-hand window. (That's also, incidentally, where I can resume seeing highlighted text from my search pattern... I haven't investigated why, yet, so it may not necessarily be a bug - it's probably just a problem with my colorscheme...?)

image

@blueyed
Copy link
Owner

blueyed commented Apr 23, 2015

Yes, it's likely a issue with your colorscheme.
What are you using for inactiveWindow's highlighting?
Do you see the same issue when using :hi link inactiveWindow ColorColumn (in your approach)?

The idea is interesting, but it's unfortunate that it won't highlight shorter lines completely.

@SarahIluvatariel
Copy link

I'm not sure what you mean by "it won't highlight shorter lines completely"...

As for my inactiveWindow's highlighting, it was set to the same thing as ColorColumn. Linking them didn't fix my Searching issue, but I figured it out anyways: I changed this: hi Search gui=bold guibg=#ffff88 to this: hi Search gui=bold,reverse guifg=#ffff88 guibg=Black in my colorscheme file.

For whatever reason, it appears that the ColorColumn seems to "take over" the guibg color of Search. Since I'm not sure how to give the Search highlight a higher priority than ColorColumn, I guess I can trick it into keeping a background color for the Searched text by setting the guifg and reversing it. But it looses the foreground color, now. Oh well. That's much less important to me.

Now, when I add your plugin and my script together, ALL of the text in the line is now given the ColorColumn highlight (background highlighting doesn't stop after the 256th character) and I can still see Search'd text in both windows. (Unfortunately, as I mentioned before, it still stops highlighting after the final character of the line. But at least, it's a step in the direction of @jtmkrueger's request.)

Here's a "before" screenshot (with only the vim-diminactive plugin) (I'm using ColorColumn for both your plugin and my script, now and I reset ColorColumn to the default color (by commenting out all references to it in my colorscheme file) so I can see the effect better in the screenshots.):
image

And here's an "after" screenshot (with both the vim-diminactive plugin and my script):
image

For the sake of clarity, here's the final working version of my script, in case if you wish to incorporate it into your plugin somehow:

if exists('+colorcolumn')
    function! InactivateWindow(inactivate)
        if a:inactivate == 1
            " using 0 as the third parameter lets me still see Search'd patterns in inactive windows.
            let w:inactiveWindowMatchId = matchadd("ColorColumn", "\\%>0v", 0, 9999)
        else
            if exists("w:inactiveWindowMatchId")
                call matchdelete(w:inactiveWindowMatchId)
            endif
        endif
    endfunction
    augroup DimInactiveWindows
        au!
        "This highlights text beyond the 256 char mark, but it only changes the background of areas WITH text...
        au WinLeave * call InactivateWindow(1)
        au WinEnter * call InactivateWindow(0)
    augroup END
endif

@blueyed
Copy link
Owner

blueyed commented Apr 23, 2015

I'm not sure what you mean by "it won't highlight shorter lines completely"...

It only highlights the visible characters, not up to the end of the line in Vim.

Now, when I add your plugin and my script together, ALL of the text in the line is now given the ColorColumn highlight

Ah, you mean to use this additionally - makes sense.

Thanks for your suggestion, and the detailed explanation with screenshots!

Do you feel like creating a PR for this?
Otherwise I'll look into this later myself.

@SarahIluvatariel
Copy link

I'm pretty new to github, so although I'd love to attempt a PR, I'm not sure I have the time to figure out how that all works, right now.

Plus, your plugin has come a long way from the simple version I found on stackoverflow! :) That's great, but that also means that it has more complexity than I have time to learn at the moment. I think I'll need to leave this one up to you or someone else.

Thanks for the great plugin, though! :)

@gmhawash
Copy link

@blueyed has this been incorporated in the latest release? I am still seeing an issue with my search highlight where the inactive window search disappears.

@blueyed
Copy link
Owner

blueyed commented Sep 25, 2016

@gmhawash
No, not any updates recently.
PRs are welcome, but I'd rather spent the time on adding this to Neovim/Vim proper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants