bunmicro 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/LICENSE +22 -0
  2. package/PORTING.md +34 -0
  3. package/README.md +153 -0
  4. package/bmi +5 -0
  5. package/bun.lock +17 -0
  6. package/bunmicro +5 -0
  7. package/hlw.md +5 -0
  8. package/package.json +18 -0
  9. package/runtime/colorschemes/atom-dark.micro +33 -0
  10. package/runtime/colorschemes/bubblegum.micro +31 -0
  11. package/runtime/colorschemes/cmc-16.micro +47 -0
  12. package/runtime/colorschemes/cmc-tc.micro +43 -0
  13. package/runtime/colorschemes/darcula.micro +34 -0
  14. package/runtime/colorschemes/default.micro +1 -0
  15. package/runtime/colorschemes/dracula-tc.micro +49 -0
  16. package/runtime/colorschemes/dukedark-tc.micro +38 -0
  17. package/runtime/colorschemes/dukelight-tc.micro +38 -0
  18. package/runtime/colorschemes/dukeubuntu-tc.micro +38 -0
  19. package/runtime/colorschemes/geany.micro +29 -0
  20. package/runtime/colorschemes/gotham.micro +29 -0
  21. package/runtime/colorschemes/gruvbox-tc.micro +29 -0
  22. package/runtime/colorschemes/gruvbox.micro +26 -0
  23. package/runtime/colorschemes/material-tc.micro +36 -0
  24. package/runtime/colorschemes/monokai-dark.micro +28 -0
  25. package/runtime/colorschemes/monokai.micro +34 -0
  26. package/runtime/colorschemes/one-dark.micro +39 -0
  27. package/runtime/colorschemes/railscast.micro +37 -0
  28. package/runtime/colorschemes/simple.micro +33 -0
  29. package/runtime/colorschemes/solarized-tc.micro +31 -0
  30. package/runtime/colorschemes/solarized.micro +30 -0
  31. package/runtime/colorschemes/sunny-day.micro +29 -0
  32. package/runtime/colorschemes/twilight.micro +40 -0
  33. package/runtime/colorschemes/zenburn.micro +30 -0
  34. package/runtime/help/actions.md +161 -0
  35. package/runtime/help/colors.md +421 -0
  36. package/runtime/help/commands.md +161 -0
  37. package/runtime/help/copypaste.md +149 -0
  38. package/runtime/help/defaultkeys.md +141 -0
  39. package/runtime/help/help.md +63 -0
  40. package/runtime/help/keybindings.md +760 -0
  41. package/runtime/help/linter.md +90 -0
  42. package/runtime/help/options.md +701 -0
  43. package/runtime/help/plugins.md +544 -0
  44. package/runtime/help/tutorial.md +112 -0
  45. package/runtime/jsplugins/chapter/chapter.js +108 -0
  46. package/runtime/jsplugins/diff/diff.js +46 -0
  47. package/runtime/jsplugins/example/example.js +108 -0
  48. package/runtime/jsplugins/linter/linter.js +281 -0
  49. package/runtime/plugins/autoclose/autoclose.lua +75 -0
  50. package/runtime/plugins/ftoptions/ftoptions.lua +17 -0
  51. package/runtime/plugins/literate/README.md +5 -0
  52. package/runtime/plugins/literate/literate.lua +55 -0
  53. package/runtime/plugins/status/help/status.md +21 -0
  54. package/runtime/plugins/status/status.lua +62 -0
  55. package/runtime/syntax/LICENSE +22 -0
  56. package/runtime/syntax/PowerShell.yaml +128 -0
  57. package/runtime/syntax/README.md +63 -0
  58. package/runtime/syntax/ada.yaml +43 -0
  59. package/runtime/syntax/apacheconf.yaml +59 -0
  60. package/runtime/syntax/arduino.yaml +101 -0
  61. package/runtime/syntax/asciidoc.yaml +51 -0
  62. package/runtime/syntax/asm.yaml +123 -0
  63. package/runtime/syntax/ats.yaml +99 -0
  64. package/runtime/syntax/awk.yaml +44 -0
  65. package/runtime/syntax/b.yaml +87 -0
  66. package/runtime/syntax/bat.yaml +57 -0
  67. package/runtime/syntax/c.yaml +60 -0
  68. package/runtime/syntax/caddyfile.yaml +23 -0
  69. package/runtime/syntax/cake.yaml +7 -0
  70. package/runtime/syntax/clojure.yaml +38 -0
  71. package/runtime/syntax/cmake.yaml +42 -0
  72. package/runtime/syntax/coffeescript.yaml +56 -0
  73. package/runtime/syntax/colortest.yaml +19 -0
  74. package/runtime/syntax/conky.yaml +17 -0
  75. package/runtime/syntax/cpp.yaml +91 -0
  76. package/runtime/syntax/crontab.yaml +36 -0
  77. package/runtime/syntax/crystal.yaml +72 -0
  78. package/runtime/syntax/csharp.yaml +52 -0
  79. package/runtime/syntax/css.yaml +44 -0
  80. package/runtime/syntax/csx.yaml +8 -0
  81. package/runtime/syntax/cuda.yaml +68 -0
  82. package/runtime/syntax/cython.yaml +52 -0
  83. package/runtime/syntax/d.yaml +121 -0
  84. package/runtime/syntax/dart.yaml +46 -0
  85. package/runtime/syntax/default.yaml +10 -0
  86. package/runtime/syntax/dockerfile.yaml +36 -0
  87. package/runtime/syntax/dot.yaml +29 -0
  88. package/runtime/syntax/elixir.yaml +30 -0
  89. package/runtime/syntax/elm.yaml +38 -0
  90. package/runtime/syntax/erb.yaml +42 -0
  91. package/runtime/syntax/erlang.yaml +45 -0
  92. package/runtime/syntax/fish.yaml +48 -0
  93. package/runtime/syntax/forth.yaml +34 -0
  94. package/runtime/syntax/fortran.yaml +64 -0
  95. package/runtime/syntax/freebsd-kernel.yaml +14 -0
  96. package/runtime/syntax/fsharp.yaml +48 -0
  97. package/runtime/syntax/gdscript.yaml +61 -0
  98. package/runtime/syntax/gemini.yaml +19 -0
  99. package/runtime/syntax/gentoo-ebuild.yaml +48 -0
  100. package/runtime/syntax/gentoo-etc-portage.yaml +23 -0
  101. package/runtime/syntax/git-commit.yaml +35 -0
  102. package/runtime/syntax/git-config.yaml +14 -0
  103. package/runtime/syntax/git-rebase-todo.yaml +19 -0
  104. package/runtime/syntax/gleam.yaml +69 -0
  105. package/runtime/syntax/glsl.yaml +26 -0
  106. package/runtime/syntax/gnuplot.yaml +15 -0
  107. package/runtime/syntax/go.yaml +62 -0
  108. package/runtime/syntax/godoc.yaml +17 -0
  109. package/runtime/syntax/golo.yaml +73 -0
  110. package/runtime/syntax/gomod.yaml +31 -0
  111. package/runtime/syntax/graphql.yaml +47 -0
  112. package/runtime/syntax/groff.yaml +30 -0
  113. package/runtime/syntax/groovy.yaml +111 -0
  114. package/runtime/syntax/haml.yaml +16 -0
  115. package/runtime/syntax/hare.yaml +52 -0
  116. package/runtime/syntax/haskell.yaml +52 -0
  117. package/runtime/syntax/hc.yaml +52 -0
  118. package/runtime/syntax/html.yaml +70 -0
  119. package/runtime/syntax/html4.yaml +25 -0
  120. package/runtime/syntax/html5.yaml +25 -0
  121. package/runtime/syntax/ini.yaml +23 -0
  122. package/runtime/syntax/inputrc.yaml +14 -0
  123. package/runtime/syntax/java.yaml +37 -0
  124. package/runtime/syntax/javascript.yaml +76 -0
  125. package/runtime/syntax/jinja2.yaml +19 -0
  126. package/runtime/syntax/json.yaml +39 -0
  127. package/runtime/syntax/jsonnet.yaml +92 -0
  128. package/runtime/syntax/julia.yaml +57 -0
  129. package/runtime/syntax/justfile.yaml +40 -0
  130. package/runtime/syntax/keymap.yaml +27 -0
  131. package/runtime/syntax/kickstart.yaml +16 -0
  132. package/runtime/syntax/kotlin.yaml +66 -0
  133. package/runtime/syntax/kvlang.yaml +67 -0
  134. package/runtime/syntax/ledger.yaml +14 -0
  135. package/runtime/syntax/lfe.yaml +17 -0
  136. package/runtime/syntax/lilypond.yaml +26 -0
  137. package/runtime/syntax/lisp.yaml +17 -0
  138. package/runtime/syntax/log.yaml +92 -0
  139. package/runtime/syntax/lua.yaml +111 -0
  140. package/runtime/syntax/mail.yaml +25 -0
  141. package/runtime/syntax/makefile.yaml +38 -0
  142. package/runtime/syntax/man.yaml +12 -0
  143. package/runtime/syntax/markdown.yaml +49 -0
  144. package/runtime/syntax/mc.yaml +23 -0
  145. package/runtime/syntax/meson.yaml +51 -0
  146. package/runtime/syntax/micro.yaml +34 -0
  147. package/runtime/syntax/mpdconf.yaml +13 -0
  148. package/runtime/syntax/msbuild.yaml +6 -0
  149. package/runtime/syntax/nanorc.yaml +16 -0
  150. package/runtime/syntax/nftables.yaml +30 -0
  151. package/runtime/syntax/nginx.yaml +22 -0
  152. package/runtime/syntax/nim.yaml +27 -0
  153. package/runtime/syntax/nix.yaml +32 -0
  154. package/runtime/syntax/nu.yaml +114 -0
  155. package/runtime/syntax/objc.yaml +60 -0
  156. package/runtime/syntax/ocaml.yaml +43 -0
  157. package/runtime/syntax/octave.yaml +83 -0
  158. package/runtime/syntax/odin.yaml +64 -0
  159. package/runtime/syntax/pascal.yaml +45 -0
  160. package/runtime/syntax/patch.yaml +14 -0
  161. package/runtime/syntax/peg.yaml +16 -0
  162. package/runtime/syntax/perl.yaml +58 -0
  163. package/runtime/syntax/php.yaml +60 -0
  164. package/runtime/syntax/pkg-config.yaml +12 -0
  165. package/runtime/syntax/po.yaml +12 -0
  166. package/runtime/syntax/pony.yaml +37 -0
  167. package/runtime/syntax/pov.yaml +21 -0
  168. package/runtime/syntax/privoxy-action.yaml +14 -0
  169. package/runtime/syntax/privoxy-config.yaml +10 -0
  170. package/runtime/syntax/privoxy-filter.yaml +12 -0
  171. package/runtime/syntax/proto.yaml +40 -0
  172. package/runtime/syntax/prql.yaml +84 -0
  173. package/runtime/syntax/puppet.yaml +22 -0
  174. package/runtime/syntax/python2.yaml +60 -0
  175. package/runtime/syntax/python3.yaml +62 -0
  176. package/runtime/syntax/r.yaml +32 -0
  177. package/runtime/syntax/raku.yaml +42 -0
  178. package/runtime/syntax/reST.yaml +18 -0
  179. package/runtime/syntax/renpy.yaml +15 -0
  180. package/runtime/syntax/rpmspec.yaml +43 -0
  181. package/runtime/syntax/ruby.yaml +73 -0
  182. package/runtime/syntax/rust.yaml +78 -0
  183. package/runtime/syntax/sage.yaml +60 -0
  184. package/runtime/syntax/scad.yaml +53 -0
  185. package/runtime/syntax/scala.yaml +33 -0
  186. package/runtime/syntax/sed.yaml +13 -0
  187. package/runtime/syntax/sh.yaml +69 -0
  188. package/runtime/syntax/sls.yaml +15 -0
  189. package/runtime/syntax/smalltalk.yaml +55 -0
  190. package/runtime/syntax/solidity.yaml +41 -0
  191. package/runtime/syntax/sql.yaml +35 -0
  192. package/runtime/syntax/stata.yaml +67 -0
  193. package/runtime/syntax/svelte.yaml +27 -0
  194. package/runtime/syntax/swift.yaml +103 -0
  195. package/runtime/syntax/systemd.yaml +16 -0
  196. package/runtime/syntax/tcl.yaml +18 -0
  197. package/runtime/syntax/terraform.yaml +87 -0
  198. package/runtime/syntax/tex.yaml +32 -0
  199. package/runtime/syntax/toml.yaml +56 -0
  200. package/runtime/syntax/twig.yaml +55 -0
  201. package/runtime/syntax/typescript.yaml +49 -0
  202. package/runtime/syntax/v.yaml +80 -0
  203. package/runtime/syntax/vala.yaml +26 -0
  204. package/runtime/syntax/verilog.yaml +60 -0
  205. package/runtime/syntax/vhdl.yaml +37 -0
  206. package/runtime/syntax/vi.yaml +31 -0
  207. package/runtime/syntax/vue.yaml +64 -0
  208. package/runtime/syntax/xml.yaml +37 -0
  209. package/runtime/syntax/xresources.yaml +14 -0
  210. package/runtime/syntax/yaml.yaml +34 -0
  211. package/runtime/syntax/yum.yaml +12 -0
  212. package/runtime/syntax/zig.yaml +52 -0
  213. package/runtime/syntax/zscript.yaml +72 -0
  214. package/runtime/syntax/zsh.yaml +52 -0
  215. package/src/buffer/buffer.js +126 -0
  216. package/src/buffer/loc.js +38 -0
  217. package/src/buffer/message.js +29 -0
  218. package/src/config/colorscheme.js +109 -0
  219. package/src/config/config.js +118 -0
  220. package/src/config/defaults.js +102 -0
  221. package/src/display/ansi-style.js +60 -0
  222. package/src/highlight/highlighter.js +237 -0
  223. package/src/highlight/parser.js +137 -0
  224. package/src/index.js +5942 -0
  225. package/src/lua/engine.js +38 -0
  226. package/src/platform/archive.js +50 -0
  227. package/src/platform/clipboard.js +160 -0
  228. package/src/platform/commands.js +140 -0
  229. package/src/plugins/js-bridge.js +902 -0
  230. package/src/plugins/manager.js +619 -0
  231. package/src/runtime/registry.js +89 -0
  232. package/src/screen/cell-buffer.js +81 -0
  233. package/src/screen/events.js +263 -0
  234. package/src/screen/screen.js +118 -0
  235. package/src/screen/vt100.js +391 -0
  236. package/src/shell/shell.js +70 -0
  237. package/todo.txt +359 -0
@@ -0,0 +1,421 @@
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
7
+ highlight.
8
+
9
+ ## Colorschemes
10
+
11
+ To change your colorscheme, press `Ctrl-e` in micro to bring up the command
12
+ prompt, and type:
13
+
14
+ ```
15
+ set colorscheme twilight
16
+ ```
17
+
18
+ (or whichever colorscheme you choose).
19
+
20
+ Micro comes with a number of colorschemes by default. The colorschemes that you
21
+ can display will depend on what kind of color support your terminal has.
22
+
23
+ Omit color-link default "[fg color],[bg color]" will make the background color match the terminal's, and transparency if set.
24
+
25
+ Modern terminals tend to have a palette of 16 user-configurable colors (these
26
+ colors can often be configured in the terminal preferences), and additional
27
+ color support comes in three flavors.
28
+
29
+ * 16-color: A colorscheme that uses the 16 default colors will always work but
30
+ will only look good if the 16 default colors have been configured to the
31
+ user's liking. Using a colorscheme that only uses the 16 colors from the
32
+ terminal palette will also preserve the terminal's theme from other
33
+ applications since the terminal will often use those same colors for other
34
+ applications. Default colorschemes of this type include `simple` and
35
+ `solarized`.
36
+
37
+ * 256-color: Almost all terminals support displaying an additional 240 colors
38
+ on top of the 16 user-configurable colors (creating 256 colors total).
39
+ Colorschemes which use 256-color are portable because they will look the
40
+ same regardless of the configured 16-color palette. However, the color
41
+ range is fairly limited due to the small number of colors available.
42
+ Default 256-color colorschemes include `monokai`, `twilight`, `zenburn`,
43
+ `darcula` and more.
44
+
45
+ * true-color: Some terminals support displaying "true color" with 16 million
46
+ colors using standard RGB values. This mode will be able to support
47
+ displaying any colorscheme, but it should be noted that the user-configured
48
+ 16-color palette is ignored when using true-color mode (this means the
49
+ colors while using the terminal emulator will be slightly off). Not all
50
+ terminals support true color but at this point most do (see below).
51
+ True-color colorschemes in micro typically end with `-tc`, such as
52
+ `solarized-tc`, `atom-dark`, `material-tc`, etc... If true color is not
53
+ enabled but a true color colorscheme is used, micro will do its best to
54
+ approximate the colors to the available 256 colors.
55
+
56
+ Here is the list of colorschemes:
57
+
58
+ ### 256 color
59
+
60
+ These should work and look nice in most terminals. I recommend these
61
+ themes the most.
62
+
63
+ * `monokai` (also the `default` colorscheme)
64
+ * `zenburn`
65
+ * `gruvbox`
66
+ * `darcula`
67
+ * `twilight`
68
+ * `railscast`
69
+ * `bubblegum` (light theme)
70
+
71
+ ### 16 color
72
+
73
+ These may vary widely based on the 16 colors selected for your terminal.
74
+
75
+ * `simple`
76
+ * `solarized` (must have the solarized color palette in your terminal to use
77
+ this colorscheme properly)
78
+ * `cmc-16`
79
+ * `cmc-paper`
80
+ * `geany`
81
+
82
+ ### True color
83
+
84
+ Micro enables true color support by default as long as it detects that the
85
+ terminal supports it (which is usually indicated by the environment variable
86
+ `COLORTERM` being set to `truecolor`, `24bit` or `24-bit`). You can also force
87
+ enabling it unconditionally by setting the option `truecolor` to `on` (or
88
+ alternatively by setting the environment variable `MICRO_TRUECOLOR` to 1, which
89
+ is supported for backward compatibility).
90
+
91
+ * `solarized-tc`: this is the solarized colorscheme for true color.
92
+ * `atom-dark`: this colorscheme is based off of Atom's "dark" colorscheme.
93
+ * `cmc-tc`: A true colour variant of the cmc theme. It requires true color to
94
+ look its best. Use cmc-16 if your terminal doesn't support true color.
95
+ * `gruvbox-tc`: The true color version of the gruvbox colorscheme
96
+ * `material-tc`: Colorscheme based off of Google's Material Design palette
97
+
98
+ ## Creating a Colorscheme
99
+
100
+ Micro's colorschemes are also extremely simple to create. The default ones can
101
+ be found
102
+ [here](https://github.com/micro-editor/micro/tree/master/runtime/colorschemes).
103
+
104
+ Custom colorschemes should be placed in the `~/.config/micro/colorschemes`
105
+ directory.
106
+
107
+ A number of custom directives are placed in a `.micro` file. Colorschemes are
108
+ typically only 18-30 lines in total.
109
+
110
+ To create the colorscheme you need to link highlight groups with
111
+ actual colors. This is done using the `color-link` command.
112
+
113
+ For example, to highlight all comments in green, you would use the command:
114
+
115
+ ```
116
+ color-link comment "green"
117
+ ```
118
+
119
+ Background colors can also be specified with a comma:
120
+
121
+ ```
122
+ color-link comment "green,blue"
123
+ ```
124
+
125
+ This will give the comments a blue background.
126
+
127
+ If you would like no foreground you can just use a comma with nothing in front:
128
+
129
+ ```
130
+ color-link comment ",blue"
131
+ ```
132
+
133
+ You can also put bold, italic, or underline in front of the color:
134
+
135
+ ```
136
+ color-link comment "bold red"
137
+ ```
138
+
139
+ ---
140
+
141
+ There are three different ways to specify the color.
142
+
143
+ Color terminals usually have 16 colors that are preset by the user. This means
144
+ that you cannot depend on those colors always being the same. You can use those
145
+ colors with the names `black, red, green, yellow, blue, magenta, cyan, white`
146
+ and the bright variants of each one (brightblack, brightred...).
147
+
148
+ Then you can use the terminals 256 colors by using their numbers 1-256 (numbers
149
+ 1-16 will refer to the named colors).
150
+
151
+ If the user's terminal supports true color, then you can also specify colors
152
+ exactly using their hex codes. If the terminal is not true color but micro is
153
+ told to use a true color colorscheme it will attempt to map the colors to the
154
+ available 256 colors.
155
+
156
+ Generally colorschemes which require true color terminals to look good are
157
+ marked with a `-tc` suffix and colorschemes which supply a white background are
158
+ marked with a `-paper` suffix.
159
+
160
+ ---
161
+
162
+ Here is a list of the colorscheme groups that you can use:
163
+
164
+ * default (color of the background and foreground for unhighlighted text)
165
+ * comment
166
+ * identifier
167
+ * constant
168
+ * statement
169
+ * symbol
170
+ * preproc
171
+ * type
172
+ * special
173
+ * underlined
174
+ * error
175
+ * todo
176
+ * selection (Color of the text selection)
177
+ * statusline (Color of the statusline)
178
+ * statusline.inactive (Color of the statusline of inactive split panes)
179
+ * statusline.suggestions (Color of the autocomplete suggestions menu)
180
+ * tabbar (Color of the tabbar that lists open files)
181
+ * tabbar.active (Color of the active tab in the tabbar)
182
+ * indent-char (Color of the character which indicates tabs if the option is
183
+ enabled)
184
+ * line-number
185
+ * gutter-info
186
+ * gutter-error
187
+ * gutter-warning
188
+ * diff-added
189
+ * diff-modified
190
+ * diff-deleted
191
+ * cursor-line
192
+ * current-line-number
193
+ * color-column
194
+ * ignore
195
+ * scrollbar
196
+ * divider (Color of the divider between vertical splits)
197
+ * message (Color of messages in the bottom line of the screen)
198
+ * error-message (Color of error messages in the bottom line of the screen)
199
+ * match-brace (Color of matching brackets when `matchbracestyle` is set to `highlight`)
200
+ * hlsearch (Color of highlighted search results when `hlsearch` is enabled)
201
+ * tab-error (Color of tab vs space errors when `hltaberrors` is enabled)
202
+ * trailingws (Color of trailing whitespaces when `hltrailingws` is enabled)
203
+
204
+ Colorschemes must be placed in the `~/.config/micro/colorschemes` directory to
205
+ be used.
206
+
207
+ ---
208
+
209
+ In addition to the main colorscheme groups, there are subgroups that you can
210
+ specify by adding `.subgroup` to the group. If you're creating your own custom
211
+ syntax files, you can make use of your own subgroups.
212
+
213
+ If micro can't match the subgroup, it'll default to the root group, so it's
214
+ safe and recommended to use subgroups in your custom syntax files.
215
+
216
+ For example if `constant.string` is found in your colorscheme, micro will us
217
+ that for highlighting strings. If it's not found, it will use constant instead.
218
+ Micro tries to match the largest set of groups it can find in the colorscheme
219
+ definitions, so if, for example `constant.bool.true` is found then micro will
220
+ use that. If `constant.bool.true` is not found but `constant.bool` is found
221
+ micro will use `constant.bool`. If not, it uses `constant`.
222
+
223
+ Here's a list of subgroups used in micro's built-in syntax files.
224
+
225
+ * comment.bright (Some filetypes have distinctions between types of comments)
226
+ * constant.bool
227
+ * constant.bool.true
228
+ * constant.bool.false
229
+ * constant.number
230
+ * constant.specialChar
231
+ * constant.string
232
+ * constant.string.url
233
+ * identifier.class (Also used for functions)
234
+ * identifier.macro
235
+ * identifier.var
236
+ * preproc.shebang (The #! at the beginning of a file that tells the os what
237
+ script interpreter to use)
238
+ * symbol.brackets (`{}()[]` and sometimes `<>`)
239
+ * symbol.operator (Color operator symbols differently)
240
+ * symbol.tag (For html tags, among other things)
241
+ * type.keyword (If you want a special highlight for keywords like `private`)
242
+
243
+ In the future, plugins may also be able to use color groups for styling.
244
+
245
+ ---
246
+
247
+ Last but not least it's even possible to use `include` followed by the
248
+ colorscheme name as string to include a different colorscheme within a new one.
249
+ Additionally the groups can then be extended or overwritten. The `default.micro`
250
+ theme can be seen as an example, which links to the chosen default colorscheme.
251
+
252
+ ## Syntax files
253
+
254
+ The syntax files are written in yaml-format and specify how to highlight
255
+ languages.
256
+
257
+ Micro's builtin syntax highlighting tries very hard to be sane, sensible and
258
+ provide ample coverage of the meaningful elements of a language. Micro has
259
+ syntax files built in for over 100 languages now! However, there may be
260
+ situations where you find Micro's highlighting to be insufficient or not to
261
+ your liking. The good news is that you can create your own syntax files, and
262
+ place them in `~/.config/micro/syntax` and Micro will use those instead.
263
+
264
+ ### Filetype definition
265
+
266
+ You must start the syntax file by declaring the filetype:
267
+
268
+ ```
269
+ filetype: go
270
+ ```
271
+
272
+ ### Detect definition
273
+
274
+ Then you must provide information about how to detect the filetype:
275
+
276
+ ```
277
+ detect:
278
+ filename: "\\.go$"
279
+ ```
280
+
281
+ Micro will match this regex against a given filename to detect the filetype.
282
+
283
+ In addition to the `filename` regex (or even instead of it) you can provide
284
+ a `header` regex that will check the first line of the file. For example:
285
+
286
+ ```
287
+ detect:
288
+ filename: "\\.ya?ml$"
289
+ header: "%YAML"
290
+ ```
291
+
292
+ This is useful in cases when the given file name is not sufficient to determine
293
+ the filetype, e.g. with the above example, if a YAML file has no `.yaml`
294
+ extension but may contain a `%YAML` directive in its first line.
295
+
296
+ `filename` takes precedence over `header`, i.e. if there is a syntax file that
297
+ matches the file with a filetype by the `filename` and another syntax file that
298
+ matches the same file with another filetype by the `header`, the first filetype
299
+ will be used.
300
+
301
+ Finally, in addition to `filename` and/or `header` (but not instead of them)
302
+ you may also provide an optional `signature` regex which is useful for resolving
303
+ ambiguities when there are multiple syntax files matching the same file with
304
+ different filetypes. If a `signature` regex is given, micro will match a certain
305
+ amount of first lines in the file (this amount is determined by the `detectlimit`
306
+ option) against this regex, and if any of the lines match, this syntax file's
307
+ filetype will be preferred over other matching filetypes.
308
+
309
+ For example, to distinguish C++ header files from C and Objective-C header files
310
+ that have the same `.h` extension:
311
+
312
+ ```
313
+ detect:
314
+ filename: "\\.c(c|pp|xx)$|\\.h(h|pp|xx)?$"
315
+ signature: "namespace|template|public|protected|private"
316
+ ```
317
+
318
+ ### Syntax rules
319
+
320
+ Next you must provide the syntax highlighting rules. There are two types of
321
+ rules: patterns and regions. A pattern is matched on a single line and usually
322
+ a single word as well. A region highlights between two patterns over multiple
323
+ lines and may have rules of its own inside the region.
324
+
325
+ Here are some example patterns in Go:
326
+
327
+ ```
328
+ rules:
329
+ - special: "\\b(break|case|continue|default|go|goto|range|return)\\b"
330
+ - statement: "\\b(else|for|if|switch)\\b"
331
+ - preproc: "\\b(package|import|const|var|type|struct|func|go|defer|iota)\\b"
332
+ ```
333
+
334
+ The order of patterns does matter as patterns lower in the file will overwrite
335
+ the ones defined above them.
336
+
337
+ And here are some example regions for Go:
338
+
339
+ ```
340
+ - constant.string:
341
+ start: "\""
342
+ end: "\""
343
+ rules:
344
+ - constant.specialChar: "%."
345
+ - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
346
+ - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
347
+
348
+ - comment:
349
+ start: "//"
350
+ end: "$"
351
+ rules:
352
+ - todo: "(TODO|XXX|FIXME):?"
353
+
354
+ - comment:
355
+ start: "/\\*"
356
+ end: "\\*/"
357
+ rules:
358
+ - todo: "(TODO|XXX|FIXME):?"
359
+ ```
360
+
361
+ Notice how the regions may contain rules inside of them. Any inner rules that
362
+ are matched are then skipped when searching for the end of the region. For
363
+ example, when highlighting `"foo \" bar"`, since `\"` is matched by an inner
364
+ rule in the region, it is skipped. Likewise for `"foo \\" bar`, since `\\` is
365
+ matched by an inner rule, it is skipped, and then the `"` is found and the
366
+ string ends at the correct place.
367
+
368
+ You may also explicitly mark skip regexes if you don't want them to be
369
+ highlighted. For example:
370
+
371
+ ```
372
+ - constant.string:
373
+ start: "\""
374
+ end: "\""
375
+ skip: "\\."
376
+ ```
377
+
378
+ #### Includes
379
+
380
+ You may also include rules from other syntax files as embedded languages. For
381
+ example, the following is possible for html:
382
+
383
+ ```
384
+ - default:
385
+ start: "<script.*?>"
386
+ end: "</script.*?>"
387
+ rules:
388
+ - include: "javascript"
389
+
390
+ - default:
391
+ start: "<style.*?>"
392
+ end: "</style.*?>"
393
+ rules:
394
+ - include: "css"
395
+ ```
396
+
397
+ Note that nested include (i.e. including syntax files that include other syntax
398
+ files) is not supported yet.
399
+
400
+ ### Default syntax highlighting
401
+
402
+ If micro cannot detect the filetype of the file, it falls back to using the
403
+ default syntax highlighting for it, which highlights just the bare minimum:
404
+ email addresses, URLs etc.
405
+
406
+ Just like in other cases, you can override the default highlighting by adding
407
+ your own custom `default.yaml` file to `~/.config/micro/syntax`.
408
+
409
+ For example, if you work with various config files that use the `#` sign to mark
410
+ the beginning of a comment, you can use the following custom `default.yaml` to
411
+ highlight those comments by default:
412
+
413
+ ```
414
+ filetype: unknown
415
+
416
+ detect:
417
+ filename: ""
418
+
419
+ rules:
420
+ - comment: "(^|\\s)#.*$"
421
+ ```
@@ -0,0 +1,161 @@
1
+ # Command bar
2
+
3
+ The command bar is opened by pressing `Ctrl-e`. It is a single-line buffer,
4
+ meaning that all keybindings from a normal buffer are supported (as well
5
+ as mouse and selection).
6
+
7
+ When running a command, you can use extra syntax that micro will expand before
8
+ running the command. To use an argument with a space in it, put it in
9
+ quotes. The command bar parser uses the same rules for parsing arguments that
10
+ `/bin/sh` would use (single quotes, double quotes, escaping). The command bar
11
+ does not look up environment variables.
12
+
13
+ # Commands
14
+
15
+ Micro provides the following commands that can be executed at the command-bar
16
+ by pressing `Ctrl-e` and entering the command. Arguments are placed in single
17
+ quotes here but these are not necessary when entering the command in micro.
18
+
19
+ * `bind 'key' 'action'`: creates a keybinding from key to action. See the
20
+ `keybindings` documentation for more information about binding keys.
21
+ This command will modify `bindings.json` and overwrite any bindings to
22
+ `key` that already exist.
23
+
24
+ * `help ['topic'] ['flags']`: opens the corresponding help topics.
25
+ If no topic is provided opens the default help screen. If multiple topics are
26
+ provided (separated via ` `) they are opened all as splits.
27
+ Help topics are stored as `.md` files in the `runtime/help` directory of
28
+ the source tree, which is embedded in the final binary.
29
+ The `flags` are optional.
30
+ * `-hsplit`: Opens the help topic in a horizontal split
31
+ * `-vsplit`: Opens the help topic in a vertical split
32
+
33
+ The default split type is defined by the global `helpsplit` option.
34
+
35
+ * `save ['filename']`: saves the current buffer. If the file is provided it
36
+ will 'save as' the filename.
37
+
38
+ * `quit`: quits micro.
39
+
40
+ * `goto 'line[:col]'`: goes to the given absolute line (and optional column)
41
+ number.
42
+ A negative number can be passed to go inward from the end of the file.
43
+ Example: -5 goes to the 5th-last line in the file.
44
+
45
+ * `jump 'line[:col]'`: goes to the given relative number from the current
46
+ line (and optional absolute column) number.
47
+ Example: -5 jumps 5 lines up in the file, while (+)3 jumps 3 lines down.
48
+
49
+ * `replace 'search' 'value' ['flags']`: This will replace `search` with `value`.
50
+ The `flags` are optional. Possible flags are:
51
+ * `-a`: Replace all occurrences at once
52
+ * `-l`: Do a literal search instead of a regex search
53
+
54
+ Note that `search` must be a valid regex (unless `-l` is passed). If one
55
+ of the arguments does not have any spaces in it, you may omit the quotes.
56
+
57
+ In case the search is done non-literal (without `-l`), the 'value'
58
+ is interpreted as a template:
59
+ * `$3` or `${3}` substitutes the submatch of the 3rd (capturing group)
60
+ * `$foo` or `${foo}` substitutes the submatch of the (?P<foo>named group)
61
+ * You have to write `$$` to substitute a literal dollar.
62
+
63
+ * `replaceall 'search' 'value'`: this will replace all occurrences of `search`
64
+ with `value` without user confirmation.
65
+
66
+ See `replace` command for more information.
67
+
68
+ * `set 'option' 'value'`: sets the option to value. See the `options` help
69
+ topic for a list of options you can set. This will modify your
70
+ `settings.json` with the new value.
71
+
72
+ * `setlocal 'option' 'value'`: sets the option to value locally (only in the
73
+ current buffer). This will *not* modify `settings.json`.
74
+
75
+ * `toggle 'option'`: toggles the option. Only works with options that accept
76
+ exactly two values. This will modify your `settings.json` with the new value.
77
+
78
+ * `togglelocal 'option'`: toggles the option locally (only in the
79
+ current buffer). Only works with options that accept exactly two values.
80
+ This will *not* modify `settings.json`.
81
+
82
+ * `reset 'option'`: resets the given option to its default value.
83
+
84
+ * `show 'option'`: shows the current value of the given option.
85
+
86
+ * `showkey 'key'`: Show the action(s) bound to a given key. For example
87
+ running `> showkey Ctrl-c` will display `Copy`.
88
+
89
+ * `run 'sh-command'`: runs the given shell command in the background. The
90
+ command's output will be displayed in one line when it finishes running.
91
+
92
+ * `vsplit ['filename']`: opens a vertical split with `filename`. If no filename
93
+ is provided, a vertical split is opened with an empty buffer. If multiple
94
+ files are provided (separated via ` `) they are opened all as splits.
95
+
96
+ * `hsplit ['filename']`: same as `vsplit` but opens a horizontal split instead
97
+ of a vertical split.
98
+
99
+ * `tab ['filename']`: opens the given file in a new tab. If no filename
100
+ is provided, a tab is opened with an empty buffer. If multiple files are
101
+ provided (separated via ` `) they are opened all as tabs.
102
+
103
+ * `tabmove '[-+]n'`: Moves the active tab to another slot. `n` is an integer.
104
+ If `n` is prefixed with `-` or `+`, then it represents a relative position
105
+ (e.g. `tabmove +2` moves the tab to the right by `2`). If `n` has no prefix,
106
+ it represents an absolute position (e.g. `tabmove 2` moves the tab to slot `2`).
107
+
108
+ * `tabswitch 'tab'`: This command will switch to the specified tab. The `tab`
109
+ can either be a tab number, or a name of a tab.
110
+
111
+ * `textfilter 'sh-command'`: filters the current selection through a shell
112
+ command as standard input and replaces the selection with the stdout of
113
+ the shell command. For example, to sort a list of numbers, first select
114
+ them, and then execute `> textfilter sort -n`.
115
+
116
+ * `log`: opens a log of all messages and debug statements.
117
+
118
+ * `plugin list`: lists all installed plugins.
119
+
120
+ * `plugin install 'pl'`: install a plugin.
121
+
122
+ * `plugin remove 'pl'`: remove a plugin.
123
+
124
+ * `plugin update ['pl']`: update a plugin (if no arguments are provided
125
+ updates all plugins).
126
+
127
+ * `plugin search 'pl'`: search available plugins for a keyword.
128
+
129
+ * `plugin available`: show available plugins that can be installed.
130
+
131
+ * `reload`: reloads all runtime files (settings, keybindings, syntax files,
132
+ colorschemes, plugins). All plugins will be unloaded by running their
133
+ `deinit()` function (if it exists), and then loaded again by calling the
134
+ `preinit()`, `init()` and `postinit()` functions (if they exist).
135
+
136
+ * `cd 'path'`: Change the working directory to the given `path`.
137
+
138
+ * `pwd`: Print the current working directory.
139
+
140
+ * `open 'filename'`: Open a file in the current buffer.
141
+
142
+ * `reopen`: Reopens the current file from disk.
143
+
144
+ * `retab`: Replaces all leading tabs with spaces or leading spaces with tabs
145
+ depending on the value of `tabstospaces`.
146
+
147
+ * `raw`: micro will open a new tab and show the escape sequence for every event
148
+ it receives from the terminal. This shows you what micro actually sees from
149
+ the terminal and helps you see which bindings aren't possible and why. This
150
+ is most useful for debugging keybindings.
151
+
152
+ * `term ['exec']`: Open a terminal emulator running the given executable. If no
153
+ executable is given, this will open the default shell in the terminal
154
+ emulator.
155
+
156
+ ---
157
+
158
+ The following commands are provided by the default plugins:
159
+
160
+ * `lint`: Lint the current file for errors.
161
+ * `comment`: automatically comment or uncomment current selection or line.