Skip to content

Instantly share code, notes, and snippets.

@wcasanova
Forked from jwhett/kakrc
Created July 9, 2020 15:55
Show Gist options
  • Save wcasanova/ea10860cd952e004fa1294ab3cf6be85 to your computer and use it in GitHub Desktop.
Save wcasanova/ea10860cd952e004fa1294ab3cf6be85 to your computer and use it in GitHub Desktop.
Kakrc
colorscheme desertex
###########
# Plugins #
###########
source "%val{config}/plugins/plug.kak/rc/plug.kak"
plug "andreyorst/plug.kak" branch "dev" noload
plug "andreyorst/fzf.kak"
plug "occivink/kakoune-sudo-write"
plug "whereswaldon/shellcheck.kak"
plug "eraserhd/kak-ansi"
plug "golang/tools" noload do %{
env --chdir=$HOME GO111MODULE=on go get -v golang.org/x/tools/gopls@latest
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
}
# 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 X11 clipboard" global user C :xcopy<ret>
map -docstring "paste from X11 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
define-command -docstring "copy main selection to X11 clipboard" xcopy %{
nop %sh{ (echo -n "$kak_selection" | xclip -i -f -selection primary | xclip -i -selection clipboard) < /dev/null > /dev/null 2>&1 & }
}
# 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>
define-command -docstring "paste X11 clipboard at cursor" xpaste %{
exec i %sh{ xclip -o -sel clip } <esc>
}
#########
# 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment