187 lines
6.2 KiB
Text
187 lines
6.2 KiB
Text
# Daniel's Personal kakrc
|
|
# Author: Daniel Fichtinger <daniel@ficd.ca>
|
|
# See README.md for explanations.
|
|
|
|
declare-option -hidden bool on_server %sh{
|
|
if [ -z "$KAK_ON_SERVER" ]; then
|
|
printf 'false'
|
|
else
|
|
printf 'true'
|
|
fi
|
|
}
|
|
|
|
define-command -override true nop
|
|
define-command -override false fail
|
|
|
|
require-module ui-mode
|
|
require-module colemak
|
|
require-module clipboard
|
|
|
|
try %{
|
|
%opt{on_server}
|
|
set-option global clipboard_copy_cmd %<base64 | tr -d '\n' | awk '{print "\033]52;c;" $0 "\a"}'>
|
|
colorscheme ashen-local
|
|
} catch %{
|
|
colorscheme ashen
|
|
source %exp{%val{config}/extra.kak}
|
|
}
|
|
|
|
require-module surround
|
|
require-module expand
|
|
require-module ficgrep
|
|
require-module byline
|
|
set-option global scrolloff 3,3
|
|
try %{
|
|
set-option global ashen_dynamic_cursor true
|
|
set-option global ashen_eol_cursor true
|
|
}
|
|
|
|
# disable clippy
|
|
set-option -add global ui_options terminal_assistant=none
|
|
|
|
|
|
# This gets overridden by editorconfig but we set sane default anyways
|
|
set-option global tabstop 4
|
|
set-option global indentwidth 4
|
|
|
|
hook -once global WinSetOption filetype=kak %{
|
|
# highlight extra keywords
|
|
declare-option str-list extra_kak_keywords addhl decl def compl eval exec rmhl rmhooks face set unset
|
|
eval %sh{
|
|
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
|
|
if [ -n "$kak_opt_extra_kak_keywords" ]; then
|
|
printf '%s' "add-highlighter shared/kakrc/code/extra_keywords regex (?:\s|\A)\K($(join "${kak_opt_extra_kak_keywords}" '|'))(?:(?=\s)|\z) 0:keyword"
|
|
fi
|
|
}
|
|
}
|
|
|
|
hook global WinSetOption filetype=kak %{
|
|
# make brackets gray a-la Ashen
|
|
|
|
add-highlighter window/bracket regex [\[\]\(\)\{\}]{1} 0:rgb:737373
|
|
add-highlighter window/info regex '#\h*(INFO|NOTE|TODO|PERF|OPTIMIZE|PERFORMANCE|QUESTION|ASK):[^\n]*' 1:+a@ts_info
|
|
add-highlighter window/hint regex '#\h*(HINT|MARK|PASSED|STUB|MOCK):[^\n]*' 1:+a@ts_hint
|
|
add-highlighter window/warning regex '#\h*(HACK|WARN|WARNING|TEST|TEMPHACK|WARN|WARNING|TEST|TEMPHACK|WARN|WARNING|TEST|TEMPHACK|WARN|WARNING|TEST|TEMP):[^\n]*' 1:+a@ts_warning
|
|
add-highlighter window/error regex '#\h*(BUG|FIXME|ISSUE|XXX|FIX|SAFETY|FIXIT|FAILED|DEBUG|INVARIANT|COMPLIANCE):[^\n]*' 1:+a@ts_error
|
|
# special highlighting for escaped goodies in regex
|
|
# add-highlighter window/regex-escaped regex \\[\[\]\(\)\{\}fnrtv0\\dwshDWSH] 0:rgb:e5e5e5
|
|
}
|
|
|
|
# default window settings
|
|
# wrap enabled
|
|
# scrolloff enabled
|
|
hook global WinCreate .* %{
|
|
ui-wrap-enable
|
|
# TODO: fix ui-scrolloff-enable and use that instead
|
|
ui-scrolloff-toggle
|
|
add-highlighter window/number-lines number-lines -hlcursor -relative -separator " "
|
|
# only-trailing is nice QOL otherwise it gets hard to read the screen
|
|
# and it makes it easy to see trailing spaces
|
|
add-highlighter window/show-whitespaces show-whitespaces -only-trailing
|
|
add-highlighter window/show-matching show-matching
|
|
# TODO: update plugin so it auto clears if escaped out of search,
|
|
# but if search is accepted then auto clear on <esc> in normal mode?
|
|
require-module search-highlight
|
|
set window search_highlight_face %exp{%opt{orange_golden}+u}
|
|
search-highlight-enable
|
|
}
|
|
|
|
|
|
# convenience mappings
|
|
# quitting & saving
|
|
map -docstring "quit" global user q ": q<ret>"
|
|
map -docstring "quit" global normal <c-q> ": q<ret>"
|
|
map -docstring "force quit" global user Q ": q!<ret>"
|
|
map -docstring "force quit" global normal <c-Q> ": q!<ret>"
|
|
map -docstring "kill session" global normal <a-q> ':kill<ret>'
|
|
map -docstring "force kill session" global normal <a-q> ':kill!<ret>'
|
|
map -docstring "save" global normal <c-s> ": write<ret>"
|
|
map -docstring "save" global normal <c-S> ": write!<ret>"
|
|
|
|
# buffer operations
|
|
map -docstring "close current buffer" global user x ": db<ret>"
|
|
map -docstring "goto previous buffer" global user m ": bp<ret>"
|
|
map -docstring "goto next buffer" global user i ": bn<ret>"
|
|
map -docstring "goto previous buffer" global normal <c-m> ": bp<ret>"
|
|
map -docstring "goto next buffer" global normal <c-i> ": bn<ret>"
|
|
|
|
# trim whitespace
|
|
map global normal <tab> _
|
|
|
|
# comments
|
|
define-command comment-line-as-block %{
|
|
execute-keys -draft 'xs[^\n]<ret><a-_>: comment-block<ret>'
|
|
}
|
|
define-command smart-comment %{
|
|
evaluate-commands %sh{
|
|
if [ -z "${kak_opt_comment_line}" ]; then
|
|
echo "comment-line-as-block"
|
|
else
|
|
echo "comment-line"
|
|
fi
|
|
}
|
|
}
|
|
map -docstring "smart comment" global normal "#" ": smart-comment<ret>"
|
|
map -docstring "comment block" global normal "<a-#>" ": comment-block<ret>"
|
|
|
|
# formatting
|
|
map -docstring "format" global normal = ": format-buffer<ret>"
|
|
map -docstring "format" global normal <a-=> ": format-selections<ret>"
|
|
|
|
# Case-insensitive Search
|
|
map -docstring 'case insensitive search' global user '/' /(?i)
|
|
map -docstring 'case insensitive backward search' global user '<a-/>' <a-/>(?i)
|
|
map -docstring 'case insensitive extend search' global user '?' ?(?i)
|
|
map -docstring 'case insensitive backward extend-search' global user '<a-?>' <a-?>(?i)
|
|
|
|
# TODO: how to bind these to goto mode while respecting g/G??
|
|
map -docstring 'Select to file end' global user N "Gj<a-L>L"
|
|
map -docstring 'Extend to file end' global user n "gj<a-l>l"
|
|
|
|
define-command -docstring "Create a scratch buffer" scratch %{
|
|
edit -scratch
|
|
}
|
|
|
|
alias global s scratch
|
|
|
|
define-command -params 1 -docstring "Set buffer filetype" filetype %{
|
|
set-option buffer filetype %arg{1}
|
|
}
|
|
|
|
alias global ft filetype
|
|
alias global lang filetype
|
|
|
|
map global normal <backspace> '"_'
|
|
define-command goto-debug %{
|
|
buffer *debug*
|
|
try %{
|
|
ui-scrolloff-disable
|
|
execute-keys 'gj'
|
|
}
|
|
}
|
|
|
|
map -docstring 'open debug buffer' global user d ':goto-debug<ret>'
|
|
|
|
declare-filetype-mode kak
|
|
# TODO: automatically add -override for overridable commands?
|
|
define-command exec-selection %{
|
|
execute-keys ':<c-r>.<ret>'
|
|
}
|
|
|
|
map -docstring 'execute selection' global kak x ': exec-selection<ret>'
|
|
|
|
define-command repl %{
|
|
new %{ edit -scratch; set buffer filetype kak }
|
|
}
|
|
|
|
# jumplist
|
|
|
|
map -docstring 'jump forward' global normal <c-f> <c-i>
|
|
map -docstring 'save to jumplist' global normal <c-v> <c-s>
|
|
|
|
# selection saving
|
|
map -docstring 'add selection' global normal Y <a-Z>a
|
|
|
|
# open URL
|
|
require-module url-open
|
|
map -docstring "Open URL" global goto u '<esc>: url-open<ret>'
|