mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-31 07:07:09 +09:00
Merge branch 'master' into patch-1
This commit is contained in:
@@ -16,7 +16,8 @@ color-link identifier "#9B703F"
|
||||
color-link identifier.class "#DAD085"
|
||||
color-link identifier.var "#7587A6"
|
||||
color-link indent-char "#515151"
|
||||
color-link line-number "#868686"
|
||||
color-link line-number "#868686,#1B1B1B"
|
||||
color-link current-line-number "#868686,#141414"
|
||||
color-link preproc "#E0C589"
|
||||
color-link special "#E0C589"
|
||||
color-link statement "#CDA869"
|
||||
|
||||
@@ -2,48 +2,62 @@
|
||||
|
||||
This help page aims to cover two aspects of micro's syntax highlighting engine:
|
||||
|
||||
- How to create colorschemes and use them
|
||||
- How to create syntax files to add to the list of languages micro can highlight
|
||||
|
||||
- How to create colorschemes and use them.
|
||||
- How to create syntax files to add to the list of languages micro can highlight.
|
||||
|
||||
## Colorschemes
|
||||
|
||||
To change your colorscheme, press Ctrl-E in micro to bring up the command
|
||||
prompt, and type:
|
||||
|
||||
```
|
||||
set colorscheme solarized
|
||||
set colorscheme monokai
|
||||
```
|
||||
|
||||
(or whichever colorscheme you choose).
|
||||
|
||||
Micro comes with a number of colorschemes by default. Here is the list:
|
||||
Micro comes with a number of colorschemes by default. Modern terminals tend to
|
||||
have three different kinds of color support. The most common is 256 color where
|
||||
the terminal provides 256 standardized colors (except the first 16 may be configured
|
||||
by the user). A 256-color theme requires a terminal with 256 color support and
|
||||
is the most portable.
|
||||
|
||||
A 16-color theme uses the 16 user-configurable colors (or 16 default colors on
|
||||
old terminals). These colorschemes are guranteed to work, but won't look great
|
||||
unless the 16 colors are configured to the user's liking. Using a 16-color theme
|
||||
will also preserve the terminal's theme because the terminal usually uses its 16
|
||||
colors for prompts or other coloring.
|
||||
|
||||
Some terminals support "true color" with 16 million colors (using standard RGB values).
|
||||
There is no one standard for this color support among terminals so this method
|
||||
is not guaranteed to work. Usually truecolor must also be enabled by the user. The
|
||||
colorschemes using true color will look exactly as intended. If true color is not
|
||||
supported, a true color colorscheme will approximate its colors to 256-color.
|
||||
|
||||
Here is the list of colorschemes:
|
||||
|
||||
### 256 color
|
||||
|
||||
These should work and look nice in most terminals. I recommend these
|
||||
themes the most.
|
||||
|
||||
* `monokai`: this is the monokai colorscheme; you may recognize it as Sublime
|
||||
Text's default colorscheme. It requires true color to look perfect, but the
|
||||
256 color approximation looks very good as well. It's also the default
|
||||
colorscheme.
|
||||
* `monokai` (also the `default` colorscheme)
|
||||
* `zenburn`
|
||||
* `gruvbox`
|
||||
* `darcula`
|
||||
* `twilight`
|
||||
* `railscast`
|
||||
* `bubblegum`: a light colorscheme
|
||||
* `bubblegum`
|
||||
|
||||
### 16 color
|
||||
|
||||
These may vary widely based on the 16 colors selected for your terminal.
|
||||
|
||||
* `simple`: this is the simplest colorscheme. It uses 16 colors which are set by
|
||||
your terminal
|
||||
* `solarized`: You should have the solarized color palette in your terminal to use this colorscheme properly.
|
||||
* `simple`
|
||||
* `solarized` (must have the solarized color palette in your terminal to use this colorscheme properly)
|
||||
* `cmc-16`
|
||||
* `cmc-paper`: cmc-16, but on a white background. (Actually light grey
|
||||
on most ANSI (16-color) terminals)
|
||||
* `geany`: Colorscheme based on geany's default highlighting.
|
||||
* `cmc-paper`
|
||||
* `geany`
|
||||
|
||||
### True color
|
||||
|
||||
@@ -56,22 +70,10 @@ These require terminals that support true color and require `MICRO_TRUECOLOR=1`
|
||||
* `gruvbox-tc`: The true color version of the gruvbox colorscheme
|
||||
* `github-tc`: The true color version of the Github colorscheme
|
||||
|
||||
### Monochrome
|
||||
|
||||
You can also use `monochrome` if you'd prefer to have just the terminal's default
|
||||
foreground and background colors. Note: This provides no syntax highlighting!
|
||||
|
||||
### Other
|
||||
|
||||
See `help gimmickcolors` for a list of some true colour themes that are more
|
||||
just for fun than for serious use. (Though feel free if you want!)
|
||||
|
||||
|
||||
## Creating a Colorscheme
|
||||
|
||||
Micro's colorschemes are also extremely simple to create. The default ones can
|
||||
be found
|
||||
[here](https://github.com/zyedidia/micro/tree/master/runtime/colorschemes).
|
||||
be found [here](https://github.com/zyedidia/micro/tree/master/runtime/colorschemes).
|
||||
|
||||
They are only about 18-30 lines in total.
|
||||
|
||||
|
||||
@@ -29,9 +29,6 @@ Here are the possible commands that you can use.
|
||||
|
||||
* `show option`: shows the current value of the given option.
|
||||
|
||||
* `eval "expression"`: Evaluates a Lua expression. Note that micro will not
|
||||
print anything so you should use `messenger:Message(...)` to display a value.
|
||||
|
||||
* `run sh-command`: runs the given shell command in the background. The
|
||||
command's output will be displayed in one line when it finishes running.
|
||||
|
||||
@@ -48,26 +45,19 @@ Here are the possible commands that you can use.
|
||||
|
||||
* `tabswitch tab`: This command will switch to the specified tab. The `tab` can
|
||||
either be a tab number, or a name of a tab.
|
||||
|
||||
* `textfilter sh-command`: filters the current selection through a shell command
|
||||
as standard input and replaces the selection with the stdout of the shell command.
|
||||
For example, to sort a list of numbers, first select them, and then execute
|
||||
`> textfilter sort -n`.
|
||||
|
||||
* `log`: opens a log of all messages and debug statements.
|
||||
|
||||
* `plugin install plugin_name`: installs the given plugin.
|
||||
|
||||
* `plugin remove plugin_name`: removes the given plugin.
|
||||
|
||||
* `plugin list`: lists all installed plugins.
|
||||
|
||||
* `plugin update`: updates all installed plugins.
|
||||
* `plugin version pl`: shows version for specified plugin.
|
||||
|
||||
* `plugin search plugin_name`: searches for the given plugin. Note that you can
|
||||
find a list of all available plugins at
|
||||
github.com/micro-editor/plugin-channel.
|
||||
|
||||
You can also see more information about the plugin manager in the
|
||||
`Plugin Manager` section of the `plugins` help topic.
|
||||
|
||||
* `plugin available`: list plugins available for download (this includes any
|
||||
plugins that may be already installed).
|
||||
* `plugin info pl`: shows additional info for specified plugin.
|
||||
|
||||
* `reload`: reloads all runtime files.
|
||||
|
||||
@@ -77,6 +67,8 @@ Here are the possible commands that you can use.
|
||||
|
||||
* `open filename`: Open a file in the current buffer.
|
||||
|
||||
* `reset option`: resets the given option to its default value
|
||||
|
||||
* `retab`: Replaces all leading tabs with spaces or leading spaces with tabs
|
||||
depending on the value of `tabstospaces`.
|
||||
|
||||
@@ -96,6 +88,8 @@ The following commands are provided by the default plugins:
|
||||
|
||||
* `lint`: Lint the current file for errors.
|
||||
|
||||
* `comment`: automatically comment or uncomment current selection or line.
|
||||
|
||||
# Command Parsing
|
||||
|
||||
When running a command, you can use extra syntax that micro will expand before
|
||||
|
||||
@@ -10,29 +10,29 @@ can change it!
|
||||
### Power user
|
||||
|
||||
| Key | Description of function |
|
||||
|-------- |-------------------------------------------------------------------------------------------------- |
|
||||
|---------- |-------------------------------------------------------------------------------------------------- |
|
||||
| Ctrl+E | Open a command prompt for running commands (see `> help commands` for a list of valid commands). |
|
||||
| Tab | In command prompt, it will autocomplete if possible. |
|
||||
| Ctrl+B | Run a shell command (this will close micro while your command executes). |
|
||||
|
||||
### Navigation
|
||||
|
||||
| Key | Description of function |
|
||||
|-------------------------- |------------------------------------------------------------------------------------------ |
|
||||
| Arrows | Move the cursor around |
|
||||
| Shift+arrows | Move and select text |
|
||||
| Home or CtrlLeftArrow | Move to the beginning of the current line |
|
||||
| End or CtrlRightArrow | Move to the end of the current line |
|
||||
| AltLeftArrow | Move cursor one word left |
|
||||
| AltRightArrow | Move cursor one word right |
|
||||
| Alt+{ | Move cursor to previous empty line, or beginning of document |
|
||||
| Alt+} | Move cursor to next empty line, or end of document |
|
||||
| PageUp | Move cursor up one page |
|
||||
| PageDown | Move cursor down one page |
|
||||
| CtrlHome or CtrlUpArrow | Move cursor to start of document |
|
||||
| CtrlEnd or CtrlDownArrow | Move cursor to end of document |
|
||||
| Ctrl+L | Jump to a line in the file (prompts with #) |
|
||||
| Ctrl+W | Cycle between splits in the current tab (use `> vsplit` or `> hsplit` to create a split) |
|
||||
| Key | Description of function |
|
||||
|--------------------------- |------------------------------------------------------------------------------------------ |
|
||||
| Arrows | Move the cursor around |
|
||||
| Shift+arrows | Move and select text |
|
||||
| Home or Ctrl+LeftArrow | Move to the beginning of the current line |
|
||||
| End or Ctrl+RightArrow | Move to the end of the current line |
|
||||
| Alt+LeftArrow | Move cursor one word left |
|
||||
| Alt+RightArrow | Move cursor one word right |
|
||||
| Alt+{ | Move cursor to previous empty line, or beginning of document |
|
||||
| Alt+} | Move cursor to next empty line, or end of document |
|
||||
| PageUp | Move cursor up one page |
|
||||
| PageDown | Move cursor down one page |
|
||||
| Ctrl+Home or Ctrl+UpArrow | Move cursor to start of document |
|
||||
| Ctrl+End or Ctrl+DownArrow | Move cursor to end of document |
|
||||
| Ctrl+L | Jump to a line in the file (prompts with #) |
|
||||
| Ctrl+W | Cycle between splits in the current tab (use `> vsplit` or `> hsplit` to create a split) |
|
||||
|
||||
### Tabs
|
||||
|
||||
@@ -45,7 +45,7 @@ can change it!
|
||||
### Find Operations
|
||||
|
||||
| Key | Description of function |
|
||||
|-------- |------------------------------------------ |
|
||||
|---------- |------------------------------------------ |
|
||||
| Ctrl+F | Find (opens prompt) |
|
||||
| Ctrl+N | Find next instance of current search |
|
||||
| Ctrl+P | Find previous instance of current search |
|
||||
@@ -53,55 +53,55 @@ can change it!
|
||||
### File Operations
|
||||
|
||||
| Key | Description of function |
|
||||
|-------- |---------------------------------------------------------------- |
|
||||
|---------- |------------------------------------------------------------------ |
|
||||
| Ctrl+Q | Close current file (quits micro if this is the last file open) |
|
||||
| Ctrl+O | Open a file (prompts for filename) |
|
||||
| Ctrl+S | Save current file |
|
||||
|
||||
### Text operations
|
||||
|
||||
| Key | Description of function |
|
||||
|--------------------------------- |------------------------------------------ |
|
||||
| AltShiftRightArrow | Select word right |
|
||||
| AltShiftLeftArrow | Select word left |
|
||||
| ShiftHome or CtrlShiftLeftArrow | Select to start of current line |
|
||||
| ShiftEnd or CtrlShiftRightArrow | Select to end of current line |
|
||||
| CtrlShiftUpArrow | Select to start of file |
|
||||
| CtrlShiftDownArrow | Select to end of file |
|
||||
| Ctrl+X | Cut selected text |
|
||||
| Ctrl+C | Copy selected text |
|
||||
| Ctrl+V | Paste |
|
||||
| Ctrl+K | Cut current line |
|
||||
| Ctrl+D | Duplicate current line |
|
||||
| Ctrl+Z | Undo |
|
||||
| Ctrl+Y | Redo |
|
||||
| AltUpArrow | Move current line or selected lines up |
|
||||
| AltDownArrow | Move current line of selected lines down |
|
||||
| AltBackspace or AltCtrl+H | Delete word left |
|
||||
| Ctrl+A | Select all |
|
||||
| Key | Description of function |
|
||||
|------------------------------------ |------------------------------------------ |
|
||||
| Alt+Shift+RightArrow | Select word right |
|
||||
| Alt+Shift+LeftArrow | Select word left |
|
||||
| Shift+Home or Ctrl+Shift+LeftArrow | Select to start of current line |
|
||||
| Shift+End or Ctrl+Shift+RightArrow | Select to end of current line |
|
||||
| Ctrl+Shift+UpArrow | Select to start of file |
|
||||
| Ctrl+Shift+DownArrow | Select to end of file |
|
||||
| Ctrl+X | Cut selected text |
|
||||
| Ctrl+C | Copy selected text |
|
||||
| Ctrl+V | Paste |
|
||||
| Ctrl+K | Cut current line |
|
||||
| Ctrl+D | Duplicate current line |
|
||||
| Ctrl+Z | Undo |
|
||||
| Ctrl+Y | Redo |
|
||||
| Alt+UpArrow | Move current line or selected lines up |
|
||||
| Alt+DownArrow | Move current line of selected lines down |
|
||||
| Alt+Backspace or Alt+Ctrl+H | Delete word left |
|
||||
| Ctrl+A | Select all |
|
||||
|
||||
### Macros
|
||||
|
||||
| Key | Description of function |
|
||||
|-------- |---------------------------------------------------------------------------------- |
|
||||
|---------- |---------------------------------------------------------------------------------- |
|
||||
| Ctrl+U | Toggle macro recording (press Ctrl+U to start recording and press again to stop) |
|
||||
| Ctrl+J | Run latest recorded macro |
|
||||
|
||||
### Multiple cursors
|
||||
|
||||
| Key | Description of function |
|
||||
|---------------- |---------------------------------------------------------------------------------------------- |
|
||||
|------------------ |---------------------------------------------------------------------------------------------- |
|
||||
| Alt+N | Create new multiple cursor from selection (will select current word if no current selection) |
|
||||
| Alt+P | Remove latest multiple cursor |
|
||||
| Alt+C | Remove all multiple cursors (cancel) |
|
||||
| Alt+X | Skip multiple cursor selection |
|
||||
| Alt+M | Spawn a new cursor at the beginning of every line in the current selection |
|
||||
| Ctrl-MouseLeft | Place a multiple cursor at any location |
|
||||
| Ctrl+MouseLeft | Place a multiple cursor at any location |
|
||||
|
||||
### Other
|
||||
|
||||
| Key | Description of function |
|
||||
|-------- |----------------------------------------------------------------------------------- |
|
||||
|---------- |-------------------------------------------------------------------------------------- |
|
||||
| Ctrl+G | Open help file |
|
||||
| Ctrl+H | Backspace (old terminals do not support the backspace key and use Ctrl+H instead) |
|
||||
| Ctrl+R | Toggle the line number ruler |
|
||||
@@ -109,7 +109,7 @@ can change it!
|
||||
### Emacs style actions
|
||||
|
||||
| Key | Description of function |
|
||||
|------- |------------------------- |
|
||||
|---------- |-------------------------- |
|
||||
| Alt+F | Next word |
|
||||
| Alt+B | Previous word |
|
||||
| Alt+A | Move to start of line |
|
||||
@@ -120,7 +120,7 @@ can change it!
|
||||
Warning! The function keys may not work in all terminals!
|
||||
|
||||
| Key | Description of function |
|
||||
|----- |------------------------- |
|
||||
|------ |-------------------------- |
|
||||
| F1 | Open help |
|
||||
| F2 | Save |
|
||||
| F3 | Find |
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# Gimmick colors
|
||||
|
||||
We have included a few colorschemes that are for fun:
|
||||
|
||||
* funky-cactus: I don't know why I made this. (Written by CaptainMcClellan)
|
||||
* gameboy-tc: Colorscheme based on the olive green original Gameboy!
|
||||
* nes-tc: A colorscheme and syntax highlighting using only colors in the
|
||||
Nintendo Entertainment System color palette.
|
||||
* symbian-tc: Colorscheme based on SymbOS's GUI.
|
||||
* matrix: Pretend it's 1981 with a colorscheme based on a monochrome
|
||||
IBM 5151. (Does not include the ghosting and trailing)
|
||||
|
||||
Check the plugin repo periodically for gimmick-color extension packs and genuine
|
||||
additional themes.
|
||||
@@ -1,25 +1,23 @@
|
||||
# Micro help text
|
||||
|
||||
Thank you for downloading and using micro.
|
||||
|
||||
Micro is a terminal-based text editor that aims to be easy to use and intuitive,
|
||||
while also taking advantage of the full capabilities of modern terminals.
|
||||
|
||||
To open the command bar, press CtrlE. This enables a `>` prompt for typing
|
||||
commands. From now on when the documentation says to run a command such as
|
||||
`> help`, this means press CtrlE and type `help` (and press enter to execute
|
||||
the command).
|
||||
|
||||
|
||||
For a list of the default keybindings press CtrlE and type `help defaultkeys`.
|
||||
For a list of the default keybindings run `> help defaultkeys`.
|
||||
For more information on keybindings see `> help keybindings`.
|
||||
|
||||
See the next section for more information about documentation and help.
|
||||
|
||||
## Quick-start
|
||||
|
||||
Press CtrlQ to quit, and CtrlS to save. Press CtrlE to start typing commands and
|
||||
you can see which commands are available by pressing tab, or by viewing the help
|
||||
topic `> help commands`. When I write `> ...` I mean press CtrlE and then type
|
||||
whatever is there.
|
||||
topic `> help commands`.
|
||||
|
||||
Move the cursor around with the mouse or the arrow keys. Type
|
||||
Move the cursor around with the mouse or the arrow keys. Run
|
||||
`> help defaultkeys` to get a quick, easy overview of the default hotkeys and
|
||||
what they do. For more info on rebinding keys, see type `> help keybindings`.
|
||||
|
||||
@@ -30,7 +28,6 @@ see more information with `> help colors`.
|
||||
Press CtrlW to move between splits, and type `> vsplit filename` or
|
||||
`> hsplit filename` to open a new split.
|
||||
|
||||
|
||||
## Accessing more help
|
||||
|
||||
Micro has a built-in help system much like Vim's (although less extensive).
|
||||
@@ -53,8 +50,7 @@ Here are the possible help topics that you can read:
|
||||
* colors: Explains micro's colorscheme and syntax highlighting engine and how to
|
||||
create your own colorschemes or add new languages to the engine
|
||||
|
||||
For example, to open the help page on plugins you would press CtrlE and type
|
||||
`help plugins`.
|
||||
For example, to open the help page on plugins you would run `> help plugins`.
|
||||
|
||||
I recommend looking at the `tutorial` help file because it is short for each
|
||||
section and gives concrete examples of how to use the various configuration
|
||||
|
||||
@@ -5,10 +5,11 @@ hotkeys are fully customizable to your liking.
|
||||
|
||||
Custom keybindings are stored internally in micro if changed with the `> bind`
|
||||
command or you can also be added in the file `~/.config/micro/bindings.json` as
|
||||
discussed below. For a list of the default keybindings in the json format used
|
||||
discussed below. For a list of the default keybindings in the json format used
|
||||
by micro, please see the end of this file. For a more user-friendly list with
|
||||
explanations of what the default hotkeys are and what they do, please see
|
||||
`>help defaultkeys`
|
||||
`> help defaultkeys` (a json formatted list of default keys is included
|
||||
at the end of this document).
|
||||
|
||||
If `~/.config/micro/bindings.json` does not exist, you can simply create it.
|
||||
Micro will know what to do with it.
|
||||
@@ -19,7 +20,6 @@ cursor the start and end of the buffer.
|
||||
|
||||
You can hold shift with all of these movement actions to select while moving.
|
||||
|
||||
|
||||
## Rebinding keys
|
||||
|
||||
The bindings may be rebound using the `~/.config/micro/bindings.json` file. Each
|
||||
@@ -47,6 +47,21 @@ save and quit you can bind it like so:
|
||||
}
|
||||
```
|
||||
|
||||
Each action will return a success flag. Actions can be chained such that
|
||||
the chain only continues when there are successes, or failures, or either.
|
||||
The `,` separator will always chain to the next action. The `|` separator
|
||||
will abort the chain if the action preceding it succeeds, and the `&` will
|
||||
abort the chain if the action preceding it fails. For example, in the default
|
||||
bindings, tab is bound as
|
||||
|
||||
```
|
||||
"Tab": "Autocomplete|IndentSelection|InsertTab"
|
||||
```
|
||||
|
||||
This means that if the `Autocomplete` action is successful, the chain will abort.
|
||||
Otherwise, it will try `IndentSelection`, and if that fails too, it will
|
||||
execute `InsertTab`.
|
||||
|
||||
## Binding commands
|
||||
|
||||
You can also bind a key to execute a command in command mode (see
|
||||
@@ -119,12 +134,10 @@ You can do this in linux using the loadkeys program.
|
||||
|
||||
Coming soon!
|
||||
|
||||
|
||||
## Unbinding keys
|
||||
|
||||
It is also possible to disable any of the default key bindings by use of the
|
||||
`UnbindKey` action in the user's `bindings.json` file.
|
||||
|
||||
`None` action in the user's `bindings.json` file.
|
||||
|
||||
## Bindable actions and bindable keys
|
||||
|
||||
@@ -221,8 +234,9 @@ SpawnMultiCursorSelect
|
||||
RemoveMultiCursor
|
||||
RemoveAllMultiCursors
|
||||
SkipMultiCursor
|
||||
UnbindKey
|
||||
None
|
||||
JumpToMatchingBrace
|
||||
Autocomplete
|
||||
```
|
||||
|
||||
You can also bind some mouse actions (these must be bound to mouse buttons)
|
||||
@@ -409,8 +423,8 @@ MouseWheelRight
|
||||
"Backspace": "Backspace",
|
||||
"Alt-CtrlH": "DeleteWordLeft",
|
||||
"Alt-Backspace": "DeleteWordLeft",
|
||||
"Tab": "IndentSelection,InsertTab",
|
||||
"Backtab": "OutdentSelection,OutdentLine",
|
||||
"Tab": "Autocomplete|IndentSelection|InsertTab",
|
||||
"Backtab": "OutdentSelection|OutdentLine",
|
||||
"CtrlO": "OpenFile",
|
||||
"CtrlS": "Save",
|
||||
"CtrlF": "Find",
|
||||
@@ -433,9 +447,12 @@ MouseWheelRight
|
||||
"CtrlEnd": "CursorEnd",
|
||||
"PageUp": "CursorPageUp",
|
||||
"PageDown": "CursorPageDown",
|
||||
"CtrlPageUp": "PreviousTab",
|
||||
"CtrlPageDown": "NextTab",
|
||||
"CtrlG": "ToggleHelp",
|
||||
"Alt-g": "ToggleKeyMenu",
|
||||
"CtrlR": "ToggleRuler",
|
||||
"CtrlL": "JumpLine",
|
||||
"CtrlL": "command-edit:goto ",
|
||||
"Delete": "Delete",
|
||||
"CtrlB": "ShellMode",
|
||||
"CtrlQ": "Quit",
|
||||
@@ -443,6 +460,7 @@ MouseWheelRight
|
||||
"CtrlW": "NextSplit",
|
||||
"CtrlU": "ToggleMacro",
|
||||
"CtrlJ": "PlayMacro",
|
||||
"Insert": "ToggleOverwriteMode",
|
||||
|
||||
// Emacs-style keybindings
|
||||
"Alt-f": "WordRight",
|
||||
@@ -451,7 +469,6 @@ MouseWheelRight
|
||||
"Alt-e": "EndOfLine",
|
||||
|
||||
// Integration with file managers
|
||||
"F1": "ToggleHelp",
|
||||
"F2": "Save",
|
||||
"F3": "Find",
|
||||
"F4": "Quit",
|
||||
@@ -466,12 +483,11 @@ MouseWheelRight
|
||||
"MouseMiddle": "PastePrimary",
|
||||
"Ctrl-MouseLeft": "MouseMultiCursor",
|
||||
|
||||
// Multiple cursors bindings
|
||||
"Alt-n": "SpawnMultiCursor",
|
||||
"Alt-m": "SpawnMultiCursorSelect",
|
||||
"Alt-p": "RemoveMultiCursor",
|
||||
"Alt-c": "RemoveAllMultiCursors",
|
||||
"Alt-x": "SkipMultiCursor",
|
||||
"Alt-x": "SkipMultiCursor"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -485,3 +501,9 @@ Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or
|
||||
`Ctrl` so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings).
|
||||
This is why in the default keybindings you can see `AltShiftLeft` instead of
|
||||
`Alt-ShiftLeft` (they are equivalent).
|
||||
|
||||
Please note that terminal emulators are strange applications and micro only receives
|
||||
key events that the terminal decides to send. Some terminal emulators may not
|
||||
send certain events even if this document says micro can receive the event. To see
|
||||
exactly what micro receives from the terminal when you press a key, run the `> raw`
|
||||
command.
|
||||
|
||||
@@ -13,12 +13,16 @@ Here are the options that you can set:
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `autosave`: micro will save the buffer every 8 seconds automatically. Micro
|
||||
also will automatically save and quit when you exit without asking. Be
|
||||
careful when using this feature, because you might accidentally save a file,
|
||||
overwriting what was there before.
|
||||
* `backup`: micro will automatically keep backups of all open buffers. Backups
|
||||
are stored in `~/.config/micro/backups` and are removed when the buffer is
|
||||
closed cleanly. In the case of a system crash or a micro crash, the contents
|
||||
of the buffer can be recovered automatically by opening the file that
|
||||
was being edited before the crash, or manually by searching for the backup
|
||||
in the backup directory. Backups are made in the background when a buffer is
|
||||
modified and the latest backup is more than 8 seconds old, or when micro
|
||||
detects a crash. It is highly recommended that you leave this feature enabled.
|
||||
|
||||
default value: `false`
|
||||
default value: `true`
|
||||
|
||||
* `basename`: in the infobar, show only the basename of the file being edited
|
||||
rather than the full path.
|
||||
@@ -51,8 +55,12 @@ Here are the options that you can set:
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `eofnewline`: micro will automatically add a newline to the end of the file
|
||||
when saving.
|
||||
* `encoding`: the encoding to open and save files with. Supported encodings
|
||||
are listed at https://www.w3.org/TR/encoding/.
|
||||
|
||||
default value: `utf-8`
|
||||
|
||||
* `eofnewline`: micro will automatically add a newline to the file.
|
||||
|
||||
default value: `false`
|
||||
|
||||
@@ -109,6 +117,17 @@ Here are the options that you can set:
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `matchbrace`: underline matching braces for '()', '{}', '[]' when the cursor
|
||||
is on a brace character.
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `mkparents`: if a file is opened on a path that does not exist, the file cannot
|
||||
be saved because the parent directories don't exist. This option lets micro
|
||||
automatically create the parent directories in such a situation.
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `mouse`: whether to enable mouse support. When mouse support is disabled,
|
||||
usually the terminal will be able to access mouse events which can be useful
|
||||
if you want to copy from the terminal instead of from micro (if over ssh for
|
||||
@@ -117,19 +136,6 @@ Here are the options that you can set:
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `pluginchannels`: contains all the channels micro's plugin manager will search
|
||||
for plugins in. A channel is simply a list of 'repository' json files which
|
||||
contain metadata about the given plugin. See the `Plugin Manager` section of
|
||||
the `plugins` help topic for more information.
|
||||
|
||||
default value: `https://github.com/micro-editor/plugin-channel`
|
||||
|
||||
* `pluginrepos`: contains all the 'repositories' micro's plugin manager will
|
||||
search for plugins in. A repository consists of a `repo.json` file which
|
||||
contains metadata for a single plugin.
|
||||
|
||||
default value: ` `
|
||||
|
||||
* `rmtrailingws`: micro will automatically trim trailing whitespaces at eol.
|
||||
|
||||
default value: `false`
|
||||
@@ -186,30 +192,35 @@ Here are the options that you can set:
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `statusformatl`: format string definition for the left-justified part of the
|
||||
statusline. Special directives should be placed inside `$()`. Special
|
||||
directives include: `filename`, `modified`, `line`, `col`, `opt`, `bind`.
|
||||
The `opt` and `bind` directives take either an option or an action afterward
|
||||
and fill in the value of the option or the key bound to the action.
|
||||
|
||||
default value: `$(filename) $(modified)($(line),$(col)) $(opt:filetype)
|
||||
$(opt:fileformat) $(opt:encoding)`
|
||||
|
||||
* `statusformatl`: format string definition for the left-justified part of the
|
||||
statusline.
|
||||
|
||||
default value: `$(bind:ToggleKeyMenu): show bindings, $(bind:ToggleHelp):
|
||||
toggle help`
|
||||
|
||||
* `statusline`: display the status line at the bottom of the screen.
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `matchbrace`: highlight matching braces for '()', '{}', '[]'
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `matchbraceleft`: when matching a closing brace, should matching match the
|
||||
brace directly under the cursor, or the character to the left? only matters
|
||||
if `matchbrace` is true
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `syntax`: turns syntax highlighting on or off.
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `sucmd`: specifies the super user command. On most systems this is "sudo" but
|
||||
on BSD it can be "doas." This option can be customized and is only used when
|
||||
saving with su.
|
||||
|
||||
default value: `sudo`
|
||||
|
||||
* `syntax`: turns syntax on or off.
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `tabmovement`: navigate spaces at the beginning of lines as if they are tabs
|
||||
(e.g. move over 4 spaces at once). This option only does anything if
|
||||
`tabstospaces` is on.
|
||||
@@ -237,31 +248,14 @@ Here are the options that you can set:
|
||||
|
||||
---
|
||||
|
||||
Default plugin options:
|
||||
|
||||
* `autoclose`: automatically close `{}` `()` `[]` `""` `''`. Provided by the
|
||||
`autoclose` plugin
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `ftoptions`: by default, micro will set some options based on the filetype. At
|
||||
the moment, micro will use tabs for makefiles and spaces for python and yaml
|
||||
files regardless of your settings. If you would like to disable this behavior
|
||||
turn this option off.
|
||||
|
||||
default value: `true`
|
||||
|
||||
* `linter`: Automatically lint when the file is saved. Provided by the `linter`
|
||||
plugin.
|
||||
|
||||
default value: `true`
|
||||
Plugin options: all plugins come with a special option to enable or disable them. THe option
|
||||
is a boolean with the same name as the plugin itself.
|
||||
|
||||
Any option you set in the editor will be saved to the file
|
||||
~/.config/micro/settings.json so, in effect, your configuration file will be
|
||||
created for you. If you'd like to take your configuration with you to another
|
||||
machine, simply copy the settings.json to the other machine.
|
||||
|
||||
|
||||
## Global and local settings
|
||||
|
||||
You can set these settings either globally or locally. Locally means that the
|
||||
|
||||
@@ -1,23 +1,76 @@
|
||||
# Plugins
|
||||
|
||||
Micro supports creating plugins with a simple Lua system. Every plugin has a
|
||||
main script which is run at startup which should be placed in
|
||||
`~/.config/micro/plugins/pluginName/pluginName.lua`.
|
||||
Micro supports creating plugins with a simple Lua system. Plugins are
|
||||
folders containing Lua files and possibly other source files placed
|
||||
in `~/.config/micro/plug`. The plugin directory (within `plug`) should
|
||||
contain at least one Lua file and an `info.json` file. The info file
|
||||
provides additional information such as the name of the plugin, the
|
||||
plugin's website, dependencies, etc... Here is an example info file
|
||||
from the go plugin, which has the following file structure:
|
||||
|
||||
There are a number of callback functions which you can create in your plugin to
|
||||
run code at times other than startup. The naming scheme is `onAction(view)`. For
|
||||
example a function which is run every time the user saves the buffer would be:
|
||||
```
|
||||
~/.config/micro/plug/go-plugin
|
||||
go.lua
|
||||
info.json
|
||||
```
|
||||
|
||||
info.json:
|
||||
```
|
||||
{
|
||||
"name": "go",
|
||||
"description": "Go formatting and tool support",
|
||||
"website": "https://github.com/micro-editor/go-plugin",
|
||||
"install": "https://github.com/micro-editor/go-plugin",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
All fields are simply interpreted as strings, so the version does not
|
||||
need to be a semantic version, and the dependencies are also only
|
||||
meant to be parsed by humans. The name should be an identifier, and
|
||||
the website should point to a valid website. The install field should
|
||||
provide info about installing the plugin, or point to a website that
|
||||
provides information.
|
||||
|
||||
## Lua callbacks
|
||||
|
||||
Plugins use Lua but also have access to many functions both from micro
|
||||
and from the Go standard library. Many callbacks are also defined which
|
||||
are called when certain events happen. Here is the list of callbacks
|
||||
which micro defines:
|
||||
|
||||
* `init()`: this function should be used for your plugin initialization.
|
||||
|
||||
* `onBufferOpen(buf)`: runs when a buffer is opened. The input contains
|
||||
the buffer object.
|
||||
|
||||
* `onBufPaneOpen(bufpane)`: runs when a bufpane is opened. The input
|
||||
contains the bufpane object.
|
||||
|
||||
* `onAction(bufpane)`: runs when `Action` is triggered by the user, where
|
||||
`Action` is a bindable action (see `> help keybindings`). A bufpane
|
||||
is passed as input and the function should return a boolean defining
|
||||
whether the view should be relocated after this action is performed.
|
||||
|
||||
* `preAction(bufpane)`: runs immediately before `Action` is triggered
|
||||
by the user. Returns a boolean which defines whether the action should
|
||||
be canceled.
|
||||
|
||||
For example a function which is run every time the user saves the buffer
|
||||
would be:
|
||||
|
||||
```lua
|
||||
function onSave(view)
|
||||
function onSave(bp)
|
||||
...
|
||||
return false
|
||||
end
|
||||
```
|
||||
|
||||
The `view` variable is a reference to the view the action is being executed on.
|
||||
This is almost always the current view, which you can get with `CurView()` as
|
||||
well.
|
||||
The `bp` variable is a reference to the bufpane the action is being executed within.
|
||||
This is almost always the current bufpane.
|
||||
|
||||
All available actions are listed in the keybindings section of the help.
|
||||
|
||||
@@ -31,191 +84,96 @@ function onMousePress(view, event)
|
||||
end
|
||||
```
|
||||
|
||||
These functions should also return a boolean specifying whether the view should
|
||||
These functions should also return a boolean specifying whether the bufpane should
|
||||
be relocated to the cursor or not after the action is complete.
|
||||
|
||||
Note that these callbacks occur after the action has been completed. If you want
|
||||
a callback before the action is executed, use `preAction()`. In this case the
|
||||
boolean returned specifies whether or not the action should be executed after
|
||||
the lua code completes.
|
||||
## Accessing micro functions
|
||||
|
||||
Another useful callback to know about which is not an action is
|
||||
`onViewOpen(view)` which is called whenever a new view is opened and the new
|
||||
view is passed in. This is useful for setting local options based on the
|
||||
filetype, for example turning off `tabstospaces` only for Go files when they are
|
||||
opened.
|
||||
Some of micro's internal information is exposed in the form of packages which
|
||||
can be imported by Lua plugins. A package can be imported in Lua and a value
|
||||
within it can be accessed using the following syntax:
|
||||
|
||||
---
|
||||
```lua
|
||||
local micro = import("micro")
|
||||
micro.Log("Hello")
|
||||
```
|
||||
|
||||
There are a number of functions and variables that are available to you in order
|
||||
to access the inner workings of micro. Here is a list (the type signatures for
|
||||
functions are given using Go's type system):
|
||||
The packages and functions are listed below:
|
||||
|
||||
* `OS`: variable which gives the OS micro is currently running on (this is the
|
||||
same as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
|
||||
* `micro`
|
||||
- `TermMessage(msg interface{}...)`
|
||||
- `TermError()`
|
||||
- `InfoBar()`
|
||||
- `Log(msg interface{}...)`
|
||||
- `SetStatusInfoFn`
|
||||
* `micro/config`
|
||||
- `MakeCommand`
|
||||
- `FileComplete`
|
||||
- `HelpComplete`
|
||||
- `OptionComplete`
|
||||
- `OptionValueComplete`
|
||||
- `NoComplete`
|
||||
- `TryBindKey`
|
||||
- `Reload`
|
||||
- `AddRuntimeFilesFromDirectory`
|
||||
- `AddRuntimeFileFromMemory`
|
||||
- `AddRuntimeFile`
|
||||
- `ListRuntimeFiles`
|
||||
- `ReadRuntimeFile`
|
||||
- `RTColorscheme`
|
||||
- `RTSyntax`
|
||||
- `RTHelp`
|
||||
- `RTPlugin`
|
||||
- `RegisterCommonOption`
|
||||
- `RegisterGlobalOption`
|
||||
* `micro/shell`
|
||||
- `ExecCommand`
|
||||
- `RunCommand`
|
||||
- `RunBackgroundShell`
|
||||
- `RunInteractiveShell`
|
||||
- `JobStart`
|
||||
- `JobSpawn`
|
||||
- `JobStop`
|
||||
- `JobStop`
|
||||
- `RunTermEmulator`
|
||||
- `TermEmuSupported`
|
||||
* `micro/buffer`
|
||||
- `NewMessage`
|
||||
- `NewMessageAtLine`
|
||||
- `MTInfo`
|
||||
- `MTWarning`
|
||||
- `MTError`
|
||||
- `Loc`
|
||||
- `BTDefault`
|
||||
- `BTLog`
|
||||
- `BTRaw`
|
||||
- `BTInfo`
|
||||
- `NewBufferFromFile`
|
||||
- `ByteOffset`
|
||||
* `micro/util`
|
||||
- `RuneAt`
|
||||
- `GetLeadingWhitespace`
|
||||
- `IsWordChar`
|
||||
|
||||
* `configDir`: contains the path to the micro configuration files
|
||||
|
||||
* `tabs`: a list of all the tabs currently in use
|
||||
|
||||
* `curTab`: the index of the current tabs in the tabs list
|
||||
|
||||
* `messenger`: lets you send messages to the user or create prompts
|
||||
|
||||
* `NewBuffer(text, path string) *Buffer`: creates a new buffer from a given
|
||||
reader with a given path
|
||||
|
||||
* `NewBufferFromFile(path string) *Buffer`: creates a new buffer from a given
|
||||
path
|
||||
|
||||
* `GetLeadingWhitespace() bool`: returns the leading whitespace of the given
|
||||
string
|
||||
|
||||
* `IsWordChar(str string) bool`: returns whether or not the string is a 'word
|
||||
character'
|
||||
|
||||
* `RuneStr(r rune) string`: returns a string containing the given rune
|
||||
|
||||
* `Loc(x, y int) Loc`: returns a new `Loc` struct
|
||||
|
||||
* `WorkingDirectory() string`: returns a rooted path name to the current working
|
||||
directory
|
||||
|
||||
* `JoinPaths(dir... string) string`: combines multiple directories to a full
|
||||
path
|
||||
|
||||
* `DirectoryName(path string)`: returns all but the last element of path,
|
||||
typically the path's directory
|
||||
|
||||
* `GetOption(name string)`: returns the value of the requested option
|
||||
|
||||
* `AddOption(name string, value interface{})`: sets the given option with the
|
||||
given value (`interface{}` means any type in Go)
|
||||
|
||||
* `SetOption(option, value string)`: sets the given option to the value. This
|
||||
will set the option globally, unless it is a local only option.
|
||||
|
||||
* `SetLocalOption(option, value string, view *View)`: sets the given option to
|
||||
the value locally in the given buffer
|
||||
|
||||
* `BindKey(key, action string)`: binds `key` to `action`
|
||||
|
||||
* `MakeCommand(name, function string, completions ...Completion)`:
|
||||
creates a command with `name` which will call `function` when executed. Use 0
|
||||
for completions to get NoCompletion.
|
||||
|
||||
* `MakeCompletion(function string)`:
|
||||
creates a `Completion` to use with `MakeCommand`
|
||||
|
||||
* `CurView()`: returns the current view
|
||||
|
||||
* `HandleCommand(cmd string)`: runs the given command
|
||||
|
||||
* `ExecCommand(name string, args []string) (string, error)`: exec a (shell) command with the
|
||||
given arguments. Returns the command's output and a possible error.
|
||||
|
||||
* `RunShellCommand(cmd string) (string, error)`: Run a shell command. This uses `ExecCommand`
|
||||
under the hood but also does some parsing for the arguments (i.e. quoted arguments). The
|
||||
function returns the command's output and a possible error.
|
||||
|
||||
* `RunBackgroundShell(cmd string)`: Run a shell command in the background.
|
||||
|
||||
* `RunInteractiveShell(cmd string, wait bool, getOutput bool) (string, error)`: Run a shell command
|
||||
by closing micro and running the command interactively. If `wait` is true, a prompt will be
|
||||
used after the process exits to prevent the terminal from immediately returning to micro, allowing
|
||||
the user to view the output of the process. If `getOutput` is true, the command's standard output
|
||||
will be returned. Note that if `getOutput` is true, some interactive commands may not behave
|
||||
normally because `isatty` will return false.
|
||||
|
||||
* `RunTermEmulator(cmd string, wait bool, getOutput bool, callback string) error`: Same as
|
||||
`RunInteractiveShell` except the command is run within the current split in a terminal emulator.
|
||||
The `callback` input is a string callback to a lua function which will be called when the process
|
||||
exits. The output of the process will be provided as the first and only argument to the callback
|
||||
(it will be empty if `getOutput` is false).
|
||||
Note that this functionality is only supported on some operating systems (linux, darwin, dragonfly,
|
||||
openbsd, freebsd). Use the `TermEmuSupported` (see below) boolean to determine if the current
|
||||
system is supported.
|
||||
|
||||
* `TermEmuSupported`: Boolean specifying if the terminal emulator is supported on the version of
|
||||
micro that is running.
|
||||
|
||||
* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a
|
||||
given x, y location
|
||||
|
||||
* `Reload`: (Re)load everything
|
||||
|
||||
* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it
|
||||
counts bytes instead of runes
|
||||
|
||||
* `JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...string)`:
|
||||
Starts running the given process in the background. `onStdout` `onStderr` and
|
||||
`onExit` are callbacks to lua functions which will be called when the given
|
||||
actions happen to the background process. `userargs` are the arguments which
|
||||
will get passed to the callback functions
|
||||
|
||||
* `JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string)`:
|
||||
Starts running the given shell command in the background. Note that the
|
||||
command execute is first parsed by a shell when using this command. It is
|
||||
executed with `sh -c`.
|
||||
|
||||
* `JobSend(cmd *exec.Cmd, data string)`: send a string into the stdin of the job
|
||||
process
|
||||
|
||||
* `JobStop(cmd *exec.Cmd)`: kill a job
|
||||
|
||||
This may seem like a small list of available functions but some of the objects
|
||||
returned by the functions have many methods. `CurView()` returns a view object
|
||||
which has all the actions which you can call. For example
|
||||
`CurView():Save(false)`. You can see the full list of possible actions in the
|
||||
keybindings help topic. The boolean on all the actions indicates whether or not
|
||||
the lua callbacks should be run. I would recommend generally sticking to false
|
||||
when making a plugin to avoid recursive problems, for example if you call
|
||||
`CurView():Save(true)` in `onSave()`. Just use `CurView():Save(false)` so that
|
||||
it won't call `onSave()` again.
|
||||
returned by the functions have many methods. The Lua plugin may access any
|
||||
public methods of an object returned by any of the functions above. For example,
|
||||
with a BufPane object called `bp`, you could called the `Save` function in Lua
|
||||
with `bp:Save()`.
|
||||
|
||||
Using the view object, you can also access the buffer associated with that view
|
||||
by using `CurView().Buf`, which lets you access the `FileType`, `Path`,
|
||||
`Name`...
|
||||
|
||||
The possible methods which you can call using the `messenger` variable are:
|
||||
|
||||
* `messenger.Message(msg ...interface{})`
|
||||
* `messenger.Error(msg ...interface{})`
|
||||
* `messenger.YesNoPrompt(prompt string) (bool,bool)`
|
||||
* `messenger.Prompt(prompt, historyType string, completionType Completion) (string, bool)`
|
||||
* `messenger.AddLog(msg ...interface{})`
|
||||
|
||||
#### Note
|
||||
|
||||
Go function signatures use `.` and lua uses `:` so
|
||||
Note that Lua uses the `:` syntax to call a function rather than Go's `.` syntax.
|
||||
|
||||
```go
|
||||
messenger.Message()
|
||||
micro.InfoBar().Message()
|
||||
```
|
||||
|
||||
turns to
|
||||
|
||||
```lua
|
||||
messenger:Message()
|
||||
micro.InfoBar():Message()
|
||||
```
|
||||
|
||||
If you want a standard prompt, just use
|
||||
|
||||
```lua
|
||||
messenger:Prompt(prompt, "", 0)
|
||||
```
|
||||
|
||||
Debug or logging your plugin can be done with below lua example code.
|
||||
|
||||
```lua
|
||||
messenger:AddLog("Message goes here ",pluginVariableToPrintHere)
|
||||
```
|
||||
|
||||
In Micro to see your plugin logging output press `CtrlE` then type `log`, a
|
||||
logging window will open and any logging sent from your plugin will be displayed
|
||||
here.
|
||||
|
||||
|
||||
## Accessing the Go standard library
|
||||
|
||||
It is possible for your lua code to access many of the functions in the Go
|
||||
@@ -226,11 +184,12 @@ Simply import the package you'd like and then you can use it. For example:
|
||||
```lua
|
||||
local ioutil = import("io/ioutil")
|
||||
local fmt = import("fmt")
|
||||
local micro = import("micro")
|
||||
|
||||
local data, err = ioutil.ReadFile("SomeFile.txt")
|
||||
|
||||
if err ~= nil then
|
||||
messenger:Error("Error reading file: SomeFile.txt")
|
||||
micro.InfoBar():Error("Error reading file: SomeFile.txt")
|
||||
else
|
||||
-- Data is returned as an array of bytes
|
||||
-- Using Sprintf will convert it to a string
|
||||
@@ -282,7 +241,6 @@ files to the runtime. To read the content of a runtime file use
|
||||
`ReadRuntimeFile(fileType, name string)` or `ListRuntimeFiles(fileType string)`
|
||||
for all runtime files.
|
||||
|
||||
|
||||
## Autocomplete command arguments
|
||||
|
||||
See this example to learn how to use `MakeCompletion` and `MakeCommand`
|
||||
@@ -313,7 +271,6 @@ end
|
||||
MakeCommand("foo", "example.foo", MakeCompletion("example.complete"))
|
||||
```
|
||||
|
||||
|
||||
## Default plugins
|
||||
|
||||
For examples of plugins, see the default `autoclose` and `linter` plugins
|
||||
@@ -321,7 +278,6 @@ For examples of plugins, see the default `autoclose` and `linter` plugins
|
||||
plugins that are stored in the official channel
|
||||
[here](https://github.com/micro-editor/plugin-channel).
|
||||
|
||||
|
||||
## Plugin Manager
|
||||
|
||||
Micro also has a built in plugin manager which you can invoke with the
|
||||
|
||||
@@ -8,17 +8,6 @@ Hopefully you'll find this useful.
|
||||
|
||||
See `> help defaultkeys` for a list an explanation of the default keybindings.
|
||||
|
||||
### Plugins
|
||||
|
||||
Micro has a plugin manager which can automatically download plugins for you. To
|
||||
see the 'official' plugins, go to github.com/micro-editor/plugin-channel.
|
||||
|
||||
For example, if you'd like to install the snippets plugin (listed in that repo),
|
||||
just press `CtrlE` to execute a command, and type `plugin install snippets`.
|
||||
|
||||
For more information about the plugin manager, see the end of the `plugins` help
|
||||
topic.
|
||||
|
||||
### Settings
|
||||
|
||||
In micro, your settings are stored in `~/.config/micro/settings.json`, a file
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10
runtime/plugins/autoclose/info.json
Normal file
10
runtime/plugins/autoclose/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "autoclose",
|
||||
"description": "Automatically places closing characters for quotes, parentheses, brackets, etc...",
|
||||
"website": "https://github.com/zyedidia/micro",
|
||||
"install": "https://github.com/zyedidia/micro",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
106
runtime/plugins/comment/comment.lua
Normal file
106
runtime/plugins/comment/comment.lua
Normal file
@@ -0,0 +1,106 @@
|
||||
local util = import("micro/util")
|
||||
local config = import("micro/config")
|
||||
local buffer = import("micro/buffer")
|
||||
|
||||
local ft = {}
|
||||
|
||||
ft["c"] = "// %s"
|
||||
ft["c++"] = "// %s"
|
||||
ft["go"] = "// %s"
|
||||
ft["python"] = "# %s"
|
||||
ft["python3"] = "# %s"
|
||||
ft["html"] = "<!-- %s -->"
|
||||
ft["java"] = "// %s"
|
||||
ft["julia"] = "# %s"
|
||||
ft["perl"] = "# %s"
|
||||
ft["php"] = "// %s"
|
||||
ft["rust"] = "// %s"
|
||||
ft["shell"] = "# %s"
|
||||
ft["lua"] = "-- %s"
|
||||
ft["javascript"] = "// %s"
|
||||
ft["ruby"] = "# %s"
|
||||
ft["d"] = "// %s"
|
||||
ft["swift"] = "// %s"
|
||||
|
||||
function onBufferOpen(buf)
|
||||
if buf.Settings["commenttype"] == nil then
|
||||
if ft[buf.Settings["filetype"]] ~= nil then
|
||||
buf.Settings["commenttype"] = ft[buf.Settings["filetype"]]
|
||||
else
|
||||
buf.Settings["commenttype"] = "# %s"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function commentLine(bp, lineN)
|
||||
local line = bp.Buf:Line(lineN)
|
||||
local commentType = bp.Buf.Settings["commenttype"]
|
||||
local commentRegex = "^%s*" .. commentType:gsub("%*", "%*"):gsub("%-", "%-"):gsub("%.", "%."):gsub("%+", "%+"):gsub("%]", "%]"):gsub("%[", "%["):gsub("%%s", "(.*)")
|
||||
local sel = -bp.Cursor.CurSelection
|
||||
local curpos = -bp.Cursor.Loc
|
||||
local index = string.find(commentType, "%%s") - 1
|
||||
if string.match(line, commentRegex) then
|
||||
uncommentedLine = string.match(line, commentRegex)
|
||||
bp.Buf:Replace(buffer.Loc(0, lineN), buffer.Loc(#line, lineN), util.GetLeadingWhitespace(line) .. uncommentedLine)
|
||||
if bp.Cursor:HasSelection() then
|
||||
bp.Cursor.CurSelection[1].Y = sel[1].Y
|
||||
bp.Cursor.CurSelection[2].Y = sel[2].Y
|
||||
bp.Cursor.CurSelection[1].X = sel[1].X
|
||||
bp.Cursor.CurSelection[2].X = sel[2].X
|
||||
else
|
||||
bp.Cursor.X = curpos.X - index
|
||||
bp.Cursor.Y = curpos.Y
|
||||
end
|
||||
else
|
||||
local commentedLine = commentType:gsub("%%s", trim(line))
|
||||
bp.Buf:Replace(buffer.Loc(0, lineN), buffer.Loc(#line, lineN), util.GetLeadingWhitespace(line) .. commentedLine)
|
||||
if bp.Cursor:HasSelection() then
|
||||
bp.Cursor.CurSelection[1].Y = sel[1].Y
|
||||
bp.Cursor.CurSelection[2].Y = sel[2].Y
|
||||
bp.Cursor.CurSelection[1].X = sel[1].X
|
||||
bp.Cursor.CurSelection[2].X = sel[2].X
|
||||
else
|
||||
bp.Cursor.X = curpos.X + index
|
||||
bp.Cursor.Y = curpos.Y
|
||||
end
|
||||
end
|
||||
bp.Cursor:Relocate()
|
||||
bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
|
||||
end
|
||||
|
||||
function commentSelection(bp, startLine, endLine)
|
||||
for line = startLine, endLine do
|
||||
commentLine(bp, line)
|
||||
end
|
||||
end
|
||||
|
||||
function comment(bp, args)
|
||||
if bp.Cursor:HasSelection() then
|
||||
if bp.Cursor.CurSelection[1]:GreaterThan(-bp.Cursor.CurSelection[2]) then
|
||||
local endLine = bp.Cursor.CurSelection[1].Y
|
||||
if bp.Cursor.CurSelection[1].X == 0 then
|
||||
endLine = endLine - 1
|
||||
end
|
||||
commentSelection(bp, bp.Cursor.CurSelection[2].Y, endLine)
|
||||
else
|
||||
local endLine = bp.Cursor.CurSelection[2].Y
|
||||
if bp.Cursor.CurSelection[2].X == 0 then
|
||||
endLine = endLine - 1
|
||||
end
|
||||
commentSelection(bp, bp.Cursor.CurSelection[1].Y, endLine)
|
||||
end
|
||||
else
|
||||
commentLine(bp, bp.Cursor.Y)
|
||||
end
|
||||
end
|
||||
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
function string.starts(String,Start)
|
||||
return string.sub(String,1,string.len(Start))==Start
|
||||
end
|
||||
|
||||
config.MakeCommand("comment", "comment.comment", config.NoComplete)
|
||||
config.TryBindKey("Alt-/", "lua:comment.comment", false)
|
||||
10
runtime/plugins/comment/info.json
Normal file
10
runtime/plugins/comment/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "comment",
|
||||
"description": "Support for automatically commenting blocks of code. Extensible and multiple languages supported.",
|
||||
"website": "https://github.com/zyedidia/micro",
|
||||
"install": "https://github.com/zyedidia/micro",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
@@ -1,23 +1,15 @@
|
||||
if GetOption("ftoptions") == nil then
|
||||
AddOption("ftoptions", true)
|
||||
end
|
||||
|
||||
function onViewOpen(view)
|
||||
if not GetOption("ftoptions") then
|
||||
return
|
||||
end
|
||||
|
||||
local ft = view.Buf.Settings["filetype"]
|
||||
function onBufferOpen(b)
|
||||
local ft = b:FileType()
|
||||
|
||||
if ft == "go" or
|
||||
ft == "makefile" then
|
||||
SetOption("tabstospaces", "off")
|
||||
b:SetOption("tabstospaces", "off")
|
||||
elseif ft == "fish" or
|
||||
ft == "python" or
|
||||
ft == "python2" or
|
||||
ft == "python3" or
|
||||
ft == "yaml" or
|
||||
ft == "nim" then
|
||||
SetOption("tabstospaces", "on")
|
||||
b:SetOption("tabstospaces", "on")
|
||||
end
|
||||
end
|
||||
|
||||
10
runtime/plugins/ftoptions/info.json
Normal file
10
runtime/plugins/ftoptions/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "ftoptions",
|
||||
"description": "Sets basic options based on the filetype (for example Makefiles require tabs).",
|
||||
"website": "https://github.com/zyedidia/micro",
|
||||
"install": "https://github.com/zyedidia/micro",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
10
runtime/plugins/linter/info.json
Normal file
10
runtime/plugins/linter/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "linter",
|
||||
"description": "Automatic code linting for a variety of languages.",
|
||||
"website": "https://github.com/zyedidia/micro",
|
||||
"install": "https://github.com/zyedidia/micro",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
@@ -1,85 +1,167 @@
|
||||
if GetOption("linter") == nil then
|
||||
AddOption("linter", true)
|
||||
local micro = import("micro")
|
||||
local runtime = import("runtime")
|
||||
local filepath = import("path/filepath")
|
||||
local shell = import("micro/shell")
|
||||
local buffer = import("micro/buffer")
|
||||
local config = import("micro/config")
|
||||
|
||||
local linters = {}
|
||||
|
||||
-- creates a linter entry, call from within an initialization function, not
|
||||
-- directly at initial load time
|
||||
--
|
||||
-- name: name of the linter
|
||||
-- filetype: filetype to check for to use linter
|
||||
-- cmd: main linter process that is executed
|
||||
-- args: arguments to pass to the linter process
|
||||
-- use %f to refer to the current file name
|
||||
-- use %d to refer to the current directory name
|
||||
-- errorformat: how to parse the linter/compiler process output
|
||||
-- %f: file, %l: line number, %m: error/warning message
|
||||
-- os: list of OSs this linter is supported or unsupported on
|
||||
-- optional param, default: {}
|
||||
-- whitelist: should the OS list be a blacklist (do not run the linter for these OSs)
|
||||
-- or a whitelist (only run the linter for these OSs)
|
||||
-- optional param, default: false (should blacklist)
|
||||
-- domatch: should the filetype be interpreted as a lua pattern to match with
|
||||
-- the actual filetype, or should the linter only activate on an exact match
|
||||
-- optional param, default: false (require exact match)
|
||||
-- loffset: line offset will be added to the line number returned by the linter
|
||||
-- useful if the linter returns 0-indexed lines
|
||||
-- optional param, default: 0
|
||||
-- coffset: column offset will be added to the col number returned by the linter
|
||||
-- useful if the linter returns 0-indexed columns
|
||||
-- optional param, default: 0
|
||||
function makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domatch, loffset, coffset)
|
||||
if linters[name] == nil then
|
||||
linters[name] = {}
|
||||
linters[name].filetype = filetype
|
||||
linters[name].cmd = cmd
|
||||
linters[name].args = args
|
||||
linters[name].errorformat = errorformat
|
||||
linters[name].os = os or {}
|
||||
linters[name].whitelist = whitelist or false
|
||||
linters[name].domatch = domatch or false
|
||||
linters[name].loffset = loffset or 0
|
||||
linters[name].coffset = coffset or 0
|
||||
end
|
||||
end
|
||||
|
||||
MakeCommand("lint", "linter.lintCommand", 0)
|
||||
|
||||
function lintCommand()
|
||||
CurView():Save(false)
|
||||
runLinter()
|
||||
function removeLinter(name)
|
||||
linters[name] = nil
|
||||
end
|
||||
|
||||
function runLinter()
|
||||
local ft = CurView().Buf:FileType()
|
||||
local file = CurView().Buf.Path
|
||||
local dir = DirectoryName(file)
|
||||
if OS == "windows" then
|
||||
function init()
|
||||
local devnull = "/dev/null"
|
||||
if runtime.GOOS == "windows" then
|
||||
devnull = "NUL"
|
||||
else
|
||||
devnull = "/dev/null"
|
||||
end
|
||||
|
||||
if ft == "c" then
|
||||
lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "c++" then
|
||||
lint("gcc", "gcc", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "d" then
|
||||
lint("dmd", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", file}, "%f%(%l%):.+: %m")
|
||||
elseif ft == "go" then
|
||||
lint("gobuild", "go", {"build", "-o", devnull}, "%f:%l: %m")
|
||||
lint("golint", "golint", {file}, "%f:%l:%d+: %m")
|
||||
elseif ft == "java" then
|
||||
lint("javac", "javac", {"-d", dir, file}, "%f:%l: error: %m")
|
||||
elseif ft == "javascript" then
|
||||
lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
|
||||
elseif string.match(ft, "literate") then
|
||||
lint("literate", "lit", {"-c", file}, "%f:%l:%m")
|
||||
elseif ft == "lua" then
|
||||
lint("luacheck", "luacheck", {"--no-color", file}, "%f:%l:%d+: %m")
|
||||
elseif ft == "nim" then
|
||||
lint("nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", file}, "%f.%l, %d+. %m")
|
||||
elseif ft == "Objective-C" then
|
||||
lint("clang", "xcrun", {"clang", "-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "python" then
|
||||
lint("pyflakes", "pyflakes", {file}, "%f:%l:.-:? %m")
|
||||
lint("mypy", "mypy", {file}, "%f:%l: %m")
|
||||
lint("pylint", "pylint", {"--output-format=parseable", "--reports=no", file}, "%f:%l: %m")
|
||||
elseif ft == "shell" then
|
||||
lint("shfmt", "shfmt", {file}, "%f:%l:%d+: %m")
|
||||
elseif ft == "swift" and OS == "darwin" then
|
||||
lint("switfc", "xcrun", {"swiftc", file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "swift" and OS == "linux" then
|
||||
lint("switfc", "swiftc", {file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "yaml" then
|
||||
lint("yaml", "yamllint", {"--format", "parsable", file}, "%f:%l:%d+:.+ %m")
|
||||
makeLinter("gcc", "c", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
|
||||
makeLinter("gcc", "c++", "gcc", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
|
||||
makeLinter("dmd", "d", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", "%f"}, "%f%(%l%):.+: %m")
|
||||
makeLinter("gobuild", "go", "go", {"build", "-o", devnull}, "%f:%l:%c:? %m")
|
||||
-- makeLinter("golint", "go", "golint", {"%f"}, "%f:%l:%c: %m")
|
||||
makeLinter("javac", "java", "javac", {"-d", "%d", "%f"}, "%f:%l: error: %m")
|
||||
makeLinter("jshint", "javascript", "jshint", {"%f"}, "%f: line %l,.+, %m")
|
||||
makeLinter("literate", "literate", "lit", {"-c", "%f"}, "%f:%l:%m", {}, false, true)
|
||||
makeLinter("luacheck", "lua", "luacheck", {"--no-color", "%f"}, "%f:%l:%c: %m")
|
||||
makeLinter("nim", "nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", "%f"}, "%f.%l, %c. %m")
|
||||
makeLinter("clang", "objective-c", "xcrun", {"clang", "-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
|
||||
makeLinter("pyflakes", "python", "pyflakes", {"%f"}, "%f:%l:.-:? %m")
|
||||
makeLinter("mypy", "python", "mypy", {"%f"}, "%f:%l: %m")
|
||||
makeLinter("pylint", "python", "pylint", {"--output-format=parseable", "--reports=no", "%f"}, "%f:%l: %m")
|
||||
makeLinter("shfmt", "shell", "shfmt", {"%f"}, "%f:%l:%c: %m")
|
||||
makeLinter("swiftc", "swift", "xcrun", {"swiftc", "%f"}, "%f:%l:%c:.+: %m", {"darwin"}, true)
|
||||
makeLinter("swiftc", "swiftc", {"%f"}, "%f:%l:%c:.+: %m", {"linux"}, true)
|
||||
makeLinter("yaml", "yaml", "yamllint", {"--format", "parsable", "%f"}, "%f:%l:%c:.+ %m")
|
||||
|
||||
config.MakeCommand("lint", "linter.lintCmd", config.NoComplete)
|
||||
end
|
||||
|
||||
function lintCmd(bp, args)
|
||||
bp:Save()
|
||||
runLinter(bp.Buf)
|
||||
end
|
||||
|
||||
function contains(list, element)
|
||||
for k, v in pairs(list) do
|
||||
if v == element then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function runLinter(buf)
|
||||
local ft = buf:FileType()
|
||||
local file = buf.Path
|
||||
local dir = filepath.Dir(file)
|
||||
|
||||
for k, v in pairs(linters) do
|
||||
local ftmatch = ft == v.filetype
|
||||
if v.domatch then
|
||||
ftmatch = string.match(ft, v.filetype)
|
||||
end
|
||||
|
||||
local hasOS = contains(v.os, runtime.GOOS)
|
||||
if not hasOS and v.whitelist then
|
||||
ftmatch = false
|
||||
end
|
||||
if hasOS and not v.whitelist then
|
||||
ftmatch = false
|
||||
end
|
||||
|
||||
local args = {}
|
||||
for k, arg in pairs(v.args) do
|
||||
args[k] = arg:gsub("%%f", file):gsub("%%d", dir)
|
||||
end
|
||||
|
||||
if ftmatch then
|
||||
lint(buf, k, v.cmd, args, v.errorformat, v.loffset, v.coffset)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function onSave(view)
|
||||
if GetOption("linter") then
|
||||
runLinter()
|
||||
else
|
||||
CurView():ClearAllGutterMessages()
|
||||
end
|
||||
function onSave(bp)
|
||||
runLinter(bp.Buf)
|
||||
return true
|
||||
end
|
||||
|
||||
function lint(linter, cmd, args, errorformat)
|
||||
CurView():ClearGutterMessages(linter)
|
||||
function lint(buf, linter, cmd, args, errorformat, loff, coff)
|
||||
buf:ClearMessages(linter)
|
||||
|
||||
JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
|
||||
shell.JobSpawn(cmd, args, "", "", "linter.onExit", buf, linter, errorformat, loff, coff)
|
||||
end
|
||||
|
||||
function onExit(output, linter, errorformat)
|
||||
function onExit(output, args)
|
||||
local buf, linter, errorformat, loff, coff = args[1], args[2], args[3], args[4], args[5]
|
||||
local lines = split(output, "\n")
|
||||
|
||||
local regex = errorformat:gsub("%%f", "(..-)"):gsub("%%l", "(%d+)"):gsub("%%m", "(.+)")
|
||||
local regex = errorformat:gsub("%%f", "(..-)"):gsub("%%l", "(%d+)"):gsub("%%c", "(%d+)"):gsub("%%m", "(.+)")
|
||||
for _,line in ipairs(lines) do
|
||||
-- Trim whitespace
|
||||
line = line:match("^%s*(.+)%s*$")
|
||||
if string.find(line, regex) then
|
||||
local file, line, msg = string.match(line, regex)
|
||||
if basename(CurView().Buf.Path) == basename(file) then
|
||||
CurView():GutterMessage(linter, tonumber(line), msg, 2)
|
||||
local file, line, col, msg = string.match(line, regex)
|
||||
local hascol = true
|
||||
if not string.find(errorformat, "%%c") then
|
||||
hascol = false
|
||||
msg = col
|
||||
elseif col == nil then
|
||||
hascol = false
|
||||
end
|
||||
micro.Log(basename(buf.Path), basename(file))
|
||||
if basename(buf.Path) == basename(file) then
|
||||
local bmsg = nil
|
||||
if hascol then
|
||||
local mstart = buffer.Loc(tonumber(col-1+coff), tonumber(line-1+loff))
|
||||
local mend = buffer.Loc(tonumber(col+coff), tonumber(line-1+loff))
|
||||
bmsg = buffer.NewMessage(linter, msg, mstart, mend, buffer.MTError)
|
||||
else
|
||||
bmsg = buffer.NewMessageAtLine(linter, msg, tonumber(line+loff), buffer.MTError)
|
||||
end
|
||||
buf:AddMessage(bmsg)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -96,7 +178,7 @@ end
|
||||
|
||||
function basename(file)
|
||||
local sep = "/"
|
||||
if OS == "windows" then
|
||||
if runtime.GOOS == "windows" then
|
||||
sep = "\\"
|
||||
end
|
||||
local name = string.gsub(file, "(.*" .. sep .. ")(.*)", "%2")
|
||||
|
||||
10
runtime/plugins/literate/info.json
Normal file
10
runtime/plugins/literate/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "literate",
|
||||
"description": "Highlighting and language support for the Literate programming tool.",
|
||||
"website": "https://github.com/zyedidia/Literate",
|
||||
"install": "https://github.com/zyedidia/micro",
|
||||
"version": "1.0.0",
|
||||
"require": [
|
||||
"micro >= 2.0.0"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
-- VERSION = "1.0.0"
|
||||
if GetOption("literate") == nil then
|
||||
AddOption("literate", true)
|
||||
end
|
||||
local config = import("micro/config")
|
||||
|
||||
function startswith(str, start)
|
||||
return string.sub(str,1,string.len(start))==start
|
||||
@@ -12,21 +9,20 @@ function endswith(str, endStr)
|
||||
end
|
||||
|
||||
function split(string, sep)
|
||||
local sep, fields = sep or ":", {}
|
||||
local pattern = string.format("([^%s]+)", sep)
|
||||
string:gsub(pattern, function(c) fields[#fields+1] = c end)
|
||||
return fields
|
||||
local sep, fields = sep or ":", {}
|
||||
local pattern = string.format("([^%s]+)", sep)
|
||||
string:gsub(pattern, function(c) fields[#fields+1] = c end)
|
||||
return fields
|
||||
end
|
||||
|
||||
function onViewOpen(view)
|
||||
if not GetOption("literate") then return end
|
||||
if not endswith(view.Buf.Path, ".lit") then
|
||||
function onBufferOpen(buf)
|
||||
if not endswith(buf.Path, ".lit") then
|
||||
return
|
||||
end
|
||||
|
||||
local codetype = "unknown"
|
||||
for i=1,view.Buf.NumLines do
|
||||
local line = view.Buf:Line(i-1)
|
||||
for i=1,buf:LinesNum() do
|
||||
local line = buf:Line(i-1)
|
||||
if startswith(line, "@code_type") then
|
||||
codetype = split(line, " ")[2]
|
||||
break
|
||||
@@ -52,6 +48,7 @@ function onViewOpen(view)
|
||||
syntaxFile = syntaxFile .. " rules: []\n"
|
||||
syntaxFile = syntaxFile .. " - include: " .. codetype .. "\n"
|
||||
|
||||
AddRuntimeFileFromMemory("literate", "syntax", "literate.yaml", syntaxFile)
|
||||
Reload()
|
||||
config.AddRuntimeFileFromMemory(config.RTSyntax, "literate.yaml", syntaxFile)
|
||||
config.Reload()
|
||||
buf:UpdateRules()
|
||||
end
|
||||
|
||||
@@ -64,5 +64,4 @@ Here is a list of the files that have been converted to properly use colorscheme
|
||||
|
||||
# License
|
||||
|
||||
Because the nano syntax files I have modified are distributed under the GNU GPLv3 license, these files are also distributed
|
||||
under that license. See [LICENSE](LICENSE).
|
||||
See [LICENSE](LICENSE).
|
||||
|
||||
58
runtime/syntax/bat.yaml
Normal file
58
runtime/syntax/bat.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
filetype: batch
|
||||
|
||||
detect:
|
||||
filename: "(\\.bat$)"
|
||||
# header: ""
|
||||
|
||||
rules:
|
||||
# Numbers
|
||||
- constant.number: "\\b[0-9]+\\b"
|
||||
# Brackets and symbols
|
||||
- special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)"
|
||||
# Conditionals and control flow
|
||||
# note (?i) means case insensitive match
|
||||
- type: "\\b(?i)(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|then|until|while)\\b"
|
||||
- type: "\\b(?i)(equ|neq|lss|leq|gtr|geq|on|off)\\b"
|
||||
- type: "\\b(?i)(goto|for|in|do|call|exit|not|exist|errorlevel|defined)\\b"
|
||||
- type: "\\b(?i)(prn|nul|lpt3|lpt2|lpt1|con|com4|com3|com2|com1|aux)\\b"
|
||||
# keywords
|
||||
- statement: "\\b(?i)(adprep|append|arp|assoc|at|atmadm|attrib|auditpol|autochk|autoconv|autofmt|bcdboot|bcdedit|bdehdcfg|bitsadmin|bootcfg|break|brea)\\b"
|
||||
- statement: "\\b(?i)(cacls|cd|certreq|certutil|chcp|change|choice|cipher|chdir|chkdsk|chkntfs|chglogon|chgport|chgusr|clip|cls|clscluadmin|cluster|cmd|cmdkey|cmstp|color)\\b"
|
||||
- statement: "\\b(?i)(comp|compact|convert|copy|cprofile|cscript|csvde|date|dcdiag|dcgpofix|dcpromo|defra|del|dfscmd|dfsdiag|dfsrmig|diantz|dir|dirquota|diskcomp|diskcopy|diskpart|diskperf|diskraid|diskshadow|dispdiag|doin|dnscmd|doskey|driverquery|dsacls|dsadd|dsamain|dsdbutil|dsget|dsmgmt|dsmod|dsmove|dsquery|dsrm)\\b"
|
||||
- statement: "\\b(?i)(echo|edit|endlocal|erase|esentutl|eventcreate|eventquery|eventtriggers|evntcmd|expand|extract)\\b"
|
||||
- statement: "\\b(?i)(fc|filescrn|find|findstr|finger|flattemp|fonde|forfiles|format|freedisk|fs|fsutil|ftp|ftype|fveupdate|getmac|gettype|gpfixup|gpresult|gpupdate|graftabl)\\b"
|
||||
- statement: "\\b(?i)(hashgen|hep|help|helpctr|hostname|icacls|iisreset|inuse|ipconfig|ipxroute|irftp|ismserv|jetpack|keyb|klist|ksetup|ktmutil|ktpass|label|ldifd|ldp|lodctr|logman|logoff|lpq|lpr|macfile)\\b"
|
||||
- statement: "\\b(?i)(makecab|manage-bde|mapadmin|md|mkdir|mklink|mmc|mode|more|mount|mountvol|move|mqbup|mqsvc|mqtgsvc|msdt|msg|msiexec|msinfo32|mstsc|nbtstat|net computer|net group)\\b"
|
||||
- statement: "\\b(?i)(net localgroup|net print|net session|net share|net start|net stop|net use|net user|net view|net|netcfg|netdiag|netdom|netsh|netstat|nfsadmin|nfsshare|nfsstat|nlb)\\b"
|
||||
- statement: "\\b(?i)(nlbmgr|nltest|nslookup|ntackup|ntcmdprompt|ntdsutil|ntfrsutl|openfiles|pagefileconfig|path|pathping|pause|pbadmin|pentnt|perfmon|ping|pnpunatten|pnputil|popd)\\b"
|
||||
- statement: "\\b(?i)(powercfg|powershell|powershell_ise|print|prncnfg|prndrvr|prnjobs|prnmngr|prnport|prnqctl|prompt|pubprn|pushd|pushprinterconnections|pwlauncher|qappsrv|qprocess)\\b"
|
||||
- statement: "\\b(?i)(query|quser|qwinsta|rasdial|rcp|rd|rdpsign|regentc|recover|redircmp|redirusr|reg|regini|regsvr32|relog|ren|rename|rendom|repadmin|repair-bde|replace|reset|restore)\\b"
|
||||
- statement: "\\b(?i)(rxec|risetup|rmdir|robocopy|route|rpcinfo|rpcping|rsh|runas|rundll32|rwinsta|scp|sc|setlocal|session|schtasks|scwcmd|secedit|serverceipoptin|servrmanagercmd|serverweroptin|set|setspn)\\b"
|
||||
- statement: "\\b(?i)(setx|sfc|shadow|shift|showmount|shutdown|sort|ssh|start|storrept|subst|sxstrace|ysocmgr|systeminfo|takeown|tapicfg|taskkill|tasklist|tcmsetup|telnet|tftp|time)\\b"
|
||||
- statement: "\\b(?i)(timeout|title|tlntadmn|tpmvscmgr|tpmvscmgr|tacerpt|tracert|tree|tscon|tsdiscon|tsecimp|tskill|tsprof|type|typeperf|tzutil|uddiconfig|umount|unlodctr|ver|verify)\\b"
|
||||
- statement: "\\b(?i)(verifier|verif|vol|vssadmin|w32tm|waitfor|wbadmin|wdsutil|wecutil|wevtutil|where|whoami|winnt|winnt32|winpop|winrm|winrs|winsat|wlbs|mic|wscript|xcopy)\\b"
|
||||
# / Flags
|
||||
- constant: "(/\\w+)"
|
||||
# Variables
|
||||
- special: "(%%\\w+)"
|
||||
- special: "(%\\w+%)"
|
||||
# Conditional flags
|
||||
- type: "--[a-z-]+"
|
||||
- type: "\\ -[a-z]+"
|
||||
|
||||
- identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?"
|
||||
- identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?"
|
||||
# "" String
|
||||
- constant.string:
|
||||
start: \"
|
||||
end: \"
|
||||
skip: \.
|
||||
rules:
|
||||
- constant.specialChar: (\\0|\\\\|\\t|\\n|\\r|\\"|\\')
|
||||
- constant.unicode: \\u\{[[:xdigit:]]+}
|
||||
# '' string
|
||||
- constant.string: "(\\'.+\\')"
|
||||
# rem as comment
|
||||
- comment.rem: "(?i)(rem\\s.*)"
|
||||
# :: as comment
|
||||
- comment.rem: "(?i)(\\:\\:\\s.*)"
|
||||
@@ -36,7 +36,11 @@ rules:
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
- special: "#\\{[^}]*\\}"
|
||||
- symbol.brackets:
|
||||
start: "#\\{"
|
||||
end: "\\}"
|
||||
rules:
|
||||
- default: ".*"
|
||||
|
||||
- constant.string:
|
||||
start: "'"
|
||||
|
||||
17
runtime/syntax/godoc.yaml
Normal file
17
runtime/syntax/godoc.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
# godoc
|
||||
# example: go doc -all | micro
|
||||
|
||||
filetype: godoc
|
||||
|
||||
detect:
|
||||
filename: "\\.godoc$"
|
||||
header: package.*import
|
||||
|
||||
rules:
|
||||
- preproc: "^[^ ].*"
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
@@ -18,9 +18,13 @@ rules:
|
||||
|
||||
- symbol.tag: "<|>"
|
||||
- constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+"
|
||||
- comment: "<!--.+?-->"
|
||||
- preproc: "<!DOCTYPE.+?>"
|
||||
|
||||
- comment:
|
||||
start: "<!--"
|
||||
end: "-->"
|
||||
rules: []
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
|
||||
@@ -8,7 +8,8 @@ rules:
|
||||
- constant.number: "\\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\\b"
|
||||
- constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
|
||||
- constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
|
||||
- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
|
||||
#- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
|
||||
# ^ this is not correct usage of the identifier color
|
||||
- symbol.brackets: "(\\{|\\})"
|
||||
- symbol.brackets: "(\\(|\\))"
|
||||
- symbol.brackets: "(\\[|\\])"
|
||||
@@ -22,16 +23,21 @@ rules:
|
||||
- statement: "\\b(set|super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b"
|
||||
# reserved but unassigned
|
||||
- error: "\\b(enum|implements|interface|package|private|protected|public|TODO)"
|
||||
- constant: "\\b(globalThis|Infinity|null|undefined|NaN)\\b"
|
||||
- constant: "\\b(null|undefined|NaN)\\b"
|
||||
- constant: "\\b(true|false)\\b"
|
||||
- type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Generator|Map|Math)\\b"
|
||||
- type: "\\b(Number|Object|Promise|Proxy|Reflect|RegExp|Set|String|Symbol|WeakMap|WeakSet)\\b"
|
||||
- type: "\\b(BigInt64Array|BigUint64Array|Float32Array|Float64Array|Int16Array)\\b"
|
||||
- type: "\\b(Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray)\\b"
|
||||
|
||||
# - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*"
|
||||
- constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]"
|
||||
- comment: "^#!.*/(env +)?node( |$)"
|
||||
|
||||
- identifier: "\\b(alert|decodeURI|decodeURIComponent|document|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|uneval|window)\\b"
|
||||
- identifier: "\\b(Intl|WebAssembly)\\b"
|
||||
- identifier: "\\b(Arguments)\\b"
|
||||
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
|
||||
19
runtime/syntax/jinja2.yaml
Normal file
19
runtime/syntax/jinja2.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
filetype: jinja2
|
||||
|
||||
rules:
|
||||
- include: "html"
|
||||
- special: "({{|}}|{%-?|-?%})"
|
||||
- default:
|
||||
start: "({%-?|{{)"
|
||||
end: "(-?%}|}})"
|
||||
limit-group: special
|
||||
rules:
|
||||
- include: "python"
|
||||
- statement: "\\b(ignore missing|with(out)? context|block|call|endblock|endcall|endfilter|endfor|endmacro|endraw|endset|extends|filter|for|include|macro|raw|recursive|scoped|set)\\b"
|
||||
- identifier.builtinfunc: "\\b(attr|batch|capitalize|center|count|d|default|dictsort|e|escape|filesizeformat|first|forceescape|groupby|indent|join|last|length|lower|pprint|random|reject|rejectattr|replace|reverse|safe|select|selectattr|striptags|title|tojson|trim|truncate|unique|upper|urlencode|urlize|wordcount|wordwrap|xmlattr)\\b"
|
||||
- identifier.builtintest: "\\b(callable|defined|divisibleby|eq|equalto|escaped|even|ge|gt|iterable|le|lower|lt|mapping|ne|none|number|odd|sameas|sequence|string|undefined|upper)\\b"
|
||||
- identifier.defaultglobal: "\\b(lipsum|cycler|joiner|namespace)\\b"
|
||||
- comment:
|
||||
start: "{#"
|
||||
end: "#}"
|
||||
rules: []
|
||||
@@ -13,11 +13,11 @@ rules:
|
||||
# definitions
|
||||
- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
|
||||
# keywords
|
||||
- statement: "\\b(begin|break|catch|continue|function|elseif|struct|else|end|finally|for|global|local|const|if|include|import|using|require|macro|println|return|try|type|while|module)\\b"
|
||||
- statement: "\\b(begin|break|catch|continue|function|elseif|struct|else|end|finally|for|global|local|let|const|if|import|using|macro|println|return|try|while|module)\\b"
|
||||
# decorators
|
||||
- identifier.macro: "@[A-Za-z0-9_]+"
|
||||
# operators
|
||||
- symbol.operator: "[-+*/|=%<>&~^]|\\b(and|not|or|is|in)\\b"
|
||||
- symbol.operator: "[-+*/|=%<>&~^]|\\b(isa|in)\\b"
|
||||
# parentheses
|
||||
- symbol.brackets: "([(){}]|\\[|\\])"
|
||||
# numbers
|
||||
|
||||
74
runtime/syntax/make_headers.go
Normal file
74
runtime/syntax/make_headers.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type HeaderYaml struct {
|
||||
FileType string `yaml:"filetype"`
|
||||
Detect struct {
|
||||
FNameRgx string `yaml:"filename"`
|
||||
HeaderRgx string `yaml:"header"`
|
||||
} `yaml:"detect"`
|
||||
}
|
||||
|
||||
type Header struct {
|
||||
FileType string
|
||||
FNameRgx string
|
||||
HeaderRgx string
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 {
|
||||
os.Chdir(os.Args[1])
|
||||
}
|
||||
files, _ := ioutil.ReadDir(".")
|
||||
for _, f := range files {
|
||||
fname := f.Name()
|
||||
if strings.HasSuffix(fname, ".yaml") {
|
||||
convert(fname[:len(fname)-5])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func convert(name string) {
|
||||
filename := name + ".yaml"
|
||||
var hdr HeaderYaml
|
||||
source, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = yaml.Unmarshal(source, &hdr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
encode(name, hdr)
|
||||
}
|
||||
|
||||
func encode(name string, c HeaderYaml) {
|
||||
f, _ := os.Create(name + ".hdr")
|
||||
f.WriteString(c.FileType + "\n")
|
||||
f.WriteString(c.Detect.FNameRgx + "\n")
|
||||
f.WriteString(c.Detect.HeaderRgx + "\n")
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func decode(name string) Header {
|
||||
start := time.Now()
|
||||
data, _ := ioutil.ReadFile(name + ".hdr")
|
||||
strs := bytes.Split(data, []byte{'\n'})
|
||||
var hdr Header
|
||||
hdr.FileType = string(strs[0])
|
||||
hdr.FNameRgx = string(strs[1])
|
||||
hdr.HeaderRgx = string(strs[2])
|
||||
fmt.Printf("took %v\n", time.Since(start))
|
||||
|
||||
return hdr
|
||||
}
|
||||
23
runtime/syntax/mc.yaml
Normal file
23
runtime/syntax/mc.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
# sendmail config files
|
||||
|
||||
filetype: mc
|
||||
|
||||
detect:
|
||||
filename: "\\.mc$"
|
||||
|
||||
rules:
|
||||
- statement: "^(divert|VERSIONID|OSTYPE|DOMAIN|FEATURE|define)"
|
||||
- statement: "^(DAEMON_OPTIONS|MAILER)"
|
||||
- comment:
|
||||
start: "#"
|
||||
end: "$"
|
||||
rules: []
|
||||
- comment:
|
||||
start: "dnl"
|
||||
end: "$"
|
||||
rules: []
|
||||
- constant.string:
|
||||
start: "`"
|
||||
end: "'"
|
||||
rules: []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
filetype: nim
|
||||
|
||||
detect:
|
||||
filename: "\\.nim$|\\.nims$|nim.cfg"
|
||||
filename: "\\.nims?$|nim.cfg"
|
||||
|
||||
rules:
|
||||
- preproc: "[\\{\\|]\\b(atom|lit|sym|ident|call|lvalue|sideeffect|nosideeffect|param|genericparam|module|type|let|var|const|result|proc|method|iterator|converter|macro|template|field|enumfield|forvar|label|nk[a-zA-Z]+|alias|noalias)\\b[\\}\\|]"
|
||||
|
||||
40
runtime/syntax/proto.yaml
Normal file
40
runtime/syntax/proto.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
filetype: proto
|
||||
|
||||
detect:
|
||||
filename: "(\\.(proto)$$)"
|
||||
|
||||
rules:
|
||||
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
|
||||
- type: "\\b(int(8|16|32|64))|string|bytes|repeated|bool|required|map|optional|oneof|union\\b"
|
||||
- statement: "\\b(import|service|enum|syntax|package|option|message|rpc|returns|extensions|to)\\b"
|
||||
- constant: "'\\\\(([0-3]?[0-7]{1,2}))'"
|
||||
- constant: "'\\\\x[0-9A-Fa-f]{1,2}'"
|
||||
- symbol.brackets: "[(){}]|\\[|\\]"
|
||||
- constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- constant.string:
|
||||
start: "'"
|
||||
end: "'"
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- preproc: "..+"
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
@@ -1,26 +1,68 @@
|
||||
filetype: ruby
|
||||
|
||||
detect:
|
||||
filename: "\\.rb$|\\.gemspec$|Gemfile|config.ru|Rakefile|Capfile|Vagrantfile"
|
||||
filename: "\\.(rb|rake|gemspec)$|^(Gemfile|config.ru|Rakefile|Capfile|Vagrantfile|Guardfile)$"
|
||||
header: "^#!.*/(env +)?ruby( |$)"
|
||||
|
||||
rules:
|
||||
- statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\\b"
|
||||
- comment.bright:
|
||||
start: "##"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)"
|
||||
- comment:
|
||||
start: "#"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)"
|
||||
|
||||
- statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|for|if|in|module|next|nil|not|or|private|protected|public|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\\b"
|
||||
- constant: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*"
|
||||
- constant.number: "\\b[0-9]+\\b"
|
||||
- constant.number: "(?i)\\b0x[0-9a-f][0-9a-f_]*\\b"
|
||||
- constant.number: "(?i)\\b0b[01][01_]*\\b"
|
||||
- constant.number: "(?i)\\b[0-9][0-9_]*(['.'][0-9_]+)?(e[\\-]?[0-9_]+)?\\b"
|
||||
# Ruby "Symbols"
|
||||
- constant: "(i?)([ ]|^):[0-9A-Z_]+\\b"
|
||||
- constant: "\\b(__FILE__|__LINE__)\\b"
|
||||
- constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*"
|
||||
- constant.string: "`[^`]*`|%x\\{[^}]*\\}"
|
||||
- constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!"
|
||||
- special: "#\\{[^}]*\\}"
|
||||
- constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!"
|
||||
- comment: "#[^{].*$|#$"
|
||||
- comment.bright: "##[^{].*$|##$"
|
||||
|
||||
- constant.string:
|
||||
start: "'"
|
||||
end: "'"
|
||||
skip: "\\\\."
|
||||
rules: []
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- symbol.brackets:
|
||||
start: "#\\{"
|
||||
end: "\\}"
|
||||
rules:
|
||||
- default: ".*"
|
||||
|
||||
- constant.string.exec:
|
||||
start: "`"
|
||||
end: "`"
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- symbol.brackets:
|
||||
start: "#\\{"
|
||||
end: "\\}"
|
||||
rules:
|
||||
- default: ".*"
|
||||
|
||||
- constant.string: "%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!"
|
||||
- constant.string: "%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!"
|
||||
- constant.string.exec: "%[x]\\{[^}]*\\}|%[x]\\([^)]*\\)|%[x]<[^>]*>|%[x]\\[[^]]*\\]|%[x]\\$[^$]*\\$|%[x]\\^[^^]*\\^|%[x]![^!]*!"
|
||||
- constant.bool: "\\b(true|false|nil|TRUE|FALSE|NIL)\\b"
|
||||
- symbol.operator: "[-+/*=<>!~%&|^]|\\b:"
|
||||
- symbol.brackets: "([(){}]|\\[|\\])"
|
||||
- constant.macro:
|
||||
start: "<<-?'?EOT'?"
|
||||
end: "^EOT"
|
||||
rules: []
|
||||
|
||||
- todo: "(XXX|TODO|FIXME|\\?\\?\\?)"
|
||||
- preproc.shebang: "^#!.+?( |$)"
|
||||
|
||||
27
runtime/syntax/svelte.yaml
Normal file
27
runtime/syntax/svelte.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
filetype: svelte
|
||||
|
||||
detect:
|
||||
filename: "\\.svelte$"
|
||||
|
||||
rules:
|
||||
- default:
|
||||
start: "<script>"
|
||||
end: "</script>"
|
||||
rules:
|
||||
- include: "javascript"
|
||||
|
||||
- default:
|
||||
start: "<script lang=\"ts\">"
|
||||
end: "</script>"
|
||||
rules:
|
||||
- include: "typescript"
|
||||
- default:
|
||||
start: "<style.*?>"
|
||||
end: "</style.*?>"
|
||||
rules:
|
||||
- include: "css"
|
||||
- default:
|
||||
start: "^"
|
||||
end: "$"
|
||||
rules:
|
||||
- include: "html5"
|
||||
@@ -20,9 +20,10 @@ rules:
|
||||
- special: "[&\\\\]"
|
||||
# macros
|
||||
- statement: "\\\\@?[a-zA-Z_]+"
|
||||
- statement: "\\\\%"
|
||||
# comments
|
||||
- comment:
|
||||
start: "%"
|
||||
start: "[^\\\\]%"
|
||||
end: "$"
|
||||
rules: []
|
||||
- comment:
|
||||
|
||||
85
runtime/syntax/v.yaml
Normal file
85
runtime/syntax/v.yaml
Normal file
@@ -0,0 +1,85 @@
|
||||
filetype: v
|
||||
|
||||
detect:
|
||||
filename: "\\.v$"
|
||||
|
||||
rules:
|
||||
# Conditionals and control flow
|
||||
- keywords: "\\b(import|go|defer)\\b"
|
||||
- special: "\\b(or|break|continue|match|case|goto|return|none)\\b"
|
||||
- function: "\\b(fn)\\b"
|
||||
- main_function: "\\b(fn main\\(\\))"
|
||||
- optionals: "\\b(none|error\\()"
|
||||
- statement: "\\b(if|else|for|match)\\b"
|
||||
- assert: "\\b(assert)\\b"
|
||||
- symbol.operator: "\\b([-+/*=<>!~%&|^])\\b"
|
||||
- symbol.operator: "\\b(:=)\\b"
|
||||
- symbol.operator: "\\b(\\|\\|)\b"
|
||||
- symbol.operator: "\\b(\\&\\&)\\b"
|
||||
|
||||
- compile_if: "\\b(\\$if|\\$else)\\b"
|
||||
- oses: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|js|android|solaris|haiku)\\b"
|
||||
|
||||
# Types
|
||||
- symbol: "(,|\\.)"
|
||||
- btype: "\\b(bool)\\b"
|
||||
- ztype: "\\b(char|byte)\\b"
|
||||
- itype: "\\b(int|i(8|16|64)|u(8|16|32|64))\\b"
|
||||
- ftype: "\\b(f(32|64))\\b"
|
||||
- ptype: "\\b(uintptr|charptr|byteptr|voidptr)\\b"
|
||||
- atype: "\\b(array)\\b"
|
||||
- stype: "\\b(string|ustring)\\b"
|
||||
- mtype: "\\b(map)\\b"
|
||||
- type.keyword: "\\b(pub|mut|struct|enum|interface|module|type|const)\\b"
|
||||
- constant.bool: "\\b(true|false)\\b"
|
||||
|
||||
# Brackets
|
||||
- symbol.brackets: "(\\{|\\})"
|
||||
- symbol.brackets: "(\\(|\\))"
|
||||
- symbol.brackets: "(\\[|\\])"
|
||||
|
||||
# Numbers and strings
|
||||
- constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "%."
|
||||
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
|
||||
|
||||
- constant.string:
|
||||
start: "'"
|
||||
end: "'"
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- error: "..+"
|
||||
- constant.specialChar: "%."
|
||||
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
|
||||
|
||||
- constant.string:
|
||||
start: "`"
|
||||
end: "`"
|
||||
rules: []
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- function.attribute:
|
||||
start: "^\\["
|
||||
end: "\\]$"
|
||||
rules:
|
||||
- known: "\\b(deprecated|inline|typedef|if)\\b"
|
||||
|
||||
60
runtime/syntax/verilog.yaml
Normal file
60
runtime/syntax/verilog.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
filetype: verilog
|
||||
|
||||
detect:
|
||||
filename: "\\.(vh|sv|svh)$"
|
||||
|
||||
rules:
|
||||
- preproc: "\\b(module|package|program|endmodule|endpackage|endprogram)\\b"
|
||||
- type.keyword: "\\b(task|interface|class|endtask|endinterface|endclass)\\b"
|
||||
# builtin functions like $display
|
||||
- special: "\\$[0-9A-Za-z_]+"
|
||||
|
||||
# Verilog keywords
|
||||
- statement: "\\b(always|and|assign|automatic|begin|buf|bufif0|bufif1|case|casex|casez|cell|cmos|config)\\b"
|
||||
- statement: "\\b(deassign|default|defparam|design|disable|edge|else|end|endcase|endconfig|endfunction|endgenerate)\\b"
|
||||
- statement: "\\b(endprimitive|endspecify|endtable|event|for|force|forever|fork|function|generate)\\b"
|
||||
- statement: "\\b(genvar|highz0|highz1|if|iff|ifnone|incdir|include|initial|input|instance|join)\\b"
|
||||
- statement: "\\b(large|liblist|library|localparam|macromodule|medium|nand|negedge|nmos|nor|noshowcancelled)\\b"
|
||||
- statement: "\\b(not|notif0|notif1|null|or|output|parameter|pmos|posedge|primitive|pull0|pull1|pulldown|pullup)\\b"
|
||||
- statement: "\\b(pulsestyle_onevent|pulsestyle_ondetect|rcmos|realtime|reg|release|repeat|rnmos|rpmos|rtran)\\b"
|
||||
- statement: "\\b(rtranif0|rtranif1|scalared|showcancelled|small|specify|specparam|strong0|strong1|supply0)\\b"
|
||||
- statement: "\\b(supply1|table|time|tran|tranif0|tranif1|tri0|tri1|triand|trior|trireg|use|uwire)\\b"
|
||||
- statement: "\\b(vectored|wait|wand|weak0|weak1|while|wor|xnor|xor)\\b"
|
||||
|
||||
# SystemVerilog keywords
|
||||
- statement: "\\b(alias|always_comb|always_ff|always_latch|assert|assume|before|bind|bins|binsof|break)\\b"
|
||||
- statement: "\\b(chandle|clocking|const|constraint|context|continue|cover|covergroup|coverpoint|cross|dist|do)\\b"
|
||||
- statement: "\\b(endclocking|endgroup|endproperty|endsequence|enum)\\b"
|
||||
- statement: "\\b(expect|export|extends|extern|final|first_match|foreach|forkjoin|ignore_bins|illegal_bins|import)\\b"
|
||||
- statement: "\\b(inside|intersect|join_any|join_none|local|longint|matches|modport|new)\\b"
|
||||
- statement: "\\b(packed|priority|property|protected|pure|rand|randc|randcase|randsequence|ref|return)\\b"
|
||||
- statement: "\\b(sequence|solve|static|struct|super|tagged|this|throughout|timeprecision)\\b"
|
||||
- statement: "\\b(timeunit|type|typedef|union|unique|virtual|wait_order|wildcard|with|within)\\b"
|
||||
|
||||
# types
|
||||
- type.keyword: "\\b(int|integer|logic|wire|tri|unsigned|signed|inout|var|shortint|shortreal|real|void|string|bit|byte)\\b"
|
||||
|
||||
# constants
|
||||
- constant.number: "\\b[0-9]+\\b"
|
||||
- constant.number: "\\b'[su]?[dboh][0-9xzXZa-fA-F]+\\b"
|
||||
# .asdf(...) argument syntax
|
||||
- special: "\\.((\\*)|([A-Za-z][A-Za-z0-9_]*))"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
@@ -24,7 +24,7 @@ rules:
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- constant.comment:
|
||||
- comment:
|
||||
start: "\""
|
||||
end: "$"
|
||||
rules: []
|
||||
|
||||
@@ -11,14 +11,20 @@ rules:
|
||||
- include: "html5"
|
||||
|
||||
- default:
|
||||
start: "<script.*?>"
|
||||
end: "</script.*?>"
|
||||
start: "<script>"
|
||||
end: "</script>"
|
||||
rules:
|
||||
- include: "javascript"
|
||||
|
||||
- default:
|
||||
start: "<script[ ]+lang=(\"ts\"|'ts')>"
|
||||
end: "</script>"
|
||||
rules:
|
||||
- include: "typescript"
|
||||
|
||||
- default:
|
||||
start: "<style.*?>"
|
||||
end: "</style.*?>"
|
||||
rules:
|
||||
- include: "css"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user