Hi,
powerline.kak is an example of well designed, documented and modulable plugin for kakoune but I was missing an extended git status and other things I liked with my starship prompt. I was too lazy to make a powerline.kak module so I was wondering if it would be possible quickly to make an executable using starship library in rust.
I quickly realized that starship could work pretty decently out of the box with kakoune. You just have to tell starship to use a dedicated config with the STARSHIP_CONFIG env var, use a selected list of plugins, remove all styles (to not have ansi code in the modeline), and insert face syntax in the prompt.
# Use starship to format the modeline
hook global WinCreate .* %{
hook window NormalIdle .* %{
evaluate-commands %sh{
prompt=$(cd $(dirname $kak_buffile) && STARSHIP_CONFIG=~/.config/kak/starship.toml starship prompt)
printf 'set window modelinefmt %%{%s}' "${prompt}"
}
}
}
and with following ~/.config/kak/starship.toml config file you have time, battery, memory, rust, directory icons, …
add_newline = false
format = "%val{cursor_line}:%val{cursor_char_column} {{mode_info}} {{context_info}} {builtin}$directory/$custom{meta}$package$rust{keyword}$git_branch$git_commit$git_state{operator}$git_status{value} %val{client}:%val{session} {comment}$memory_usage{module}$battery{mono}$time"
[time]
disabled = false
format = "[ $time ]($style)"
time_format = "%T"
style = ""
[git_branch]
format = ' [$symbol$branch]($style) '
symbol = ' '
# style = 'green'
style = ''
truncation_length = 9223372036854775807
truncation_symbol = '…'
only_attached = false
always_show_remote = true
disabled = false
[git_commit]
commit_hash_length = 7
format = '[\($hash$tag\)]($style) '
# style = 'green bold'
style = ''
only_detached = true
disabled = false
tag_symbol = ' '
tag_disabled = true
[git_state]
rebase = 'REBASING'
merge = 'MERGING'
revert = 'REVERTING'
cherry_pick = 'CHERRY-PICKING'
bisect = 'BISECTING'
am = 'AM'
am_or_rebase = 'AM/REBASE'
# style = 'bold yellow'
style = ''
format = '\([$state( $progress_current/$progress_total)]($style)\) '
disabled = false
[git_status]
format = '([\[$all_status$ahead_behind\]]($style) )'
# style = 'red bold'
style = ''
stashed = '\$'
ahead = '⇡${count}'
behind = '⇣${count}'
diverged = '⇕⇡${ahead_count}⇣${behind_count}'
conflicted = '='
deleted = '✘'
renamed = '»'
modified = '!'
staged = '+'
untracked = '?'
disabled = false
[directory]
truncation_length = 3
truncate_to_repo = false
fish_style_pwd_dir_length = 0
use_logical_path = true
format = '[$path]($style)[$read_only]($read_only_style)'
# style = 'bold bright-red'
style = ''
disabled = false
read_only = '[]'
# read_only_style = 'red'
read_only_style = ''
truncation_symbol = ''
[directory.substitutions]
"~/Nextcloud" = " "
"~/Videos" = " "
"~/Pictures" = " "
"~/Music" = " "
"~/Downloads" = " "
"~/Desktop" = " "
"~/Sync" = "מּ "
"~/.workspace/rust" = ""
"~/.workspace/docker" = " "
"~/.workspace/alpine" = " "
"~/.workspace/arch" = " "
"~/.workspace/kustomize" = "ﴱ "
"~/.workspace/node" = ""
"~/.workspace" = " "
"~/scm" = " "
"~" = " "
[rust]
format = '[$symbol$version]($style)'
version_format = 'v${raw}'
# symbol = '🦀 '
symbol = ' '
# style = 'bold red'
style = ''
disabled = false
detect_extensions = ['rs']
detect_files = ['Cargo.toml']
detect_folders = []
[package]
format = '[$symbol$version]($style) '
symbol = ' '
# style = '208 bold'
style = ''
display_private = false
disabled = false
[battery]
format = "[$symbol]($style) "
# style = 'red bold'
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 10
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 20
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 30
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 40
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 50
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 60
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 70
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 80
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 90
style = ''
charging_symbol = ''
discharging_symbol = ''
[[battery.display]]
threshold = 99
style = ''
charging_symbol = ''
discharging_symbol = ''
[memory_usage]
format = "$symbol [${ram}( | ${swap})]($style) "
disabled = true
threshold = -1
symbol = ''
# style = "bold dimmed green"
style = ''
[custom.kakfile]
command = 'basename $kak_buffile'
when = '[ -n "$kak_buffile" ]'
shell = ['sh']
description = 'The current Kakoune buffername'
style = ''
format = '[$symbol $output]($style)'