Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/syntax.txt`
237479efc6ff8b4424390dd2a97f429634ac8eccde0edf130000000100000fa1
 in there called "after/syntax".  For Unix: >
	mkdir -p ~/.config/nvim/after/syntax

3. Write a Vim script that contains the commands you want to use.  For
   example, to change the colors for the C syntax: >
	highlight cComment ctermfg=Green guifg=Green

4. Write that file in the "after/syntax" directory.  Use the name of the
   syntax, with ".vim" added.  For our C syntax: >
	:w ~/.config/nvim/after/syntax/c.vim

That's it.  The next time you edit a C file the Comment color will be
different.  You don't even have to restart Vim.

If you have multiple files, you can use the filetype as the directory name.
All the "*.vim" files in this directory will be used, for example:
	~/.config/nvim/after/syntax/c/one.vim
	~/.config/nvim/after/syntax/c/two.vim


REPLACING AN EXISTING SYNTAX FILE			*mysyntaxfile-replace*

If you don't like a distributed syntax file, or you have downloaded a new
version, follow the same steps as for |mysyntaxfile| above.  Just make sure
that you write the syntax file in a directory that is early in 'runtimepath'.
Vim will only load the first syntax file found, assuming that it sets
b:current_syntax.


NAMING CONVENTIONS		    *group-name* *{group-name}* *E669* *E5248*

A syntax group name is to be used for syntax items that match the same kind of
thing.  These are then linked to a highlight group that specifies the color.
A syntax group name doesn't specify any color or attributes itself.

The name for a highlight or syntax group must consist of ASCII letters,
digits, underscores, dots, hyphens, or `@`.  As a regexp: `[a-zA-Z0-9_.@-]*`.
The maximum length of a group name is about 200 bytes.  *E1249*

To be able to allow each user to pick their favorite set of colors, there must
be preferred names for highlight groups that are common for many languages.
These are the suggested group names (if syntax highlighting works properly
you can see the actual color, except for "Ignore"):

Comment		any comment

Constant	any constant
String		a string constant: "this is a string"
Character	a character constant: 'c', '\n'
Number		a number constant: 234, 0xff
Boolean		a boolean constant: TRUE, false
Float		a floating point constant: 2.3e10

Identifier	any variable name
Function	function name (also: methods for classes)

Statement	any statement
Conditional	if, then, else, endif, switch, etc.
Repeat		for, do, while, etc.
Label		case, default, etc.
Operator	"sizeof", "+", "*", etc.
Keyword		any other keyword
Exception	try, catch, throw

PreProc		generic Preprocessor
Include		preprocessor #include
Define		preprocessor #define
Macro		same as Define
PreCondit	preprocessor #if, #else, #endif, etc.

Type		int, long, char, etc.
StorageClass	static, register, volatile, etc.
Structure	struct, union, enum, etc.
Typedef		a typedef

Special		any special symbol
SpecialChar	special character in a constant
Tag		you can use CTRL-] on this
Delimiter	character that needs attention
SpecialComment	special things inside a comment
Debug		debugging statements

Underlined	text that stands out, HTML links

Ignore		left blank, hidden  |hl-Ignore|

Error		any erroneous construct

Todo		anything that needs extra attention; mostly the
		keywords TODO FIXME and XXX

Added		added line in a diff
Changed		changed line in a diff
Removed		removed line in a diff

Note that highlight group names are not case sensitive.  "String" and "string"
can be used for the same group.

The following names are reserved and cannot be used as a group name:
	NONE   ALL   ALLBUT   contains	 contained

							*hl-Ignore*
When using the Ignore group, you may also consider using the conceal
mechanism.  See |conceal|.

==============================================================================
3. Syntax loading procedure				*syntax-loading*

This explains the details that happen when the command ":syntax enable" is
issued.  When Vim initializes itself, it finds out where the runtime files are
located.  This is used here as the variable |$VIMRUNTIME|.

":syntax enable" and ":syntax

Title: Adding/Replacing Syntax Files and Naming Conventions
Summary
This section describes how to add to or replace existing syntax files by creating a directory in 'after/syntax' and placing a Vim script with the desired changes in it. It also outlines the naming conventions for syntax groups, emphasizing the use of standard highlight group names like 'Comment', 'String', and 'Function' to ensure consistency and user customization. Reserved names are also mentioned.