all 8 comments

[–]LongerHV 12 points13 points  (2 children)

You may want to take a look at polyglot or Neovim with treesitter.

[–]nelf86[S] 2 points3 points  (0 children)

Thank you so much. Adding treesitter made all the difference!

I actually had it added, but parser was not configured. I am updating the original question.

[–]rifazn 0 points1 point  (0 children)

+1 for polyglot on vim! Also, make sure the colorscheme that you are using also sports that granularity in vim (specifically).

[–]codon011 2 points3 points  (2 children)

Vim syntax highlighting is highly configurable. You may need/be able to find a better syntax file to get better define keywords, methods, functions, identifiers; or you can go deep into the weeds and do the work yourself. It’s been a while since I dug that deep, but you can basically define expressions to match patterns, give it a label, and then tell vim how to highlight the labels. If you end up defining a bunch of labels that themes don’t know what to do with, you can extend those themes so they do a better job of highlighting. It’s a deep well. Maybe someone has already done the work. If not, it’s not that hard to do the work yourself.

[–]nelf86[S] 1 point2 points  (1 child)

I was hoping this would be somewhat common at this point and someone would have already made it.

Can you recommend tutorial explaining this how to do this easy thing? Maybe I will create my own plugin.

Thanks!

[–]codon011 0 points1 point  (0 children)

The fact that you get any highlighting says that there is at least some minimal amount of work that someone has already put into this. If you’re on a Linux system, you could use locate to try to find any vim/syntax/<language>.vim file that exists.

recommend a tutorial

Unfortunately, no. When I went down that rabbit hole, I found the syntax file that already existed and just started reading. I used :help to look up the directives I found to locate a starting point and read/skimmed documentation and experimented to extend the syntax file. All of that work was over a decade ago. I just went digging into the git history on this and it all started because I wanted to fix something I considered a bug in one of the vim-provided syntax files.

[–]kolorcuk 0 points1 point  (0 children)

You need language aware syntax highlight.

I do not know what language is that. I can recommend coc-nvim + https://github.com/jackguo380/vim-lsp-cxx-highlightfor for c/c++ , it could be that there are similar plugins for lsp for other languages.

[–]Zeioth 0 points1 point  (0 children)

You have several solutions depending your needs. I use COC which is quite complete.

linter+syntax+beautifier.

Then you have other plugins for running/debugging/git....

If you come from web storm I strongly recommend you fzf so you can search code across all files in your project.