2017-11-02 05:03:24 +03:00
|
|
|
= Highlighters
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-11-02 05:03:24 +03:00
|
|
|
== Description
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2016-02-11 00:03:49 +03:00
|
|
|
Manipulation of the displayed text is done through highlighters, which can
|
|
|
|
be added or removed with the following commands:
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2020-03-30 13:03:51 +03:00
|
|
|
-----------------------------------------------------------------
|
|
|
|
add-highlighter [-override] <path>/<name> <type> <parameters> ...
|
|
|
|
-----------------------------------------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
|
|
|
and
|
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
--------------------------------
|
|
|
|
remove-highlighter <path>/<name>
|
|
|
|
--------------------------------
|
2017-11-01 14:00:44 +03:00
|
|
|
|
2019-04-04 05:48:27 +03:00
|
|
|
*path* is the name of a highlighter group, it is expressed as a */*
|
2017-11-01 14:00:44 +03:00
|
|
|
separated path starting with a scope. Scopes are *global*, *buffer*,
|
|
|
|
*window* and *shared*
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
*name* is the name of the highlighter, if name is omitted in
|
|
|
|
`add-highlighter` (the path ends with a `/`), it will be auto-generated
|
|
|
|
from the remaining parameters.
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2020-03-30 13:03:51 +03:00
|
|
|
if `-override` is specified and the given name already exists, that
|
|
|
|
highlighter is replaced with the new one.
|
|
|
|
|
2018-03-06 13:34:00 +03:00
|
|
|
== Convenient highlighters
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2018-07-08 12:11:04 +03:00
|
|
|
*show-matching*::
|
2017-11-02 12:37:39 +03:00
|
|
|
highlight matching char of the character under the selections' cursor
|
2023-06-14 12:49:06 +03:00
|
|
|
using `MatchingChar` face, with the following *options*:
|
|
|
|
|
|
|
|
*-previous*:::
|
|
|
|
fall back to the character before the cursor when the cursor is not
|
|
|
|
over a matching char
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2018-07-08 12:11:04 +03:00
|
|
|
*show-whitespaces* [options]::
|
2017-11-02 12:37:39 +03:00
|
|
|
display symbols on top of whitespaces to make them more explicit
|
2018-03-06 13:34:00 +03:00
|
|
|
using the `Whitespace` face, with the following *options*:
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-lf* <separator>:::
|
|
|
|
a one character long separator that will replace line feeds
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-spc* <separator>:::
|
|
|
|
a one character long separator that will replace spaces
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-nbsp* <separator>:::
|
|
|
|
a one character long separator that will replace non-breakable spaces
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-tab* <separator>:::
|
|
|
|
a one character long separator that will replace tabulations
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-tabpad* <separator>:::
|
|
|
|
a one character long separator that will be appended to tabulations to honor the *tabstop* option
|
2017-02-04 10:10:14 +03:00
|
|
|
|
2023-09-07 22:50:11 +03:00
|
|
|
*-only-trailing*:::
|
|
|
|
only highlight whitespaces at the end of the line
|
|
|
|
|
2018-07-08 12:11:04 +03:00
|
|
|
*number-lines* [options]::
|
2018-05-18 16:47:44 +03:00
|
|
|
show line numbers using the `LineNumbers`, `LineNumberCursor` and `LineNumbersWrapped` faces,
|
|
|
|
with the following *options*:
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-relative*:::
|
|
|
|
show line numbers relative to the main cursor line
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-hlcursor*:::
|
|
|
|
highlight the cursor line with a separate face
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-separator* <separator text>:::
|
2020-05-28 19:37:26 +03:00
|
|
|
specify a string to separate the line numbers column from
|
2017-11-02 12:37:39 +03:00
|
|
|
the rest of the buffer (default is '|')
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2021-11-04 08:01:30 +03:00
|
|
|
*-cursor-separator* <separator text>:::
|
|
|
|
identical to *-separator* but applies only to the line of the cursor
|
|
|
|
(default is the same value passed to *-separator*)
|
|
|
|
|
2019-12-14 15:18:34 +03:00
|
|
|
*-min-digits* <num>:::
|
|
|
|
always reserve room for at least *num* digits,
|
|
|
|
so text doesn't jump around as lines are added or removed
|
|
|
|
(default is 2)
|
|
|
|
|
2017-05-06 18:21:10 +03:00
|
|
|
*wrap* [options]::
|
2017-11-02 12:37:39 +03:00
|
|
|
soft wrap buffer text at window width, with the following *options*:
|
2017-05-06 18:21:10 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-word*:::
|
|
|
|
wrap at word boundaries instead of codepoint boundaries.
|
2017-05-06 18:21:10 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-indent*:::
|
|
|
|
preserve line indent when wrapping.
|
2017-11-01 20:26:00 +03:00
|
|
|
|
2017-11-02 12:37:39 +03:00
|
|
|
*-width <max_width>*:::
|
|
|
|
wrap text at *max_width* if the window is wider.
|
2017-06-08 09:05:44 +03:00
|
|
|
|
2018-05-26 15:22:00 +03:00
|
|
|
*-marker <marker_text>*:::
|
|
|
|
prefix wrapped lines with *marker_text*; if *-indent* was given,
|
|
|
|
the marker_text is displayed into the indentation if possible.
|
|
|
|
|
2018-03-06 13:34:00 +03:00
|
|
|
== General highlighters
|
|
|
|
|
2017-08-31 16:08:57 +03:00
|
|
|
*fill* <face>::
|
2017-11-02 12:37:39 +03:00
|
|
|
fill using the given *face*, mostly useful with regions highlighters
|
2017-08-31 16:08:57 +03:00
|
|
|
|
|
|
|
*column* <number> <face>::
|
2017-11-02 12:37:39 +03:00
|
|
|
highlight column *number* with face *face*
|
2017-08-31 16:08:57 +03:00
|
|
|
|
|
|
|
*line* <number> <face>::
|
2017-11-02 12:37:39 +03:00
|
|
|
highlight line *number* with face *face*
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2018-03-06 13:34:00 +03: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 05:03:24 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
--------------------------------------------------------------------
|
|
|
|
add-highlighter window/ regex //\h*(TODO:)[^\n]* 0:cyan 1:yellow,red
|
|
|
|
--------------------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
|
2019-01-03 14:52:15 +03:00
|
|
|
capture_id can be either the capture number, or its name if a
|
|
|
|
named capture is used in the regex (See
|
2022-03-29 23:36:01 +03:00
|
|
|
<<regex#groups, `:doc regex groups`>>)
|
2019-01-03 14:52:15 +03:00
|
|
|
|
2018-03-06 13:34:00 +03:00
|
|
|
*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:
|
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
-----------------------------------------------
|
|
|
|
add-highlighter window/ dynregex '%reg{/}' 0:+i
|
|
|
|
-----------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
|
|
|
|
== Specs highlighters
|
|
|
|
|
|
|
|
The following highlighters are useful to add indicators like lint warnings,
|
2020-05-28 19:37:26 +03:00
|
|
|
git blame output or spelling mistakes.
|
2018-03-06 13:34:00 +03:00
|
|
|
See <<options#types,`:doc options types`>> for the format of `line-specs`
|
|
|
|
and `range-specs`.
|
|
|
|
|
2018-07-08 12:11:04 +03:00
|
|
|
*flag-lines* <face> <option_name>::
|
2018-03-06 13:34:00 +03:00
|
|
|
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:
|
|
|
|
|
2018-07-28 12:33:11 +03:00
|
|
|
------------------------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
declare-option line-specs my_flags
|
2018-07-28 12:33:11 +03:00
|
|
|
set-option window my_flags %val{timestamp} '1|Foo' '3|{red,yellow+b}Bar'
|
2018-07-08 12:11:04 +03:00
|
|
|
add-highlighter window/ flag-lines blue my_flags
|
2018-07-28 12:33:11 +03:00
|
|
|
------------------------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
|
|
|
|
*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:
|
|
|
|
|
2018-03-31 09:18:59 +03:00
|
|
|
--------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
declare-option range-specs my_range
|
2018-07-28 12:33:11 +03:00
|
|
|
set-option window my_range %val{timestamp} '1.1,1.3|red'
|
2018-03-06 13:34:00 +03:00
|
|
|
add-highlighter window/ ranges my_range
|
2018-03-31 09:18:59 +03:00
|
|
|
--------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
|
|
|
|
*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
|
2020-05-28 01:45:38 +03:00
|
|
|
interpreted as markup string (see <<faces#markup-strings,
|
|
|
|
`:doc faces markup-strings`>>) and displayed in place of the range.
|
2018-03-06 13:34:00 +03:00
|
|
|
Here, the 3 first chars of the buffer will be replaced by the word 'red':
|
|
|
|
|
2018-03-31 09:18:59 +03:00
|
|
|
--------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
declare-option range-specs my_range
|
2018-07-28 12:33:11 +03:00
|
|
|
set-option window my_range %val{timestamp} '1.1,1.3|red'
|
2018-03-06 13:34:00 +03:00
|
|
|
add-highlighter window/ replace-ranges my_range
|
2018-03-31 09:18:59 +03:00
|
|
|
--------------------------------------------------------
|
2018-03-06 13:34:00 +03:00
|
|
|
|
|
|
|
== Highlighting Groups
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-11-12 17:44:04 +03: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 22:15:12 +03:00
|
|
|
|
2017-11-01 14:00:44 +03:00
|
|
|
-----------------------------------
|
2018-06-28 13:48:53 +03:00
|
|
|
add-highlighter <path>/<name> group
|
2017-11-01 14:00:44 +03:00
|
|
|
-----------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
Other highlighters can then be added to that group
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-01-04 03:07:45 +03:00
|
|
|
------------------------------------------------
|
2017-11-01 14:00:44 +03:00
|
|
|
add-highlighter <path>/<name> <type> <params>...
|
2017-01-04 03:07:45 +03:00
|
|
|
------------------------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03: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-08-31 16:08:57 +03:00
|
|
|
|
2017-11-01 14:00:44 +03:00
|
|
|
--------------------------------------------------------------
|
2018-06-28 13:48:53 +03:00
|
|
|
add-highlighter window/<name> group -passes colorize|move|wrap
|
2017-11-01 14:00:44 +03:00
|
|
|
--------------------------------------------------------------
|
2017-08-31 16:08:57 +03:00
|
|
|
|
2017-11-02 05:03:24 +03:00
|
|
|
== Regions highlighters
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2016-02-11 00:03:49 +03:00
|
|
|
A special highlighter provides a way to segment the buffer into regions,
|
|
|
|
which are to be highlighted differently.
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
-------------------------------------
|
|
|
|
add-highlighter <path>/<name> regions
|
|
|
|
-------------------------------------
|
|
|
|
|
|
|
|
Individual region definitions can then be added to that highlighter
|
|
|
|
|
|
|
|
----------------------------------------------------
|
|
|
|
add-highlighter <path>/<name>/<region_name> region \
|
2018-07-02 13:59:12 +03:00
|
|
|
[-match-capture] [-recurse <recurse>] \
|
|
|
|
<opening> <closing> <type> <params>...
|
2018-06-28 13:48:53 +03:00
|
|
|
----------------------------------------------------
|
|
|
|
|
2016-02-03 20:15:35 +03:00
|
|
|
*opening*::
|
2017-11-02 12:37:39 +03:00
|
|
|
regex that defines the region start text
|
2018-06-28 13:48:53 +03:00
|
|
|
|
2016-02-03 20:15:35 +03:00
|
|
|
*closing*::
|
2017-11-02 12:37:39 +03:00
|
|
|
regex that defines the region end text
|
2018-06-28 13:48:53 +03:00
|
|
|
|
2016-02-03 20:15:35 +03:00
|
|
|
*recurse*::
|
2017-11-02 12:37:39 +03:00
|
|
|
regex that defines the text that matches recursively an end token
|
2018-07-02 13:59:12 +03:00
|
|
|
into the region, every match of *recurse* will consume a following
|
2022-05-23 14:21:05 +03:00
|
|
|
match of *closing* regex, preventing it from closing the region.
|
2016-02-03 20:15:35 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
*type* and *params*::
|
2020-05-28 19:37:26 +03:00
|
|
|
A highlighter type, and associated params, as they would be passed
|
2018-06-28 13:48:53 +03:00
|
|
|
to `add-highlighter` if they were not applied as a region.
|
|
|
|
|
2022-05-23 14:21:05 +03:00
|
|
|
If the *-match-capture* switch is passed, then region *closing* and *recurse*
|
|
|
|
regex matches are considered valid for a given region opening match only if they
|
|
|
|
matched the same content for the capture 1 in the *opening* regex.
|
2018-06-28 13:48:53 +03:00
|
|
|
|
2016-02-11 00:03:49 +03:00
|
|
|
The *recurse* option is useful for regions that can be nested, for example
|
2020-05-02 18:36:58 +03:00
|
|
|
the following construct:
|
2016-02-03 20:15:35 +03:00
|
|
|
|
|
|
|
----------
|
|
|
|
%sh{ ... }
|
|
|
|
----------
|
|
|
|
|
|
|
|
accepts nested braces scopes ('{ ... }') so the following string is valid:
|
|
|
|
|
|
|
|
----------------------
|
|
|
|
%sh{ ... { ... } ... }
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
This region can be defined with:
|
|
|
|
|
2018-07-02 13:59:12 +03:00
|
|
|
---------------------------------
|
|
|
|
shell_expand -recurse \{ %sh\{ \}
|
|
|
|
---------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2016-02-11 00:03:49 +03: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 22:15:12 +03:00
|
|
|
|
|
|
|
That matches the rule governing most programming language parsing.
|
|
|
|
|
2020-05-28 19:37:26 +03:00
|
|
|
A default region, that will apply its given highlighter to the segments of the
|
2018-06-28 13:48:53 +03:00
|
|
|
buffer that are not in any defined region, can be added with the *default-region*
|
|
|
|
highlighter type.
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
add-highlighter <path>/<name>/<region_name> default-region <type> <params>...
|
|
|
|
-----------------------------------------------------------------------------
|
2017-02-07 02:00:13 +03:00
|
|
|
|
2017-04-21 13:32:47 +03:00
|
|
|
Most programming languages can then be properly highlighted using a region
|
2016-02-11 00:03:49 +03:00
|
|
|
highlighter as root:
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2016-02-03 20:15:35 +03:00
|
|
|
-----------------------------------------------------------------
|
2018-06-28 13:48:53 +03:00
|
|
|
add-highlighter <path>/<lang> regions
|
2021-10-19 19:21:48 +03:00
|
|
|
add-highlighter <path>/<lang>/string region '"' '"' fill string
|
|
|
|
add-highlighter <path>/<lang>/comment region '//' '$' fill comment
|
2018-06-28 13:48:53 +03:00
|
|
|
add-highlighter <path>/<lang>/code default-region group
|
|
|
|
add-highlighter <path>/<lang>/code/variable regex ...
|
|
|
|
add-highlighter <path>/<lang>/code/function regex ...
|
2016-02-03 20:15:35 +03:00
|
|
|
-----------------------------------------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-11-02 05:03:24 +03:00
|
|
|
== Shared Highlighters
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2016-02-11 00:03:49 +03: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 22:15:12 +03:00
|
|
|
|
2017-11-01 14:00:44 +03:00
|
|
|
Highlighters can be put in the shared scope in order to make them reusable.
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
---------------------------------
|
|
|
|
add-highlighter shared/<name> ...
|
|
|
|
---------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
The common case would be to create a named shared group, or regions and then
|
|
|
|
fill it with highlighters:
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-11-01 14:00:44 +03:00
|
|
|
---------------------------------------
|
2019-10-15 22:28:35 +03:00
|
|
|
add-highlighter shared/<name> group
|
|
|
|
add-highlighter shared/<name>/ regex ...
|
2017-11-01 14:00:44 +03:00
|
|
|
---------------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
|
|
|
It can then be referenced in a window using the ref highlighter.
|
|
|
|
|
2018-06-28 13:48:53 +03:00
|
|
|
----------------------------------
|
|
|
|
add-highlighter window/ ref <name>
|
|
|
|
----------------------------------
|
2016-02-02 22:15:12 +03:00
|
|
|
|
2017-11-01 14:00:44 +03:00
|
|
|
The ref can reference any named highlighter in the shared scope.
|