junegunn / fzf.vim

fzf :heart: vim
MIT License
9.55k stars 583 forks source link

Wrong path scheme on windows #1411

Closed grappas closed 2 years ago

grappas commented 2 years ago

I have recently got back on Windows, fired PlugInstall and all of the sudden I cannot run fzf anymore. Seems like plugin uses slashes in path instead of backslashes. Running neovim 0.7.2 on Windows 11. obraz

junegunn commented 2 years ago

Are you running the latest version of the main repo?

Is this patch included in your copy? https://github.com/junegunn/fzf/commit/728f73528192a24e01f63fed3f4215125543c937

grappas commented 2 years ago

Are you running the latest version of the main repo?

Installed with vim-plug, so yes I think so. obraz obraz

Is this patch included in your copy?

It not seems to be there obraz

junegunn commented 2 years ago

It not seems to be there

Strange. Why git pull is not fetching the latest commits?

https://github.com/junegunn/fzf/commits/master

What does git show-ref HEAD show in plugged/fzf directory?

grappas commented 2 years ago

What does git show-ref HEAD show in plugged/fzf directory?

obraz

junegunn commented 2 years ago

Then you have the latest version. A few questions:

grappas commented 2 years ago

:echo &shell?

obraz

:echo fzf#exec()

obraz

:echo system(fzf#exec() . ' --version')

obraz

:echo system(shellescape(fzf#exec()) . ' --version')

obraz

:echo system('&' . shellescape(fzf#exec()) . ' --version')

obraz

grappas commented 2 years ago

if has('win64') set shell=powershell.exe set shellxquote= let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ' let &shellquote = '' let &shellpipe = '| Out-File -Encoding UTF8 %s' let &shellredir = '| Out-File -Encoding UTF8 %s' endif

in init.vim

junegunn commented 2 years ago

Can you try applying this patch to the main fzf repo and see if it helps?

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 6fada6c..4dd7ece 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -164,7 +164,7 @@ function s:get_version(bin)
   if has_key(s:versions, a:bin)
     return s:versions[a:bin]
   end
-  let command = (&shell == 'powershell' ? '&' : '') . shellescape(a:bin) . ' --version --no-height'
+  let command = (&shell =~ 'powershell' ? '&' : '') . shellescape(a:bin) . ' --version --no-height'
   let output = systemlist(command)
   if v:shell_error || empty(output)
     return ''
grappas commented 2 years ago

Yep - it done the trick.

Have a 🍺 :)

junegunn commented 2 years ago

Thanks for the confirmation, I've pushed to fix to master.