Files
dotfiles/kakoune/.config/kak/kakrc

278 lines
11 KiB
Plaintext

# OPTIONS
set-option global startup_info_version 20260412
set-option global ui_options terminal_assistant=none
hook global WinCreate .* %{
add-highlighter window/number-lines number-lines -relative -hlcursor
}
add-highlighter global/ show-matching
# LOCAL
nop %sh{
mkdir -p "$kak_config/autoload"
[ -e "$kak_config/autoload/stdlib" ] || ln -s "$kak_runtime/autoload" "$kak_config/autoload/stdlib"
}
map global -docstring 'Buffer' user ' ' ': b '
declare-user-mode file-mode
map global -docstring 'Search/open' user 's' ': enter-user-mode file-mode<ret>'
map global -docstring 'Open (git)' file-mode 'a' ': file-open-git<ret>'
map global -docstring 'Open (fd)' file-mode 'f' ': file-open<ret>'
map global -docstring 'Open (fd -H)' file-mode 'h' ': file-open-with-hidden<ret>'
map global -docstring 'Open (recent)' file-mode 'r' ': file-open-recent<ret>'
map global -docstring 'Open (nnn)' file-mode 'n' ': nnn-open %val{buffile}<ret>'
map global -docstring 'Open (nnn)' file-mode 'N' ': nnn-open .<ret>'
map global -docstring 'Open/create in dir' file-mode 'c' ': open-create-in-dir<ret>'
map global -docstring 'ctags file symbols' file-mode 's' ': ctags-file-symbols<ret>'
map global -docstring 'ctags project symbols' file-mode 'p' ': ctags-project-symbols<ret>'
declare-user-mode git-mode
map global -docstring 'Git' user 'g' ': enter-user-mode git-mode<ret>'
map global -docstring 'Blame' git-mode 'b' ': git blame<ret>'
map global -docstring 'Blame' git-mode 'B' ': git blame-jump<ret>'
map global -docstring 'Diff file' git-mode 'd' ': git diff %val{buffile}<ret>'
map global -docstring 'Diff' git-mode 'D' ': git diff<ret>'
map global -docstring 'Grep' git-mode 'g' ': git grep '
map global -docstring 'Log' git-mode 'l' ': git log -- %val{buffile}<ret>'
map global -docstring 'Log' git-mode 'L' ': git log<ret>'
map global -docstring 'Show branch' git-mode 'c' ': git show-branch<ret>'
map global -docstring 'Status' git-mode 't' ': git status<ret>'
map global -docstring 'Show diff' git-mode 's' ': git-show-diff<ret>'
map global -docstring 'Hide diff' git-mode 'h' ': git-hide-diff<ret>'
map global -docstring 'Next hunk' git-mode 'n' ': git next-hunk<ret>'
map global -docstring 'Prev hunk' git-mode 'p' ': git prev-hunk<ret>'
declare-user-mode options-mode
map global -docstring 'Options' user 'o' ': enter-user-mode options-mode<ret>'
map global -docstring 'Five Dark mode' options-mode 'd' ': colorscheme five-colors-dark<ret>'
map global -docstring 'Five Light mode' options-mode 'l' ': colorscheme five-colors-light<ret>'
map global -docstring 'Light mode' options-mode 'L' ': colorscheme one-light<ret>'
map global -docstring 'Dark mode' options-mode 'D' ': colorscheme one-darker<ret>'
declare-user-mode make-mode
map global -docstring 'Make' user 'k' ': enter-user-mode make-mode<ret>'
map global -docstring 'Make' make-mode 'a' ':make '
map global -docstring 'Next' make-mode 'n' ': make-next-error<ret>'
map global -docstring 'Previous' make-mode 'p' ': make-previous-error<ret>'
map global -docstring 'General messages' make-mode 'g' ': set window make_error_pattern "^([^:\n]+):(\d+):(?:(\d+):)? ([^\n]+)?"<ret>'
evaluate-commands %sh{
if [ -n "$WAYLAND_DISPLAY" ]; then
echo "
map global -docstring 'Paste clipboard (append)' user 'p' '<a-!> wl-paste -n<ret>'
map global -docstring 'Paste clipboard (insert)' user 'P' '! wl-paste -n<ret>'
map global -docstring 'Yank to clipboard' user 'y' '<a-|> wl-copy<ret>'
"
elif [ -n "$DISPLAY" ]; then
echo "
map global -docstring 'Paste clipboard (append)' user 'p' '<a-!> xsel -bo<ret>'
map global -docstring 'Paste clipboard (insert)' user 'P' '! xsel -bo<ret>'
map global -docstring 'Yank to clipboard' user 'y' '<a-|> xsel -bi<ret>'
"
fi
}
map global -docstring 'Replace jump mode' user 'j' ': enter_jump_mode_with_replace_select_mode<ret>'
map global -docstring 'Extend jump mode' user 'e' ': enter_jump_mode_with_extend_select_mode<ret>'
map global -docstring 'Append jump mode' user 'a' ': enter_jump_mode_with_append_select_mode<ret>'
define-command -override file-open %{
prompt -menu -shell-script-candidates %{ fd -t f } 'File: ' %{ edit -- %val{text} }
}
define-command -override file-open-with-hidden %{
prompt -menu -shell-script-candidates %{ fd -t f -H } 'File: ' %{ edit -- %val{text} }
}
define-command -override file-open-git %{
prompt -menu -shell-script-candidates %{ git ls-files } 'File (git): ' %{ edit -- %val{text} }
}
define-command -override file-open-recent %{
prompt -menu -shell-script-candidates %{ cat ~/.cache/kak-mru } 'File (recent): ' %{ edit -- %val{text} }
}
define-command -override -params 1 nnn-open %{
terminal nnn-kak-edit %arg{1} %val{session} %val{client}
}
define-command -override open-create-in-dir %{
execute-keys ': edit ' %sh{dirname "$kak_buffile"}/
}
define-command git-log-show-current-commit %{
execute-keys ';<a-/>^commit\s[0-9a-f]+<ret>b'
git show %val{selection}
}
define-command -override git-show-diff %{
hook buffer -group git-show-diff NormalIdle .* %{ git update-diff }
git show-diff
}
define-command -override git-hide-diff %{
remove-hooks buffer git-show-diff
git hide-diff
}
define-command -override ctags-file-symbols %{
prompt -menu -shell-script-candidates %{
ctags -uo - -x "$kak_buffile" | awk '{ print $1, $2, $3 }'
} 'File symbols: ' %{
evaluate-commands %sh{ printf '%s\n' "$kak_text" | awk '{ print "execute-keys", $3, "g", "/\\b" $1 "\\b<ret>" }' }
}
}
define-command -override ctags-project-symbols %{
prompt -menu -shell-script-candidates %{
git ls-files | xargs ctags -uo - -x | awk '{ print $1, $2, $3, $4 }'
} 'Project symbols: ' %{
evaluate-commands %sh{ printf '%s\n' "$kak_text" | awk '{ print "edit --", $4, $3 "; execute-keys /\\b" $1 "\\b<ret>" }' }
}
}
set-face global JumpLabel 'rgb:faf8f5,rgb:af8842+F'
# CHANGE STATUS BAR COLOR IN INSERT MODE
hook global ModeChange push:.*:insert %{
set-face window StatusLine 'default,rgb:04785d'
set-option window idle_timeout 500
}
hook global ModeChange pop:insert:.* %{
unset-face window StatusLine
unset-option window idle_timeout
}
# ODIN
hook global BufSetOption filetype=odin %{
set-option buffer formatcmd 'odinfmt -stdin'
}
# LSP
eval %sh{kak-lsp}
lsp-enable
set-option global modelinefmt "%opt{lsp_modeline} %opt{modelinefmt}"
map global user l ': enter-user-mode lsp<ret>' -docstring 'LSP mode'
map global goto d <esc>:lsp-definition<ret> -docstring 'LSP definition'
map global goto r <esc>:lsp-references<ret> -docstring 'LSP references'
map global goto y <esc>:lsp-type-definition<ret> -docstring 'LSP type definition'
map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
map global object t '<a-semicolon>lsp-object Class Interface Module Namespace Struct<ret>' -docstring 'LSP class or module'
map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
map global lsp p '<esc>: lsp-find-error --previous error<ret>' -docstring 'find previous error'
# BUNDLE
source "%val{config}/bundle/kak-bundle/rc/kak-bundle.kak"
bundle-noload kak-bundle https://codeberg.org/jdugan6240/kak-bundle
# COLORSCHEME
bundle-theme kak-one 'https://codeberg.org/raiguard/kak-one'
bundle-theme kakoune-themes 'https://codeberg.org/anhsirk0/kakoune-themes'
# FZF
bundle fzf.kak 'https://github.com/andreyorst/fzf.kak' %{
map global -docstring 'FZF menu' user 'f' ': fzf-mode<ret>'
require-module fzf
set-option global fzf_highlight_command "bat"
}
hook global BufCreate [^*].* %{
nop %sh{
mru=~/.cache/kak-mru
echo "$kak_buffile" | awk '!seen[$0]++' - "$mru" | sponge "$mru"
}}
# MATCH
bundle match 'https://github.com/kmafeni04/match.kak' %{
declare-user-mode match
map global user m ': enter-user-mode match<ret>' -docstring 'Match'
map global match m m -docstring 'Match next matching pair'
map global match i ': match-inside<ret>' -docstring 'Match inside object'
map global match a ': match-around<ret>' -docstring 'Match around object'
map global match n ': match-next<ret>' -docstring 'Match next object'
map global match p ': match-prev<ret>' -docstring 'Match previous object'
map global match s ': match-surround-add<ret>' -docstring 'Surround selection with character'
map global match d ': match-surround-delete<ret>' -docstring "Delete selection's surrounding character"
map global match r ': match-surround-replace<ret>' -docstring "Replace selection's surrounding character"
map global match u ': match-surround-undo<ret>' -docstring "Undo"
map global match U ': match-surround-redo<ret>' -docstring "Redo"
}
# HARPOON
bundle kak-harpoon 'https://codeberg.org/raiguard/kak-harpoon' %{
harpoon-add-bindings
}
# PENEIRA
bundle 'luar' 'https://github.com/gustavo-hms/luar' %{
require-module luar
}
bundle 'peneira' 'https://github.com/gustavo-hms/peneira' %{
require-module peneira
define-command buffers %{
peneira 'buffers: ' %{ eval "printf '%s\n' $kak_quoted_buflist" } %{
buffer %arg{1}
}
}
define-command peneira-git-files %{
peneira 'git files: ' %{ git ls-files } %{ edit -- %arg{1} }
}
define-command peneira-files-with-hidden %{
peneira 'git files: ' %{ fd -t f -H } %{ edit -- %arg{1} }
}
define-command peneira-recent-files %{
peneira 'mru files: ' %{ cat ~/.cache/kak-mru } %{ edit -- %arg{1} }
}
map global -docstring 'Buffer' user ' ' ': buffers<ret>'
map global -docstring 'Git files' file-mode 'a' ': peneira-git-files<ret>'
map global -docstring 'Buffers' file-mode 'b' ': buffers<ret>'
map global -docstring 'Files' file-mode 'f' ': peneira-files<ret>'
map global -docstring 'Files' file-mode 'F' ': peneira-local-files<ret>'
map global -docstring 'Files (with hidden)' file-mode 'h' ': peneira-files-with-hidden<ret>'
map global -docstring 'Lines' file-mode 'l' ': peneira-lines<ret>'
map global -docstring 'Symbols' file-mode 's' ': peneira-symbols<ret>'
map global -docstring 'Recent files' file-mode 'r' ': peneira-recent-files<ret>'
}
# LOCAL
colorscheme %sh{
if [ -e ~/.lightmode ]; then
echo five-colors-light
else
echo five-colors-dark
fi
}