From ebb5ec46003a8317c9821275584339c20235f129 Mon Sep 17 00:00:00 2001 From: Madeleine Date: Fri, 21 Apr 2023 22:44:21 +0100 Subject: [PATCH] kakoune improvements --- maddie/common/kakoune.nix | 45 +++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/maddie/common/kakoune.nix b/maddie/common/kakoune.nix index 0ced3a6..c90418f 100644 --- a/maddie/common/kakoune.nix +++ b/maddie/common/kakoune.nix @@ -23,15 +23,15 @@ setTitle = true; }; hooks = [ - { - name = "WinSetOption"; - option = "filetype=nix"; - commands = '' - set-option window indentwidth 2 - set-option window formatcmd nixpkgs-fmt - ''; - } - ]; + { + name = "WinSetOption"; + option = "filetype=nix"; + commands = '' + set-option window indentwidth 2 + set-option window formatcmd nixpkgs-fmt + ''; + } + ]; }; plugins = with pkgs.kakounePlugins; [ kakoune-rainbow @@ -40,9 +40,36 @@ pkgs.kak-lsp ]; extraConfig = '' + # Tabs hook global InsertChar \t %{ exec -draft h@ } + add-highlighter global/ show-whitespaces -tab '│' -tabpad '╌' + + # Kak-LSP eval %sh{kak-lsp --kakoune -s $kak_session} lsp-enable + + # Modeline + declare-option bool lsp_enabled false + declare-option -hidden str lsp_modeline_progress "" + define-command -hidden -params 6 -override lsp-handle-progress %{ + set-option global lsp_modeline_progress %sh{ + if ! "$6"; then + echo "$2\$\{5:+" ($5%)"}\$\{4:+": $4"}" + fi + } + } + + declare-option -hidden str modeline_git_branch + hook global WinDisplay .* %{ + set-option window modeline_git_branch %sh{ + branch=$(git -C "\$\{kak_buffile%/*}" rev-parse --abbrev-ref HEAD 2>/dev/null) + if [ -n "$branch" ]; then + printf "$branch " + fi + } + } + + set-option global modelinefmt '%opt{lsp_modeline_progress} {StatusLine}{string}%opt{modeline_git_branch}{type}%sh{ [ -n "$kak_opt_filetype" ] && echo "$kak_opt_filetype " }{default}%val{bufname}{{context_info}}{default} {{mode_info}} {meta}%val{cursor_line}:%val{cursor_char_column}' ''; }; }