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

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

Open
jmwatte opened this issue Nov 17, 2022 · 18 comments

Comments

@jmwatte
Copy link

jmwatte commented Nov 17, 2022

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

@vijaymarupudi
Copy link
Owner

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?

@jmwatte
Copy link
Author

jmwatte commented Nov 21, 2022

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>

@vijaymarupudi
Copy link
Owner

Interesting...

What does this output?

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

@jmwatte
Copy link
Author

jmwatte commented Nov 21, 2022

On bash... 48

@vijaymarupudi
Copy link
Owner

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?

@jmwatte
Copy link
Author

jmwatte commented Nov 24, 2022

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

@vijaymarupudi
Copy link
Owner

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)()

@jmwatte
Copy link
Author

jmwatte commented Nov 25, 2022

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...

@vijaymarupudi
Copy link
Owner

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

@jmwatte
Copy link
Author

jmwatte commented Dec 1, 2022

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

@vijaymarupudi
Copy link
Owner

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)()

@yashamon
Copy link

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

@vijaymarupudi
Copy link
Owner

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.

@yashamon
Copy link

yashamon commented Jan 6, 2023

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.

@vijaymarupudi
Copy link
Owner

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.

@yashamon
Copy link

yashamon commented Jan 7, 2023 via email

@vijaymarupudi
Copy link
Owner

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.

@yashamon
Copy link

yashamon commented Jan 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants