diff --git a/.config/kak/autoload/filetype.kak b/.config/kak/autoload/filetype.kak index 7ec03f4d..2bcc6a61 100644 --- a/.config/kak/autoload/filetype.kak +++ b/.config/kak/autoload/filetype.kak @@ -10,14 +10,11 @@ hook global WinSetOption filetype=go %{ hook global WinSetOption filetype=kak %{ set-option window formatcmd "%val{config}/scripts/kakfmt" - set-option window expandtab false + # set-option window expandtab false } hook global WinSetOption filetype=markdown %{ set-option window formatcmd "dprint fmt --stdin md" } -hook global BufCreate .*[.](typ|typst) %{ - set-option buffer filetype typst - set-option buffer formatcmd "typstyle --wrap-text" -} + diff --git a/.config/kak/kakrc b/.config/kak/kakrc index 91e35b86..ca72e149 100644 --- a/.config/kak/kakrc +++ b/.config/kak/kakrc @@ -79,6 +79,7 @@ map global ui z ": ui-scrolloff-toggle" hook global WinCreate .* %{ ui-wrap-enable + ui-scrolloff-toggle } map -docstring "yank the selection into the clipboard" global user y " wl-copy" diff --git a/.config/kak/scripts/kakfmt b/.config/kak/scripts/kakfmt index 7321d05c..5751fa03 100755 --- a/.config/kak/scripts/kakfmt +++ b/.config/kak/scripts/kakfmt @@ -1,24 +1,5 @@ #!/usr/bin/env perl -# old -# use strict; -# use warnings; - -# my $Indent = 0; -# my $Blank_Lines = 0; -# my $Open = qr/[{\[(]$/; -# my $Close = qr/^[}\])]/; -# while (<>) { -# s/^\h*//; -# $Blank_Lines++, next if m/^$/; -# my $Comment = m/^#/; -# $Indent-- if m/$Close/ and not $Comment; -# $Blank_Lines = 0, print "\n" if $Blank_Lines; -# print "\t" x $Indent, $_; -# $Indent++ if m/$Open/ and not $Comment; -# } -#!/usr/bin/env perl - use strict; use warnings; @@ -26,45 +7,12 @@ my $Indent = 0; my $Blank_Lines = 0; my $Open = qr/[{\[(]$/; my $Close = qr/^[}\])]/; -my $InShell = 0; -my $ShellIndent = 0; - while (<>) { s/^\h*//; - - # Track blank lines - if (/^$/) { - $Blank_Lines++; - next; - } - - # Detect start of %sh{ - if (/^%sh\s*{/) { - print "\t" x $Indent, $_; - $InShell = 1; - $ShellIndent = 0; - next; - } - - # Detect end of shell block - if ($InShell && /^\}/) { - $InShell = 0; - print "\t" x $Indent, $_; - next; - } - - if ($InShell) { - $ShellIndent-- if /^\s*(?:fi|done|esac|elif|else|elif|;;)/; - print "\t" x ($Indent + $ShellIndent), $_; - $ShellIndent++ if /\b(?:then|do|case)\b(?:\s*#.*)?$/ or /{\s*$/; - next; - } - + $Blank_Lines++, next if m/^$/; my $Comment = m/^#/; $Indent-- if m/$Close/ and not $Comment; - print "\n" if $Blank_Lines; - $Blank_Lines = 0; + $Blank_Lines = 0, print "\n" if $Blank_Lines; print "\t" x $Indent, $_; $Indent++ if m/$Open/ and not $Comment; } - diff --git a/.config/kak/scripts/kakfmt.bak b/.config/kak/scripts/kakfmt.bak new file mode 100755 index 00000000..5751fa03 --- /dev/null +++ b/.config/kak/scripts/kakfmt.bak @@ -0,0 +1,18 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +my $Indent = 0; +my $Blank_Lines = 0; +my $Open = qr/[{\[(]$/; +my $Close = qr/^[}\])]/; +while (<>) { + s/^\h*//; + $Blank_Lines++, next if m/^$/; + my $Comment = m/^#/; + $Indent-- if m/$Close/ and not $Comment; + $Blank_Lines = 0, print "\n" if $Blank_Lines; + print "\t" x $Indent, $_; + $Indent++ if m/$Open/ and not $Comment; +}