WIP x11 support
This commit is contained in:
parent
8381d831cc
commit
d855e32b90
1 changed files with 28 additions and 25 deletions
53
rc/fzf.kak
53
rc/fzf.kak
|
@ -11,21 +11,20 @@
|
|||
# │ different fzf commands. │
|
||||
# ╰─────────────────────────────────╯
|
||||
|
||||
# New mode
|
||||
evaluate-commands %sh{ modes="_ "$kak_user_modes; [ -z "${modes##*fzf*}" ] || echo declare-user-mode fzf }
|
||||
declare-user-mode fzf
|
||||
|
||||
# Options
|
||||
declare-option -docstring "command to provide list of files to fzf.
|
||||
Supported tools:
|
||||
find - GNU Find
|
||||
ag - The Silver Searcher
|
||||
rg - ripgrep
|
||||
find - GNU Find
|
||||
ag - The Silver Searcher
|
||||
rg - ripgrep
|
||||
|
||||
Arguments are also can be passed along with it.
|
||||
Default arguments are:
|
||||
find -type f
|
||||
ag -l -f --hidden --one-device .
|
||||
rg -L --hidden --files
|
||||
find -type f
|
||||
ag -l -f --hidden --one-device .
|
||||
rg -L --hidden --files
|
||||
" \
|
||||
str fzf_file_command "find"
|
||||
|
||||
|
@ -43,14 +42,14 @@ map global fzf -docstring "change directory" c '<esc>: fzf-cd<ret>'
|
|||
map global fzf -docstring "edif file in git tree" g '<esc>: fzf-git<ret>'
|
||||
|
||||
# Commands
|
||||
define-command -override -docstring \
|
||||
define-command -docstring \
|
||||
"fzf-mode: Enter fzf-mode
|
||||
This is to be used in mappings to enter fzf-mode
|
||||
For example: map global normal <c-p> ': fzf-mode<ret>'
|
||||
" \
|
||||
fzf-mode %{ evaluate-commands 'enter-user-mode fzf' }
|
||||
|
||||
define-command -override -hidden -docstring \
|
||||
define-command -hidden -docstring \
|
||||
"fzf-file: Run fzf to open file
|
||||
Configurable options:
|
||||
fzf_file_command: command to run with fzf to list possible files.
|
||||
|
@ -83,37 +82,41 @@ fzf-file %{
|
|||
}
|
||||
}
|
||||
|
||||
define-command -override -hidden fzf-git %{
|
||||
define-command -hidden fzf-git %{
|
||||
fzf "edit $1" "git ls-tree --name-only -r HEAD"
|
||||
}
|
||||
|
||||
define-command -override -hidden fzf-tag %{
|
||||
define-command -hidden fzf-tag %{
|
||||
fzf "ctags-search $1" "readtags -l | cut -f1 | sort -u"
|
||||
}
|
||||
|
||||
define-command -override -hidden fzf-cd %{
|
||||
define-command -hidden fzf-cd %{
|
||||
fzf "change-directory $1" "find \( -path '*/.svn*' -o -path '*/.git*' \) -prune -o -type d -print"
|
||||
}
|
||||
|
||||
define-command -override -hidden fzf -params 2 %{ evaluate-commands %sh{
|
||||
if [ -z "${kak_client_env_TMUX}" ]; then
|
||||
echo 'fail "client was not started under tmux"'
|
||||
exit
|
||||
define-command -hidden fzf -params 2 %{ evaluate-commands %sh{
|
||||
callback=$1
|
||||
items_command=$2
|
||||
if [ ! -z "${kak_client_env_TMUX}" ]; then
|
||||
cmd="$items_command | fzf-tmux -d 15 --color=16"
|
||||
fi
|
||||
if [ ! -z "${kak_opt_termcmd}" ]; then
|
||||
cmd="$kak_opt_termcmd \"sh -c '$items_command | fzf'\""
|
||||
else
|
||||
echo "fail termcmd option is not set"
|
||||
# exit
|
||||
fi
|
||||
tmp=$(mktemp $(eval echo $kak_opt_fzf_tmp/kak-fzf.XXXXXX))
|
||||
exec=$(mktemp $(eval echo $kak_opt_fzf_tmp/kak-exec.XXXXXX))
|
||||
callback=$1; shift
|
||||
items_command=$1; shift
|
||||
if [ -z $(command -v $(echo $items_command | head -n 1)) ]; then
|
||||
eval echo fail "\'$(echo $items_command | head -n 1)' executable not found. Is it installed?"
|
||||
items_executable=$(echo $items_command | awk '{print $1}')
|
||||
if [ -z $(command -v $items_executable) ]; then
|
||||
eval echo fail "\'$items_executable' executable not found. Is it installed?"
|
||||
exit
|
||||
fi
|
||||
flags='--color=16'
|
||||
[ -z "${@##* -multi*}" ] && flags="$flags -m"
|
||||
echo "echo eval -client $kak_client \"$callback\" | kak -p $kak_session" > $exec
|
||||
chmod 755 $exec
|
||||
(
|
||||
eval "$items_command | fzf-tmux -d 15 $flags > $tmp"
|
||||
eval "$cmd > $tmp"
|
||||
(while read file; do
|
||||
$exec $file
|
||||
done) < $tmp
|
||||
|
@ -122,7 +125,7 @@ define-command -override -hidden fzf -params 2 %{ evaluate-commands %sh{
|
|||
) > /dev/null 2>&1 < /dev/null &
|
||||
}}
|
||||
|
||||
define-command -override -hidden fzf-buffer %{ evaluate-commands %sh{
|
||||
define-command -hidden fzf-buffer %{ evaluate-commands %sh{
|
||||
if [ -z "${kak_client_env_TMUX}" ]; then
|
||||
echo 'fail "client was not started under tmux"'
|
||||
exit
|
||||
|
|
Loading…
Reference in a new issue