Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clp support #1427

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ so you can omit it if you use a plugin manager that doesn't support hooks.

- [fzf][fzf-main] 0.23.0 or above
- For syntax-highlighted preview, install [bat](https://github.com/sharkdp/bat)
or [clp](https://github.com/jpe90/clp)
- If [delta](https://github.com/dandavison/delta) is available, `GF?`,
`Commits` and `BCommits` will use it to format `git diff` output.
- `Ag` requires [The Silver Searcher (ag)][ag]
Expand Down Expand Up @@ -203,8 +204,9 @@ command! -bang -nargs=? -complete=dir Files

It kind of works, but you probably want a nicer previewer program than `cat`.
fzf.vim ships [a versatile preview script](bin/preview.sh) you can readily
use. It internally executes [bat](https://github.com/sharkdp/bat) for syntax
highlighting, so make sure to install it.
use. It internally executes [bat](https://github.com/sharkdp/bat) or
[clp](https://github.com/jpe90/clp) for syntax highlighting, so make sure to
install one of them.

```vim
command! -bang -nargs=? -complete=dir Files
Expand Down
11 changes: 10 additions & 1 deletion bin/preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,23 @@ if [ -z "$CENTER" ]; then
CENTER=0
fi

if command -v clp > /dev/null; then
CLPNAME="clp"
fi

# Sometimes bat is installed as batcat.
if command -v batcat > /dev/null; then
jpe90 marked this conversation as resolved.
Show resolved Hide resolved
BATNAME="batcat"
elif command -v bat > /dev/null; then
BATNAME="bat"
fi

if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
# Use clp if it's available
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${CLPNAME:+x}" ]; then
${CLPNAME} --highlight-line="${CENTER}" \
"$FILE"
exit $?
elif [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
${BATNAME} --style="${BAT_STYLE:-numbers}" --color=always --pager=never \
--highlight-line=$CENTER -- "$FILE"
exit $?
Expand Down
11 changes: 10 additions & 1 deletion bin/tagpreview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ if (( START_LINE <= 0 )); then
fi
END_LINE="$(( START_LINE + FZF_PREVIEW_LINES - 1 ))"

if command -v clp > /dev/null; then
CLPNAME="clp"
fi

# Sometimes bat is installed as batcat.
if command -v batcat > /dev/null; then
BATNAME="batcat"
elif command -v bat > /dev/null; then
BATNAME="bat"
fi

if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
# Use clp if it's available
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${CLPNAME:+x}" ]; then
${CLPNAME} --highlight-line="${CENTER}" \
"$FILE"
exit $?
elif [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
${BATNAME} --style="${BAT_STYLE:-numbers}" \
--color=always \
--pager=never \
Expand Down
17 changes: 9 additions & 8 deletions doc/fzf-vim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,19 @@ so you can omit it if you use a plugin manager that doesn't support hooks.
*fzf-vim-dependencies*

- {fzf}{1} 0.23.0 or above
- For syntax-highlighted preview, install {bat}{5}
- For syntax-highlighted preview, install {bat}{5} or {clp}{14}
- If {delta}{6} is available, `GF?`, `Commits` and `BCommits` will use it to
format `git diff` output.
- `Ag` requires {The Silver Searcher (ag)}{7}
- `Rg` requires {ripgrep (rg)}{8}
- `Tags` and `Helptags` require Perl

{1} https://github.com/junegunn/fzf
{5} https://github.com/sharkdp/bat
{6} https://github.com/dandavison/delta
{7} https://github.com/ggreer/the_silver_searcher
{8} https://github.com/BurntSushi/ripgrep
{1} https://github.com/junegunn/fzf
{5} https://github.com/sharkdp/bat
{6} https://github.com/dandavison/delta
{7} https://github.com/ggreer/the_silver_searcher
{8} https://github.com/BurntSushi/ripgrep
{14} https://github.com/jpe90/clp


COMMANDS *fzf-vim-commands*
Expand Down Expand Up @@ -272,8 +273,8 @@ Want a preview window?
<
It kind of works, but you probably want a nicer previewer program than `cat`.
fzf.vim ships {a versatile preview script}{12} you can readily use. It
internally executes {bat}{5} for syntax highlighting, so make sure to install
it.
internally executes {clp}{14} or {bat}{5} for syntax highlighting, so make sure to install
one of them.
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)
Expand Down