1
0
Fork 0

lf: highlight line in find_word

This commit is contained in:
Luca Bilke 2024-10-23 17:12:35 +02:00
parent 6e2e0d6d89
commit ee67adaf8e
Signed by: luca
GPG Key ID: F6E11C9BAA7C82F5
1 changed files with 26 additions and 19 deletions

View File

@ -141,26 +141,33 @@ cmd fzf ${{
}}
cmd find_word ${{
set +ue
rg_cmd="rg -uu --column --line-number --no-heading --color=always --smart-case --follow"
res="$(
set +ue
BAT="bat --style=plain --color=always --italic-text=always --pager=never --tabs=4 --theme=base16"
rg_cmd="rg -uu --column --line-number --no-heading --color=always --smart-case --follow"
res="$(
fzf --disabled --ansi --exact --layout=reverse --header 'Searching file contents' --delimiter=: \
--bind="start:reload([ -n {q} ] && $rg_cmd -- {q} || true)" \
--bind="change:reload([ -n {q} ] && $rg_cmd -- {q} || true)" \
--preview-window="right,50%" \
--preview='~/.config/lf/preview {1} "$FZF_PREVIEW_COLUMNS" "$FZF_PREVIEW_LINES" "$FZF_PREVIEW_LEFT" "$FZF_PREVIEW_TOP"'
)"
file="$(realpath "$(echo "$res" | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" 2>/dev/null)"
row="$(echo "$res" | cut -d':' -f2)"
column="$(echo "$res" | cut -d':' -f3)"
if [ -n "$res" ]; then
--preview-window="right,50%,+{2}/2" \
--preview="$BAT"' --highlight-line {2} {1} "$FZF_PREVIEW_COLUMNS" "$FZF_PREVIEW_LINES" "$FZF_PREVIEW_LEFT" "$FZF_PREVIEW_TOP"'
)"
file="$(realpath "$(echo "$res" | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" 2>/dev/null)"
row="$(echo "$res" | cut -d':' -f2)"
column="$(echo "$res" | cut -d':' -f3)"
if [ -n "$res" ]; then
if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then
lf -remote "send $id \$$EDITOR +'call cursor($row, $column)' -- '$file'"
else
lf -remote "send $id \$$EDITOR '$file'"
fi
fi
return 0
fi
return 0
}}
cmd find_project ${{