Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
YuFei29 edited this pageJun 5, 2023 ·13 revisions

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 ofhighlighters, so to enable them in yourkakrc:

add-highlighterglobal/ number-lines

Line flags can also provide valuable contextual data ; when usinggit-tools.kak and triggering thegit blame command, the name and date of the last commit of each lines will be displayed in an extra column on the left.When usinglint.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

Notes

Previous to thiscommit (May 2017), theline-specs type used to be calledline-flags.

Examples

This feature is used inkakoune-palette

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp