nvim-fzf-commands icon indicating copy to clipboard operation
nvim-fzf-commands copied to clipboard

require("fzf-commands").files() ... stops on ... --line-range=:$(($FZF_PREVIEW_LINES

Open jmwatte opened this issue 2 years ago • 18 comments

I'm on windows 11.

got a keymap vim.keymap.set('n','<leader>xx',function () require("fzf-commands").files() end) when I run it the floating window pops up and leaves in a blink. the message at the topline reads ... unknown option--line-range=:$(($FZF_PREVIEW_LINES Bash and bat are on the system ... Any ideas ? thx

jmwatte avatar Nov 17 '22 21:11 jmwatte

It doesn't look like your bash is interpreting the inline math operators... Not sure why. Is this bash emulation or the real bash itself?

vijaymarupudi avatar Nov 19 '22 13:11 vijaymarupudi

on Pwsh ... ⮞ bash --version GNU bash, version 5.1.16(1)-release (x86_64-pc-msys) Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

jmwatte avatar Nov 21 '22 13:11 jmwatte

Interesting...

What does this output?

A=45
echo $(($A + 3))

vijaymarupudi avatar Nov 21 '22 19:11 vijaymarupudi

On bash... 48

jmwatte avatar Nov 21 '22 21:11 jmwatte

Just pushed a commit, it's possible that the preview command wasn't being run by bash. Perhaps it isn't the default shell. Could you try it now?

vijaymarupudi avatar Nov 23 '22 15:11 vijaymarupudi

on windows and nvim nightly only plugins ...

use 'junegunn/fzf' use 'vijaymarupudi/nvim-fzf' use 'vijaymarupudi/nvim-fzf-commands'

and only this command ...

vim.keymap.set('n', '<leader>f', '<cmd>lua require("fzf-commands").files()<cr>',{desc= "files"})

preview pops up in a blink and says

unknown option : -c

jmwatte avatar Nov 24 '22 09:11 jmwatte

That's pretty odd, it looks like bash, when run using fzf, is not bash. Could you try running this snippet?

local fzf = require('fzf')

coroutine.wrap(function() print(fzf.fzf({"1", "2", "3"}, "--preview 'bash -c \"echo testing\"'")) end)()

vijaymarupudi avatar Nov 25 '22 14:11 vijaymarupudi

the ZFZ_window pops up, I can read ...

unknow option -c

and there is output

nil 2

don't know if this helps... I have also tried this. Maybe it helps to shed some light. I have set up these...

vim.env.BAT_STYLE="numbers,changes"

vim.env.FZF_DEFAULT_OPTS=[[--no-mouse --layout=default --preview-window=hidden:border-left --margin=0 --padding=1 --pointer=⏵ --marker=+ --info=inline --tabstop=4 --no-bold --bind=f2:toggle-preview,f3:toggle-preview-wrap,shift-down:preview-down,shift-up:preview-up,ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-f:page-down,ctrl-b:page-up,ctrl-a:toggle-all,ctrl-l:clear-query,ctrl-s:toggle-sort]]

vim.env.FZF_DEFAULT_COMMAND=[[rg --files --no-ignore --hidden --follow --glob "!.git/*" --color=auto]]

vim.env.FZF_PREVIEW_COMMAND=[[bat --decorations=always --paging=never --italic-text=never --color=always --theme=ansi --wrap=never {}]]

and when I call ...

FZF --preview

I get the window and all works but when I toggle the preview to see it, I get ...

'--expect' is not recognized as an internal or ex

The plot thickens...

jmwatte avatar Nov 25 '22 16:11 jmwatte

I think this is conflating fzf's default vim support with nvim-fzf. The command you're running is for the plugin from fzf.

vijaymarupudi avatar Nov 26 '22 15:11 vijaymarupudi

Yes, I know. It was just some extra information. The original command still gives the same problem. unknown option -c

jmwatte avatar Dec 01 '22 22:12 jmwatte

Got it.

I think this should help diagnose the problem. Can you post what is being displayed in the preview window?

local fzf = require('fzf')

coroutine.wrap(function() print(fzf.fzf({"1", "2", "3"}, "--preview 'bash --version'")) end)()

vijaymarupudi avatar Dec 02 '22 14:12 vijaymarupudi

I have the same problem loading the lua snippet above gives: unknown option --version

yashamon avatar Dec 26 '22 23:12 yashamon

It's not clear to me why the subshell that fzf spawns to execute the preview command does not execute bash. Since I do not have a Windows computer, I'm not quite sure what's happening here. Step 1 would be to figure out what the environment in that subshell, and what shell that is.

vijaymarupudi avatar Jan 05 '23 23:01 vijaymarupudi

By the way is there a reason to use Bash at all? The preview in Telescope and bqf seems to be neovim native. The bqf code in particular looks simple enough.

yashamon avatar Jan 06 '23 17:01 yashamon

bash is needed as fzf launches a shell for the preview, and nvim-fzf is about using fzf for its speed. The shell part is to calculate the number of lines for bat to show, so that there won't be a scrollbar and so that bat won't read the entire file, which can take a very long time if the file is large.

vijaymarupudi avatar Jan 07 '23 15:01 vijaymarupudi

On Sat, Jan 7, 2023, 09:21 Vijay Marupudi @.***> wrote:

fzf launches a shell for the preview,

But this is for compatibility with vim. In neovim there are native methods to get preview. I don't know exactly how, but telescope and bqf launch native preview. This has advantage of TS based highlighting, speed etc.

— Reply to this email directly, view it on GitHub https://github.com/vijaymarupudi/nvim-fzf-commands/issues/6#issuecomment-1374514075, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQGIZQVBHJUWDYGG4G3N7TWRGCXRANCNFSM6AAAAAASD2BHG4 . You are receiving this because you commented.Message ID: @.***>

yashamon avatar Jan 07 '23 18:01 yashamon

That's not for compatibility with vim, that's just what fzf does with the --preview argument. You can use nvim for previewing items with nvim-fzf, but that involves running a new neovim instance that communicates with the main instance using the shell command and a named pipe. Either way, there's not getting away from shell commands.

In the case of this, we're using an external command, bat. Shell commands are the way to get fzf to preview using an external command.

vijaymarupudi avatar Jan 09 '23 15:01 vijaymarupudi

that makes sense.

On Mon, Jan 9, 2023, 09:58 Vijay Marupudi @.***> wrote:

That's not for compatibility with vim, that's just what fzf does with the --preview argument. You can use nvim for previewing items with nvim-fzf, but that involves running a new neovim instance that communicates with the main instance using the shell command and a named pipe. Either way, there's not getting away from shell commands.

In the case of this, we're using an external command, bat. Shell commands are the way to get fzf to preview using an external command.

— Reply to this email directly, view it on GitHub https://github.com/vijaymarupudi/nvim-fzf-commands/issues/6#issuecomment-1375851431, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQGIZT5R2RZXM5E3MJKJDDWRQYRFANCNFSM6AAAAAASD2BHG4 . You are receiving this because you commented.Message ID: @.***>

yashamon avatar Jan 09 '23 17:01 yashamon