Skip to content
Raghu R edited this page Dec 8, 2022 · 27 revisions

TOC

Highlighters

Syntax highlighting is supported through highlighters. You may add your own Syntax definitions in the rc directory. There is a syntax highlighting section in the highlighters.asciidoc file.

There is a good overview of highlighters in Kakoune here.

Examples

column, line

# same ideas apply to `line`
addhl column 4 red           # all chars in column 4 will be have a red color
addhl column 5 red,blue+b    # all chars in column 5 will be red on blue and in bold
addhl column 6 PrimaryCursor # all chars in column 6 will be the same face than `PrimaryCursor` (see below)

https://github.com/insipx/kak-crosshairs provides automatic highlighting of current Line/Column

ranges

declare-option range-specs foo                          # declare an option called foo, of type range-specs
add-highlighter window/ ranges foo                      # use this option as the parameter
set-option buffer foo %val{timestamp} '2:3.1,3.10|blue' # update the option to trigger changes

ui.kak plugin

The ui.kak plugin provides commands and a user mode to quickly toggle various highlighters and related hooks.

Search highlighting

First add a search face. Here, it will emphasis the searched word in bold and italic without changing the foreground or background colors:

set-face global search +bi

Then enable search highlighting. Dynregex is plugged on the content of the search register /:

add-highlighter global/search dynregex '%reg{/}' 0:search

Highlight a column

If you want a visual hint about code that exceeds a given width, try the column highlighter:

add-highlighter global/ column '%opt{autowrap_column}' default,red

...highlights the column named by the autowrap_column option with a red background, and will automatically move as the option is updated. The autowrap_column option is used by the autowrap script what column to wrap to, but even if you don't use autowrap's functionality, it's a good place to record the buffer's wrapping column so other wrapping and formatting hooks can find it.

FIXME/TODO/XXX keywords

The following highlighter will display words "FIXME"/"TODO"/"XXX"/"NOTE" in bold and reversed.

add-highlighter global/ regex \b(TODO|FIXME|XXX|NOTE)\b 0:default+rb

Faces

Faces can be taken from the colorscheme files, which is what is usually done, or directly from the the list of default faces:

Name Foreground Background Attribute
Default Default Default
PrimarySelection White Blue
SecondarySelection Black Blue
PrimaryCursor Black White
SecondaryCursor Black White
PrimaryCursorEol Black Cyan
SecondaryCursorEol Black Cyan
LineNumbers Default Default
LineNumberCursor Default Default Reverse
LineNumbersWrapped Default Default Italic
MenuForeground White Blue
MenuBackground Blue White
MenuInfo Cyan Default
Information Black Yellow
Error Black Red
StatusLine Cyan Default
StatusLineMode Yellow Default
StatusLineInfo Blue Default
StatusLineValue Green Default
StatusCursor Black Cyan
Prompt Yellow Default
MatchingChar Default Default Bold
BufferPadding Blue Default
Whitespace Default Default FinalFg
WrapMarker Blue Default
Clone this wiki locally