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

Is it possible to achieve different colors for arguments and local variables? Java parser #255

Closed
ChrisAmelia opened this issue Aug 3, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@ChrisAmelia
Copy link

Regarding to config, I've pasted what is defined in the readme's setup.

java parser healthcheck

colorscheme sublimemonokai

  • TSBufEnable highlight

image

  • TSBufDisable highlight

image

The differences are:

  1. Class name Main from non-italic to italic.
  2. Return type void from non-italic to italic.
  3. Type variable String from non-italic to italic.
  4. Highlight of function name main.
  5. Highlight of brackets.

colorscheme default

  • TSBufEnable highlight

image

  • TSBufDisable highlight

image

The differences are:

  1. Highlight of class name Main.
  2. Highlight of keyword static.
  3. Highlight of return type void.
  4. Highlight of function name main.
  5. Highlight of type variable String[].
  6. Highlight of argument args.
  7. Highlights of local type variable String and variable name element.
  8. Highlight of brackets.
@ChrisAmelia ChrisAmelia changed the title Is it possible to have arguments and local variables set to different colors? Java parser Is it possible to achieve different colors for arguments and local variables? Java parser Aug 3, 2020
@theHamsta
Copy link
Member

The highlights for argument is TSParameter you can configure it freely and locals currently have no highlight.

@stsewd
Copy link
Member

stsewd commented Aug 3, 2020

Some symbols may not be highlighted after enabling the feature on the fly, you can try forcing the buffer to reload :e! or redraw (Ctrl-L), or just give it a try by enabling it by default :) this is how a java file looks like for me

Screenshot from 2020-08-03 17-39-04

You can modify the highlight groups defined in https://github.com/nvim-treesitter/nvim-treesitter/blob/master/plugin/nvim-treesitter.vim#L25-L75 as you like (like marking some elements with italics).

@ChrisAmelia
Copy link
Author

I've tried a few but not all of them work.

hi TSMethod      guifg=#0066FF " Only one working
hi TSParameter   guifg=red
hi TSProperty    guifg=pink
hi TSField       guifg=forestgreen
hi TSConstructor guifg=#66FF22 

This is the result:

image

Is there something I'm missing?

@vigoux vigoux added question enhancement New feature or request labels Aug 15, 2020
@TravonteD
Copy link
Contributor

TravonteD commented Aug 19, 2020

I've looked into the field groups that you are trying to use and it looks like they don't necessarily line up.

TSMethod -> works.
TSParameter -> works.
TSProperty -> not used.
TSField -> not used, seems to be mapped TSType instead.
TSConstructor -> not used, also mapped to TSType.

We can update the queries to better match the expected highlight groups, or at least add documentation so that users know which to use.

@kyazdani42
Copy link
Member

@vigoux should we close this in favor of #81 ?

@vigoux vigoux closed this as completed Sep 9, 2020
@p00f
Copy link
Contributor

p00f commented Sep 15, 2020

Is there something I'm missing?

surely, because atleast TSParameter works for me (java)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants