2020-11-14 20:53:21 +01:00
|
|
|
# {{@@ header() @@}}
|
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
try %{
|
2021-03-31 19:02:21 +02:00
|
|
|
declare-user-mode buffer
|
2021-03-10 00:11:43 +01:00
|
|
|
declare-user-mode surround
|
|
|
|
declare-user-mode git
|
|
|
|
declare-user-mode find
|
|
|
|
}
|
|
|
|
|
2021-04-16 07:06:50 +02:00
|
|
|
map global user 'w' ': wa<ret>' -docstring 'write buffer'
|
2021-03-10 00:11:43 +01:00
|
|
|
map global user 'u' ': config-source<ret>' -docstring 'source configuration'
|
2020-11-15 04:49:18 +01:00
|
|
|
map global user 'g' ': enter-user-mode lsp<ret>' -docstring 'lsp mode'
|
|
|
|
map global user 'z' ':zoxide ' -docstring 'zoxide'
|
2021-03-31 20:27:00 +02:00
|
|
|
map global user 'n' ': new<ret>' -docstring 'new window'
|
2020-11-14 20:53:21 +01:00
|
|
|
|
2021-03-05 02:21:42 +01:00
|
|
|
map global user 'e' 'x|emmet<ret>{{@@ "@" if not tabs @@}}' -docstring 'process line with emmet'
|
2021-03-31 19:02:21 +02:00
|
|
|
map global user 'm' ': try format-buffer catch lsp-formatting<ret>' -docstring 'format document'
|
|
|
|
map global user 'M' ': try format-selections catch lsp-range-formatting<ret>' -docstring 'format selection'
|
2021-03-05 02:21:42 +01:00
|
|
|
|
2020-11-15 04:49:18 +01:00
|
|
|
map global user 'c' ': comment-line<ret>' -docstring 'comment line'
|
|
|
|
map global user 'C' ': comment-block<ret>' -docstring 'comment block'
|
2020-11-14 20:53:21 +01:00
|
|
|
|
2021-04-05 01:12:02 +02:00
|
|
|
map global user 'p' '! wl-paste -n<ret>' -docstring 'clipboard paste'
|
|
|
|
map global user 'P' '<a-o>j! wl-paste -n<ret>' -docstring 'clipboard paste on next line'
|
2021-02-22 00:50:51 +01:00
|
|
|
map global user 'R' '"_d! wl-paste -n <ret>' -docstring 'clipboard replace'
|
2020-11-14 20:53:21 +01:00
|
|
|
|
2021-03-31 19:02:21 +02:00
|
|
|
map global user 'b' ': enter-user-mode buffer<ret>' -docstring 'buffer mode'
|
|
|
|
map global buffer 'n' ':buffer-next<ret>' -docstring 'next'
|
|
|
|
map global buffer 'p' ':buffer-previous<ret>' -docstring 'previous'
|
|
|
|
map global buffer 'd' ':delete-buffer<ret>' -docstring 'delete'
|
|
|
|
|
2020-11-15 04:49:18 +01:00
|
|
|
map global user 's' ': enter-user-mode surround<ret>' -docstring 'surround mode'
|
|
|
|
map global surround 's' ': surround<ret>' -docstring 'surround'
|
|
|
|
map global surround 'c' ': change-surround<ret>' -docstring 'change'
|
|
|
|
map global surround 'd' ': delete-surround<ret>' -docstring 'delete'
|
2021-03-05 02:21:42 +01:00
|
|
|
map global surround 'x' ': select-surround<ret>' -docstring 'select surround'
|
2020-11-14 20:53:21 +01:00
|
|
|
|
2020-11-15 00:05:59 +01:00
|
|
|
map global user 'v' ': enter-user-mode git<ret>' -docstring 'git vcs mode'
|
2021-04-18 19:56:27 +02:00
|
|
|
map global user 'V' ': enter-user-mode -lock git<ret>' -docstring 'git vcs mode'
|
2020-11-15 04:49:18 +01:00
|
|
|
map global git 's' ': git status<ret>' -docstring 'status'
|
|
|
|
map global git 'a' ': git add<ret>' -docstring 'add current'
|
|
|
|
map global git 'd' ': git diff %reg{%}<ret>' -docstring 'diff current'
|
2021-03-31 19:02:21 +02:00
|
|
|
map global git 'r' ': git checkout %reg{%}<ret>' -docstring 'restore current'
|
2020-11-15 04:49:18 +01:00
|
|
|
map global git 'A' ': git add --all<ret>' -docstring 'add all'
|
|
|
|
map global git 'D' ': git diff<ret>' -docstring 'diff all'
|
|
|
|
map global git '<a-d>' ': git diff --staged<ret>' -docstring 'diff staged'
|
|
|
|
map global git 'c' ': git commit -v<ret>' -docstring 'commit'
|
2021-04-18 19:56:27 +02:00
|
|
|
map global git 'u' ': git update-diff<ret>' -docstring 'update gutter diff'
|
2021-02-13 20:12:37 +01:00
|
|
|
map global git 'n' ': git next-hunk <ret>' -docstring 'next hunk'
|
|
|
|
map global git 'p' ': git prev-hunk <ret>' -docstring 'previous hunk'
|
2021-04-18 19:56:27 +02:00
|
|
|
map global git 'm' ': git-merge-head <ret>' -docstring 'merge using head'
|
|
|
|
map global git 'M' ': git-merge-new <ret>' -docstring 'merge using new'
|
|
|
|
map global git '<a-m>' ': git-merge-original <ret>' -docstring 'merge using original'
|
2020-11-15 00:05:59 +01:00
|
|
|
|
2020-11-15 04:49:18 +01:00
|
|
|
map global user 'f' ': enter-user-mode find<ret>' -docstring 'find mode'
|
|
|
|
map global find 'f' ': find_file<ret>' -docstring 'file'
|
|
|
|
map global find 'r' ': find_ripgrep<ret>' -docstring 'ripgrep all file'
|
|
|
|
map global find 'g' ': find_git_file<ret>' -docstring 'git files'
|
|
|
|
map global find 'c' ': find_dir<ret>' -docstring 'change dir'
|
|
|
|
map global find 'b' ': find_buffer<ret>' -docstring 'find buffer'
|
2020-11-16 14:17:10 +01:00
|
|
|
map global find 'd' ': find_delete<ret>' -docstring 'file to delete'
|
2020-11-15 00:05:59 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
try %{
|
2020-11-15 04:49:18 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_file \
|
2021-03-31 19:02:21 +02:00
|
|
|
%{ edit %sh{
|
2021-03-31 20:27:00 +02:00
|
|
|
fd -HE .git | wdmenu ||
|
|
|
|
echo "$kak_buffile"
|
2021-03-10 00:11:43 +01:00
|
|
|
} }
|
2020-11-15 04:49:18 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_delete \
|
|
|
|
%{ nop %sh{
|
2021-03-31 19:02:21 +02:00
|
|
|
fd -H -E .git -t f | wdmenu | xargs -r trash
|
2021-03-10 00:11:43 +01:00
|
|
|
} }
|
2020-11-16 14:17:10 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_git_file \
|
|
|
|
%{ edit -existing %sh{ git ls-files | wdmenu } }
|
2020-11-15 04:49:18 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_dir \
|
|
|
|
%{ cd %sh{ fd -Htd | wdmenu } }
|
2020-11-15 04:49:18 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_buffer \
|
|
|
|
%{ buffer %sh{
|
|
|
|
printf "%s\n" $kak_buflist | wdmenu
|
|
|
|
} }
|
2020-11-15 04:49:18 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -hidden find_ripgrep \
|
|
|
|
%{ eval %sh{
|
|
|
|
patter=$( wdmenu -p "Regex")
|
|
|
|
rg --column -n "$patter" | wdmenu |
|
|
|
|
perl -ne 'print "edit \"$1\" \"$2\" \"$3\" " if /(.+):(\d+):(\d+):/'
|
|
|
|
} }
|
2020-11-15 04:49:18 +01:00
|
|
|
|
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command -params .. \
|
|
|
|
-shell-script-candidates 'zoxide query -l' \
|
|
|
|
zoxide \
|
|
|
|
%{
|
|
|
|
cd %sh{ zoxide query -- "$@" || echo "$@" }
|
|
|
|
echo %sh{ pwd | sed "s|$HOME|~|" }
|
|
|
|
}
|
2020-11-14 20:53:21 +01:00
|
|
|
|
2021-03-10 00:11:43 +01:00
|
|
|
define-command config-source \
|
|
|
|
%{
|
|
|
|
source "%val{config}/kakrc"
|
|
|
|
}
|
|
|
|
|
2021-04-18 19:56:27 +02:00
|
|
|
define-command git-merge-head %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# delete head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret><a-x>d
|
|
|
|
try %{
|
|
|
|
# select original marker
|
|
|
|
execute-keys /^[|]{4,}<ret>
|
|
|
|
# extend to theirs marker
|
|
|
|
execute-keys ?^={4,}<ret><a-x>
|
|
|
|
} catch %{
|
|
|
|
# select theirs marker
|
|
|
|
execute-keys /^={4,}<ret><a-x>
|
|
|
|
}
|
|
|
|
# extend to end marker
|
|
|
|
execute-keys ?^<gt>{4,}<ret><a-x>d
|
|
|
|
}
|
|
|
|
} -docstring "merge using head"
|
|
|
|
|
|
|
|
define-command git-merge-original %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# select head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>
|
|
|
|
# select to middle of conflict
|
|
|
|
execute-keys ?^[|]{4,}<ret><a-x>d
|
|
|
|
# select theirs marker
|
|
|
|
execute-keys /^={4,}<ret>
|
|
|
|
# extend to end marker
|
|
|
|
execute-keys ?^<gt>{4,}<ret><a-x>d
|
|
|
|
}
|
|
|
|
} -docstring "merge using original"
|
|
|
|
|
|
|
|
define-command git-merge-new %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# select head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>
|
|
|
|
# extend to theirs marker
|
|
|
|
execute-keys ?^={4,}\n<ret>d
|
|
|
|
# delete end marker
|
|
|
|
execute-keys /^<gt>{4,}<ret><a-x>d
|
|
|
|
}
|
|
|
|
} -docstring "merge using new"
|
2021-03-10 00:11:43 +01:00
|
|
|
|
|
|
|
}
|