From b6e7857f274530dbb92a6692be25a73cfb467cc0 Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Mon, 18 Dec 2023 09:44:46 +0100 Subject: [PATCH] initial commit (plugins still missing) --- colors/base16.kak | 76 +++++++++++++++++ colors/dabruin.kak | 1 + kakrc | 202 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 colors/base16.kak create mode 120000 colors/dabruin.kak create mode 100644 kakrc diff --git a/colors/base16.kak b/colors/base16.kak new file mode 100644 index 0000000..0ae479e --- /dev/null +++ b/colors/base16.kak @@ -0,0 +1,76 @@ +## +## base16.kak by lenormf +## + +evaluate-commands %sh{ + black_lighterer='rgb:383838' + black_lighter='rgb:2D2D2D' + black_light='rgb:1C1C1C' + cyan_light='rgb:7CB0FF' + green_dark='rgb:A1B56C' + grey_dark='rgb:585858' + grey_medium='rgb:989898' + grey_light='rgb:D8D8D8' + magenta_dark='rgb:AB4642' + magenta_light='rgb:AB4434' + orange_dark='rgb:DC9656' + orange_light='rgb:F7CA88' + purple_dark='rgb:BA8BAF' + + ## code + echo " + face global value ${orange_dark}+b + face global type ${orange_light} + face global variable ${magenta_dark} + face global module ${green_dark} + face global function ${cyan_light} + face global string ${green_dark} + face global keyword ${purple_dark}+b + face global operator ${cyan_light} + face global attribute ${orange_dark} + face global comment ${grey_medium} + face global documentation comment + face global meta ${orange_light} + face global builtin default+b + " + + ## markup + echo " + face global title blue + face global header ${cyan_light} + face global mono ${green_dark} + face global block ${orange_dark} + face global link blue + face global bullet ${magenta_light} + face global list ${magenta_dark} + " + + ## builtin + echo " + face global Default ${grey_light},${black_light} + face global PrimarySelection white,blue+fg + face global SecondarySelection black,blue+fg + face global PrimaryCursor black,white+fg + face global SecondaryCursor black,white+fg + face global PrimaryCursorEol black,${cyan_light}+fg + face global SecondaryCursorEol black,${cyan_light}+fg + face global LineNumbers ${grey_light},${black_lighter} + face global LineNumberCursor ${grey_light},rgb:282828+b + face global MenuForeground ${grey_light},blue + face global MenuBackground blue,${grey_light} + face global MenuInfo ${cyan_light} + face global Information ${black_light},${cyan_light} + face global Error ${grey_light},${magenta_light} + face global DiagnosticError ${magenta_light} + face global DiagnosticWarning ${cyan_light} + face global StatusLine ${grey_light},${black_lighterer} + face global StatusLineMode ${orange_dark} + face global StatusLineInfo ${cyan_light} + face global StatusLineValue ${green_dark} + face global StatusCursor ${black_lighterer},${cyan_light} + face global Prompt ${black_light},${cyan_light} + face global MatchingChar ${cyan_light},${black_light}+b + face global BufferPadding ${cyan_light},${black_lighter} + face global Whitespace ${grey_dark}+f + " +} diff --git a/colors/dabruin.kak b/colors/dabruin.kak new file mode 120000 index 0000000..da4a46b --- /dev/null +++ b/colors/dabruin.kak @@ -0,0 +1 @@ +../plugins/dabruin.kak/dabruin.kak \ No newline at end of file diff --git a/kakrc b/kakrc new file mode 100644 index 0000000..faeb9fd --- /dev/null +++ b/kakrc @@ -0,0 +1,202 @@ +# Clipboard (wayland) integration +hook global NormalKey y %{ nop %sh{ + printf %s "$kak_main_reg_dquote" | wl-copy > /dev/null 2>&1 & +}} + + +# Enable PLUGin manager +# ───────────────────── +source "%val{config}/plugins/plug.kak/rc/plug.kak" +plug "andreyorst/plug.kak" noload + plug "Ersikan/bookmarks.kak" %{ + hook global WinCreate .* bookmarks-enable + } + plug "andreyorst/smarttab.kak" defer smarttab %{ + # when 'backspace' is pressed, 4 spaces are deleted at once + set-option global softtabstop 4 + } config %{ + hook global WinSetOption filetype=(rust|markdown|kak|lisp|scheme|py|sh|perl) expandtab + hook global WinSetOption filetype=(makefile|gas) noexpandtab + hook global WinSetOption filetype=(c|cpp) smarttab + } + plug "whereswaldon/shellcheck.kak" + plug "kakounedotcom/prelude.kak" + plug "occivink/kakoune-find" + plug "https://git.sr.ht/~nasmevka/dabruin.kak" + plug "https://github.com/enricozb/tabs.kak" + +# Look and Feel +# ───────────── +set-option global tabs_modelinefmt '%val{cursor_line}:%val{cursor_char_column} {{mode_info}} ' +set-option global tabs_options --minified + +add-highlighter global/trailing-whitespace regex '\h+$' 0:Error # trailing whitespaces in red +add-highlighter global/todos regex '(//|#|/\*)\h*(TODO|WARNING|FIXME)[:]?[^\n]*' 2:+bu # highlight comment tags +add-highlighter global/ show-matching # show matching brackets +add-highlighter global/ number-lines -min-digits 3 # absolute line nums everywhere +colorscheme dabruin +set-option global tabstop 4 +set-option global indentwidth 4 + +# dynamic scrolloff +# ───────────────── +hook global WinCreate [^*].* %{ + hook -once window WinDisplay .* %{ + hook window WinResize [0-9]*\.[0-9]* %{ + set-option window scrolloff %sh{ + printf '%u,%u' "$(($kak_window_height / 6))" "$(($kak_window_width / 8))" + } + } + } +} + +# Different Cursor color in insert mode +# ───────────────────────────────────── +# Shades of blue/cyan for normal mode +set-face global PrimarySelection white,blue+F +set-face global SecondarySelection black,blue+F +set-face global PrimaryCursor black,bright-cyan+F +set-face global SecondaryCursor black,bright-blue+F +set-face global PrimaryCursorEol black,bright-cyan +set-face global SecondaryCursorEol black,bright-blue + +# Shades of green/yellow for insert mode. +hook global ModeChange (push|pop):.*:insert %{ + set-face window PrimarySelection white,green+F + set-face window SecondarySelection black,green+F + set-face window PrimaryCursor black,bright-yellow+F + set-face window SecondaryCursor black,bright-green+F + set-face window PrimaryCursorEol black,bright-yellow + set-face window SecondaryCursorEol black,bright-green +} + +# Undo colour changes when we leave insert mode. +hook global ModeChange (push|pop):insert:.* %{ + unset-face window PrimarySelection + unset-face window SecondarySelection + unset-face window PrimaryCursor + unset-face window SecondaryCursor + unset-face window PrimaryCursorEol + unset-face window SecondaryCursorEol +} + +# Enable editor config +# ──────────────────── +hook global WinCreate ^[^*]+$ %{ editorconfig-load } + +# Extra editor commands +# ───────────────────── +# tab replacement +define-command clean-selections -docstring 'Replace tabs with spaces and trim trailing whitespace' %{ try %{ + execute-keys -draft @s\h+$d +} } +define-command clean-buffer -docstring 'Replace tabs with spaces and trim trailing whitespace' %{ try %{ + execute-keys -draft \%@s\h+$d +} } +# Bring back and from Vim to increment/decrement the number under the cursor +define-command -hidden -params 2 inc %{ try %{ + evaluate-commands %sh{ + [ "$1" = 0 ] && count=1 || count="$1" + printf '%s%s' 'exec h"_/\dna' "$2($count)|{catecho}|bc" + } +} catch %{ + execute-keys l +}} + + +# Various mappings +# ──────────────── +map global normal '#' :comment-line -docstring 'comment line' +map global normal '' :comment-block -docstring 'comment block' +map global goto m 'm;' -docstring 'matching char' +map -docstring 'select lines downwards' global normal X TLx +# see #inc +map global normal ': inc %val{count} +' +map global normal ': inc %val{count} -' +map global normal Q q # map q to Q +map global normal q -docstring 'tabs mode' ': enter-user-mode tabs' # map q to tabs mode + +# default user mode +# # ────────── +map global user -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert' +map global user -docstring 'disable autocomplete' A ': set-option -remove buffer autocomplete insert' +map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc' +map global user -docstring 'clean tabs and trailing whitespace in selections' c ': clean-selections' +map global user -docstring 'clean tabs and trailing whitespace in the buffer' C ': clean-buffer' +map global user -docstring 'buffer backward' b ': buffer-previous' +map global user -docstring 'buffer forward' n ': buffer-next' +map global user -docstring 'lint-buffer' L ': buffer *lint-output*' +map global user -docstring 'relative line numbers enable' r ': add-highlighter window/nl number-lines -relative -hlcursor' +map global user -docstring 'relative line numbers disable' R ': remove-highlighter window/nl' +map global user -docstring 'wrap enable' w ': add-highlighter buffer/bw wrap' +map global user -docstring 'wrap disable' W ': remove-highlighter buffer/bw' + +# tabs user mode +# # ────────── +map global normal -docstring 'kks mode' ': enter-user-mode kks' + + +# suspend and resume +# # ────────── +def suspend-and-resume \ + -params 1..2 \ + -docstring 'suspend-and-resume []: backgrounds current kakoune client and runs specified cli command. Upon exit of command the optional kak command is executed.' \ + %{ evaluate-commands %sh{ + + # Note we are adding '&& fg' which resumes the kakoune client process after the cli command exits + cli_cmd="$1 && fg" + post_resume_cmd="$2" + + # automation is different platform to platform + platform=$(uname -s) + case $platform in + Darwin) + automate_cmd="sleep 0.01; osascript -e 'tell application \"System Events\" to keystroke \"$cli_cmd\" & return '" + kill_cmd="/bin/kill" + break + ;; + Linux) + automate_cmd="sleep 0.2; xdotool type '$cli_cmd'; xdotool key Return" + kill_cmd="/usr/bin/kill" + break + ;; + esac + + # Uses platforms automation to schedule the typing of our cli command + nohup sh -c "$automate_cmd" > /dev/null 2>&1 & + # Send kakoune client to the background + $kill_cmd -SIGTSTP $kak_client_pid + + # ...At this point the kakoune client is paused until the " && fg " gets run in the $automate_cmd + + # Upon resume, run the kak command is specified + if [ ! -z "$post_resume_cmd" ]; then + echo "$post_resume_cmd" + fi +}} + +def for-each-line \ + -docstring "for-each-line : run command with the value of each line in the file" \ + -params 2 \ + %{ evaluate-commands %sh{ + + while read f; do + printf "$1 $f\n" + done < "$2" +}} + +def toggle-ranger %{ + suspend-and-resume \ + "ranger --choosefiles=/tmp/ranger-files-%val{client_pid}" \ + "for-each-line edit /tmp/ranger-files-%val{client_pid}" +} + +map global user f ': toggle-ranger' -docstring 'select files in ranger' + + +# run on file open +# ───────────── +hook global BufOpenFile .* %{ + modeline-parse +} + -- 2.51.2