junegunn / fzf.vim

fzf :heart: vim
MIT License
9.66k stars 584 forks source link

`--height` in FZF_DEFAULT_OPTS is not working in Windows #1329

Closed 3N4N closed 3 years ago

3N4N commented 3 years ago

I know that --height option doesn't work in Windows before v0.21.0, but my version is latest (0.27.2 (e086f0b)), and it works fantastic in powershell. But for some reason it shows error in vim when fzf.vim plugin is being used. I'll try and figure out what's happening in fzf#vim#files functions, but I thought I should open an issue anyway.

By the way, I tried the bare config in your gist. Same result.

The error in neovim:

Error detected while processing function fzf#vim#files[15]..<SNR>32_fzf[1]..<SNR>32_check_requirements:
line   14:
E605: Exception not caught: Failed to run "fzf --version": ['--height option is currently not supported on this platform']
Press ENTER or type command to continue
3N4N commented 3 years ago

Vim works perfectly if I don't set --height 40% in powershell profile. I'm currently working that way. But I'd like to use custom height outside vim (in powershell) as well.

junegunn commented 3 years ago
:echo fzf#exec()
:echo system(fzf#exec() .. ' --version')
3N4N commented 3 years ago

The outputs are respectively:

C:\Users\ACER\AppData\Local\nvim-data\plugged\fzf/bin/fzf
--height option is currently not supported on this platform    " when --height option added in FZF_DEFAULT_OPTS
0.27.2 (e086f0b)       " when --height option NOT added in FZF_DEFAULT_OPTS
junegunn commented 3 years ago

I see. Does this patch (for the main fzf repo) help in your case?

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index d8295df..4190e0e 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -159,7 +159,7 @@ function s:get_version(bin)
   if has_key(s:versions, a:bin)
     return s:versions[a:bin]
   end
-  let command = a:bin . ' --version'
+  let command = a:bin . ' --version --no-height'
   let output = systemlist(command)
   if v:shell_error || empty(output)
     return ''
3N4N commented 3 years ago

@junegunn, sorry for the late reply. I had exams.

Along with your patch, I needed to update the fzf#check_requirements() function in fzf.vim plugin. Not the fzf.vim file in the plugin/ directory of fzf plugin, but this separate plugin for vim.

diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim
index b15f06bfb01e..137dbe8aa9e2 100644
--- a/autoload/fzf/vim.vim
+++ b/autoload/fzf/vim.vim
@@ -72,7 +72,7 @@ function! s:check_requirements()
     throw "fzf#exec function not found. You need to upgrade Vim plugin from the main fzf repository ('junegunn/fzf')"
   endif
   let exec = fzf#exec()
-  let output = split(system(exec . ' --version'), "\n")
+  let output = split(system(exec . ' --version --no-height'), "\n")
   if v:shell_error || empty(output)
     throw 'Failed to run "fzf --version": ' . string(output)
   endif

I don't know why this diff is not being highlighted. But hopefully it's understandable.

junegunn commented 3 years ago

Thanks for the confirmation. It will work as expected if you update both repositories.