bigfish / vim-js-context-coloring

JavaScript Context Coloring in Vim
MIT License
151 stars 8 forks source link

level 0 color has the same like the background and makes code invisible #25

Closed mschaaf closed 7 years ago

mschaaf commented 8 years ago

This is the code without context colour:

bildschirmfoto vom 2016-10-22 11-12-53

With context colour its:

bildschirmfoto vom 2016-10-22 11-13-28

The CLI tool returns that JSON: {"scopes":[[0,0,160,{"a":0,"b":0,"t":0,"d":-1,"c":-1}],[1,59,159,{"d":-1,"a":0,"c":-1}],[2,78,155,{"a":0,"c":-1}],[3,110,150,{}]]}

bigfish commented 8 years ago

Yes, the default top level color as specified in REPO/colors/js_context_colors.vim is white.

You can customize the colors by copying the file to $VIMHOME/colors/js_context_colors.vim and changing them. This is what I am using currently...

hi JSCC_Level_0 ctermfg=76 hi JSCC_Level_1 ctermfg=37 hi JSCC_Level_2 ctermfg=33 hi JSCC_Level_3 ctermfg=61 hi JSCC_Level_4 ctermfg=125 hi JSCC_Level_5 ctermfg=160 hi JSCC_Level_6 ctermfg=166 hi JSCC_Level_7 ctermfg=136

hi JSCC_UndeclaredGlobal ctermfg=172

you can use XtermColorTable plugin to get color codes. Interestingly, now vim 8 has support for true colors, GUI colors can also be used, but I haven't explored this yet.

you can set the debug option to 0 now to suppress the JSON output

mschaaf commented 8 years ago

Taking your colours make the lines visible. Thanks for the hint. I played with the colours but changed the "guifg" entry (it look for me more like a colour entry :-)).

Another issue I have is now the code is fully coloured if I open a file, but if I toggle the colouring only parts get coloured. It looks like only the first function in the file gets coloured.

Initial colouring (like I expect it)

bildschirmfoto vom 2016-10-22 15-27-28

After toggling the coloring:

bildschirmfoto vom 2016-10-22 15-27-50

bigfish commented 8 years ago

hmm. It works for me.. not sure what you mean by 'changed the "guifg" entry' ? are you using vim or gvim? if gvim, yes you'll need to set 'guifg' , for terminal, use 'ctermfg' (you can also set both) .. all that is happening here is setting up the Highlight groups, see

:h hi :h highlight-args

Does it work without the guifg change?

I will push a change to the default color for top level, so white bg is not an issue.

mschaaf commented 8 years ago

Hej @bigfish, the root colour problem is no issue anymore and was solved. I only wanted to tell that I tried to change the colour myself before I opened the issue but this had no effect and now I see why because I changed only the guifg value but not the ctermfg.

But the second issue is now that after toggling the context colouring only one function and its inner functions are coloured but not level 0 and other nested functions. Should I open another issue for it?

bigfish commented 8 years ago

yes, I see what you're saying about the toplevel not being colored after toggling.. but I can't reproduce this behaviour. Can you try removing or renaming your custom js_context_colors.vim, and re-installing the plugin (or git pull) ..? Can you also check whether the JSON CLI is different, before and after toggling off and on? Thx.

mschaaf commented 8 years ago
{"scopes":[[0,0,697,{"a":0,"b":0,"t":0,"d":-1,"c":-1,"u":-1,"h":-1}],[1,59,312,{"d":-1,"a":0,"c":-1,"u":-1,"h":-1}],[2,78,308,{"a":0,"c":-1,"u":-1,"h":-1}],[3,110,303,{"u":-1,"h":-1}],[4,155,296,{"h":-1}],[5,198,226,{"ght":4}],[5,241,287,{}],[1,333,696,{
"d":-1,"a":0,"c":-1,"u":-1,"h":-1}],[2,352,692,{"a":0,"c":-1,"u":-1,"h":-1}],[3,384,687,{"u":-1,"h":-1}],[4,429,680,{"h":-1}],[5,472,531,{"ght":4}],[5,546,671,{}],[6,593,659,{"asfdf":5}]]}
bigfish commented 7 years ago

ok, suddenly I started seeing the same thing as you. It was due to the native js syntax overriding the scope colors. I've fixed this now by clearing existing syntax when enabling the plugin. I was doing this before.. looks like I thought it wasn't needed at some point and didn't notice it broke this. Oops.

mschaaf commented 7 years ago

Thanks a lot your fix solved my issue. Fixed with commit db570ac624a41143717164fcc14c2194b048e490