From b00ec8d3b4e3550e7e06458a62c69d8a55d9edc8 Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Thu, 5 Sep 2024 23:19:55 +0200 Subject: [PATCH] kak: improve linters, update starship config --- config/dot-config/kak/kakrc | 20 +++++----- config/dot-config/kak/starship.toml | 61 ++++++++++++++--------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/config/dot-config/kak/kakrc b/config/dot-config/kak/kakrc index 87ab0b75..a8ab1b1e 100644 --- a/config/dot-config/kak/kakrc +++ b/config/dot-config/kak/kakrc @@ -22,7 +22,7 @@ hook global NormalKey y %{ nop %sh{ # ────────────────────────────────────────────────────────────────────────────── hook global BufOpenFile .* %{ modeline-parse - editorconfig-load + # editorconfig-load ## fucks up linters. disable for now } hook global BufCreate [^*].* %{ @@ -90,22 +90,22 @@ bundle-noload dabruin.kak https://git.sr.ht/~nasmevka/dabruin.kak set window formatcmd 'npx prettier --stdin-filepath $kak_buffile;' } hook global WinSetOption filetype=css %{ - set window formatcmd 'npx prettier --parser css' + set-option window lintcmd "npx stylelint --formatter unix --stdin-filename='%val{buffile}'" } hook global WinSetOption filetype=scss %{ - set window formatcmd 'npx prettier --parser scss' + set window formatcmd 'npx prettier --parser scss --stdin-filepath $kak_buffile;' } hook global WinSetOption filetype=less %{ - set window formatcmd 'npx prettier --parser less' + set window formatcmd 'npx prettier --parser less --stdin-filepath $kak_buffile;' } hook global WinSetOption filetype=html %{ - set window formatcmd 'npx prettier --parser html' + set window formatcmd 'npx prettier --parser html --stdin-filepath $kak_buffile;' } hook global WinSetOption filetype=json %{ - set window formatcmd 'npx prettier --parser json' + set-option window lintcmd %{ run() { cat -- "$1" | jq 2>&1 | awk -v filename="$1" '/ at line [0-9]+, column [0-9]+$/ { line=$(NF - 2); column=$NF; sub(/ at line [0-9]+, column [0-9]+$/, ""); printf "%s:%d:%d: error: %s", filename, line, column, $0; }'; } && run } } hook global WinSetOption filetype=md %{ - set window formatcmd 'npx prettier --parser md' + set window formatcmd 'npx prettier --parser md --stdin-filepath $kak_buffile;' } hook global WinSetOption filetype=sh %{ # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest @@ -113,7 +113,7 @@ bundle-noload dabruin.kak https://git.sr.ht/~nasmevka/dabruin.kak set-option window lintcmd "shellcheck -fgcc -Cnever" } hook global WinSetOption filetype=yaml %{ - set window formatcmd 'npx prettier --parser yaml' + set window formatcmd 'npx prettier --parser yaml --stdin-filepath $kak_buffile;' set-option window lintcmd %{ run() { # change [message-type] to message-type: @@ -139,7 +139,7 @@ add-highlighter global/ wrap -word -indent # ────────────────────────────────────────────────────────────────────────────── # Shades of green/yellow for insert mode. hook global ModeChange (push|pop):.*:insert %{ - set-face window StatusLine black,rgb:800000 + set-face window StatusLine black,rgb:a1163d } # Undo colour changes when we leave insert mode. @@ -222,5 +222,5 @@ set-option global foot_panel_cmd 'footclient' # language config # ────────────────────────────────────────────────────────────────────────────── -import languagecmd +# import languagecmd diff --git a/config/dot-config/kak/starship.toml b/config/dot-config/kak/starship.toml index 846bd1b0..43a1fbc9 100644 --- a/config/dot-config/kak/starship.toml +++ b/config/dot-config/kak/starship.toml @@ -1,27 +1,24 @@ add_newline = false format = """\ -${custom.kakbuflist}\ ${custom.kaklsp_progress}\ ${custom.kakcursor}\ ${custom.kakposition}\ ${custom.kakmode}\ ${custom.kakcontext}\ -$directory\ -${custom.kakfile}\ ${custom.kakfiletype}\ +${custom.kakbuflist}\ +${directory}\ +${custom.kakfile}\ ${custom.kaklsp_err}\ ${custom.kaklsp_warn}\ ${custom.kaklsp_hint}\ ${custom.kaklsp_code_actions}\ -$package\ -$git_branch\ -$git_commit\ -$git_state\ -$git_status\ +${package}\ +${git_branch}\ +${git_commit}\ +${git_state}\ +${git_status}\ ${custom.kaksession}\ -$memory_usage\ -$battery\ -$time\ ${custom.kaktime} """ @@ -44,7 +41,7 @@ disabled = false [git_commit] format = '[\($hash$tag\)]($style)' style = 'fg:blue dimmed' -commit_hash_length = 7 +commit_hash_length = 6 only_detached = false tag_symbol = ' 笠' tag_disabled = false @@ -63,7 +60,7 @@ am_or_rebase = 'AM/REBASE' disabled = false [git_status] -format = '[\[$all_status$ahead_behind\]]($style)[ ]($style)' +format = '[\[$all_status$ahead_behind\]]($style)[]($style)' style = 'fg:cyan dimmed bold' stashed = '\$' ahead = '⇡${count}' @@ -79,8 +76,8 @@ disabled = false [directory] format = '[]($style)[$read_only]($read_only_style)[$path]($style)' -truncation_length = 3 -truncate_to_repo = false +truncation_length = 8 +truncate_to_repo = true fish_style_pwd_dir_length = 0 use_logical_path = true style = 'bg:blue fg:black' @@ -90,7 +87,8 @@ truncation_symbol = '…' disabled = false [directory.substitutions] -"~/dotfiles" = " " +"dotfiles/config/dot-config" = "config" +"dotfiles/local/dot-local" = "local" "~/.config" = " " "~/.workspace/rust" = "" "~/.workspace/docker" = " " @@ -192,15 +190,15 @@ disabled = false [custom.kaksession] description = 'The current Kakoune session' format = '[]($style)[  %val{client}:%val{session} ]($style)[]($style inverted)' -style = 'bg:yellow fg:black italic' +style = 'bg:yellow fg:black' when = '' shell = ['true'] -disabled = true +disabled = false [custom.kakcursor] description = 'The current Kakoune cursor position' format = '[%val{cursor_line}:%val{cursor_char_column}]($style)' -style = 'fg:bright-white' +style = 'fg:white' when = '' shell = ['true'] disabled = false @@ -214,22 +212,23 @@ disabled = false [custom.kakcontext] description = 'The current Kakoune context' -format = ' {{context_info}}' +format = ' {{context_info}} ' when = '' shell = ['true'] disabled = false [custom.kakfiletype] description = 'The current buffer filetype' -format = '\[%opt{filetype}\] ' +format = '[%opt{filetype}]($style) ' +style = 'fg:13' when = '' shell = ['true'] -disabled = true +disabled = false [custom.kakposition] description = 'Relative position of the cursor inside the buffer' -format = '[  $output]($style)[ ]($style)' -style = 'white' +format = '[ 󰗉 $output]($style) ' +style = 'bright-white' command = 'echo -n $(($kak_cursor_line * 100 / $kak_buf_line_count))%' when = '[ -n "$kak_cursor_line" ]' shell = ['sh'] @@ -237,11 +236,11 @@ disabled = false [custom.kaktime] description = "Alternate time segment using kakoune evaluation" -format = "[]($style)[  %sh{date +%T} ]($style)" +format = "[]($style)[  %sh{date +%H:%M} ]($style)" style = "fg:black bg:bright-green" when = '' shell = ['true'] -disabled = true +disabled = false [custom.kaklsp_err] description = "Show errors number from kak-lsp if any" @@ -262,13 +261,13 @@ disabled = false [custom.kaklsp_hint] description = "Show hints number from kak-lsp if any" format = "[ ﯦ %opt{lsp_diagnostic_hint_count}]($style)" -style = "white bold" +style = "yellow bold" when = '[ -n "$kak_opt_lsp_diagnostic_hint_count" -a "$kak_opt_lsp_diagnostic_hint_count" -ne 0 ]' shell = ['sh'] disabled = false [custom.kaklsp_code_actions] -description = "Show lsp code actions" +description = "Show lsp code actions if any" format = "[ %opt{lsp_modeline_code_actions} ]($style)" style = "yellow bold" when = '[ -n "$kak_opt_lsp_modeline_code_actions" ]' @@ -285,9 +284,9 @@ disabled = false [custom.kakbuflist] description = "Open buffers" -format = "[ $output ]($style)" -style = "fg:white" +format = '[]($style inverted)[$output]($style)[]($style inverted)' +style = 'bg:8 fg:0' when = 'true' shell = ['sh'] -command = 'kks get -s ${kak_session##*/} %val{buflist} | grep -vE "(\*debug\*|${kak_buffile##*/})" | paste -s -d "|" ' +command = 'kks get -s ${kak_session##*/} %val{buflist} | grep -vE "(\*scratch\*|\*debug\*|${kak_buffile##*/})" | rev | cut -d"/" -f1 | rev | paste -s -d "|" ' disabled = false -- 2.51.2