vim-scala icon indicating copy to clipboard operation
vim-scala copied to clipboard

Cannot give ScalaSquareBrackets a custom color

Open fdietze opened this issue 11 years ago • 4 comments

Hi, I'm writing my own colorscheme with focus on Scala.

When I'm trying to give ScalaSquareBrackets a custom one it doesn't work:

hi scalaSquareBrackets guifg=#006fe6 guibg=NONE guisp=NONE gui=bold

Is this a bug or am I doing something wrong?

Thanks!

fdietze avatar May 27 '14 10:05 fdietze

AFAIK that's not the way to do it. What you can specify is the colour highlighting for Type, which is what the scalaSquareBrackets is specified to be. If you want to change the highlighting group that scalaSquareBrackets is defined for, we do that a different way. Effectively, we would specify the value for the matchgroup in a variable and you could override that. A pull request for the change (or a better idea) would be heavily appreciated.

derekwyatt avatar Jun 08 '14 13:06 derekwyatt

I'm four years late, but here goes...

Is this a bug or am I doing something wrong?

Use scalaSquareBracketsBrackets (note the extra Brackets) to highlight the end brackets. The scalaSquareBrackets region contains other matches, and vim uses those for inner colors.

What you can specify is the colour highlighting for Type... (or a better idea) ...

It's common for syntax scripts to use hi def link rather than hi link to link a language style name to a global style name (syntax/scala.vim is one of the few that doesn't). This allows the user to relink a language name to whatever they want from their .vimrc file. Using hi link instead requires the user to change global styles (as mentioned) or to modify the language's syntax file directly.

vim-ruby, for example, uses hi def link. I don't like the special treatment vim gives to Ruby's regular expressions, so I change it by adding the following lines in my .vimrc:

hi! link rubyRegexpDelimiter rubyRegexp
hi! link rubyRegexpSpecial rubyRegexp

Using hi def link in syntax/scala.vim would give users the same kind of options.

More details from :help :highlight-default:

Using [default] is especially useful to overrule the highlighting of a
specific syntax file.  For example, the C syntax file contains:
        :highlight default link cComment Comment
If you like Question highlighting for C comments, put this in your vimrc file:
        :highlight link cComment Question
Without the "default" in the C syntax file, the highlighting would be
overruled when the syntax file is loaded.

fldef avatar Jun 29 '18 18:06 fldef

If you've got a fix, could you put in a PR?

derekwyatt avatar Jul 02 '18 17:07 derekwyatt

@fldef Thanks! :grinning:

When I get back to my working on my colorscheme, I'll take this into account.

fdietze avatar Jul 02 '18 21:07 fdietze