aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-06-21 21:56:01 +0530
committerAkshay Nair <phenax5@gmail.com>2026-06-21 21:56:01 +0530
commited0e8f48b59607c138f8d9a6ecdbf7dd5c011c95 (patch)
tree51d1b6349aa152aa955adf88eb7e1311f185e674 /autoload
parent1ccf3d5c1d2ee7ff8ec97488c0b15b8316fb29f9 (diff)
downloadkakoune-config-ed0e8f48b59607c138f8d9a6ecdbf7dd5c011c95.tar.gz
kakoune-config-ed0e8f48b59607c138f8d9a6ecdbf7dd5c011c95.zip
Add handling for dir open + line number open + justfile
Diffstat (limited to 'autoload')
-rw-r--r--autoload/+init.kak32
-rw-r--r--autoload/build.kak11
-rw-r--r--autoload/system.kak3
3 files changed, 40 insertions, 6 deletions
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<ret>'
+ 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 ""<left>' -docstring 'Set global compile command'
map global system m ': make<ret>' -docstring 'Compile'
+map global system j ': just<ret>' -docstring 'Just'
# Run oneshot shell command
map global system ! ':info %sh{}<left>' -docstring 'Run command with %sh'
# New term
-map global system t ': terminal %sh{ echo "$SHELL" }<ret>' -docstring 'Open new term'
+map global system t ': connect terminal<ret>' -docstring 'Open new term'