lf: highlight line in find_word
This commit is contained in:
parent
6e2e0d6d89
commit
ee67adaf8e
|
@ -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="$(
|
||||
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
|
||||
if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then
|
||||
lf -remote "send $id \$$EDITOR +'call cursor($row, $column)' -- '$file'"
|
||||
else
|
||||
lf -remote "send $id \$$EDITOR '$file'"
|
||||
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%,+{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
|
||||
fi
|
||||
return 0
|
||||
|
||||
return 0
|
||||
}}
|
||||
|
||||
cmd find_project ${{
|
||||
|
|
Loading…
Reference in New Issue