Skip to content

Instantly share code, notes, and snippets.

@lf94
Created October 6, 2024 21:54
Show Gist options
  • Save lf94/7c23c9a712c7d8950971bd988e2e641d to your computer and use it in GitHub Desktop.
Save lf94/7c23c9a712c7d8950971bd988e2e641d to your computer and use it in GitHub Desktop.
require-module x11
set global windowing_modules x11
colorscheme black-on-white
# Don't show startup changelog
set-option global startup_info_version 99999999999
# Instead of wrapping on column 80, indicate where it is
# so we know when to "carriage return" like in the days
# of the typewriter.
add-highlighter global/ column 81 PrimarySelection
# Setup ide variables to open new clients for commands
def ide %{
rename-client main
set global jumpclient main
new rename-client tools
set global toolsclient tools
}
# Make opening new terminals easy
set global termcmd 'zutty -e sh -c'
map global normal <c-t> ': terminal /bin/bash<ret>'
# Make opening new buffers easy
map global normal <c-n> ':new<ret>'
# Easier buffer management
map global normal <c-b> ': b '
def git-link-yank %{
nop %sh{
url="$(git remote get-url origin | sed -e 's/:/\//' -e 's/git@/https:\/\//' -e 's/\.git//')/blob"
branch="/$(git status -b --porcelain=v2 | grep branch.oid | cut -d ' ' -f 3)"
top=$(git rev-parse --show-toplevel | sed 's/\//\\\//g')
path=$(echo -n "$kak_buffile" | sed "s/$top//")
line1="#L$(echo $kak_selection_desc | sed 's/\..*$//')"
line2="-L$(echo $kak_selection_desc | cut -d ',' -f 2 | sed 's/\..*$//')"
printf "%s%s%s%s" "$url" "$branch" "$path" "$line1" "$line2" | xsel -b
}
}
map global normal <c-y> ': git-link-yank<ret>'
map global normal y '\<a-|>xsel -b<ret>y'
# Use ctrl-a to search
set global grepcmd 'git grep -Hn'
map global normal <c-a> ':grep '
# Use git ls-files for quick jump to files
declare-option str findcmd 'git ls-files'
define-command find -menu -params 1 -shell-script-candidates %opt{findcmd} %{ edit %arg{1} }
map global normal <c-f> ':find '
# Prevent any more highlighters from being added.
define-command -override -params .. add-highlighter ""
# Indentation - always 2 spaces
hook global InsertChar \t %{ exec -draft -itersel h@ }
set global tabstop 2
set global indentwidth 2
# Delete word in insert mode
map global insert <c-w> <esc>bdi
# Less keystrokes to use make, and navigate errors
declare-user-mode error-mode
map global normal <c-e> ":enter-user-mode error-mode<ret>"
map -docstring "make" global error-mode m ":make<ret>"
map -docstring "next error" global error-mode n ":make-next-error<ret>"
map -docstring "previous error" global error-mode p ":make-previous-error<ret>"
# Stop scratch buffer from having anything in it
hook global WinCreate \*scratch\* %{
execute-keys xjd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment