From 0ddb094cf38a671ef7a8d4ed65a89efd8bdafde0 Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Sun, 4 May 2025 14:39:51 +0200 Subject: [PATCH] initial commit --- .gitignore | 472 ++++++++++++++++++++++++++++++++++++++ .gitmodules | 3 + README | 8 + bundle/plugins/kak-bundle | 1 + description | 1 + kakrc | 419 +++++++++++++++++++++++++++++++++ languagecmd.kak | 77 +++++++ reload-kakrc.kak | 28 +++ starship.toml | 202 ++++++++++++++++ 9 files changed, 1211 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README create mode 160000 bundle/plugins/kak-bundle create mode 100644 description create mode 100644 kakrc create mode 100644 languagecmd.kak create mode 100644 reload-kakrc.kak create mode 100644 starship.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..931d0ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,472 @@ +*.log +*.bak +*.gho +*.ori +*.orig +*.tmp +secring.* +*.kdbx +*.key +*.keyx + +**/previews/* + +OpenRGB.json + +# qutebrowser private data +autoconfig.yml +urls +quickmarks +QtProject.conf + +# linux stuff +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# vim stuff +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# It's better to unpack these files and commit the raw source because +# git has its own built in compression methods. +*.7z +*.jar +*.rar +*.zip +*.gz +*.gzip +*.tgz +*.bzip +*.bzip2 +*.bz2 +*.xz +*.lzma +*.cab +*.xar + +# Swap Files # +.*.kate-swp +.swp.* + +# Packing-only formats +*.iso +*.tar + +# Package management formats +*.dmg +*.xpi +*.gem +*.egg +*.deb +*.rpm +*.msi +*.msm +*.msp +*.txz + +# patches and diffs +*.patch +*.diff + +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +.build/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.so.* +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* +*.qm +*.prl + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +# QtCreator 4.8< compilation database +compile_commands.json + +# QtCreator local machine specific files for imported projects +*creator.user* + +*_qmlcache.qrc + +!Build/ +.last_cover_stats +/META.yml +/META.json +/MYMETA.* +*.o +*.pm.tdy +*.bs + +# Devel::Cover +cover_db/ + +# Devel::NYTProf +nytprof.out + +# Dist::Zilla +/.build/ + +# Module::Build +_build/ +Build +Build.bat + +# Module::Install +inc/ + +# ExtUtils::MakeMaker +/blib/ +/_eumm/ +/*.gz +/Makefile +/Makefile.old +/MANIFEST.bak +/pm_to_blib +/*.zip + +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +!**/.gitkeep + +# exclude all files from bundle dir but keep its subdirs: +# ref: https://stackoverflow.com/questions/46301811/gitignore-all-files-in-folders-but-keep-folder-structure +bundle/** +!bundle/plugins/kak-bundle #no-trailing-slash !!! +colors/** +plugins/** +.reload.kak + +# base16 generated files +dabruin-wrapper.kak diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8535b4d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "bundle/plugins/kak-bundle"] + path = bundle/plugins/kak-bundle + url = https://codeberg.org/jdugan6240/kak-bundle diff --git a/README b/README new file mode 100644 index 0000000..a7e4517 --- /dev/null +++ b/README @@ -0,0 +1,8 @@ +# Freerunner's Kakoune config + +Usage: +1) clone this repo +2) (re-)add kak-bundle as submodule + ```git submodule add https://codeberg.org/jdugan6240/kak-bundle bundle/plugins/kak-bundle``` +3) launch kakoune and run :bundle-install[enter] + diff --git a/bundle/plugins/kak-bundle b/bundle/plugins/kak-bundle new file mode 160000 index 0000000..6fb2fcc --- /dev/null +++ b/bundle/plugins/kak-bundle @@ -0,0 +1 @@ +Subproject commit 6fb2fccfec714abdf4f0a6288ad1ac6e42913ded diff --git a/description b/description new file mode 100644 index 0000000..3f1ef7d --- /dev/null +++ b/description @@ -0,0 +1 @@ +Personal config for Kakoune diff --git a/kakrc b/kakrc new file mode 100644 index 0000000..5a4046f --- /dev/null +++ b/kakrc @@ -0,0 +1,419 @@ +# begin +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# set global ui_options terminal_set_title=true +# this is shit as hell and needs pull request #4265 +# its usage is only documented in #3829 +hook global WinCreate .* %{ + set-option window ui_options "terminal_set_title=%val{bufname} - Kakoune" + # hacky debug window + #set-option window ui_options "terminal_set_title=%val{config} - Kakoune" +} + +def import -override -params 1 %{ + source %sh{echo ${kak_config}/$1.kak} +} + +# Clipboard (wayland) integration +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +hook global NormalKey y %{ nop %sh{ + printf %s "$kak_main_reg_dquote" | wl-copy > /dev/null 2>&1 & +}} + + +# run on file open +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +hook global BufCreate [^*].* %{ + nop %sh{ + mru=~/.cache/kak-mru + echo "$kak_buffile" | awk '!seen[$0]++' - "$mru" | sponge "$mru" + } +} + +hook global WinCreate ^[^*]+$ %{ + editorconfig-load # needs editorconfig-core-c with use-flag "+cli" on Gentoo +} + +hook global BufOpenFile .* %{ + modeline-parse +} + +# 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 / 7))" "$(($kak_window_width / 28))" + } + } + } +} + +# session manager integration (kkga/kks) +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# evaluate-commands %sh{ kks init } +# define-command -override kks-connect -params 1.. -command-completion %{ +# %arg{1} sh -c %{ +# export EDITOR='kks edit' +# export KKS_SESSION=$1 +# export KKS_CLIENT=$2 +# shift 3 + +# [ $# = 0 ] && set "$SHELL" + +# "$@" +# } -- %val{session} %val{client} %arg{@} +# } + +# Enable PLUGin manager +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# after first sync of the dotfiles, bundle needs to be installed manually, +# in order to sync all other plugins with git" + +source "%val{config}/bundle/plugins/kak-bundle/rc/kak-bundle.kak" +bundle kak-bundle https://codeberg.org/jdugan6240/kak-bundle +bundle kakoune-sudo-write https://github.com/occivink/kakoune-sudo-write +bundle kakoune-find https://github.com/occivink/kakoune-find +bundle kakoune-expand https://github.com/occivink/kakoune-expand +bundle foot.kak https://github.com/kkga/foot.kak +bundle kakoune-surround https://github.com/h-youhei/kakoune-surround +bundle kakship https://github.com/eburghar/kakship %{ + kakship-enable +} + bundle-install-hook kakship %{ + cargo install --force --path . --root ~/.local + [ ! -e $kak_config/starship.toml ] && cp starship.toml $kak_config/ + } +bundle-noload dabruin.kak https://git.sr.ht/~nasmevka/dabruin.kak + bundle-install-hook dabruin.kak %{ + mkdir -p ${kak_config}/colors + ln -sf "${kak_opt_bundle_path}/dabruin.kak" "${kak_config}/colors/" + ln -sf "${kak_opt_bundle_path}/dabruin-light.kak" "${kak_config}/colors/" + } + bundle-cleaner dabruin.kak %{ + rm -f "${kak_config}/colors/dabruin.kak" + rm -f "${kak_config}/colors/dabruin-light.kak" + } +bundle kakoune-table https://gitlab.com/listentolist/kakoune-table +bundle kakoune-lsp https://github.com/kakoune-lsp/kakoune-lsp %{ + bundle-install-hook kakoune-lsp %{ + cargo build --release --locked + cargo install --locked --force --path . + } + set global lsp_diagnostic_line_error_sign '║' + set global lsp_diagnostic_line_warning_sign '┊' + define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings } + define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings } + define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings } + # define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start } + # hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript) %{ + # 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 + # } + # hook global WinSetOption filetype=(rust) %{ + # set window lsp_server_configuration rust.clippy_preference="on" + # } + # hook global WinSetOption filetype=rust %{ + # hook window BufWritePre .* %{ + # evaluate-commands %sh{ + # test -f rustfmt.toml && printf lsp-formatting-sync + # } + # } + # } + evaluate-commands %sh{ kak-lsp } + lsp-enable + hook global KakEnd .* lsp-exit +} + +# Enable some linting and formatting +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +source %sh{ + echo ${kak_config}/languagecmd.kak # borrowed from https://git.sr.ht/~nasmevka +} + +# Enable some code formaters +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +hook global BufSetOption filetype=(js|javascript) %{ + set-option buffer formatcmd "prettier --stdin-filepath=%val{buffile}" +} +hook global WinSetOption filetype=scss %{ + set-option buffer formatcmd 'npx prettier --parser scss --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=less %{ + set-option buffer formatcmd 'npx prettier --parser less --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=html %{ + set-option buffer formatcmd 'npx prettier --parser html --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=md %{ + set-option buffer formatcmd 'npx prettier --parser md --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=sh %{ + # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest + set-option buffer formatcmd "shfmt -i 4 -ci -sr -" +} +hook global WinSetOption filetype=yaml %{ + set-option buffer formatcmd "npx prettier --parser yaml --stdin-filepath=%val{buffile}" +} +hook global WinSetOption filetype=(json|jsonc) %{ + set-option buffer formatcmd "jq --indent %opt{tabstop} ." +} + +# Enable some code linters +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +hook global WinSetOption filetype=(c|h) %{ + set-option window lintcmd "cppcheck --language=c --enable=warning,style,information --template='{file}:{line}:{column}: {severity}: {message}' --suppress='*:*.h' 2>&1" +} +hook global WinSetOption filetype=css %{ + set-option window lintcmd "npx stylelint --formatter unix --stdin-filename='%val{buffile}'" +} +hook global WinSetOption filetype=(json|jsonc) %{ + set-option window lintcmd %{ run() { cat -- "$1" | jq 2>&1 | awk -v filename="$1" '/ at line [0-9]+, column [0-9]+$/ { line=$(NF - 2); column=$NF; sub(/ at line [0-9]+, column [0-9]+$/, ""); printf "%s:%d:%d: error: %s", filename, line, column, $0; }'; } && run } +} +hook global WinSetOption filetype=sh %{ + # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest + set-option window lintcmd "shellcheck -fgcc -Cnever" +} +hook global WinSetOption filetype=yaml %{ + set-option window lintcmd %{ + run() { + # change [message-type] to message-type: + yamllint -f parsable "$1" | sed 's/ \[\(.*\)\] / \1: /' + } && run } +} + + +# Look and Feel +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# dabruin colorscheme config in separate file +source "%val{config}/dabruin-wrapper.kak" +# with the following values: +# declare-option str dabruin_background 'rgb:181818' +# declare-option str dabruin_accent 'rgb:86c1b9' +# colorscheme dabruin + +set-face global StatusLine cyan,default,default +set-face global StatusLineInfo blue,default,default +set-face global StatusLineMode black,yellow,default +set-face global StatusLineValue green,default,default + + +# wrapping only word-wise +add-highlighter global/ wrap -word -indent + +# trailing whitespaces in red +add-highlighter global/trailing-whitespace regex '\h+$' 0:Error + +# highlight comment tags +add-highlighter global/todos regex '(//|#|/\*)\h*(TODO|WARNING|FIXME|MAYBE)[:]?[^\n]*' 1:default+bu@comment + +# show matching brackets +add-highlighter global/ show-matching + +# absolute line nums everywhere +add-highlighter global/ number-lines -hlcursor -min-digits 3 + + +# Different Cursor color in insert mode +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# Recolor the status line on insert mode. +hook global ModeChange (push|pop):.*:insert %{ + set-face window StatusLine black,yellow + set-face window StatusLineInfo blue,black + set-face window StatusLineMode black,yellow +} + +# Undo colour changes when we leave insert mode. +hook global ModeChange (push|pop):insert:.* %{ + # unset-face window StatusLine + set-face window StatusLine yellow,black + set-face window StatusLineInfo blue,default + set-face window StatusLineMode black,yellow +} + + +# Extra editor commands +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# tab replacement +define-command -hidden clean-selections -docstring 'Replace tabs with spaces and trim trailing whitespace' %{ try %{ + execute-keys -draft @s\h+$d +} } +define-command -hidden clean-buffer -docstring 'Replace tabs with spaces and trim trailing whitespace' %{ try %{ + execute-keys -draft \%@s\h+$d +} } + +# Bring back inc command to increment/decrement the number under the cursor +define-command -hidden -params 2 inc %{ try %{ + evaluate-commands %sh{ + [ "$1" = 0 ] && count=1 || count="$3" + printf '%s%s' 'exec h"_/\dna' "$2($count)|{catecho}|bc" + } +} catch %{ + execute-keys l +}} + +# preview hex color codes with a leading # +declare-option -hidden range-specs hex_color_code_ranges +add-highlighter shared/hex_color_code ranges hex_color_code_ranges + +define-command update_hex_color_code_ranges %{ + set-option window hex_color_code_ranges %val{timestamp} + evaluate-commands -draft %{ + execute-keys 'gtGbx' + evaluate-commands -draft -verbatim try %{ + execute-keys 's\B#([0-9A-Fa-f]{6})\b' + evaluate-commands -itersel %{ + set-option -add window hex_color_code_ranges "%val{selection_desc}|default,rgb:%reg{1}" + } + } + evaluate-commands -draft -verbatim try %{ + execute-keys 's\B#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])\b' + evaluate-commands -itersel %{ + set-option -add window hex_color_code_ranges "%val{selection_desc}|default,rgb:%reg{1}%reg{1}%reg{2}%reg{2}%reg{3}%reg{3}" + } + } + } +} + +hook -always global NormalIdle '' update_hex_color_code_ranges +hook -always global InsertIdle '' update_hex_color_code_ranges +hook -always global PromptIdle '' update_hex_color_code_ranges + +# preview hex color codes without leading # +declare-option -hidden range-specs hex_color_code_ranges2 +add-highlighter shared/hex_color_code2 ranges hex_color_code_ranges2 + +define-command update_hex_color_code_ranges2 %{ + set-option window hex_color_code_ranges2 %val{timestamp} + evaluate-commands -draft %{ + execute-keys 'gtGbx' + evaluate-commands -draft -verbatim try %{ + execute-keys 's\B"([0-9A-Fa-f]{6})\b"' + execute-keys -draft 'S"' + evaluate-commands -itersel %{ + set-option -add window hex_color_code_ranges2 "%val{selection_desc}|default,rgb:%reg{1}" + } + } + } +} + +hook -always global NormalIdle '' update_hex_color_code_ranges2 +hook -always global InsertIdle '' update_hex_color_code_ranges2 +hook -always global PromptIdle '' update_hex_color_code_ranges2 + +# normal mode kks mappings +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +map global normal -docstring 'terminal' ': kks-connect terminal' +map global normal -docstring 'files' ': kks-connect popup kks-files' +map global normal -docstring 'buffers' ': kks-connect popup kks-buffers' +map global normal -docstring 'live grep' ': kks-connect popup kks-grep' +map global normal -docstring 'lines in buffer' ': kks-connect popup kks-lines' +map global normal -docstring 'recent files' ': kks-connect popup kks-mru' +map global normal -docstring 'vcs client' ': kks-connect popup lazygit' +map global normal -docstring 'file browser' ': kks-connect popup kks-lf' + +# normal mode additional mappings +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +map global normal q Q # move record to 'Q' +unmap global normal q # keep 'q' clean +map global goto m 'm;' -docstring 'matching char' +map global normal -docstring 'comment line' '#' ': comment-line' +map global normal -docstring 'comment block' ': comment-block' +map global normal -docstring 'Next buffer ' ': buffer-next' +map global normal -docstring 'Previous buffer' ': buffer-previous' +map global normal -docstring 'Delete buffer' ': delete-buffer' +map global normal -docstring 'add 1 int' '^' ': inc %val{count} +' +map global normal -docstring 'substract 1 int' ': inc %val{count} -' +map global normal -docstring 'surround' 0 ': surround' + +# default user mode +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +map global user -docstring 'buffer mode' b ': enter-user-mode buffermode' +map global user -docstring 'git mode' g ': enter-user-mode gitmode' +map global user -docstring 'selection mode' s ': enter-user-mode selmode' +map global user -docstring 'LSP mode' l ': enter-user-mode lsp' +map global user -docstring 'Table mode' t ': enter-user-mode table' +map global user -docstring 'Table mode (locked)' T ': enter-user-mode -lock table' +map global user -docstring ':::::::::::::::::::::::::::::::: ::' : ': ' +map global user -docstring 'Edit kakrc' E ': e ~/.config/kak/kakrc' +map global user -docstring 'highlight hex color without leading #' p ': addhl global/hex_color_code2 ref hex_color_code2' +map global user -docstring 'unhighlight hex color without leading #' ': rmhl global/hex_color_code2' +map global user -docstring 'highlight hex color with leading #' '#' ': addhl global/hex_color_code ref hex_color_code' +map global user -docstring 'unhighlight hex color with leading #' ': rmhl global/hex_color_code' +map global user -docstring 'Scratch buffer' S ': buffer *scratch*' +map global user -docstring 'Debug buffer' D ': buffer *debug*' +map global user -docstring 'expand selection' e ': expand' +map global user -docstring 'insert newline above current' n ' Oj' +map global user -docstring 'insert newline below current' N ' ok' +map global user -docstring 'relative line numbers enable' r ': addhl window/nl number-lines -min-digits -1 -relative -hlcursor' +map global user -docstring 'relative line numbers disable' R ': rmhl window/nl' +map global user -docstring 'help command mode enable' h ': set -add global autoinfo normal' +map global user -docstring 'help command mode disable' H ': set -remove global autoinfo normal' +map global user -docstring 'case insensitive search' '/' /(?i) +map global user -docstring 'case insensitive backward search' '' (?i) +map global user -docstring 'case insensitive extend search' '?' ?(?i) +map global user -docstring 'case insensitive backward extend-search' '' (?i) + + +# kak-lsp keys +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' +map global object a 'lsp-object' -docstring 'LSP any symbol' +map global object 'lsp-object' -docstring 'LSP any symbol' +map global object f 'lsp-object Function Method' -docstring 'LSP function or method' +map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' +map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' +map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' + +# buffer user mode +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +declare-user-mode buffermode +map global buffermode -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert' +map global buffermode -docstring 'disable Autocomplete' A ': set-option -remove buffer autocomplete insert' +map global buffermode -docstring 'clean tabs and trailing whitespaces' c ': clean-buffer' +map global buffermode -docstring 'delete buffer' d ': delete-buffer' +map global buffermode -docstring 'show file info' i ': info "file saved at %sh{date}"' +map global buffermode -docstring 'list buffers' l ': kks-connect terminal-popup kks-buffers' +map global buffermode -docstring 'Lint buffer' L ': buffer *lint-output*' +map global buffermode -docstring 'next buffer' n ': buffer-next' +map global buffermode -docstring 'previous buffer' p ': buffer-previous' +map global buffermode -docstring 'wrap enable' w ': add-highlighter buffer/bw wrap' +map global buffermode -docstring 'Wrap disable' W ': remove-highlighter buffer/bw' + +# selection user mode +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +declare-user-mode selmode +map global selmode -docstring 'clean tabs and trailing whitespaces' C ': clean-selections' +map global selmode -docstring 'sort words Horizontally in selection' h '| xargs -n1 | sort -u | xargs ' +map global selmode -docstring 'sort words Vertically in selection ' v '| sort -n ' +map global selmode -docstring 'surround' s ':surround' +map global selmode -docstring 'change surround' c ':change-surround' +map global selmode -docstring 'delete surround' d ':delete-surround' +map global selmode -docstring 'select tag' t ':select-surrounding-tag' + +# git user mode +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +declare-user-mode gitmode +map global gitmode -docstring 'Blame jump' b ':git blame-jump' +map global gitmode -docstring 'Blame annotations' B ':git blame' +map global gitmode -docstring 'Diff' d ':git diff' +map global gitmode -docstring 'Edit' e ':git edit' +map global gitmode -docstring 'Log' l ':git log --oneline' +map global gitmode -docstring 'Log (full)' L ':git log' +map global gitmode -docstring 'Next hunk' n ':git next-hunk' +map global gitmode -docstring 'Previous hunk' p ':git prev-hunk' +map global gitmode -docstring 'Status' s ':git status' + +# terminal config (via foot.kak) +# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +set-option global foot_normal_cmd 'foot' +set-option global foot_popup_cmd 'foot' +set-option global foot_panel_cmd 'foot' +set-option global foot_normal_flags '' +set-option global foot_popup_flags '--app-id=kakpopup' '--window-size-chars=240x40' +# set-option global foot_popup_flags '--app-id=kakpopup' +set-option global foot_panel_flags '--app-id=kakpanel' '--window-size-chars=240x1' + diff --git a/languagecmd.kak b/languagecmd.kak new file mode 100644 index 0000000..e582773 --- /dev/null +++ b/languagecmd.kak @@ -0,0 +1,77 @@ +## Languages +# ────────────────────────────────────────────────────────────────────────────── +# stolen from git.sr.ht/~nasmevka/kak +### golang +hook -group languagecmd global WinSetOption filetype=go %{ + set-option buffer formatcmd 'gofumpt' + set-option buffer lintcmd "golangci-lint run --out-format=line-number --uniq-by-line=true --allow-parallel-runners | grep %val{bufname} #" +} + +### python +hook -group languagecmd global WinSetOption filetype=python %{ + set-option buffer formatcmd 'black --line-length 150 -' + set-option buffer lintcmd 'ruff check --format=text --line-length=150' +} + +### shell +hook -group languagecmd global WinSetOption filetype=sh %{ + set-option buffer formatcmd 'shfmt -i 4 -ci -sr -' + set-option buffer lintcmd 'shellcheck -f gcc' + try %{ + alias buffer subprocess surround-with-proc + alias buffer variable surround-with-env + } +} + +### C +hook -group languagecmd global WinSetOption filetype=c %{ + set-option buffer formatcmd 'clang-format -' + set-option buffer lintcmd "clang-check --analyze %val{buffile} 2>&1 | sed '/^[^/]/d' #" +} + +### scheme (CHICKEN) +hook -group languagecmd global WinSetOption filetype=scheme %{ + set-option buffer formatcmd '' + set-option buffer lintcmd '' + # spaces for indent, using only two since scheme can have a lot of indentation + set-option buffer tabstop 2 + set-option buffer indentwidth 2 + + enter-spacemode + enable-replkak-bindings + # launch parinfer last since we want the tabulation->space transformation before + parinfer-enable-window -indent +} + +hook -group languagecmd global WinSetOption filetype=markdown %{ + try %{ + declare-surrounding-pair 'surround selection with italic syntax' ital * * + declare-surrounding-pair 'surround selection with bold syntax' bold ** ** + declare-surrounding-pair 'surround selection with inline code syntax' icode ` ` + declare-surrounding-pair 'surround selection with bloc code syntax' bcode ``` ``` + alias buffer italic surround-with-ital + alias buffer bold surround-with-bold + alias buffer inline surround-with-icode + alias buffer bloc surround-with-bcode + } +} + +### Javascript +hook -group languagecmd global WinSetOption filetype=javascript %{ + set-option buffer formatcmd '2>/dev/null npx standard --stdin --fix ||:' + set-option buffer lintcmd '2>/dev/null npx standard' +} + +### D +hook -group languagecmd global WinSetOption filetype=d %{ + set-option buffer formatcmd '' # no need for format + set-option buffer lintcmd 'dscanner -S -f "{filepath}:{line}:{column}: {type}: {message}"' +} + +### Hare +hook -group languagecmd global WinSetOption filetype=hare %{ + set-option buffer tabstop 8 + set-option buffer indentwidth 8 +} + + diff --git a/reload-kakrc.kak b/reload-kakrc.kak new file mode 100644 index 0000000..8bc50e6 --- /dev/null +++ b/reload-kakrc.kak @@ -0,0 +1,28 @@ +# Reload kakrc and .kak when saving. +# Adds -override to definitions (unless they seem to be python defs!) +# Evals provide module directly + +def resource -params 1 %{ + eval %sh{ + file=$(dirname "$1")/.reload.kak + cat "$1" | + sed 's/^def \([^:]*\)$/def -override \1/' | + sed 's/^define-command /def -override /' | + sed 's/^addhl /addhl -override/' | + sed 's/^add-highlighter /addhl -override /' | + sed 's/^provide-module \w\+ /eval /' | + cat > "$file" + printf %s " + source $file + nop %sh{ + rm $file + } + " + } + echo Reloaded %arg{1} +} + +rmhooks global reload-kak +hook -group reload-kak global BufWritePost (.*kakrc|.*\.kak) %{ + resource %val{hook_param} +} diff --git a/starship.toml b/starship.toml new file mode 100644 index 0000000..d6b81e1 --- /dev/null +++ b/starship.toml @@ -0,0 +1,202 @@ +add_newline = false +format = """\ +${custom.kaklsp_err}\ +${custom.kaklsp_warn}\ +${custom.kaklsp_hint}\ +${custom.kaklsp_code_actions}\ +${custom.kaklsp_progress}\ +${custom.kakmode}\ +${custom.kakcontext}\ +$git_branch\ +$git_commit\ +$git_state\ +$git_status\ +$directory\ +${custom.kakfile}\ +${custom.kakfiletype}\ +$package\ +${custom.kaksession}\ +${custom.kakbuflist}\ +${custom.kakcursor}\ +${custom.kakposition}\ +""" +# use this useless block to prevent spilling colors on insert mode +# [█](fg:black bg:black) +# powerline symbols +# ' '' '' '' '' '' '' + +[fill] +symbol = ' ' + +[custom.kaklsp_err] +description = "Show errors number from kak-lsp if any" +format = "[ %opt{lsp_diagnostic_error_count}]($style)" +style = "fg:red bold bg:default" +when = '[ -n "$kak_opt_lsp_diagnostic_error_count" -a "$kak_opt_lsp_diagnostic_error_count" -ne 0 ]' +shell = ['sh'] +disabled = false + +[custom.kaklsp_warn] +description = "Show warnings number from kak-lsp if any" +format = "[  %opt{lsp_diagnostic_warning_count}]($style)" +style = "fg:yellow bold bg:default" +when = '[ -n "$kak_opt_lsp_diagnostic_warning_count" -a "$kak_opt_lsp_diagnostic_warning_count" -ne 0 ]' +shell = ['sh'] +disabled = false + +[custom.kaklsp_hint] +description = "Show hints number from kak-lsp if any" +format = "[ ﯦ %opt{lsp_diagnostic_hint_count}]($style)" +style = "fg:white bold bg:default" +when = '[ -n "$kak_opt_lsp_diagnostic_hint_count" -a "$kak_opt_lsp_diagnostic_hint_count" -ne 0 ]' +shell = ['sh'] +disabled = false + +[custom.kaklsp_code_actions] +description = "Show lsp code actions if any" +format = "[ %opt{lsp_modeline_code_actions} ]($style)" +style = "fg:yellow bold bg:default" +when = '[ -n "$kak_opt_lsp_modeline_code_actions" ]' +shell = ['sh'] +disabled = false + +[custom.kaklsp_progress] +description = "Show activity of kak-lsp if any" +format = " [ ]($style)" +style = "fg:bright-white bold bg:default" +when = '[ -n "$kak_opt_lsp_modeline_progress" ]' +shell = ['sh'] +disabled = false + +[git_branch] +symbol = "" +style = "fg:black bg:cyan bold" +format = '[ ](fg:cyan bg:black)[ $symbol $branch ]($style)' + +[git_commit] +format = '[ \($hash$tag\)]($style)' +style = 'bg:cyan fg:bright-black' +commit_hash_length = 6 +only_detached = false +tag_symbol = ' 笠' +tag_disabled = false +disabled = false + +[git_state] +format = '\( [$state($progress_current/$progress_total)]($style)\)' +style = "bg:cyan fg:black" +rebase = 'REBASING' +merge = 'MERGING' +revert = 'REVERTING' +cherry_pick = 'CHERRY-PICKING' +bisect = 'BISECTING' +am = 'AM' +am_or_rebase = 'AM/REBASE' +disabled = true + +[git_status] +format = '[ \[$all_status$ahead_behind\]]($style)[ ]($style)' +style = 'fg:black bold bg:cyan' +stashed = '\$' +ahead = '⇡${count}' +behind = '⇣${count}' +diverged = '⇕⇡${ahead_count}⇣${behind_count}' +conflicted = '=' +deleted = '✘' +renamed = '»' +modified = '!' +staged = '+' +untracked = '?' +disabled = false + +[directory] +format = '[](fg:green bg:cyan)[ $read_only]($style)[$path]($style)' +truncation_length = 8 +truncate_to_repo = true +fish_style_pwd_dir_length = 0 +use_logical_path = true +style = 'bg:green fg:black' +read_only_style = 'bg:green fg:red' +read_only = '[]' +truncation_symbol = '…' +home_symbol = " " +disabled = false + +[directory.substitutions] +"dotfiles" = "󱗾" +"~/.config" = " " +"~/.workspace/rust" = "" +"~/.workspace/docker" = " " +"~/.workspace/alpine" = " " +"~/.workspace/arch" = " " +"~/.workspace/kustomize" = "ﴱ " +"~/.workspace/node" = "" +"~/.workspace" = " " +"~/scm" = " " +# "~" = " " + +[custom.kakfile] +description = 'The current Kakoune buffername' +format = '[/$output ]($style)' +style = 'bg:green fg:black' +command = 'echo -n ${kak_buffile##*/}' +when = 'true' +shell = ['sh'] +disabled = false + +[custom.kakfiletype] +description = 'The current buffer filetype' +format = '[](fg:black bg:green)[ %opt{filetype} ]($style)' +style = 'bg:black fg:yellow' +when = '' +shell = ['true'] +disabled = false + +[custom.kakbuflist] +description = "Open buffers" +format = '[](fg:white bg:bright-black)[ numbufs: $output ]($style)' +style = 'bg:white fg:black' +when = 'true' +shell = ['sh'] +command = 'kks get -s ${kak_session##*/} %val{buflist} | grep -vE "(\*debug\*|\*scratch\*)" | wc -w' +disabled = false + +[custom.kaksession] +description = 'The current Kakoune session' +format = '[](fg:bright-black bg:black)[  %val{client}:%val{session} ]($style)' +style = 'bg:bright-black fg:black' +when = '' +shell = ['true'] +disabled = false + +[custom.kakcursor] +description = 'The current Kakoune cursor position' +format = '[](fg:bright-white bg:white)[%val{cursor_line}:%val{cursor_char_column}]($style)' +style = 'fg:black bg:bright-white' +when = '' +shell = ['true'] +disabled = false + +[custom.kakposition] +description = 'Relative position of the cursor inside the buffer' +format = '[  $output]($style)[ ]($style)' +style = 'fg:black bg:bright-white' +command = 'echo -n $(($kak_cursor_line * 100 / $kak_buf_line_count))%' +when = '[ -n "$kak_cursor_line" ]' +shell = ['sh'] +disabled = false + +[custom.kakcontext] +description = 'The current Kakoune context' +format = '{{context_info}}' +when = '' +shell = ['true'] +disabled = false + +[custom.kakmode] +description = 'The current Kakoune mode' +format = '{{mode_info}}' +when = '' +shell = ['true'] +disabled = false + -- 2.51.2