2017-11-02 03:03:24 +01:00
|
|
|
= Highlighters
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-02 03:03:24 +01:00
|
|
|
== Description
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
Manipulation of the displayed text is done through highlighters, which can
|
|
|
|
be added or removed with the following commands:
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
add-highlighter <path> <highlighter_name> <highlighter_parameters> ...
|
|
|
|
----------------------------------------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
and
|
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
------------------------------------------
|
|
|
|
remove-highlighter <path>/<highlighter_id>
|
|
|
|
------------------------------------------
|
|
|
|
|
|
|
|
*path* is the name of an highlighter group, it is expressed as a */*
|
|
|
|
separated path starting with a scope. Scopes are *global*, *buffer*,
|
|
|
|
*window* and *shared*
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
*highlighter_id* is a name generated by the highlighter specified with
|
|
|
|
*highlighter_name*, possibly dependent on the parameters. Use command
|
2017-11-06 10:08:59 +01:00
|
|
|
completion in a prompt on the *remove-highlighter* command to see the
|
|
|
|
existing highlighters ids.
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2018-03-06 11:34:00 +01:00
|
|
|
== Convenient highlighters
|
2016-02-03 18:15:35 +01:00
|
|
|
|
|
|
|
*show_matching*::
|
2017-11-02 10:37:39 +01:00
|
|
|
highlight matching char of the character under the selections' cursor
|
2018-03-06 11:34:00 +01:00
|
|
|
using `MatchingChar` face
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-02-04 08:10:14 +01:00
|
|
|
*show_whitespaces* [options]::
|
2017-11-02 10:37:39 +01:00
|
|
|
display symbols on top of whitespaces to make them more explicit
|
2018-03-06 11:34:00 +01:00
|
|
|
using the `Whitespace` face, with the following *options*:
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-lf* <separator>:::
|
|
|
|
a one character long separator that will replace line feeds
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-spc* <separator>:::
|
|
|
|
a one character long separator that will replace spaces
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-nbsp* <separator>:::
|
|
|
|
a one character long separator that will replace non-breakable spaces
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-tab* <separator>:::
|
|
|
|
a one character long separator that will replace tabulations
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-tabpad* <separator>:::
|
|
|
|
a one character long separator that will be appended to tabulations to honor the *tabstop* option
|
2017-02-04 08:10:14 +01:00
|
|
|
|
2016-02-03 18:15:35 +01:00
|
|
|
*number_lines* [options]::
|
2017-11-02 10:37:39 +01:00
|
|
|
show line numbers, with the following *options*:
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-relative*:::
|
|
|
|
show line numbers relative to the main cursor line
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-hlcursor*:::
|
|
|
|
highlight the cursor line with a separate face
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-separator* <separator text>:::
|
|
|
|
specify a string to separate the line numbers column with
|
|
|
|
the rest of the buffer (default is '|')
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2017-05-06 17:21:10 +02:00
|
|
|
*wrap* [options]::
|
2017-11-02 10:37:39 +01:00
|
|
|
soft wrap buffer text at window width, with the following *options*:
|
2017-05-06 17:21:10 +02:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-word*:::
|
|
|
|
wrap at word boundaries instead of codepoint boundaries.
|
2017-05-06 17:21:10 +02:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-indent*:::
|
|
|
|
preserve line indent when wrapping.
|
2017-11-01 18:26:00 +01:00
|
|
|
|
2017-11-02 10:37:39 +01:00
|
|
|
*-width <max_width>*:::
|
|
|
|
wrap text at *max_width* if the window is wider.
|
2017-06-08 08:05:44 +02:00
|
|
|
|
2018-03-06 11:34:00 +01:00
|
|
|
== General highlighters
|
|
|
|
|
2017-08-31 15:08:57 +02:00
|
|
|
*fill* <face>::
|
2017-11-02 10:37:39 +01:00
|
|
|
fill using the given *face*, mostly useful with regions highlighters
|
2017-08-31 15:08:57 +02:00
|
|
|
|
|
|
|
*column* <number> <face>::
|
2017-11-02 10:37:39 +01:00
|
|
|
highlight column *number* with face *face*
|
2017-08-31 15:08:57 +02:00
|
|
|
|
|
|
|
*line* <number> <face>::
|
2017-11-02 10:37:39 +01:00
|
|
|
highlight line *number* with face *face*
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2018-03-06 11:34:00 +01:00
|
|
|
*regex* <regex> <capture_id>:<face> ...::
|
|
|
|
highlight a regex, takes the regex as first parameter, followed by
|
|
|
|
any number of face parameters.
|
|
|
|
This highlights C++ style comments in cyan, with an eventual 'TODO:'
|
|
|
|
in yellow on red background:
|
2017-11-02 03:03:24 +01:00
|
|
|
|
2018-03-06 11:34:00 +01:00
|
|
|
-------------------------------------------------------------------
|
|
|
|
add-highlighter window regex //\h*(TODO:)[^\n]* 0:cyan 1:yellow,red
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
|
|
|
|
*dynregex* <expression> <capture_id>:<face> ...::
|
|
|
|
similar to regex, but expand (like a command parameter would) the
|
|
|
|
given expression before building a regex from the result.
|
|
|
|
This highlights all the current search matches in italic:
|
|
|
|
|
|
|
|
---------------------------------------------
|
|
|
|
add-highlighter window dynregex '%reg{/}' 0:i
|
|
|
|
---------------------------------------------
|
|
|
|
|
|
|
|
== Specs highlighters
|
|
|
|
|
|
|
|
The following highlighters are useful to add indicators like lint warnings,
|
|
|
|
git blame output or spelling typos.
|
|
|
|
See <<options#types,`:doc options types`>> for the format of `line-specs`
|
|
|
|
and `range-specs`.
|
|
|
|
|
|
|
|
*flag_lines* <face> <option_name>::
|
|
|
|
add columns in front of the buffer, and display the flags specified
|
|
|
|
in `line-specs` option, using <face>.
|
|
|
|
In this example two words will be added in the gutter: a blue Foo at
|
|
|
|
line 1 and a bold red/yellow Bar on line 3:
|
|
|
|
|
|
|
|
---------------------------------------------------------------
|
|
|
|
declare-option line-specs my_flags
|
|
|
|
set-option window my_flags 1486635122:1|Foo:3|{red,yellow+b}Bar
|
|
|
|
add-highlighter window/ flag_lines blue my_flags
|
|
|
|
---------------------------------------------------------------
|
|
|
|
|
|
|
|
*ranges* <option_name>::
|
|
|
|
use the data in the `range-specs` option of the given name to highlight
|
|
|
|
the buffer. The string part of each tuple of the range-specs is
|
|
|
|
interpreted as a *face* to apply to the range.
|
|
|
|
In this example the 3 first chars of the buffer will be colored in red:
|
|
|
|
|
|
|
|
-------------------------------------------------
|
|
|
|
declare-option range-specs my_range
|
|
|
|
set-option window my_range 1486635122:1.1,1.3|red
|
|
|
|
add-highlighter window/ ranges my_range
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
|
|
*replace-ranges* <option_name>::
|
|
|
|
use the data in the `range-specs` option of the given name to highlight
|
|
|
|
the buffer. The string part of each tuple of the range-specs is
|
|
|
|
interpreted as a *display line* to display in place of the range.
|
|
|
|
Here, the 3 first chars of the buffer will be replaced by the word 'red':
|
|
|
|
|
|
|
|
-------------------------------------------------
|
|
|
|
declare-option range-specs my_range
|
|
|
|
set-option window my_range 1486635122:1.1,1.3|red
|
|
|
|
add-highlighter window/ replace-ranges my_range
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
|
|
== Highlighting Groups
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-12 15:44:04 +01:00
|
|
|
The *group* highlighter is a container for other highlighters. A subgroup
|
|
|
|
can be added to an existing group or scope using:
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
-----------------------------------
|
|
|
|
add-highlighter <path> group <name>
|
|
|
|
-----------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
That group is then accessible using the *<path>/<name>* path
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
------------------------------------------------
|
2017-11-01 12:00:44 +01:00
|
|
|
add-highlighter <path>/<name> <type> <params>...
|
2017-01-04 01:07:45 +01:00
|
|
|
------------------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-08-31 15:08:57 +02:00
|
|
|
In order to specify which kinds of highlighters can be added to a given group, the *-passes*
|
|
|
|
flag set can be passed along with the group name. Possible values for this option can be one
|
|
|
|
or several (separated with a pipe sign) of *colorize*, *move* or *wrap* (default: *colorize*):
|
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
--------------------------------------------------------------
|
|
|
|
add-highlighter window group -passes colorize|move|wrap <name>
|
|
|
|
--------------------------------------------------------------
|
2017-08-31 15:08:57 +02:00
|
|
|
|
2017-11-02 03:03:24 +01:00
|
|
|
== Regions highlighters
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
A special highlighter provides a way to segment the buffer into regions,
|
|
|
|
which are to be highlighted differently.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-03 18:15:35 +01:00
|
|
|
*name*::
|
2017-11-02 10:37:39 +01:00
|
|
|
user defined, used to identify the region
|
2016-02-03 18:15:35 +01:00
|
|
|
*opening*::
|
2017-11-02 10:37:39 +01:00
|
|
|
regex that defines the region start text
|
2016-02-03 18:15:35 +01:00
|
|
|
*closing*::
|
2017-11-02 10:37:39 +01:00
|
|
|
regex that defines the region end text
|
2016-02-03 18:15:35 +01:00
|
|
|
*recurse*::
|
2017-11-02 10:37:39 +01:00
|
|
|
regex that defines the text that matches recursively an end token
|
|
|
|
into the region
|
2016-02-03 18:15:35 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
The *recurse* option is useful for regions that can be nested, for example
|
|
|
|
the following contruct:
|
2016-02-03 18:15:35 +01:00
|
|
|
|
|
|
|
----------
|
|
|
|
%sh{ ... }
|
|
|
|
----------
|
|
|
|
|
|
|
|
accepts nested braces scopes ('{ ... }') so the following string is valid:
|
|
|
|
|
|
|
|
----------------------
|
|
|
|
%sh{ ... { ... } ... }
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
This region can be defined with:
|
|
|
|
|
|
|
|
------------------------
|
|
|
|
shell_expand %sh\{ \} \{
|
|
|
|
------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-04-21 12:32:47 +02:00
|
|
|
Regions are used in the region highlighters which can take any number
|
2016-02-10 22:03:49 +01:00
|
|
|
of regions.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-03 18:15:35 +01:00
|
|
|
The following command:
|
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
------------------------------------------------------
|
|
|
|
add-highlighter <path> regions <name> \
|
|
|
|
<region_name1> <opening1> <closing1> <recurse1> \
|
|
|
|
<region_name2> <opening2> <closing2> <recurse2>...
|
|
|
|
------------------------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
defines multiple regions in which other highlighters can be added as follows:
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
-----------------------------------------------
|
2017-11-01 12:00:44 +01:00
|
|
|
add-highlighter <path>/<name>/<region_name> ...
|
2017-01-04 01:07:45 +01:00
|
|
|
-----------------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
Regions are matched using the left-most rule: the left-most region opening
|
|
|
|
starts a new region. When a region closes, the closest next opening start
|
|
|
|
another region.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
That matches the rule governing most programming language parsing.
|
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
Regions also supports a *-default <default_region>* switch to define the
|
|
|
|
default region, when no other region matches the current buffer range.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-02-07 00:00:13 +01:00
|
|
|
If the *-match-capture* switch is passed, then region closing and recurse
|
|
|
|
matches are considered valid for a given region opening match only if they
|
|
|
|
matched the same content for the capture 1.
|
|
|
|
|
2017-04-21 12:32:47 +02:00
|
|
|
Most programming languages can then be properly highlighted using a region
|
2016-02-10 22:03:49 +01:00
|
|
|
highlighter as root:
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-03 18:15:35 +01:00
|
|
|
-----------------------------------------------------------------
|
2017-11-01 12:00:44 +01:00
|
|
|
add-highlighter <path> regions -default code <lang> \
|
2017-11-02 10:37:39 +01:00
|
|
|
string <str_opening> <str_closing> <str_recurse> \
|
|
|
|
comment <comment_opening> <comment_closing> <comment_recurse>
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
add-highlighter <path>/<lang>/code ...
|
|
|
|
add-highlighter <path>/<lang>/string ...
|
|
|
|
add-highlighter <path>/<lang>/comment ...
|
2016-02-03 18:15:35 +01:00
|
|
|
-----------------------------------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-02 03:03:24 +01:00
|
|
|
== Shared Highlighters
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
Highlighters are often defined for a specific filetype, and it makes then
|
|
|
|
sense to share the highlighters between all the windows on the same filetypes.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
Highlighters can be put in the shared scope in order to make them reusable.
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
---------------------------------------
|
|
|
|
add-highlighter shared/<group_name> ...
|
|
|
|
---------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2016-02-10 22:03:49 +01:00
|
|
|
The common case would be to create a named shared group, and then fill it
|
|
|
|
with highlighters:
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
---------------------------------------
|
|
|
|
add-highlighter shared/ group <name>
|
|
|
|
add-highlighter shared/<name> regex ...
|
|
|
|
---------------------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
It can then be referenced in a window using the ref highlighter.
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
--------------------------
|
|
|
|
add-highlighter ref <name>
|
|
|
|
--------------------------
|
2016-02-02 20:15:12 +01:00
|
|
|
|
2017-11-01 12:00:44 +01:00
|
|
|
The ref can reference any named highlighter in the shared scope.
|