From 17b59f5ed7acac5dc852c831e1650daac7f169d7 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 3 Nov 2025 23:30:39 +0530 Subject: Improve formatters to fallback to lsp + change lsp config --- autoload/+init.kak | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'autoload/+init.kak') diff --git a/autoload/+init.kak b/autoload/+init.kak index b7e7d27..f9ca258 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -1,7 +1,8 @@ # Link builtin autoloads nop %sh{ ln -sf "$kak_runtime/rc" "$kak_config/autoload/standard-library" 2>/dev/null || true } -evaluate-commands %sh{kcr init kakoune} -evaluate-commands %sh{kak-tree-sitter -dksvv --init "${kak_session}" --with-highlighting --with-text-objects} + +eval %sh{kak-tree-sitter -dksvv --init "${kak_session}" --with-highlighting --with-text-objects} +eval %sh{kcr init kakoune} hook global KakBegin .* %{ require-module luar @@ -18,7 +19,7 @@ set-option global startup_info_version 20250603 set-option global scrolloff 10,3 set-option -add global ui_options terminal_enable_mouse=false terminal_set_title=true set-option global modelinefmt \ -'{StatusLineDetails}{{context_info}} {{mode_info}} +'%opt{lsp_modeline_progress} {StatusLineDetails}{{context_info}} {{mode_info}} %val{cursor_line}/%val{buf_line_count}:%val{cursor_char_column} {StatusLineBufname}%sh{echo "$kak_bufname" | awk -F/ "{if (NF >= 2) {print \$(NF-1) \"/\" \$NF} else {print \$NF}}"}' @@ -49,10 +50,12 @@ map global user p " xclip -selection clipboard -o" -docstring "paste t declare-user-mode system map global user q ': enter-user-mode system' -docstring 'System mode' -map global system o ':echo %opt{}' -map global system v ':echo %val{}' -map global system d ':buffer *debug*' -map global system f ':fennel %{()}' +map global system o ':echo %opt{}' -docstring 'Print opt' +map global system v ':echo %val{}' -docstring 'Print value' +map global system d ': buffer *debug*' -docstring 'Switch to debug buffer' +map global system f ':set buffer filetype ' -docstring 'Set filetype' +map global system m ':set buffer makecmd ""' -docstring 'Set compile command' +map global system p ': info %val{buffile}' -docstring 'Print file path' # Preserve count for user modes (look for alternatives) # TODO: Reset count on modechange? @@ -64,15 +67,20 @@ define-command enter-user-mode-with-count -params 1 %{ # Code mode declare-user-mode code -map global user c ':enter-user-mode code' -docstring 'Code mode' -map global code c :comment-line -docstring 'Comment/uncomment lines' -map global code f :format -docstring 'Format buffer' +map global user c ': enter-user-mode code' -docstring 'Code mode' +map global code c ': comment-line' -docstring 'Comment/uncomment lines' +map global code f ': apply-formatting' -docstring 'Apply configured formatter' def casecamel %{ exec '`s[-_]d~w' } def casesnake %{ exec 's-|[a-z][A-Z];as[-\s]+c_w`' } def casekebab %{ exec 's_|[a-z][A-Z];as[_\s]+c-w`' } -map global code :casekebab -docstring 'kebab-casing' -map global code :casesnake -docstring 'snake_casing' -map global code :casecamel -docstring 'camelCasing' +map global code ': casekebab' -docstring 'kebab-casing' +map global code ': casesnake' -docstring 'snake_casing' +map global code ': casecamel' -docstring 'camelCasing' + +declare-user-mode ai +map global code a ': enter-user-mode ai' -docstring 'AI' +map global ai ! '!ai ""' -docstring 'Insert output' +map global ai | '|ai ""' -docstring 'Replace output' # Editorconfig hook global BufOpenFile .* %{ try %{ editorconfig-load } } -- cgit v1.3.1