2023-10-12 22:51:18 +02:00
|
|
|
hook global WinSetOption .* %{
|
|
|
|
remove-highlighter global/show-ws
|
|
|
|
add-highlighter global/show-ws show-whitespaces -tabpad ' '
|
|
|
|
|
|
|
|
face global Whitespace rgb:3c3836+f
|
|
|
|
face global comment rgb:665c54+f
|
|
|
|
}
|
|
|
|
|
|
|
|
add-highlighter global/ show-matching
|
|
|
|
|
|
|
|
set global indentwidth 4
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=(verilog|nix|vhdl) %{
|
|
|
|
set buffer tabstop 2
|
|
|
|
set buffer indentwidth 2
|
|
|
|
}
|
|
|
|
|
2023-11-12 12:43:16 +01:00
|
|
|
set-option global ignored_files "^(\..*|.*\.(o|so|a)|__pycache__)$"
|
2023-10-12 22:51:18 +02:00
|
|
|
|
|
|
|
## == keybinds ==
|
|
|
|
|
|
|
|
map global normal 'J' "Jx"
|
|
|
|
map global normal 'K' "Kx"
|
|
|
|
|
|
|
|
# tabs
|
|
|
|
map global insert '<tab>' '<a-;><a-gt>'
|
|
|
|
map global insert '<s-tab>' '<a-;><a-lt>'
|
|
|
|
|
|
|
|
define-command W w
|
|
|
|
|
|
|
|
# Commenting
|
|
|
|
map global normal '#' ':comment-line<ret>'
|
|
|
|
map global user '#' ':comment-block<ret>' -docstring 'Block comment'
|
|
|
|
|
|
|
|
# Clipboard commands
|
|
|
|
map global normal '<a-y>' '|pbcopy<ret>u:echo "Copied text to clipboard"<ret>'
|
|
|
|
map global normal '<c-v>' '!pbpaste<ret>'
|
|
|
|
|
|
|
|
# Buffer user mode
|
|
|
|
map global user 'b' ':enter-user-mode buffers<ret>' -docstring 'buffer mode'
|
|
|
|
map global user 'B' ':enter-user-mode -lock buffers<ret>' -docstring 'buffer mode (lock)'
|
|
|
|
|
|
|
|
## == plugin configuration ==
|
|
|
|
|
|
|
|
# Custom function surround
|
|
|
|
define-command -hidden surround-function %{
|
|
|
|
prompt 'function: ' %{
|
|
|
|
execute-keys "<a-:><a-;>Z;ha%val{text}(<esc><a-;>L<a-z>ua)<esc>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
define-command -hidden surround-tag %{
|
|
|
|
prompt 'tag: ' %{
|
|
|
|
execute-keys "<a-:><a-;>Z;ha<lt>%val{text}<gt><esc><a-;>L<a-z>ua<lt>/%val{text}<gt><esc>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
define-command -hidden surround-Tag %{
|
|
|
|
prompt 'tag: ' %{
|
|
|
|
execute-keys "xZ<a-:><a-;>gih<a-h>yz<gt>xZO<c-r>""<lt>%val{text}<gt><esc>zo<c-r>""<lt>%val{text}<gt><esc>z"
|
|
|
|
}
|
|
|
|
}
|
2023-11-12 12:43:16 +01:00
|
|
|
define-command -hidden surround-space %{
|
|
|
|
execute-keys "i <esc>Ha <esc>"
|
2023-10-12 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
map global mirror 'f' ':surround-function<ret>' -docstring 'function'
|
2023-11-12 12:43:16 +01:00
|
|
|
map global mirror 't' ':surround-tag<ret>mjau' -docstring 'tag'
|
|
|
|
map global mirror 'T' ':surround-Tag<ret>' -docstring 'tag, break line'
|
|
|
|
map global mirror ' ' ':surround-space<ret>' -docstring 'spaces'
|
2023-10-12 22:51:18 +02:00
|
|
|
|
|
|
|
map global normal ö ':enter-user-mode mirror<ret>' -docstring 'mirror mode'
|
|
|
|
|
|
|
|
# LSP stuff
|
|
|
|
map global normal 'Å' ':lsp-enable<ret>' -docstring 'Enable LSP'
|
|
|
|
map global normal 'å' ':enter-user-mode lsp<ret>' -docstring 'LSP mode'
|
|
|
|
map global lsp 'R' ':lsp-rename-prompt<ret>' -docstring 'Rename symbol'
|
|
|
|
|
|
|
|
define-command lsp-clear-references %{
|
|
|
|
set-option window lsp_references # empty
|
|
|
|
}
|
|
|
|
map global lsp '"' ':lsp-clear-references<ret>' -docstring "Clear references"
|
|
|
|
|
|
|
|
face global Reference white,rgb:550055
|
|
|
|
face global ReferenceBind white,rgb:552200
|
|
|
|
|
2023-11-12 22:57:44 +01:00
|
|
|
# tree-sitter
|
|
|
|
tree-always-highlight
|
|
|
|
set-option global tree_highlight_style ",rgb:404040"
|
|
|
|
declare-user-mode tree
|
|
|
|
map global normal 't' ":enter-user-mode tree<ret>"
|
2023-11-13 09:48:08 +01:00
|
|
|
map global normal '<tab>' ":enter-user-mode tree<ret>"
|
2023-11-12 22:57:44 +01:00
|
|
|
map global normal 'T' ":enter-user-mode -lock tree<ret>"
|
|
|
|
|
2023-11-13 09:48:08 +01:00
|
|
|
map -docstring "select node" global tree 'n' ":tree-select-node<ret>"
|
|
|
|
map -docstring "select parent" global tree 'k' ":tree-select-parent-node<ret>"
|
|
|
|
map -docstring "select children" global tree 'C' ":tree-select-children<ret>"
|
2023-11-12 22:57:44 +01:00
|
|
|
map -docstring "select children of type" global tree 'c' ":enter-user-mode tree-children<ret>"
|
2023-11-13 09:48:08 +01:00
|
|
|
map -docstring "select next node of type" global tree 'l' ":enter-user-mode tree-next<ret>"
|
|
|
|
map -docstring "select previous node of type" global tree 'h' ":enter-user-mode tree-prev<ret>"
|
|
|
|
map -docstring "show sexp" global tree 's' ":tree-node-sexp<ret>"
|
|
|
|
map -docstring "enable highlighting" global tree '"' ":tree-always-highlight<ret>"
|
|
|
|
map -docstring "disable highlighting" global tree '&' ":tree-always-highlight-disable<ret>"
|
2023-11-12 22:57:44 +01:00
|
|
|
|
|
|
|
declare-user-mode tree-children
|
|
|
|
declare-user-mode tree-next
|
|
|
|
declare-user-mode tree-prev
|
|
|
|
|
2023-11-13 09:48:08 +01:00
|
|
|
map global normal 'f' ":enter-user-mode tree-next<ret>"
|
|
|
|
map global normal 'F' ":enter-user-mode tree-children<ret>"
|
|
|
|
|
2023-11-12 22:57:44 +01:00
|
|
|
evaluate-commands %sh{
|
|
|
|
echo "i,identifier
|
2023-11-13 09:48:08 +01:00
|
|
|
t,type
|
2023-11-12 22:57:44 +01:00
|
|
|
c,call
|
|
|
|
a,arguments
|
2023-11-13 09:48:08 +01:00
|
|
|
s,statement
|
|
|
|
d,declaration
|
|
|
|
n,number
|
|
|
|
\",string" |
|
2023-11-12 22:57:44 +01:00
|
|
|
while IFS=, read -r cmd group ; do
|
|
|
|
echo "map -docstring '$group child' global tree-children '$cmd' ':tree-select-children $group<ret>'"
|
|
|
|
echo "map -docstring 'next $group' global tree-next '$cmd' ':tree-select-next-node $group<ret>'"
|
|
|
|
echo "map -docstring 'previous $group' global tree-prev '$cmd' ':tree-select-previous-node $group<ret>'"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-11-13 09:48:08 +01:00
|
|
|
|
2023-10-12 22:51:18 +02:00
|
|
|
#TODO
|
|
|
|
# map global user '&' ':qhl-word<ret>' -docstring "Highlight current word"
|
|
|
|
# map global user '"' ':unqhl<ret>' -docstring "Remove highlight"
|
|
|
|
|
|
|
|
## == Colors ==
|
|
|
|
|
2023-11-12 12:43:16 +01:00
|
|
|
## Highlight whitespace at end of line
|
|
|
|
add-highlighter global/ regex '^.*[^ ]( +)$' 1:black,red
|
|
|
|
add-highlighter global/ number-lines -relative -hlcursor
|
|
|
|
|
2023-10-12 22:51:18 +02:00
|
|
|
define-command update-cursor-style %{
|
|
|
|
evaluate-commands %sh{
|
|
|
|
if [ $(echo "$kak_selection" | wc -c) -eq 2 ] ; then
|
|
|
|
echo 'face buffer PrimaryCursor white,+uiF'
|
|
|
|
else
|
|
|
|
echo 'face buffer PrimaryCursor white,rgb:b05fde+uiF'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hook global NormalKey .* %{
|
|
|
|
update-cursor-style
|
|
|
|
}
|
|
|
|
|
|
|
|
hook global WinCreate .* %{
|
|
|
|
update-cursor-style
|
|
|
|
}
|
|
|
|
|
|
|
|
face global PrimaryCursorEol PrimaryCursor
|
|
|
|
face global SecondaryCursorEol SecondaryCursor
|
|
|
|
|
|
|
|
face global operator blue
|
|
|
|
face global type rgb:aa66ee+b
|
|
|
|
|
|
|
|
face global MenuBackground rgb:eecc44+i
|
|
|
|
face global MenuForeground blue+bi
|
|
|
|
face global Information rgb:44ccee+b
|
|
|
|
|
|
|
|
face global MatchingChar ,rgb:665c54+bF
|
|
|
|
|
|
|
|
## Filetype formatting
|
|
|
|
|
|
|
|
hook global BufSetOption filetype=rust %{
|
|
|
|
set-option buffer formatcmd 'rustfmt'
|
|
|
|
|
|
|
|
hook buffer -group rust-inlay-hints BufReload .* rust-analyzer-inlay-hints
|
|
|
|
hook buffer -group rust-inlay-hints NormalIdle .* rust-analyzer-inlay-hints
|
|
|
|
}
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=python %{
|
|
|
|
set-option window formatcmd 'black -q -'
|
|
|
|
}
|
|
|
|
|