diff --git a/README.md b/README.md index 0bc582c..9152a30 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,13 @@ This plugin gets clipboard content by running the `xclip` command. install `xclip` first. +### For WSL user + +Set your WSL path in .vimrc (you can check your WSL path from Windows File Explorer) +``` +let g:mdip_wsl_path = '\\\\wsl.localhost\\Ubuntu-22.04' +``` + ## Acknowledgements I'm not yet perfect at writing vim plugins but I managed to do it. Thanks to [Karl Yngve LervÄg](https://vi.stackexchange.com/users/21/karl-yngve-lerv%C3%A5g) and [Rich](https://vi.stackexchange.com/users/343/rich) for help on [vi.stackexchange.com](https://vi.stackexchange.com/questions/14114/paste-link-to-image-in-clipboard-when-editing-markdown) where they proposed a solution for my use case. diff --git a/plugin/mdip.vim b/plugin/mdip.vim index 5f61c08..8349a03 100644 --- a/plugin/mdip.vim +++ b/plugin/mdip.vim @@ -31,9 +31,9 @@ function! s:SaveFileTMPWSL(imgdir, tmpname) abort let tmpfile = a:imgdir . '/' . a:tmpname . '.png' let tmpfile = substitute(tmpfile, "\/", "\\\\\\", "g") if tmpfile =~ "mnt" - let tmpfile = substitute(tmpfile, "\\\\\\\\mnt\\\\\\\\c", "C:", "g") + let tmpfile = substitute(tmpfile, '\\\\mnt\\\\\(.\)', '\1:', "g") else - let tmpfile = '\\\\wsl\$\\Ubuntu'.tmpfile + let tmpfile = g:mdip_wsl_path.tmpfile endif let clip_command = 'powershell.exe -nologo -noprofile -noninteractive -sta "Add-Type -Assembly PresentationCore;'. @@ -252,3 +252,7 @@ endif if !exists('g:mdip_imgname') let g:mdip_imgname = 'image' endif + +if !exists('g:mdip_wsl_path') + let g:mdip_wsl_path = '\\\\wsl\$\\Ubuntu' +endif