339 lines
12 KiB
Plaintext
339 lines
12 KiB
Plaintext
### Plugins ###
|
|
evaluate-commands %sh{
|
|
plugins="$kak_config/plugins"
|
|
mkdir -p "$plugins"
|
|
[ ! -e "$plugins/plug.kak" ] && \
|
|
git clone -q https://github.com/andreyorst/plug.kak.git "$plugins/plug.kak"
|
|
printf "%s\n" "source '$plugins/plug.kak/rc/plug.kak'"
|
|
}
|
|
|
|
plug "andreyorst/plug.kak" noload
|
|
|
|
plug "andreyorst/smarttab.kak" defer smarttab %{
|
|
set-option global softtabstop 4
|
|
}
|
|
|
|
plug "occivink/kakoune-sudo-write"
|
|
|
|
plug "jtrv/grep-write.kak"
|
|
|
|
plug "kak-lsp/kak-lsp" do %{
|
|
cargo install --locked --force --path .
|
|
}
|
|
|
|
plug "gustavo-hms/luar" config %{
|
|
require-module luar
|
|
}
|
|
|
|
plug "gustavo-hms/peneira" config %{
|
|
require-module peneira
|
|
set-option global luar_interpreter luajit
|
|
set-option global peneira_files_command 'fd -t f -I'
|
|
}
|
|
|
|
plug 'theowenyoung/kakoune-buffer-manager'
|
|
|
|
plug "h-youhei/kakoune-surround"
|
|
|
|
plug "your-tools/kak-subvert" do %{
|
|
cargo install --locked --force --path .
|
|
}
|
|
|
|
### End Of Plugins ###
|
|
|
|
## Treesitter ##
|
|
eval %sh{ kak-tree-sitter -dksvvv --with-highlighting --with-text-objects --init $kak_session }
|
|
|
|
## Highlighting ##
|
|
hook global WinCreate .* %{ add-highlighter window/number-lines number-lines -relative -hlcursor}
|
|
add-highlighter global/ show-matching
|
|
add-highlighter global/ show-whitespaces -spc " " -nbsp "" -indent " "
|
|
|
|
## Wrapping ##
|
|
|
|
add-highlighter global/ wrap -word -indent
|
|
|
|
set-option global grepcmd 'ag'
|
|
## Formatting ##
|
|
define-command enable-autofmt -docstring 'enable autoformatting of buffer' %{
|
|
|
|
hook global -group autofmt BufSetOption filetype=(c|cpp) %{
|
|
set-option buffer formatcmd 'clang-format'
|
|
|
|
hook -group autofmt buffer BufOpenFile .* %{
|
|
format
|
|
}
|
|
|
|
hook -group autofmt buffer BufWritePre .* %{
|
|
format
|
|
}
|
|
}
|
|
}
|
|
|
|
define-command disable-autofmt -docstring 'disable autoformatting of buffer' %{
|
|
remove-hooks global autofmt
|
|
}
|
|
|
|
enable-autofmt
|
|
## Indentation ##
|
|
set global tabstop 4
|
|
set global indentwidth 4
|
|
hook global WinSetOption filetype=.* expandtab
|
|
hook global WinSetOption filetype=(makefile|gas) noexpandtab
|
|
hook global BufCreate .* %{
|
|
autoconfigtab
|
|
}
|
|
|
|
## LSP ##
|
|
set-option global autocomplete 'prompt'
|
|
lsp-enable
|
|
# lsp-inlay-diagnostics-enable global
|
|
# set-option global lsp_auto_highlight_references true
|
|
# set-option global lsp_hover_anchor true
|
|
lsp-auto-signature-help-enable
|
|
# lsp-inlay-hints-enable global
|
|
|
|
map global user k ':lsp-hover<ret>'
|
|
|
|
hook global WinSetOption filetype=(c|cpp|zig|rust|python|ruby|lua|java|html|css) %{
|
|
hook window -group semantic-tokens BufReload .* lsp-semantic-tokens
|
|
hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens
|
|
hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens
|
|
hook -once -always window WinSetOption filetype=.* %{
|
|
remove-hooks window semantic-tokens
|
|
}
|
|
}
|
|
|
|
face global InfoDefault Information
|
|
face global InfoBlock Information
|
|
face global InfoBlockQuote Information
|
|
face global InfoBullet Information
|
|
face global InfoHeader Information
|
|
face global InfoLink Information
|
|
face global InfoLinkMono Information
|
|
face global InfoMono Information
|
|
face global InfoRule Information
|
|
face global InfoDiagnosticError Information
|
|
face global InfoDiagnosticHint Information
|
|
face global InfoDiagnosticInformation Information
|
|
face global InfoDiagnosticWarning Information
|
|
|
|
hook -group lsp-filetype-swift global BufSetOption filetype=swift %{
|
|
set-option buffer lsp_servers %{
|
|
[sourcekit-lsp]
|
|
root_globs = [".git", ".hg"]
|
|
}
|
|
}
|
|
|
|
hook -group lsp-filetype-typst global BufSetOption filetype=typst %{
|
|
set-option buffer lsp_servers %{
|
|
[tinymist]
|
|
root_globs = [".git", ".hg"]
|
|
args = ["lsp"]
|
|
settings_section = "_"
|
|
[tinymist.settings._]
|
|
# See https://myriad-dreamin.github.io/tinymist/configurations.html
|
|
exportPdf = "onType"
|
|
# formatterMode = "typstyle"
|
|
# previewFeature = "disable"
|
|
}
|
|
}
|
|
|
|
set-option global lsp_config %{
|
|
}
|
|
|
|
define-command -docstring 'git log' git-log %{
|
|
evaluate-commands %sh{
|
|
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo
|
|
mkfifo ${output}
|
|
( trap - INT QUIT; git log > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
|
|
|
printf %s "evaluate-commands -try-client '$kak_opt_docsclient' '
|
|
edit! -fifo ${output} *git*
|
|
set-option buffer filetype git-log
|
|
$(hide_blame)
|
|
set-option buffer git_blob %{}
|
|
hook -always -once buffer BufCloseFifo .* ''
|
|
nop %sh{ rm -r $(dirname ${output}) }
|
|
''
|
|
'"
|
|
}
|
|
}
|
|
|
|
define-command -docstring 'fd find files' -params 1 fd %{
|
|
edit %arg{1}
|
|
}
|
|
|
|
complete-command -menu fd shell-script-candidates 'fd -I -t f .'
|
|
|
|
declare-option -hidden str last_command
|
|
|
|
define-command -docstring 'compile a la emacs' compile %{
|
|
prompt -init "%opt{last_command}" -shell-completion "Command: " compile_text
|
|
}
|
|
|
|
define-command -docstring 'compile_text' compile_text -hidden %{
|
|
evaluate-commands %{
|
|
evaluate-commands -try-client %opt{toolsclient} %{
|
|
fifo -scroll -name *compile-mode* -script %{
|
|
trap - INT QUIT
|
|
printf "*compilation started at $(date)*\n"
|
|
eval "$kak_quoted_text"
|
|
exit_code=$?
|
|
if [ $exit_code == 0 ]; then
|
|
printf "*compilation finished at $(date)*\n"
|
|
else
|
|
printf "*compilation exited abnormally at $(date) with exit code $exit_code*\n"
|
|
fi
|
|
} -- %arg{@}
|
|
set-option buffer filetype cmd
|
|
set-option buffer jump_current_line 0
|
|
set-option global last_command %val{text}
|
|
}
|
|
}
|
|
}
|
|
|
|
define-command -docstring 'compile_run' compile_run -params .. -hidden %{
|
|
evaluate-commands -save-regs ab %{
|
|
set-register a %arg{@}
|
|
set-register b %sh{ printf "*%s*" "$1" }
|
|
evaluate-commands -try-client %opt{toolsclient} %{
|
|
fifo -name %reg{b} -script %{
|
|
trap - INT QUIT
|
|
eval "$kak_quoted_reg_a"
|
|
} -- %arg{@}
|
|
}
|
|
}
|
|
}
|
|
|
|
define-command -hidden cmd-jmp %{
|
|
evaluate-commands -save-regs a %{
|
|
try %{
|
|
execute-keys -draft 'ght<ret>"ay'
|
|
evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing -- %reg{a}
|
|
try %{ focus %opt{jumpclient} }
|
|
} catch %{
|
|
jump
|
|
}
|
|
}
|
|
}
|
|
|
|
hook -group cmd-highlight global WinSetOption filetype=cmd %{
|
|
add-highlighter window/cmd group
|
|
add-highlighter window/cmd/path regex "^([^:\n\*]+[^/:])$" 1:cyan
|
|
add-highlighter window/cmd/num-path regex "^([^:\n\*]+):(\d+):(\d+)?" 1:cyan 2:green 3:green
|
|
add-highlighter window/cmd/error regex "^([^:\n\*]+):(\d+):(?:(\d+):)?\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow
|
|
add-highlighter window/cmd/extra regex "^\h*(~*(?:(\^)~*)?)$" 1:green 2:cyan+b
|
|
add-highlighter window/cmd/info-error regex "(\*compilation exited abnormally at .+ with exit code )([0-9]+)(\*)" 1:default+b 2:red+b 3:default+b
|
|
add-highlighter window/cmd/info regex "^(\*[^\n]+\*)$" 1:default+b
|
|
add-highlighter window/cmd/ line %{%opt{jump_current_line}} default+b
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmd}
|
|
}
|
|
|
|
hook global WinSetOption filetype=cmd %{
|
|
hook buffer -group cmd-hooks NormalKey <ret> cmd-jmp
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks buffer cmd-hooks }
|
|
}
|
|
|
|
declare-option str curpath_dirls %sh{pwd}
|
|
|
|
define-command dirls -params 1 %{
|
|
set-option global curpath_dirls "%opt{curpath_dirls}/%arg{1}"
|
|
compile_run ls -lh %opt{curpath_dirls}
|
|
set-option buffer filetype dirls
|
|
}
|
|
|
|
complete-command dirls file 0
|
|
|
|
define-command -hidden dirls-jmp %{
|
|
evaluate-commands -save-regs ab %{
|
|
try %{
|
|
execute-keys 'gl<a-t> "ay'
|
|
evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing -- %reg{a}
|
|
try %{ focus %opt{jumpclient} }
|
|
} catch %{
|
|
execute-keys 'gl<a-t> "ay'
|
|
dirls %reg{a}
|
|
}
|
|
}
|
|
}
|
|
|
|
define-command -hidden dirls-jmp-up %{
|
|
dirls ".."
|
|
}
|
|
|
|
hook -group dirls-highlight global WinSetOption filetype=dirls %{
|
|
add-highlighter window/dirls group
|
|
add-highlighter window/dirls/file regex "^(-[^\n]+)$" 1:cyan
|
|
add-highlighter window/dirls/folder regex "^(d[^\n]+)$" 1:blue
|
|
add-highlighter window/dirls/ line %{%opt{jump_current_line}} default+b
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dirls}
|
|
}
|
|
|
|
hook global WinSetOption filetype=dirls %{
|
|
hook buffer -group dirls-hooks NormalKey <ret> dirls-jmp
|
|
hook buffer -group dirls-hooks NormalKey <minus> dirls-jmp-up
|
|
}
|
|
|
|
define-command -docstring 'Print Working Directory' -params 0 pwd %{
|
|
evaluate-commands echo %sh{ echo "$(pwd)"}
|
|
}
|
|
|
|
define-command -docstring 'copy to clipboard' xcopy %{
|
|
execute-keys '<a-|>xclip -selection clipboard -i<ret>'
|
|
}
|
|
|
|
define-command -docstring 'paste from clipboard' xpaste %{
|
|
evaluate-commands -save-regs '"' %{
|
|
set-register dquote %sh{ xclip -selection clipboard -o }
|
|
execute-keys 'p'
|
|
}
|
|
}
|
|
|
|
define-command -docstring 'find files in particular directory' peneira-dir-files %{
|
|
peneira-files-configure-buffer
|
|
prompt -shell-script-completion '(fd -t d -d 1 -I . $@ || fd -t d -d 1 -I . $(dirname $@)) | (sk -f $@ || cat)' 'directory: ' peneira-files-in-dir
|
|
}
|
|
|
|
define-command peneira-files-in-dir -hidden %{
|
|
peneira 'file: ' 'fd -t f -I . $kak_text' 'edit %arg{1}'
|
|
}
|
|
|
|
map -docstring 'fix c-i in silly terminals' global normal '<tab>' '<c-i>'
|
|
declare-user-mode config
|
|
map -docstring 'enter config mode' global user e ':enter-user-mode config<ret>'
|
|
map -docstring 'edit kakoune config' global config k ':e ~/.config/kak/kakrc<ret>'
|
|
map -docstring 'edit tmux config' global config t ':e ~/.tmux.conf<ret>'
|
|
map -docstring 'edit bash config' global config b ':e ~/.bashrc<ret>'
|
|
|
|
map -docstring 'open buf manager' global user b ':buffer-manager<ret>'
|
|
map -docstring 'compile mode' global user c ':compile<ret>'
|
|
map -docstring 'next error' global user ] ':jump-next *compile-mode*<ret>'
|
|
map -docstring 'previous error' global user [ ':jump-previous *compile-mode*<ret>'
|
|
|
|
map -docstring 'clipboard paste' global user p ':xpaste<ret>'
|
|
map -docstring 'clipboard yank' global user y ':xcopy<ret>'
|
|
|
|
map -docstring 'find tags for the current project' global user t ':ctags-search '
|
|
|
|
map -docstring 'find files' global user f ':peneira-files<ret>'
|
|
map -docstring 'find files in particular dir' global user F ':peneira-dir-files<ret>'
|
|
|
|
map -docstring 'enter lsp mode' global user l ':enter-user-mode lsp<ret>'
|
|
map -docstring 'goto definition (tag)' global lsp t '<a-i>w:ctags-search<ret>'
|
|
|
|
declare-user-mode tmux
|
|
map -docstring 'enter tmux/window mode' global user w ':enter-user-mode tmux<ret>'
|
|
map -docstring 'vertical split' global tmux v ':tmux-terminal-horizontal kak -c %val{session}<ret>'
|
|
map -docstring 'horizontal split' global tmux h ':tmux-terminal-vertical kak -c %val{session}<ret>'
|
|
map -docstring 'new tab' global tmux t ':tmux-terminal-window kak -c %val{session}<ret>'
|
|
map -docstring 'vertical terminal split' global tmux V ':tmux-repl-horizontal bash<ret>'
|
|
map -docstring 'horizontal terminal split' global tmux H ':tmux-repl-vertical bash<ret>'
|
|
map -docstring 'new terminal tab' global tmux T ':tmux-repl-window<ret>'
|
|
|
|
declare-user-mode general
|
|
map -docstring 'enter general keybinds mode' global user g ':enter-user-mode general<ret>'
|
|
map -docstring 'toggle comments' global general c ':comment-line<ret>'
|
|
|
|
colorscheme dawnfox
|