0

I am using MacVim with the Cobalt theme. I found it very nice, however, coming from Sublime Text, I feel there aren't enough different colours which makes my javscript code hard to read.

For example, I'd like the function name to be coloured to make them stand out a bit more:

myClass.prototype.myFunction = function myFunction() {
// here, I'd like "myClass" to have a different color from the text
// same for "prototype" and "myFunction"
}

Another example is the use of methods:

myArray.pop();
// I'd like to change the color of ".pop()" for more visibility

How can I add these types of patterns?

Spearfisher
  • 8,445
  • 19
  • 70
  • 124

2 Answers2

1

A syntax script parses the programming language into different groups (which can be listed via :syntax list). A colorscheme then prescribes how to color and format each individual group.

So, if there are distinct groups, but your colorscheme just assigns the same color to it, that can be easily changed by putting

:hi link <syntaxGroup> <highlightGroup>

commands into your ~/.vimrc.

The detail of parsing depends on the language and syntax script. Extending an existing syntax (to parse out more details) is possible, but complex. For JavaScript, there exist some alternatives (like this) to the built-in syntax script; you might want to give those a try.

PS: :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
0

I use the plugin vim-javascript-syntax.