Skip to content

Split WSL path handling from g:previm_wsl_mode for wslview support #244

Description

@kyoh86

Background

g:previm_wsl_mode = 1 currently controls multiple WSL-specific behaviors at once.

In particular, when :PrevimOpen is executed with g:previm_open_cmd set, Previm converts the preview HTML path with wslpath -w and passes it as a Windows-style file:///C:/... URL.

This works for users who directly invoke a Windows browser executable from WSL, but it does not work well with wslview.

Problem

When using wslview, the preview HTML path should be passed as a WSL path and wslview should handle the conversion for the Windows application.

The current behavior effectively forces users to configure a Windows browser command or executable path when g:previm_wsl_mode = 1, because Previm always converts the preview path with wslpath -w.

For example, this kind of configuration is awkward or broken with wslview:

let g:previm_wsl_mode = 1
let g:previm_open_cmd = 'wslview'

Previm converts the path first, and then wslview or Windows may interpret it as an unintended path.

Proposal

Keep g:previm_wsl_mode for compatibility, but split the path format passed to g:previm_open_cmd into a separate option.

For example:

let g:previm_wsl_mode = 1

" default: 'windows'
let g:previm_wsl_open_path_format = 'windows'

Supported values:

  • windows: current behavior. Convert the preview HTML path with wslpath -w and pass it as a Windows file:///... URL.
  • wsl: pass the preview HTML path as a WSL path without converting it through wslpath -w.

Keeping the default equivalent to the current behavior preserves existing user configurations.

Example configurations

Existing usage that directly invokes a Windows browser executable:

let g:previm_wsl_mode = 1
let g:previm_open_cmd = '/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe'
" g:previm_wsl_open_path_format defaults to 'windows'

Usage with wslview:

let g:previm_wsl_mode = 1
let g:previm_open_cmd = 'wslview'
let g:previm_wsl_open_path_format = 'wsl'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions