244 lines
7.2 KiB
Text
244 lines
7.2 KiB
Text
# Daniel's Personal kakrc
|
|
# Author: Daniel Fichtinger <daniel@ficd.ca>
|
|
# See README.md for explanations.
|
|
|
|
# TODO: refactor config s.t. everything defined in autoload
|
|
# provides a module
|
|
# Then, use an environment variable to determine whether
|
|
# we're on a server. If we are, we don't load a bunch of
|
|
# the modules. This lets us keep a unified config without requiring
|
|
# all dependencies to be installed.
|
|
|
|
declare-option -hidden bool on_server %sh{
|
|
if [ -z "$KAK_ON_SERVER" ]; then
|
|
printf 'false'
|
|
else
|
|
printf 'true'
|
|
fi
|
|
}
|
|
|
|
define-command -override true nop
|
|
define-command -override false fail
|
|
|
|
try %{
|
|
%opt{on_server}
|
|
colorscheme ashen-local
|
|
} catch %{
|
|
evaluate-commands %sh{ kak-tree-sitter -dks --init $kak_session }
|
|
evaluate-commands %sh{kak-popup init}
|
|
evaluate-commands %sh{ reflow init }
|
|
set-option global reflow_command %{
|
|
cat > "${input=$(mktemp)}"
|
|
# reflow --width "$kak_opt_reflow_width" --tabstop "$kak_opt_tabstop" < "$input" || cat "$input"
|
|
fmt -u < "$input" || cat "$input"
|
|
rm -f "$input"
|
|
}
|
|
|
|
colorscheme ashen
|
|
require-module hop-kak
|
|
require-module fishr
|
|
require-module title-bar
|
|
require-module notes
|
|
require-module plugins
|
|
require-module yazi
|
|
require-module luar
|
|
require-module clipboard
|
|
set-option global luar_interpreter luajit
|
|
# only set to foot if we are on wayland
|
|
hook global ModuleLoaded wayland %{
|
|
set-option global termcmd 'footclient dash -c'
|
|
}
|
|
# needed for tree-sitter to respect show-matching
|
|
define-command -override tree-sitter-user-after-highlighter %{
|
|
add-highlighter -override buffer/show-matching show-matching
|
|
}
|
|
|
|
# manually requiring needed for some reason 😢
|
|
require-module peneira
|
|
|
|
declare-user-mode peneira
|
|
map -docstring %{
|
|
Picker mode
|
|
} global user f ': enter-user-mode peneira<ret>'
|
|
map -docstring 'pick file' global peneira f ': peneira-files<ret>'
|
|
map -docstring 'pick unopened file' global peneira F ': peneira-files -hide-opened<ret>'
|
|
map -docstring %{
|
|
pick line in buffer
|
|
} global peneira '/' ': peneira-lines<ret>'
|
|
define-command -override -hidden consume %{
|
|
nop %sh{
|
|
niri msg action consume-or-expel-window-left
|
|
}
|
|
}
|
|
|
|
define-command terminal-consume %{
|
|
terminal dash -c 'niri msg action consume-or-expel-window-left; exec fish'
|
|
}
|
|
|
|
alias global tc terminal-consume
|
|
|
|
define-command -docstring %{
|
|
Create a new client in vertial split
|
|
} new-consume %{
|
|
new consume
|
|
}
|
|
|
|
alias global nc new-consume
|
|
alias global n new
|
|
define-command -docstring 'open popup shell' popup-shell %{
|
|
popup fish
|
|
}
|
|
alias global pp popup-shell
|
|
|
|
map -docstring 'popup shell' global user . ': popup-shell<ret>'
|
|
require-module ui-mode
|
|
|
|
try %{
|
|
evaluate-commands %sh{kak-lsp-diags}
|
|
map -docstring 'enable diagnostic hover' global ui "'" ': lsp-diag-hover-enable<ret>'
|
|
map -docstring 'disable diagnostic hover' global ui '"' ': lsp-diag-hover-disable<ret>'
|
|
}
|
|
}
|
|
|
|
require-module surround
|
|
require-module expand
|
|
require-module ficgrep
|
|
require-module byline
|
|
require-module spell
|
|
set-option global scrolloff 3,3
|
|
|
|
|
|
|
|
try %{
|
|
set-option global ashen_dynamic_cursor true
|
|
set-option global ashen_eol_cursor true
|
|
}
|
|
# disable clippy
|
|
set-option -add global ui_options terminal_assistant=none
|
|
|
|
|
|
# This gets overridden by editorconfig but we set sane default anyways
|
|
set-option global tabstop 4
|
|
set-option global indentwidth 4
|
|
|
|
hook global WinSetOption filetype=kak %{
|
|
# make brackets gray a-la Ashen
|
|
add-highlighter window/bracket regex [\[\]\(\)\{\}]{1} 0:rgb:737373
|
|
# special highlighting for escaped goodies in regex
|
|
add-highlighter window/regex-escaped regex \\[\[\]\(\)\{\}fnrtv0\\dwshDWSH] 0:rgb:e5e5e5
|
|
}
|
|
|
|
# default window settings
|
|
# wrap enabled
|
|
# scrolloff enabled
|
|
hook global WinCreate .* %{
|
|
ui-wrap-enable
|
|
# TODO: fix ui-scrolloff-enable and use that instead
|
|
ui-scrolloff-toggle
|
|
add-highlighter window/number-lines number-lines -hlcursor -relative -separator " "
|
|
# only-trailing is nice QOL otherwise it gets hard to read the screen
|
|
# and it makes it easy to see trailing spaces
|
|
add-highlighter window/show-whitespaces show-whitespaces -only-trailing
|
|
add-highlighter window/show-matching show-matching
|
|
}
|
|
|
|
# convenience mappings
|
|
# quitting & saving
|
|
map -docstring "quit" global user q ": q<ret>"
|
|
map -docstring "quit" global normal <c-q> ": q<ret>"
|
|
map -docstring "force quit" global user Q ": q!<ret>"
|
|
map -docstring "force quit" global normal <c-Q> ": q!<ret>"
|
|
map -docstring "kill session" global normal <a-q> ':kill<ret>'
|
|
map -docstring "force kill session" global normal <a-q> ':kill!<ret>'
|
|
map -docstring "save" global normal <c-s> ": write<ret>"
|
|
map -docstring "save" global normal <c-S> ": write!<ret>"
|
|
|
|
# buffer operations
|
|
map -docstring "close current buffer" global user x ": db<ret>"
|
|
map -docstring "goto previous buffer" global user m ": bp<ret>"
|
|
map -docstring "goto next buffer" global user i ": bn<ret>"
|
|
map -docstring "goto previous buffer" global normal <c-m> ": bp<ret>"
|
|
map -docstring "goto next buffer" global normal <c-i> ": bn<ret>"
|
|
|
|
# trim whitespace
|
|
map global normal <tab> _
|
|
|
|
# comments
|
|
map -docstring "comment line" global normal "#" ": comment-line<ret>"
|
|
map -docstring "comment block" global normal "<a-#>" ": comment-block<ret>"
|
|
|
|
# formatting
|
|
map -docstring "format" global normal = ": format-buffer<ret>"
|
|
map -docstring "format" global normal <a-=> ": format-selections<ret>"
|
|
|
|
# Case-insensitive Search
|
|
map -docstring 'case insensitive search' global user '/' /(?i)
|
|
map -docstring 'case insensitive backward search' global user '<a-/>' <a-/>(?i)
|
|
map -docstring 'case insensitive extend search' global user '?' ?(?i)
|
|
map -docstring 'case insensitive backward extend-search' global user '<a-?>' <a-?>(?i)
|
|
|
|
# TODO: how to bind these to goto mode while respecting g/G??
|
|
map -docstring 'Select to file end' global user N "Gj<a-L>L"
|
|
map -docstring 'Extend to file end' global user n "gj<a-l>l"
|
|
|
|
define-command -docstring "Create a scratch buffer" scratch %{
|
|
edit -scratch
|
|
}
|
|
|
|
alias global s scratch
|
|
|
|
define-command -params 1 -docstring "Set buffer filetype" filetype %{
|
|
set-option buffer filetype %arg{1}
|
|
}
|
|
|
|
alias global ft filetype
|
|
alias global lang filetype
|
|
|
|
define-command -docstring "New terminal in cwd" cwd-terminal %{
|
|
terminal fish
|
|
}
|
|
# make easy to open new shell
|
|
alias global t cwd-terminal
|
|
|
|
|
|
map global normal <backspace> '"_'
|
|
define-command goto-debug %{
|
|
try %{
|
|
buffer *debug*
|
|
ui-scrolloff-disable
|
|
execute-keys 'gj'
|
|
}
|
|
}
|
|
|
|
declare-user-mode debug
|
|
map -docstring 'open debug buffer' global debug d ':goto-debug<ret>'
|
|
map -docstring 'open debug buffer' global user D ': enter-user-mode debug<ret>'
|
|
|
|
define-command exec-selection %{
|
|
execute-keys ':<c-r>.<ret>'
|
|
}
|
|
|
|
map -docstring 'execute selection' global debug x ': exec-selection<ret>'
|
|
define-command repl %{
|
|
new %{ edit -scratch; set buffer filetype kak }
|
|
}
|
|
|
|
# jumplist
|
|
|
|
map -docstring 'jump forward' global normal <c-f> <c-i>
|
|
map -docstring 'save to jumplist' global normal <c-v> <c-s>
|
|
|
|
# selection saving
|
|
map -docstring 'add selection' global normal Y <a-Z>a
|
|
|
|
# hook -once global ClientCreate .* %{
|
|
# evaluate-commands %sh{
|
|
# if [ "$kak_buflist" != "*debug* *scratch*" ]; then
|
|
# echo "delete-buffer *scratch*"
|
|
# else
|
|
# echo "echo -debug dumping buffers"
|
|
# echo "echo -debug %val{buflist}"
|
|
# fi
|
|
# }
|
|
# }
|
|
|