-
Notifications
You must be signed in to change notification settings - Fork 719
Line flags
Line flags are information optionally displayed in new columns on the left of the screen.
Line numbers belong to this category of UI gutter widgets. They are defined as special type of
highlighters, so to enable them in your kakrc
:
add-highlighter global/ number-lines
Line flags can also provide valuable contextual data ; when using git-tools.kak and triggering the git blame
command, the name and date of the last commit of each lines will be displayed in an extra column on the left.
When using lint.kak, errors (in red) and warnings (in yellow) indicators will also be added to another extra column on the left.
Good news is, you can also create your own line flags. Let's have a look at the following snippet:
define-command display-flags %{
declare-option line-specs my_flags
set-face window MyFlags white,blue
set-option global my_flags %val{timestamp} '1|Foo' '3|{red,yellow+b}Bar'
add-highlighter window/ flag-lines MyFlags my_flags
}
Here's what's going on line by line:
-
define-command display-flags
: we encapsulate our logic in a new command to call it manually later:display-flags
. -
declare-option line-specs my_flags
: we declare a new empty option calledmy_flags
of typeline-specs
. This type forces us to respect a specific format explained below. -
set-face MyFlags white,blue
: we create a new face with a white foreground and blue background. It means that the whole new column will be styled like this. Each line can then refine its style individually. A less intrusive choice could beset-face MyFlags default
-
set-option global my_flags %{timestamp} '1|Foo' '3|{red,yellow+b}Bar'
: we finally assign a value to the option declared above. We must provide a list of tuples wrapped in quotes'
. Note that the first element is an exception. In this case we should provide a number, symbolizing the current timestamp. Each tuple holds a line number followed by a pipe|
and then the text we want to display on this line. Optionally we can provide a face definition between braces{}
. So in our example, the whole flags column will be blue. The flag on line 1 will displayFoo
in white and the flag on line 3 will displayBar
in red on yellow and bold. See:doc options types
for more infos on theline-specs
type. -
add-highlighter flag-lines MyFlags my_flags
: we make the magic happens by adding a new highlighter of typeflag-lines
, using the faceMyFlags
and theline-specs
optionsmy_flags
Previous to this commit (May 2017), the line-specs
type used to be called line-flags
.
This feature is used in kakoune-palette
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV