From ed0e8f48b59607c138f8d9a6ecdbf7dd5c011c95 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 21 Jun 2026 21:56:01 +0530 Subject: Add handling for dir open + line number open + justfile --- autoload/+init.kak | 32 +++++++++++++++++++++++++++----- autoload/build.kak | 11 +++++++++++ autoload/system.kak | 3 ++- 3 files changed, 40 insertions(+), 6 deletions(-) (limited to 'autoload') diff --git a/autoload/+init.kak b/autoload/+init.kak index 4a7671d..43be837 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -18,14 +18,11 @@ set-option global tabstop 2 set-option -add global path "**" 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 -# terminal_status_on_top=true +set-option -add global ui_options terminal_enable_mouse=false terminal_set_title=true terminal_status_on_top=true # Modeline -# declare-option -hidden _lsp_modeline_diagnostics "%opt{lsp_diagnostic_error_count}" -# %opt{lsp_modeline_breadcrumbs} set-option global modelinefmt \ -'{StatusLineExtras}%opt{lsp_modeline_progress} +'{StatusLineExtras}%opt{lsp_modeline_progress} %opt{lsp_modeline_breadcrumbs} {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}}"}' @@ -48,3 +45,28 @@ define-command enter-user-mode-with-count -params 1 %{ set-option window user_mode_count %val{count} enter-user-mode %arg{1} } + +# Open directory (bits from explore.kak) +hook global RuntimeError '\d+:\d+: ''(?:edit|e)''(.+): is a directory' %{ + file-manager %val(hook_param_capture_1) +} +hook global KakBegin .* %{ hook -once global WinCreate .* %{ hook -once global NormalIdle '' %{ + try %{ evaluate-commands -draft -save-regs '/' %{ + buffer *debug* + set-register / 'error while opening file ''(.+?)'':\n\h+(.+?): is a directory' + execute-keys '%1s' + evaluate-commands -draft -itersel %{ + evaluate-commands -client %val(client) file-manager %reg(.) + } + }} +}}} + +# Open file:linenum +hook global WinDisplay (.*):(\d+)$ %{ + # Use string to eval quickly + # FIXME: Replace normalidle hack with better approach to "defer" + hook -once buffer NormalIdle .* " + delete-buffer %val{hook_param} + edit %val{hook_param_capture_1} %val{hook_param_capture_2} + " +} diff --git a/autoload/build.kak b/autoload/build.kak index d8a676c..d6f930d 100644 --- a/autoload/build.kak +++ b/autoload/build.kak @@ -26,3 +26,14 @@ provide-module make-override %{ } hook -once global KakBegin .* %{ require-module make-override } + +define-command just -params .. %{ + eval %sh{ + if [ "$#" = "0" ]; then + echo "terminal-singleton just just --choose" + else + echo "terminal-singleton just sh -c 'just ""$@""; echo ""Press enter to exit""; read a'" + fi + } +} + diff --git a/autoload/system.kak b/autoload/system.kak index bb11f4f..8f6e3fb 100644 --- a/autoload/system.kak +++ b/autoload/system.kak @@ -28,7 +28,8 @@ map global system Y ': info %sh{realpath -s "$kak_buffile" | xclip -selection cl # Make cmd map global system M ':set global makecmd ""' -docstring 'Set global compile command' map global system m ': make' -docstring 'Compile' +map global system j ': just' -docstring 'Just' # Run oneshot shell command map global system ! ':info %sh{}' -docstring 'Run command with %sh' # New term -map global system t ': terminal %sh{ echo "$SHELL" }' -docstring 'Open new term' +map global system t ': connect terminal' -docstring 'Open new term' -- cgit v1.3.1