Last active
February 19, 2020 02:09
-
-
Save BanchouBoo/309c885a67f031fc8c9eaa451c5a231c to your computer and use it in GitHub Desktop.
Kakoune Config
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
### STYLE ### | |
colorscheme improved-term | |
## HIGHLIGHTERS | |
add-highlighter global/ number-lines -relative | |
add-highlighter global/ regex '\h*$' 0:red,red # highlight trailing whitespace | |
# add-highlighter global/linewrap column 80 magenta,magenta | |
## OPTIONS | |
# tabs tabs tabs | |
set-option global indentwidth 0 | |
set-option global aligntab true | |
set-option global tabstop 4 | |
set global ui_options ncurses_enable_mouse=false | |
set global ui_options ncurses_assistant=cat | |
# show all keys | |
# set global autoinfo command|onkey|normal | |
### HOOKS ### | |
hook global WinCreate .* %{ | |
set-option global termcmd 'xst -e sh -c' | |
} | |
hook global BufOpenFile "%val{config}/kakrc" %{ | |
set-option buffer tabstop 2 | |
} | |
### COMMANDS ### | |
define-command surround %{ | |
declare-option -hidden str surround_string | |
prompt "Surround string: " %{ | |
set-option current surround_string %val{text} | |
evaluate-commands %sh{ | |
SURROUNDER="$kak_opt_surround_string" | |
SURROUNDER="$(echo $SURROUNDER | sed "s/'/'\\\''/g")" | |
SURROUNDER="$(echo $SURROUNDER | sed 's/"/""/g')" | |
SURROUNDER="$(echo $SURROUNDER | sed 's/</<lt>/g')" | |
printf 'exec "|surround %s<ret>"\n' "'${SURROUNDER}'" | |
} | |
} | |
} | |
define-command buffer-list %{ | |
declare-option -hidden str-list buffers | |
set-option global buffers | |
evaluate-commands -no-hooks -buffer * %{ | |
set-option -add global buffers "%val{bufname}|" | |
} | |
evaluate-commands %sh{ | |
BUFFER="$(echo $kak_opt_buffers | sed -E 's/\|( |$)/\n/g' | rofi -dmenu -i -p 'Buffer')" | |
test -n "$BUFFER" && echo "buffer $BUFFER" | |
} | |
} | |
define-command choose-file %{ | |
evaluate-commands %sh{ | |
FILE="$(rofi-fileselect "$(dirname $kak_buffile)" | sed 's/ /\\ /g')" | |
if [ -n "$FILE" ]; then | |
printf 'exec ": edit %s<ret>"' "$FILE" | |
fi | |
} | |
} | |
define-command align-with-spaces %{ | |
set-option current aligntab false | |
exec '&' | |
} | |
### KEYBINDS ### | |
## MODE DECLARATIONS | |
declare-user-mode file | |
declare-user-mode clip | |
## NORMAL MODE | |
# space as leader | |
map global normal <space> , -docstring 'leader' | |
map global normal , <space> | |
map global normal & ':align-with-spaces<ret>' | |
## USER MODE (leader) | |
# modes | |
map global user -docstring 'Buffer management' b ': enter-user-mode file<ret>' | |
map global user -docstring 'Clipboard' y ': enter-user-mode clip<ret>' | |
map global user -docstring 'surround selections' s ': surround<ret>' | |
map global user -docstring 'Comment lines' c ': comment-line<ret>' | |
## CLIP MODE (y) | |
map global clip -docstring 'yank to system clipboard' y '<a-|>xclip -sel clip<ret>' | |
map global clip -docstring 'paste (after) from clipboard' p '<a-!>xclip -o -sel clip<ret>' | |
map global clip -docstring 'paste (before) from clipboard' P '!xclip -o -sel clip<ret>' | |
## FILE MODE (b) | |
map global file -docstring 'change buffer throug rofi' b ': buffer-list<ret>' | |
map global file -docstring 'open a file chooser in rofi' f ': choose-file<ret>' | |
## INSERT MODE | |
# use tab with completions | |
hook global InsertCompletionShow .* %{ | |
try %{ | |
# this command temporarily removes cursors preceded by whitespace; | |
# if there are no cursors left, it raises an error, does not | |
# continue to execute the mapping commands, and the error is eaten | |
# by the `try` command so no warning appears. | |
exec -draft 'h<a-K>\h<ret>' | |
map window insert <tab> <c-n> | |
map window insert <s-tab> <c-p> | |
} | |
} | |
hook global InsertCompletionHide .* %{ | |
unmap window insert <tab> <c-n> | |
unmap window insert <s-tab> <c-p> | |
} | |
### PLUGINS ### | |
source "%val{config}/plugins/plug.kak/rc/plug.kak" | |
plug 'jjk96/kakoune-rainbow' | |
plug 'whereswaldon/shellcheck.kak' | |
plug 'delapouite/kakoune-palette' | |
## LSP | |
eval %sh{kak-lsp --kakoune -s $kak_session} | |
set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log" | |
hook global WinSetOption filetype=(csharp|gd) %{ | |
lsp-enable-window | |
map window normal <C-l> ': enter-user-mode lsp<ret>' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment