0

Usually, I edit a highlight group like this:

hi typescriptAliasDeclaration guifg=#b58900

But when I look inside an exampleColorTheme.vim, I cannot see any mention of these highlight groups.

So how do color themes set and registor highlight groups in vim (not neovim)

UPDATE:

for example i use Lucius theme -- in the file there are no typescript highlight groups. But some of TS groups have colors.

3
  • The same way. Some times they define helper functions but ultimately it is the same API that is used. May 11, 2023 at 18:09
  • Do you want to share the code? May 11, 2023 at 18:10
  • I added an example theme i use
    – Vinn
    May 11, 2023 at 18:21

1 Answer 1

2

Syntax highlighting is made of two things:

  • A syntax definition, where regular expressions are used to define custom, filetype-specific "highlight groups". Ideally, those highlight groups should all be linked to a small number of generic highlight groups in order to simplify writing colorschemes.
  • A colorscheme, where the generic highlight groups (at the very least) are given visual attributes like foreground color or weight.

In this specific case…

  • the highlight group typescriptAliasDeclaration is defined in $VIMRUNTIME/syntax/shared/typescriptcommon.vim,
  • where it is linked to the generic highlight group Identifier,
  • which any competently written colorscheme should handle out of the box.

--- EDIT ---

In the provided colorscheme, you can see how the author gives Identifier a foreground color:

hi Identifier   guifg=#00af00

which will be applied to every highlight group linked to Identifier, including typescriptAliasDeclaration.

Without that linking mechanism, colorschemes would need to explicitly include every single highlight group of every single filetype, which would make them unmaintainable.

1
  • 1
    That is an awesome explaination. Thank you so much.
    – Vinn
    May 11, 2023 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.