From dbbd98c78ca1494371334c2de31d783e5a4dd2e4 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 13 May 2025 00:24:08 -0400 Subject: [PATCH] AutoYADM commit: 2025-05-13 00:24:08 --- .config/kak/autoload/filetype.kak | 1 + .config/kak/autoload/plugins.kak | 1 - .config/kak/autoload/vim-tab.kak | 212 +++++++++++++++--------------- .config/kak/kakrc | 3 +- 4 files changed, 109 insertions(+), 108 deletions(-) diff --git a/.config/kak/autoload/filetype.kak b/.config/kak/autoload/filetype.kak index c17e0a5c..7ec03f4d 100644 --- a/.config/kak/autoload/filetype.kak +++ b/.config/kak/autoload/filetype.kak @@ -18,5 +18,6 @@ hook global WinSetOption filetype=markdown %{ } hook global BufCreate .*[.](typ|typst) %{ set-option buffer filetype typst + set-option buffer formatcmd "typstyle --wrap-text" } diff --git a/.config/kak/autoload/plugins.kak b/.config/kak/autoload/plugins.kak index ab2869de..687c63db 100644 --- a/.config/kak/autoload/plugins.kak +++ b/.config/kak/autoload/plugins.kak @@ -71,4 +71,3 @@ bundle vertical-selection https://github.com/occivink/kakoune-vertical-selection bundle kakoune-text-objects https://github.com/Delapouite/kakoune-text-objects %{ map global user s ': enter-user-mode selectors' -docstring 'selectors' } - diff --git a/.config/kak/autoload/vim-tab.kak b/.config/kak/autoload/vim-tab.kak index c078bdc8..6f6e23b0 100644 --- a/.config/kak/autoload/vim-tab.kak +++ b/.config/kak/autoload/vim-tab.kak @@ -1,110 +1,110 @@ -# Replicate expandtab from vim. -declare-option -docstring "Expand to spaces based on tabstop." bool expandtab yes +# # Replicate expandtab from vim. +# declare-option -docstring "Expand to spaces based on tabstop." bool expandtab yes -# Replicate softtabstop from vim. -declare-option -docstring "Make tabstop number of spaces feel like a when pressing or in insert mode." int softtabstop 4 +# # Replicate softtabstop from vim. +# declare-option -docstring "Make tabstop number of spaces feel like a when pressing or in insert mode." int softtabstop 4 -# Helper function for inserting a -def softtabstop-insert-tab -hidden %{ - evaluate-commands -no-hooks -draft -itersel %{ - try %sh{ - tabstop=$kak_opt_softtabstop - if [ $tabstop -lt 0 ]; then - tabstop=$kak_opt_indentwidth - fi - # Determine if this is an append operation (end column > start column). If so, prefix with ';' - prefix=$(echo $kak_selections_display_column_desc | awk -F '[.,]' '{if($4 > $2) {print ";"}}') - if [ $tabstop -eq 0 ]; then - # if tabstop is 0 that means we are just inserting tabs - printf "execute-keys '${prefix}i'\n" - # expand tabs to spaces if needed - [ $kak_opt_expandtab = "true" ] && printf "%s\n" 'execute-keys h@' - else - # compute the number of spaces needed to reach the next softtabstop - display_column=$((kak_cursor_display_column - 1)) # adjust for 1-based indexing - end_column=$((display_column % tabstop)) - space_count=$((tabstop - end_column)) - # insert enough spaces to reach the next softtabstop - printf "execute-keys '${prefix}i%${space_count}s'\n" - # if not expanding tabs, convert *all* preceding whitespace to a mix of spaces and - # tabs, not just the spaces that were inserted (this is how vim behaves) - [ $kak_opt_expandtab = "false" ] && printf "execute-keys '\h+H'" - fi - } - } -} - -# Helper function for deleting whitespace a -def softtabstop-insert-backspace -hidden %{ - evaluate-commands -no-hooks -draft -itersel -save-regs ^ %{ - # save off the current selection in case the try block fails - try %sh{ - tabstop=$kak_opt_softtabstop - if [ $tabstop -lt 0 ]; then - tabstop=$kak_opt_indentwidth - fi - if [ $tabstop -gt 0 ]; then - # compute the end display column based on tabstop and the number of - # number spaces needed to reach it - display_column=$((kak_cursor_display_column - 1)) # adjust for 1-based indexing - num_spaces=$((display_column % tabstop)) - [ $num_spaces -eq 0 ] && num_spaces=$tabstop - end_display_column=$((display_column - num_spaces)) - # extract any preceding whitespace - echo "evaluate-commands -draft %{ - execute-keys '\h+H' - echo -to-file $kak_response_fifo %val{selection} - }" > $kak_command_fifo - whitespace="$(cat $kak_response_fifo)" - # count the number of mixed tabs and spaces needed to reach the end display column - tab=$(printf "\t") - num_whitespaces=0 - adjust_cursor=";" - while [ -z "$non_ws" ] \ - && [ -n "$whitespace" ] \ - && [ $display_column -gt $end_display_column ]; - do - # iterate over the whitespace right-to-left, early out after reaching the - # first non whitespace - prefix=${whitespace%?}; - ws="${whitespace#$prefix}"; - case "$ws" in - $tab) display_column=$((display_column - $kak_opt_tabstop)); - # the first whitespace encountered is a tab. when '@' is pressed, the - # cursor moves (or extends) one char to the right. account for this here - [ $num_whitespaces -eq 0 ] && adjust_cursor="${adjust_cursor}h";; - " ") display_column=$((display_column - 1));; - *) non_ws="true";; - esac - whitespace=$prefix; - if [ -z "$non_ws" ]; then - num_whitespaces=$((num_whitespaces + 1)); - fi - done - if [ $num_whitespaces -gt 0 ]; then - # * select the number of mixed tabs and spaces computed above - # * convert to spaces and adjust the cursor position - # * select the number of spaces to reach the end column and delete them - echo "execute-keys ';h\h{$((num_whitespaces - 1))}@${adjust_cursor} {,$((num_spaces - 1))}d'" - else - echo "fail" - fi - else - echo "fail" - fi - } catch %{ - # in normal mode, delete previous character - execute-keys 'hd' - } - } -} - -# Use a hook to enable/disable key mappings such that '\' properly allows disabling specialized behavior -# hook global ModeChange 'push:.+:insert' %{ -# map buffer insert ':softtabstop-insert-tab' -# map buffer insert ':softtabstop-insert-backspace' +# # Helper function for inserting a +# def softtabstop-insert-tab -hidden %{ +# evaluate-commands -no-hooks -draft -itersel %{ +# try %sh{ +# tabstop=$kak_opt_softtabstop +# if [ $tabstop -lt 0 ]; then +# tabstop=$kak_opt_indentwidth +# fi +# # Determine if this is an append operation (end column > start column). If so, prefix with ';' +# prefix=$(echo $kak_selections_display_column_desc | awk -F '[.,]' '{if($4 > $2) {print ";"}}') +# if [ $tabstop -eq 0 ]; then +# # if tabstop is 0 that means we are just inserting tabs +# printf "execute-keys '${prefix}i'\n" +# # expand tabs to spaces if needed +# [ $kak_opt_expandtab = "true" ] && printf "%s\n" 'execute-keys h@' +# else +# # compute the number of spaces needed to reach the next softtabstop +# display_column=$((kak_cursor_display_column - 1)) # adjust for 1-based indexing +# end_column=$((display_column % tabstop)) +# space_count=$((tabstop - end_column)) +# # insert enough spaces to reach the next softtabstop +# printf "execute-keys '${prefix}i%${space_count}s'\n" +# # if not expanding tabs, convert *all* preceding whitespace to a mix of spaces and +# # tabs, not just the spaces that were inserted (this is how vim behaves) +# [ $kak_opt_expandtab = "false" ] && printf "execute-keys '\h+H'" +# fi +# } +# } # } -# hook global ModeChange 'pop:insert:normal' %{ -# unmap buffer insert ':softtabstop-insert-tab' -# unmap buffer insert ':softtabstop-insert-backspace' + +# # Helper function for deleting whitespace a +# def softtabstop-insert-backspace -hidden %{ +# evaluate-commands -no-hooks -draft -itersel -save-regs ^ %{ +# # save off the current selection in case the try block fails +# try %sh{ +# tabstop=$kak_opt_softtabstop +# if [ $tabstop -lt 0 ]; then +# tabstop=$kak_opt_indentwidth +# fi +# if [ $tabstop -gt 0 ]; then +# # compute the end display column based on tabstop and the number of +# # number spaces needed to reach it +# display_column=$((kak_cursor_display_column - 1)) # adjust for 1-based indexing +# num_spaces=$((display_column % tabstop)) +# [ $num_spaces -eq 0 ] && num_spaces=$tabstop +# end_display_column=$((display_column - num_spaces)) +# # extract any preceding whitespace +# echo "evaluate-commands -draft %{ +# execute-keys '\h+H' +# echo -to-file $kak_response_fifo %val{selection} +# }" > $kak_command_fifo +# whitespace="$(cat $kak_response_fifo)" +# # count the number of mixed tabs and spaces needed to reach the end display column +# tab=$(printf "\t") +# num_whitespaces=0 +# adjust_cursor=";" +# while [ -z "$non_ws" ] \ +# && [ -n "$whitespace" ] \ +# && [ $display_column -gt $end_display_column ]; +# do +# # iterate over the whitespace right-to-left, early out after reaching the +# # first non whitespace +# prefix=${whitespace%?}; +# ws="${whitespace#$prefix}"; +# case "$ws" in +# $tab) display_column=$((display_column - $kak_opt_tabstop)); +# # the first whitespace encountered is a tab. when '@' is pressed, the +# # cursor moves (or extends) one char to the right. account for this here +# [ $num_whitespaces -eq 0 ] && adjust_cursor="${adjust_cursor}h";; +# " ") display_column=$((display_column - 1));; +# *) non_ws="true";; +# esac +# whitespace=$prefix; +# if [ -z "$non_ws" ]; then +# num_whitespaces=$((num_whitespaces + 1)); +# fi +# done +# if [ $num_whitespaces -gt 0 ]; then +# # * select the number of mixed tabs and spaces computed above +# # * convert to spaces and adjust the cursor position +# # * select the number of spaces to reach the end column and delete them +# echo "execute-keys ';h\h{$((num_whitespaces - 1))}@${adjust_cursor} {,$((num_spaces - 1))}d'" +# else +# echo "fail" +# fi +# else +# echo "fail" +# fi +# } catch %{ +# # in normal mode, delete previous character +# execute-keys 'hd' +# } +# } # } + +# # Use a hook to enable/disable key mappings such that '\' properly allows disabling specialized behavior +# # hook global ModeChange 'push:.+:insert' %{ +# # map buffer insert ':softtabstop-insert-tab' +# # map buffer insert ':softtabstop-insert-backspace' +# # } +# # hook global ModeChange 'pop:insert:normal' %{ +# # unmap buffer insert ':softtabstop-insert-tab' +# # unmap buffer insert ':softtabstop-insert-backspace' +# # } diff --git a/.config/kak/kakrc b/.config/kak/kakrc index 56110ae1..a9da7068 100644 --- a/.config/kak/kakrc +++ b/.config/kak/kakrc @@ -20,7 +20,6 @@ define-command trampoline -docstring "open a tutorial" %{ } set-option global tabstop 4 - set-option global indentwidth 4 set-option global scrolloff 3,3 @@ -109,3 +108,5 @@ def git_blame %{ map -docstring "blame" global git b ": git_blame" map -docstring "format" global user F ": format" + +