diff --git a/dot.config/kak/autoload/autoload b/dot.config/kak/autoload/autoload new file mode 120000 index 0000000..a2d48ab --- /dev/null +++ b/dot.config/kak/autoload/autoload @@ -0,0 +1 @@ +/home/nk/.local/share/kak/autoload/ \ No newline at end of file diff --git a/dot.config/kak/autoload/ecmascript.kak b/dot.config/kak/autoload/ecmascript.kak new file mode 100644 index 0000000..7b4c752 --- /dev/null +++ b/dot.config/kak/autoload/ecmascript.kak @@ -0,0 +1,83 @@ +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](js) %{ + set buffer filetype javascript +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter -group / regions -default code javascript \ + double_string '"' (? 0:keyword + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden javascript-filter-around-selections %{ + # remove trailing white spaces + try %{ exec -draft -itersel s \h+$ d } +} + +def -hidden javascript-indent-on-char %< + eval -draft -itersel %< + # align closer token to its opener when alone on a line + try %/ exec -draft ^\h+[]}]$ m s \`|.\' 1 / + > +> + +def -hidden javascript-indent-on-new-line %< + eval -draft -itersel %< + # copy // comments prefix and following white spaces + try %{ exec -draft k s ^\h*\K#\h* y gh j P } + # preserve previous line indent + try %{ exec -draft \; K } + # filter previous line + try %{ exec -draft k : javascript-filter-around-selections } + # indent after lines beginning / ending with opener token + try %_ exec -draft k ^\h*[[{]|[[{]$ j _ + > +> + +# 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' +#} diff --git a/dot.config/kak/autoload/livedown.kak b/dot.config/kak/autoload/livedown.kak new file mode 100644 index 0000000..c9ac60a --- /dev/null +++ b/dot.config/kak/autoload/livedown.kak @@ -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 :new' +#map global normal ctrl-n ':new' + +#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 +} diff --git a/dot.config/kak/autoload/todotxt.kak b/dot.config/kak/autoload/todotxt.kak new file mode 120000 index 0000000..e3d73c6 --- /dev/null +++ b/dot.config/kak/autoload/todotxt.kak @@ -0,0 +1 @@ +/home/nk/src/koehr/kakoune-todo.txt/todotxt.kak \ No newline at end of file diff --git a/dot.config/kak/kakrc b/dot.config/kak/kakrc index 9ee2114..35fdcf5 100644 --- a/dot.config/kak/kakrc +++ b/dot.config/kak/kakrc @@ -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 +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' -# 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 +map global insert ' ' + +# 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 ':new' -#map global normal ctrl-n ':new' +addhl -group / group trailing_white_spaces +addhl -group /trailing_white_spaces regex \h+$ 0:Error -#def fedit -params 1 -shell-candidates %{ git ls-files } %{ edit %arg{1} } -#alias global fe fedit +hook global InsertBegin .* %{ + rmhl trailing_white_spaces + # echo -color Information '— INSERT —' +} -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 +hook global InsertEnd .* %{ + addhl ref trailing_white_spaces + lint +} + +# ← system clipboard +map global user y 'xsel --input --clipboard; :echo -color Information "copied selection to X11 clipboard"' -docstring 'yank from clipboard' +map global user p 'xsel --output --clipboard' -docstring 'replace from clipboard' +map global user P '!xsel --output --clipboard' -docstring 'print from clipboard' + +# → system clipboard +hook global NormalKey y|d|c %{ nop %sh{ + printf %s "$kak_reg_dquote" | xsel --input --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 -}} - -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} }