junegunn / limelight.vim

:flashlight: All the world's indeed a stage and we are merely players
MIT License
2.36k stars 54 forks source link

Being able to use own colorscheme, but little darkened? #9

Closed ReneFroger closed 9 years ago

ReneFroger commented 9 years ago

Thanks for sharing this plugin. It really adds something to Vim.

But I found it hard to read other syntax color when it's not lightened up, and navigate it every time to see the syntax highlighting.

Would it not be a great idea, to use the according colorscheme, but a little darkened (like 80% of opacitiy, while focus have 100% opacitiy), instead convert the non-focus text to one color?

junegunn commented 9 years ago

That would be extremely cool, but I don't think it's practically possible. We have to override every one of the existing syntax elements to achieve that.

ReneFroger commented 9 years ago

It would be an awesome blast indeed. No need anymore to use the distracting cursorline and cursorcolumn. I often looking around where my cursor is, or moving around to detect it. I really don't like the cursorline/cursorcolumn to solve it. I guess everyone would use that then if the syntax color could be retained in a some way.

But unfortunately, I'm still trying to learn Vimscript, in order to help on a day once. I can't be any help here. But I noticed there are some scripts that modifies the colors, like this.

There are 16,777,216 colors in HEX type for Gvim colorschemes. For cterm color you have only 256 colors. In order to convert it, the CSSApprox looks for the nearest correspodenting color within the 256 colors. So it works in the both directions. it could be the lighter of darker color.

Maybe it could be useful to tweak the CSSApprox to only match in only one direction (a.k.a. the darker colors). When Limelight is used, CSSApprox will use the colors for the unlighted regions. So the colors of the non-focused regions are little darkened, but still highlighted to be usable.

In terms of scripting this would be too hard to realize that, I guess. Maybe something for Neovim?

junegunn commented 9 years ago

Thanks for sharing your ideas. But the number of available colors is not really the crux of the problem. The real problem is the way syntax elements and regions are defined in Vim. Take a look at the following example here:

<title>

  foo

  bar

  barfoo

</title>

In share/vim/vim74/syntax/html.vim, Vim defines a syntax region named htmlTitle that starts at <title> and ends at </title>

syn region htmlTitle start="<title\>" end="</title>"me=e-8 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreproc

and it links the region to Title highlight group as follows:

hi def link htmlTitle Title

So the text inside the region is highlighted accordingly. It's simple as that.

Now let's assume that our cursor is on bar, and we want to dim the surrounding text while retaining the hues of the syntax-highlighted colors. What should we do then? We have to define a syntax region that starts at <title> and ends at the line before bar, and another region that starts after bar and ends at </title>, and we have to do such a thing for every other syntax regions and elements. That's why I said it's practically impossible. It's unfortunate, but it's probably not something a plugin can do.