Last active
November 14, 2022 14:59
-
-
Save jwhett/fa8d2a386b0c784798e912eaa8145184 to your computer and use it in GitHub Desktop.
Kakrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colorscheme desertex | |
########### | |
# Plugins # | |
########### | |
source "%val{config}/plugins/plug.kak/rc/plug.kak" | |
plug "andreyorst/plug.kak" branch "master" noload | |
plug "andreyorst/fzf.kak" | |
plug "occivink/kakoune-sudo-write" | |
plug "whereswaldon/shellcheck.kak" | |
plug "eraserhd/kak-ansi" | |
plug "golang/tools" noload do %{ | |
pushd $HOME; env GO111MODULE=on go get -v golang.org/x/tools/gopls@latest; popd | |
echo DONE | |
} | |
plug "ul/kak-lsp" do %{ | |
cargo install --locked --force --path . | |
} config %{ | |
# Uncomment for debug logging | |
# eval %sh{echo ${kak_opt_lsp_cmd} >> /tmp/kak-lsp.log} | |
# set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log" | |
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 } | |
hook global WinSetOption filetype=(go) %{ | |
set-option window lsp_auto_highlight_references true | |
set-option window lsp_hover_anchor false | |
# lsp-auto-hover-enable | |
echo -debug "Enabling LSP for filtetype %opt{filetype}" | |
lsp-enable-window | |
} | |
hook global WinSetOption filetype=(python) %{ | |
set-option window lsp_auto_highlight_references true | |
set-option window lsp_hover_anchor false | |
# lsp-auto-hover-enable | |
echo -debug "Enabling LSP for filtetype %opt{filetype}" | |
lsp-enable-window | |
} | |
# Make the hover stuff suck less | |
define-command -override -hidden lsp-show-error -params 1 -docstring "Render error (suppress useless gopls errors)" %{ | |
evaluate-commands %sh{ | |
if [ "$1" = "go language server error: 'no identifier found'" ]; then | |
exit 0 | |
fi | |
echo 'echo -debug "kak-lsp:" %arg{1}' | |
echo 'info %arg{1}' | |
} | |
} | |
hook global KakEnd .* lsp-exit | |
} | |
# My plugins | |
plug "jwhett/entr-kak" | |
plug "jwhett/boxes-kak" | |
plug "jwhett/sxhkdrc-kak" | |
plug "jwhett/graphviz-kak" | |
################ | |
# Highlighters # | |
################ | |
hook global WinCreate .* %{ | |
add-highlighter window/ number-lines -hlcursor | |
add-highlighter window/ wrap -indent -word | |
} | |
hook global BufCreate bspwmrc %{ | |
set-option buffer filetype sh | |
} | |
# Fix tabs | |
# set-option global aligntab false | |
# set-option global tabstop 4 | |
# set-option global indentwidth 4 | |
####### | |
# MAP # | |
####### | |
# Folding shortcuts; need to remove the trailing whitespace | |
map -docstring "Fold selection" global user f "| fold -s -w90 | sed -E 's/[ \t]+$//'<ret>" | |
# Whitespace visibility | |
map -docstring "show whitespace" global user w ': add-highlighter buffer/ show-whitespaces<ret>' | |
map -docstring "hide whitespace" global user W ': remove-highlighter buffer/show-whitespaces<ret>' | |
# Sync the clipboard | |
map -docstring "copy to clipboard" global user C :xcopy<ret> | |
map -docstring "paste from clipboard" global user V :xpaste<ret> | |
# Easy way to open/edit config | |
map -docstring "edit kakrc" global user e :e<space>~/.config/kak/kakrc<ret> | |
map -docstring "source kakrc" global user r :source<space>~/.config/kak/kakrc<ret> | |
# Splits | |
map -docstring "split horizontal" global user h :tmux-terminal-vertical<space>kak<space>-c<space>%val{session}<ret> | |
map -docstring "split vertical" global user v :new<ret> | |
# LSP | |
map -docstring "enable LSP hover" global user l :lsp-auto-hover-enable<ret> | |
map -docstring "disable LSP hover" global user L :lsp-auto-hover-disable<ret> | |
# FZF | |
map global normal <c-p> ': fzf-mode<ret>' | |
# Command definitions | |
## MAC Sync the clipboard | |
map -docstring "copy to X11 clipboard" global user C :xcopy<ret> | |
map -docstring "paste from X11 clipboard" global user V :xpaste<ret> | |
define-command -docstring "copy main selection to Mac clipboard" xcopy %{ | |
nop %sh{ (echo "$kak_selection" | pbcopy) < /dev/null > /dev/null 2>&1 & } | |
} | |
define-command -docstring "paste Mac clipboard at cursor" xpaste %{ | |
exec i %sh{ pbpaste } <esc> | |
} | |
define-command -docstring "copy main selection to X11 clipboard" xecopy %{ | |
nop %sh{ (echo -n "$kak_selection" | xclip -i -f -selection primary | xclip -i -selection clipboard) < /dev/null > /dev/null 2>&1 & } | |
} | |
define-command -docstring "paste X11 clipboard at cursor" xepaste %{ | |
exec i %sh{ xclip -o -sel clip } <esc> | |
} | |
# LSP control | |
map -docstring "enable lsp_auto_highlight_references" global user <c-a> :set-option<space>window<space>lsp_auto_highlight_references<space>true<ret> | |
map -docstring "disable lsp_auto_highlight_references" global user <c-A> :set-option<space>window<space>lsp_auto_highlight_references<space>false<ret> | |
######### | |
# Hooks # | |
######### | |
# Linters | |
define-command -override -docstring "enable user mode lint shortcuts" user-lint %{ | |
map -docstring "Next lint error" window user n ': lint-next-error<ret>' | |
map -docstring "Previous lint error" window user p ': lint-previous-error<ret>' | |
} | |
# Tab hook | |
hook global InsertChar \t %{ try %{ | |
execute-keys -draft "h<a-h><a-k>\A\h+\z<ret><a-;>;%opt{indentwidth}@" | |
}} | |
hook global WinSetOption filetype=go %{ | |
set window lintcmd "golangci-lint run" | |
lint-enable | |
hook buffer BufWritePre .* %{ | |
go-format -use-goimports | |
lint | |
} | |
} | |
hook global WinSetOption filetype=python %{ | |
hook buffer BufWritePre .* %{ | |
black | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment