# ------------------ # Editor Settings # ------------------ # Disables startup message showing set-option global startup_info_version 30000000 set-option global tabstop 4 set-option global indentwidth 4 set-option global scrolloff 5,3 declare-option str kakrc_path "~/system/nate/dotfiles/kak/kakrc" declare-option str sway_conf_path "~/system/nate/dotfiles/sway/config.d/default" declare-option str shell_config "~/system/nate/dotfiles/.zshrc" colorscheme catppuccin_macchiato # relative line numbers hook global BufCreate .* %{ add-highlighter buffer/ number-lines -hlcursor } # Git Gutters hook global WinCreate .* %{ evaluate-commands %sh{ if [ $kak_buffile != $kak_bufname ] && git ls-files --error-unmatch "$kak_buffile" > /dev/null 2>&1; then echo "git show-diff" fi }} # Write on unfocus hook global FocusOut .* %{ try %{ write }} hook global BufWritePost .* %{ evaluate-commands 'git update-diff' } hook global BufReload .* %{ evaluate-commands 'git update-diff' } # Add default,red and bold style to these regex matches add-highlighter global/ regex \b(TODO|FIXME|XXX|NOTE)\b 0:default,red+rb # ------------------ # Key bindings # ------------------ # Remap hjkl navigation to colemak-dh layout map global normal n h map global normal e k map global normal i j map global normal o l map global normal N H map global normal E K map global normal I J map global normal O L # Remap insert command map global normal h i # Insert line above or below map global normal l o map global normal L O # No alt, remap map global normal -docstring 'same as [f] but in the other direction' map global normal -docstring 'same as [t] but in the other direction' map global normal -docstring 'select to beginning of line' map global normal -docstring 'select to end of line' map global normal -docstring 'split selections on line boundaries' map global normal -docstring 'select first and last character of each selection' map global normal '' '' -docstring 'flip direction of each selection' map global normal -docstring 'ensure selections are in forward direction (cursor then anchor)' map global normal -docstring 'clear the main selection' # Scrolling remap map global normal -docstring 'Scroll screen up' map global normal -docstring 'Scroll screen down' map global normal ':comment-line' -docstring 'comment selected lines' # Ctrl-s to save map global normal ':w' -docstring 'write buffer' # Ctrl-x to save and exit map global normal ':w:db' -docstring 'write close buffer' # Colemak goto remappings map global goto n h -docstring 'line start' map global goto o l -docstring 'line end' map global goto e k -docstring 'buffer top' map global goto i j -docstring 'buffer bottom' map global goto h n map global goto l o map global goto k e map global goto j i # Remap view keys map global view n h map global view o l map global view e k map global view i j map global normal ( ': buffer-previous' -docstring 'prev buffer' map global normal ) ': buffer-next' -docstring 'next buffer' # map global normal [ ( -docstring 'rotate main selection' # map global normal ] ) -docstring 'rotate main selection backwards' # Make x select lines up and down def -params 1 extend-line-down %{ exec "%arg{1}J" } def -params 1 extend-line-up %{ exec "%arg{1}K" try %{ exec -draft ';\n' exec X } exec '' } map global normal x ':extend-line-down %val{count}' map global normal X ':extend-line-up %val{count}' map global normal k n -docstring 'next result' map global normal K N -docstring 'next result add selection' map global normal -docstring 'prev result' map global normal -docstring 'prev result add selection' map global insert -docstring 'next completion' map global insert -docstring 'prev completion' # ------------------ # User mode Bindings # ------------------ # Accessed with declare-user-mode git map global user g ': enter-user-mode git' -docstring "Git mode" map global user p 'wl-paste -n' -docstring 'paste from system clip board' hook global RegisterModified '"' %{ nop %sh{ printf %s "$kak_main_reg_dquote" | wl-copy > /dev/null 2>&1 & }} # Open kakrc, double quotes needed to ecsape the kakrc_path option map global user o ":edit %opt{kakrc_path}" -docstring 'open kakrc' map global user z ":edit %opt{shell_config}" -docstring 'open shell config' map global user S ":edit %opt{sway_conf_path}" -docstring 'open wm config' # Git Mode Bindings map global git d ':git show-diff' -docstring "Show diff" # ----------------- # LSP Configuration # ----------------- # plug "kak-lsp/kak-lsp" do %{ # cargo install --locked --force --path . # mkdir -p ~/.config/kak-lsp # cp -n kak-lsp.toml ~/.config/kak-lsp/ # } config %{ # enable inlay hints # set global lsp_diagnostic_line_error_sign '║' # set global lsp_diagnostic_line_warning_sign '┊' define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start } map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' map global object a 'lsp-object' -docstring 'LSP any symbol' map global object 'lsp-object' -docstring 'LSP any symbol' map global object e 'lsp-object Function Method' -docstring 'LSP function or method' map global object k 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak. hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp|dart|zig|nix|ocaml) %{ lsp-enable-window map global user l ': enter-user-mode lsp' -docstring 'lsp mode' map global user h ': enter-user-mode lsph' -docstring 'lsp help' map global user a ': enter-user-mode lspa' -docstring 'lsp code action' set-option global lsp_hover_anchor true lsp-inlay-hints-enable global lsp-inlay-diagnostics-enable global } hook global KakEnd .* lsp-exit # load lsp for supported filetypes # set-option global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log" # hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp|zig|dart|ruby) %{ # lsp-enable-window # # lsp-auto-hover-enable # map global user l ': enter-user-mode lsp' -docstring 'lsp mode' # map global user h ': enter-user-mode lsph' -docstring 'lsp help' # map global user a ': enter-user-mode lspa' -docstring 'lsp code action' # set-option global lsp_hover_anchor false # } # } # ----------------- # Other Plugins # ----------------- # fzf file picker map global goto f ':prompt -shell-script-candidates %{ fd --type f --hidden } file: %{ edit %val{text} }' -docstring "file" map global goto b ':prompt -buffer-completion buffer: %{ buffer %val{text} }' -docstring "buffer" map global user b ':fzf-modeb' -docstring 'fzf current buffers' map global user / ':fzf-modeg' -docstring 'fzf search in project' map global normal ':surround'