1
0
Fork 0
fzf.kak/rc/modules/VCS/fzf-git.kak

32 lines
1.3 KiB
Text
Raw Normal View History

2021-03-19 18:00:49 +00:00
# Author: Andrey Listopadov
# Submodule for Git support for fzf.kak
# https://github.com/andreyorst/fzf.kak
2018-11-11 10:41:15 +00:00
2021-03-19 18:00:49 +00:00
hook global ModuleLoaded fzf-vcs %§
map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: require-module fzf-git; fzf-git<ret>'
§
provide-module fzf-git %§
2018-11-11 10:41:15 +00:00
declare-option -docstring "command to provide list of files in git tree to fzf. Arguments are supported
Supported tools:
<package>: <value>:
2019-12-19 09:03:23 +00:00
Git: ""git""
2018-11-11 10:41:15 +00:00
Default arguments:
2019-12-19 09:03:23 +00:00
'git ls-tree --full-tree --name-only -r HEAD'
2018-11-11 10:41:15 +00:00
" \
str fzf_git_command "git"
2021-03-19 18:00:49 +00:00
define-command -hidden fzf-git %{ evaluate-commands %sh{
2019-09-09 14:59:38 +00:00
2018-11-11 10:41:15 +00:00
case $kak_opt_fzf_git_command in
2019-12-19 08:44:05 +00:00
(git) cmd='git ls-tree --full-tree --name-only -r HEAD' ;;
(*) cmd=$kak_opt_fzf_git_command ;;
2018-11-11 10:41:15 +00:00
esac
2021-03-21 10:33:27 +00:00
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ${kak_opt_fzf_vertical_map:-ctrl-v} --expect ${kak_opt_fzf_horizontal_map:-ctrl-s}"
printf "%s\n" "fzf -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ${kak_opt_fzf_window_map:-ctrl-w} $additional_flags} -filter %{perl -pe \"if (/${kak_opt_fzf_window_map:-ctrl-w}|${kak_opt_fzf_vertical_map:-ctrl-v}|${kak_opt_fzf_horizontal_map:-ctrl-s}|^$/) {} else {print \\\"$(git rev-parse --show-toplevel)/\\\"}\"}"
2018-11-11 10:41:15 +00:00
}}
2019-05-09 15:12:06 +00:00
§