updated kakoune config

wayland
koehr 7 years ago
parent 1b67ff54e4
commit 5c19406b9a

@ -0,0 +1 @@
/home/nk/.local/share/kak/autoload/

@ -0,0 +1,83 @@
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](js) %{
set buffer filetype javascript
}
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter -group / regions -default code javascript \
double_string '"' (?<!\\)(\\\\)*" '' \
single_string "'" (?<!\\)(\\\\)*' '' \
literal "`" (?<!\\)(\\\\)*` '' \
comment // '$' '' \
comment /\* \*/ ''
add-highlighter -group /javascript/double_string fill string
add-highlighter -group /javascript/single_string fill string
add-highlighter -group /javascript/comment fill comment
add-highlighter -group /javascript/literal fill string
add-highlighter -group /javascript/literal regex \${.*?} 0:value
add-highlighter -group /javascript/code regex \b(Infinity|NaN|false|null|this|true|undefined)\b 0:value
add-highlighter -group /javascript/code regex "-?[0-9]*\.?[0-9]+" 0:value
add-highlighter -group /javascript/code regex \b(Array|Boolean|Date|Function|JSON|Map|Math|Number|Object|Promise|Proxy|Reflect|RegExp|Set|String|Symbol|WeakMap|WeakSet)\b 0:type
add-highlighter -group /javascript/code regex \b(Error|EvalError|InternalError|RangeError|ReferenceError|SyntaxError|TypeError|URIError)\b 0:type
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
add-highlighter -group /javascript/code regex \b(async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|from|for|function|if|import|in|instanceof|let|new|of|return|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword
add-highlighter -group /javascript/code regex => 0:keyword
# Commands
# ‾‾‾‾‾‾‾‾
def -hidden javascript-filter-around-selections %{
# remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d }
}
def -hidden javascript-indent-on-char %<
eval -draft -itersel %<
# align closer token to its opener when alone on a line
try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \`|.\' <ret> 1<a-&> /
>
>
def -hidden javascript-indent-on-new-line %<
eval -draft -itersel %<
# copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft \; K <a-&> }
# filter previous line
try %{ exec -draft k : javascript-filter-around-selections <ret> }
# indent after lines beginning / ending with opener token
try %_ exec -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
>
>
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group javascript-highlight global WinSetOption filetype=javascript %{ add-highlighter ref javascript }
hook global WinSetOption filetype=javascript %{
hook window InsertEnd .* -group javascript-hooks javascript-filter-around-selections
hook window InsertChar .* -group javascript-indent javascript-indent-on-char
hook window InsertChar \n -group javascript-indent javascript-indent-on-new-line
}
hook -group javascript-highlight global WinSetOption filetype=(?!javascript).* %{ remove-highlighter javascript }
hook global WinSetOption filetype=(?!javascript).* %{
remove-hooks window javascript-indent
remove-hooks window javascript-hooks
}
# suggested hook
#hook global WinSetOption filetype=javascript %{
#set window formatcmd 'prettier --stdin --semi false --single-quote --jsx-bracket-same-line --trailing-comma all'
#}

@ -0,0 +1,11 @@
decl int livedown_port 8642
def livedown-start %{ %sh{
(
livedown start --open --port "$kak_opt_livedown_port" "$kak_buffile"
) >/dev/null 2>&1 </dev/null &
}}
def livedown-stop %{ %sh{
livedown stop --port "$kak_opt_livedown_port"
}}

@ -0,0 +1,68 @@
face Whitespace rgb:555555+b
# hooks to show line numbers, whitespaces and matching brackets
hook -group DefaultHighlights global WinCreate .* %{
addhl number_lines -hlcursor -separator ' '
addhl show_whitespaces
addhl show_matching
addhl regex '\h+$' 0:default,red # show all trailing whispaces red
addhl dynregex '%reg{/}' 0:+u 1:+b
}
hook -group MarkdownHighlights global WinCreate .*[.](md) %{
addhl wrap -word -width 80
}
# map tmux split and window commands in vim style
def -file-completion -params 1 tabe %{ tmux-new-window edit %arg{1} }
def -file-completion -params 1 vsplit %{ tmux-new-vertical edit %arg{1} }
#map global insert ctrl-n '<esc>:new<ret>'
#map global normal ctrl-n ':new<ret>'
#def fedit -params 1 -shell-candidates %{ git ls-files } %{ edit %arg{1} }
#alias global fe fedit
def -docstring 'invoke fzf to open a file' \
fzf-file %{ %sh{
if [ -z "$TMUX" ]; then
echo echo only works inside tmux
else
FILE=`fzf-tmux -d 15`
if [ -n "$FILE" ]; then
echo "eval -client '$kak_client' 'edit ${FILE}'" | kak -p ${kak_session}
fi
fi
}}
def -docstring 'invoke fzf to select a buffer' \
fzf-buffer %{ %sh{
if [ -z "$TMUX" ]; then
echo echo only works inside tmux
else
BUFFER=`echo ${kak_buflist} | tr : '\n' | fzf-tmux -d 15`
if [ -n "$BUFFER" ]; then
echo "eval -client '$kak_client' 'buffer ${BUFFER}'" | kak -p ${kak_session}
fi
fi
}}
alias global ffe fzf-file
alias global ffb fzf-buffer
set global tabstop 2
set global indentwidth 2
hook global WinSetOption filetype=(javascript|ecmascript) %{
set window formatcmd 'prettier-standard'
#hook window BufWritePre .* format
}
hook global WinSetOption filetype=rust %{
racer-enable-autocomplete
set window formatcmd 'rustfmt'
hook window BufWritePre .* format
set buffer tabstop 4
set buffer indentwidth 4
}
hook global WinSetOption filetype=json %{
set window formatcmd 'jq .'
hook window BufWritePre .* format
}

@ -0,0 +1 @@
/home/nk/src/koehr/kakoune-todo.txt/todotxt.kak

@ -1,51 +1,43 @@
colorscheme zenburn
colorscheme desertex
set global scrolloff 5,5
set global tabstop 2
set global indentwidth 2
set global incsearch true
set global aligntab true
set global ui_options ncurses_assistant=cat
# hooks to show line numbers, whitespaces and matching brackets
hook -group DefaultHighlights global WinCreate .* %{
addhl number_lines -hlcursor -separator ' '
addhl show_whitespaces
addhl show_matching
addhl regex '\h+$' 0:default,red # show all trailing whispaces red
set global ui_options ncurses_assistant=none:ncurses_change_colors=true
# set global autoinfo normal|command|onkey ## always show info box for every command key
set global grepcmd 'rg --column'
map global insert <tab> ' '
# with inspiration from
# https://github.com/Delapouite/dotfiles/blob/master/link/kak/kakrc
set global modelinefmt %{
%val{bufname} [%opt{filetype}]
· %val{cursor_line}:%val{cursor_char_column}
· {{context_info}} {{mode_info}}
}
# map tmux split and window commands in vim style
def -file-completion -params 1 tabe %{ tmux-new-window edit %arg{1} }
def -file-completion -params 1 vsplit %{ tmux-new-vertical edit %arg{1} }
#map global insert ctrl-n '<esc>:new<ret>'
#map global normal ctrl-n ':new<ret>'
#def fedit -params 1 -shell-candidates %{ git ls-files } %{ edit %arg{1} }
#alias global fe fedit
def -docstring 'invoke fzf to open a file' \
fzf-file %{ %sh{
if [ -z "$TMUX" ]; then
echo echo only works inside tmux
else
FILE=`fzf-tmux -d 15`
if [ -n "$FILE" ]; then
echo "eval -client '$kak_client' 'edit ${FILE}'" | kak -p ${kak_session}
fi
fi
}}
addhl -group / group trailing_white_spaces
addhl -group /trailing_white_spaces regex \h+$ 0:Error
hook global InsertBegin .* %{
rmhl trailing_white_spaces
# echo -color Information '— INSERT —'
}
hook global InsertEnd .* %{
addhl ref trailing_white_spaces
lint
}
# ← system clipboard
map global user y '<a-|>xsel --input --clipboard<ret>; :echo -color Information "copied selection to X11 clipboard"<ret>' -docstring 'yank from clipboard'
map global user p '<a-!>xsel --output --clipboard<ret>' -docstring 'replace from clipboard'
map global user P '!xsel --output --clipboard<ret>' -docstring 'print from clipboard'
def -docstring 'invoke fzf to select a buffer' \
fzf-buffer %{ %sh{
if [ -z "$TMUX" ]; then
echo echo only works inside tmux
else
BUFFER=`echo ${kak_buflist} | tr : '\n' | fzf-tmux -d 15`
if [ -n "$BUFFER" ]; then
echo "eval -client '$kak_client' 'buffer ${BUFFER}'" | kak -p ${kak_session}
fi
fi
# → system clipboard
hook global NormalKey y|d|c %{ nop %sh{
printf %s "$kak_reg_dquote" | xsel --input --clipboard
}}
alias global ffe fzf-file
alias global ffb fzf-buffer
def -docstring 'ripgrep in current dir' \
find -params 1 -shell-candidates %{ rg --files } %{ edit %arg{1} }

Loading…
Cancel
Save