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

Question: Ruby syntax coloring in terminal #29

Closed
hahuang65 opened this issue Mar 21, 2017 · 16 comments
Closed

Question: Ruby syntax coloring in terminal #29

hahuang65 opened this issue Mar 21, 2017 · 16 comments

Comments

@hahuang65
Copy link

For the Ruby language, are the symbols intentionally a white-ish color? If I prefer to have it stand out among other code, can I change it somehow?
screen shot 2017-03-21 at 12 33 04

@hahuang65 hahuang65 changed the title Question: Question: Ruby syntax coloring in terminal Mar 21, 2017
@arcticicestudio arcticicestudio self-assigned this Mar 22, 2017
@arcticicestudio
Copy link
Contributor

arcticicestudio commented Mar 22, 2017

As far as I know symbols are a kind of attribute / variable so they are intentionally colored with nord4.
By design all other elements of a language should be colored with another color of the palette so that nord4 colored attributes / variables stand out by being bright (white-ish).

You can easily override styles of Nord Vim by adding something like this to your ~/.vimrc file before the colorscheme nord line:

augroup nord-overrides
  autocmd!
  autocmd ColorScheme nord highlight rubySymbol ctermfg=14
augroup END

where the ctermfg=14 part is the color you'd like to use.

ghi-29-scrot-override-example

You can check out this (terminal mode) code block to see which color is assigned to which number.

@hahuang65
Copy link
Author

Hmm perhaps I have something set up wrong then? When I switched from Gotham to Nord, I seemed to lose a lot of variation in my syntax highlighting for Ruby.

screen shot 2017-03-22 at 13 43 57
screen shot 2017-03-22 at 13 45 58

Examples:

  1. self keyword is not distinguishable from the method called on it (line 10),
  2. symbols are not really distinguishable from regular code (compare line 6, 10 and 13 between the 2 files)
  3. nil is not treated as a keyword either (line 9)
  4. the iterator variable (line 13 |item|) is also not colored differently.

If these are on purpose, that's totally fine, I can apply my own overrides based on your advise above, but I just wanted to make sure I'm getting the experience as-intended.

Thanks for your patience and help!

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Mar 23, 2017

Well, this is indeed not the way it should be styled. I created the theme by filtering the official Vim language syntax definition files for color highlights, but some group names do not always fit perfectly into their function.
That's why the theme version reflects the development state of the project, there are still many languages improvements possible, users just need to report them since I'm not aware of every single language out there 😉

The self keyword should be colored for sure, it'll be linked as keyword including language reserved keywords like nil. I'll implement the styles and create a PR for it.
In line 6 seem to be a issue with the syntax highlight definition, the create method should normally be highlighted. The rubyLocalVariableOrMethod group is defined in the color theme, but strangely it has no effect.

Your bullet point 2 should be fixed if the both issues described above are solved.

The iterator variable is in the end, like the name says, a variable.
Anyway, it is possible to style iterator/block variables using the rubyBlockParameter group, but currently I don't know how to style it without loosing the scope to identify it as variable, maybe by setting the font to bold.

About the comparison with the other theme:
Themes exist because everyone has own color preferences 😉
If I'd use the Gotham theme I would have problems to distinguish between a symbol, variable and methods because they share the same color, but thats my opinion.

@hahuang65
Copy link
Author

I agree with you 100% about the themes having different preferences behind the design of it. I don't want a 100% match with Gotham or any other theme for that matter.
I was just using Gotham as a point of reference for saying that my setup seems a little under-colored.

I appreciate your hard work on this and really love Nord! I look forward to the update!

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Apr 1, 2017

I've pushed the changes to 🌱 improvement/ghi-#29-ruby-syntax-coloring-in-terminal.

  1. Symbols are now using a bold font style for a better visual distinction
  2. Block parameter list symbols | and language reserved keywords like nil, true and false are now colored corretly
  3. Local (variable) methods are now using the correct nord8 color

@hahuang65 I'd be nice if you can test the changes and provide some feedback, maybe there are more groups which need some adjustments 😄

@hahuang65
Copy link
Author

Awesome! Been out of town last couple of days, will get back to you asap, hopefully tomorrow or Tuesday at latest!

@hahuang65
Copy link
Author

@arcticicestudio that looks pretty good. The bold is a nice touch.
I'm not sure what I'm looking for in your point 3 in your list above. I didn't notice any changes for methods or local variables? Perhaps I'm misunderstanding the change?

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Apr 3, 2017

Well, for example the snippet

trackable_email_items.create(item: item)

should colorize the create as method (nord8) which is done by the groups rubyKeywordAsMethod and rubyLocalVariableOrMethod.

Both are implemented in the theme, but for some mysterious reason vim ignores it 😞
Also the belongs_to and has_many methods are not colorized as methods on my system too.
Do you use any kind of improved syntax highlighting plugin for Ruby instead of the default one provided by vim? This might explain why I have trouble to reproduce the highlighting of your screenshot 😄

Offtopic: Would you tell me the name of the font on the screenshot? 😆

@hahuang65
Copy link
Author

hahuang65 commented Apr 4, 2017

So here's what my file looks like with the changes from the branch:
screen shot 2017-04-03 at 22 31 31

Is the create nord8 color supposed to look like it does in my screenshot? It's kind of hard to tell the difference between that and the trackable_email_items. that precedes it.

The font in the screenshot is Input Mono
I LOVE THIS FONT, and a big part of it is because you can customize many of the glyphs to your liking on the download page.

If you're a font snob, I'd also recommend Hack.
I used to use Source Code Pro exclusively, but since I discovered Hack and Input, I've been switching between them endlessly.

@arcticicestudio
Copy link
Contributor

No, it should normally be colorized with nord8 as a method/dunction, but for some reason vim ignores the color definition of the theme
The belongs_to and has_may words are not colorized on my system. Can you post a list of your installed plugins, maybe I'm missing some Ruby specific plugins on my setup.

I'm using Source Code Pro Medium everywhere, but I really like the rounded glyphs of the font on your screenshot. Thanks for the link 😉

@hahuang65
Copy link
Author

hahuang65 commented Apr 4, 2017

Here's a link to my vim-plugs file in my vimrc: https://github.com/hahuang65/vim.config/blob/master/plugs.vim

Also here's all my colorscheme related changes: https://github.com/hahuang65/vim.config/blob/master/settings/colorscheme.vim

Perhaps I should take out the background=dark?

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Apr 6, 2017

Your code on the screenshot looks fine except the missing coloring for the create method which seem to be a bug of the vim core syntax highlighting definition, it's just the fact that the belongs_to and has_many methods are not colorized on my system for whatever reason 😕
I replaced my ~/.vimrc with yours, but nothing changes.

I've only copied the lines seen on the screenshot, maybe it is related to the fact that vim only highlights these methods if they exist? Can you post the whole code (if it is not private)?

@hahuang65
Copy link
Author

Hey, sorry for the really late reply. Was out of town for a friends wedding.

So I think you might be right, although, all the methods you listed create, belongs_to, and has_many are defined by Rails itself.

The code above is the full code. It doesn't look like methods are highlighted even if they are defined in the file. Do you have it working with highlighting methods? Can you post me a screenshot or example?

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Apr 17, 2017

I'll merge this change and ship a new release version as it seems to work fine for you.
Thanks for your help to get test this 😄

@arcticicestudio
Copy link
Contributor

ghi-29-scrot-improved-ruby-styles

@arcticicestudio
Copy link
Contributor

🚢 Shipped with release version 🏷 0.5.0.

@arcticicestudio arcticicestudio added this to the 0.5.0 milestone Jul 10, 2017
@arcticicestudio arcticicestudio removed their assignment Sep 23, 2017
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

2 participants