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
Bruno Heridet edited this pageMar 8, 2018 ·2 revisions

The following example is very rough and brittle. Use it as a source of inspiration to hack your own solution.

In thisPR, a C++ solution is proposed to embed a buffer list bar in the defaultncurses UI.

This wiki page offers an alternative working with stock Kakoune and rely on peripheral tools to achieve the same.

The main trick is to use an externalstatus bar. They are usually used to display information about the OS (memory, network usage…). But most of them accept arbitrary text onstdin. So, we can write a small.kak script that pipe information to it using a FIFO.

Script

In this example we uselemonbar a small (~1000 lines of C using XCB) to display what we want. 3 cores commands are provided:

  • bar-create to make a FIFO and start a lemonbar instance in the background
  • bar-refresh that takes an argument and send the text to lemonbar
  • bar-destroy that remove the FIFO (it should destroy lemonbar but it's not done here, feel free to fix that part)

Then you can build your own commands likebar-refresh-buflist. This one focus on the buffer lit but it can be anything, like stuffs related to the current mode (Normal, Insert), git branches, debugger…

declare-option str barcmd 'lemonbar'declare-option str bar_buflistdefine-command bar-create %{  %sh{    {      fifo=/tmp/kakoune/bar_$kak_session      rm "$fifo"      mkfifo "$fifo"      exec 3<> "$fifo"      cat "$fifo" | $kak_opt_barcmd -p -B '#282a36' -F '#f8f8f2' -f 'Monospace:size=9' &    } >/dev/null 2>&1 </dev/null &  }  bar-refresh-buflist}define-command bar-refresh -params 1 %{  %sh{    fifo=/tmp/kakoune/bar_$kak_session    if [ -p "$fifo" ]; then      echo "$1" > "$fifo"    fi  }}define-command bar-destroy %{ %sh{  fifo=/tmp/kakoune/bar_$kak_session  rm "$fifo"} }hook global KakEnd .* %{ %sh{  bar-destroy} }# Example with buflistdefine-command -hidden bar-bufflist %{  %sh{    list=''    while read buf; do      index=$(($index + 1))      if [ "$buf" = "$kak_bufname" ]; then        # markup specific to lemonbar        list="$list %{R} $index $buf %{R}"      else        list="$list  $index $buf "      fi    done <<< $(printf '%s\n' "$kak_buflist" | tr ':' '\n')    echo "set-option global bar_buflist '$list'"  }}define-command bar-refresh-buflist %{  bar-bufflist  bar-refresh %opt{bar_buflist}}# Suggested hookshook global WinDisplay .* bar-refresh-buflist

Screenshot

On this screenshot, kakoune is displayed on the left side of the screen andfzf with preview window on the right side (workspace managed byi3). What's relevant to this wiki page, is the lemonbar on the top which is synchronized with kakoune: every time you do abuffer-next it refreshes accordingly. By usingkakoune-buffers you can even typeb2 to jump tobuffer.cc for example.

All tools use thedracula color theme to give a coherent and seamless experience.

link for bigger imagelemonbar + kakoune

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp