junegunn / junegunn/fzf.vim

fzf preview not working when set automount in WSL on Windows

Open
#1,265 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Vim Script
Stars
10.3k
Forks
608
Avg merge
5d 8h
Merged PRs (30d)
2

Description

- [x] I have fzf 0.23.0 or above
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (`man fzf`)
- [x] I have searched through the existing issues

Setup
- neovim v0.5.0-dev+1175-g1186f7dd9 through `nvim-qt.exe` (GUI version of neovim)
- Windows 10 build 19042.867
- WSL running Ubuntu 20.04 LTS

When I have an automount set for WSL (to simplified the path from having `/mnt` prefix),

```
File: /etc/wsl.conf
----------------------------------
[automount]
root = /
options = "metadata"
```

fzf preview always complain about cannot find the correct preview script.

```
/bin/bash: /mnt/c/Users//AppData/Local/nvim/plugged/fzf.vim/bin/preview.sh: No such file or directory
```

However, when I apply this patch...

```diff
--- a/autoload/fzf/vim.vim
+++ b/autoload/fzf/vim.vim
@@ -170,7 +170,7 @@ function ! fzf#vim#with_preview(...)
let $WSLENV = 'MSWINHOME/u:'.$WSLENV
endif
let preview_cmd = 'bash '.(is_wsl_bash
- \ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/mnt/\L\1', ''), '\', '/', 'g')
+ \ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/\L\1', ''), '\', '/', 'g')
\ : escape(s:bin.preview, '\'))
else
let preview_cmd = fzf#shellescape(s:bin_preview)
```

I got it working with nothing changed.

I think rather than having fzf.vim figure out if the automount is set automatically, it would be better with a flag set in the configuration instead. This should simplified the change needed in order to have this working. WDYT?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.