]> git.lizzy.rs Git - micro.git/blob - runtime/help/colors.md
b0803b918c1f96cefb3c2d0a4f1e76d06b7303be
[micro.git] / runtime / help / colors.md
1 # Colors
2
3 This help page aims to cover two aspects of micro's syntax highlighting engine:
4
5 - How to create colorschemes and use them
6 - How to create syntax files to add to the list of languages micro can highlight
7
8 ### Colorschemes
9
10 Micro comes with a number of colorschemes by default. Here is the list:
11
12 * simple: this is the simplest colorscheme. It uses 16 colors which are
13   set by your terminal
14
15 * monokai: this is the monokai colorscheme; you may recognize it as
16   Sublime Text's default colorscheme. It requires true color to
17   look perfect, but the 256 color approximation looks very good as well.
18   It's also the default colorscheme.
19
20 * zenburn: The 'zenburn' colorscheme and works well with 256 color terminals
21
22 * solarized: this is the solarized colorscheme. 
23   You should have the solarized color palette in your terminal to use it.
24
25 * solarized-tc: this is the solarized colorscheme for true color; just 
26   make sure your terminal supports true color before using it and that the 
27   MICRO_TRUECOLOR environment variable is set to 1 before starting micro.
28
29 * atom-dark-tc: this colorscheme is based off of Atom's "dark" colorscheme.
30   It requires true color to look good.
31
32 To enable one of these colorschemes just press CtrlE in micro and type `set colorscheme solarized`.
33 (or whichever one you choose).
34
35 ---
36
37 Micro's colorschemes are also extremely simple to create. The default ones can be found
38 [here](https://github.com/zyedidia/micro/tree/master/runtime/colorschemes).
39
40 They are only about 18 lines in total.
41
42 Basically to create the colorscheme you need to link highlight groups with actual colors.
43 This is done using the `color-link` command.
44
45 For example, to highlight all comments in green, you would use the command:
46
47 ```
48 color-link comment "green"
49 ```
50
51 Background colors can also be specified with a comma:
52
53 ```
54 color-link comment "green,blue"
55 ```
56
57 This will give the comments a blue background.
58
59 If you would like no foreground you can just use a comma with nothing in front:
60
61 ```
62 color-link comment ",blue"
63 ```
64
65 You can also put bold, or underline in front of the color:
66
67 ```
68 color-link comment "bold red"
69 ```
70
71 ---
72
73 There are three different ways to specify the color.
74
75 Color terminals usually have 16 colors that are preset by the user. This means that
76 you cannot depend on those colors always being the same. You can use those colors with
77 the names `black, red, green, yellow, blue, magenta, cyan, white` and the bright variants
78 of each one (brightblack, brightred...).
79
80 Then you can use the terminals 256 colors by using their numbers 1-256 (numbers 1-16 will
81 refer to the named colors).
82
83 If the user's terminal supports true color, then you can also specify colors exactly using
84 their hex codes. If the terminal is not true color but micro is told to use a true color colorscheme
85 it will attempt to map the colors to the available 256 colors.
86
87 Generally colorschemes which require true color terminals to look good are marked with a `-tc` suffix.
88
89 ---
90
91 Here is a list of the colorscheme groups that you can use:
92
93 * default (color of the background and foreground for unhighlighted text)
94 * comment
95 * identifier
96 * constant
97 * statement
98 * preproc
99 * type
100 * special
101 * underlined
102 * error
103 * todo
104 * statusline (color of the statusline)
105 * indent-char (color of the character which indicates tabs if the option is enabled)
106 * line-number
107 * gutter-error
108 * gutter-warning
109 * cursor-line
110 * current-line-number
111 * color-column
112
113 Colorschemes can be placed in the `~/.config/micro/colorschemes` directory to be used.
114
115 ### Syntax files
116
117 The syntax files specify how to highlight certain languages.
118
119 The first statement in a syntax file will probably the syntax statement. This tells micro
120 what language the syntax file is for and how to detect a file in that language.
121
122 Essentially, it's just
123
124 ```
125 syntax "Name of language" "\.extension$"
126 ```
127
128 For the extension, micro will just compare that regex to the filename and if it matches then it
129 will use the syntax rules defined in the remainder of the file.
130
131 There is also a possibility to use a header statement which is a regex that micro will compare
132 with the first line of the file. This is almost only used for shebangs at the top of shell scripts
133 which don't have any extension (see sh.micro for an example).
134
135 ---
136
137 The rest of a syntax file is very simple and is essentially a list of regexes specifying how to highlight
138 different expressions.
139
140 It is recommended that when creating a syntax file you use the colorscheme groups (see above) to
141 highlight different expressions. You may also hard code colors, but that may not look good depending
142 on what terminal colorscheme the user has installed.
143
144 Here is an example to highlight comments (expressions starting with `//`):
145
146 ```
147 color comment "//.*"
148 ```
149
150 This will highlight the regex `//.*` in the color that the user's colorscheme has linked to the comment
151 group.
152
153 Note that this regex only matches the current line. Here is an example for multiline comments (`/* comment */`):
154
155 ```
156 color comment start="/\*" end="\*/"
157 ```