8000 add previm_wsl_mode by hirano00o · Pull Request #135 · previm/previm · GitHub
[go: up one dir, main page]

Skip to content

add previm_wsl_mode#135

Merged
mattn merged 1 commit intoprevim:masterfrom
hirano00o:add-wsl-mode
Nov 7, 2019
Merged

add previm_wsl_mode#135
mattn merged 1 commit intoprevim:masterfrom
hirano00o:add-wsl-mode

Conversation

@hirano00o
Copy link
Contributor

Windows Subsystem for Linux(WSL)に対応するためのモードです。

.vimrc にて、let g:previm_wsl_mode = 1 と指定することで、WSL上のLinuxから g:previm_open_cmd で指定したブラウザで開くことができます。

example

let g:previm_open_cmd = '/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe'
let g:previm_wsl_mode = 1

詳細

WSL上で実行される a:preview_html_file は、Linuxと同様に /home/hirano00o/.vim/.../index.html となり、Windowsから見えるパスとは異なります。
WSL <-> Windows のパス変換をするために、wslpath を利用します。
wslpath は、WSL では標準で利用できます。

この wslpath を利用し、g:previm_wsl_mode = 1 のときは、
wslpath -w a:preview_html_file
を実行し、
/home/hirano00o/.vim.../index.html -> \\wsl$\Ubuntu\home\hirano00o/.vim/.../index.html
と変換してWindowsのブラウザへ渡すことで、表示することが可能です。

g:previm_wsl_mode が、1 以外、または.vimrcで指定されていない場合は、elseifをスルーします。

@lambdalisue lambdalisue requested a review from mattn November 7, 2019 08:02
@mattn mattn merged commit e748e98 into previm:master Nov 7, 2019
@mattn
Copy link
Member
mattn commented Nov 7, 2019

Thank you

Copy link
Member
@mattn mattn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

2 participants

0