Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use CtrlP in WSL (Windows Subsystem for Linux) #770

Open
eduardoarandah opened this issue May 8, 2019 · 1 comment
Open

How to use CtrlP in WSL (Windows Subsystem for Linux) #770

eduardoarandah opened this issue May 8, 2019 · 1 comment

Comments

@eduardoarandah
Copy link

Hi!

I'm trying to use the new Windows Subsystem for Linux with gvim
(windows 10, ubuntu console)

So far, all works great using this configuration:

set shell=C:\Windows\Sysnative\wsl.exe
set shellpipe=|
set shellredir=>
set shellcmdflag=--
set shellslash

Using that, I can do :!ls or any linux command and it works great.

Problem is, now CtrlP executes user command with wsl.

if you press Ctrl+p, nothing happens

This configuration doesn't work:

    let g:ctrlp_user_command = 'rg --files %s'
    let g:ctrlp_use_caching = 1
    let g:ctrlp_working_path_mode = 'ra'
    let g:ctrlp_switch_buffer = 'et'

BUT WAIT... this other configuration works!!

(all I did was adding any dummy command before, like pwd && )

    let g:ctrlp_user_command = 'pwd && rg --files %s'
    let g:ctrlp_use_caching = 1
    let g:ctrlp_working_path_mode = 'ra'
    let g:ctrlp_switch_buffer = 'et'

I have no idea how to debug that, I tried logging everything with:
gvim -V9vimlog.txt
but it doesn't tell me exactly what is happening when I click Ctrl + P

All I want is GVim to use the linux console in windows for everything, but I can't help myself to debug the commands run by CtrlP,

any ideas?

@eduardoarandah
Copy link
Author

I've managed to list all files properly with this config:

let g:ctrlp_user_command = 'rg --files "`wslpath %s`"'

wslpath converts windows paths into linux paths

BUT when you open a file, it's opened with the "linux" path, so "/mnt/c/users/lalo/file.txt" is opened as "C:/mnt/c/users/lalo/file.txt" which is incorrect.

So...
I guess there's two options:

  1. given that I've changed the shell globally to use linux paths, open results with windows paths, executing wslpath function reversed, to transform it

  2. not use WSL shell with ctrlp, instead of that, use native windows shell, ignoring global shell

A hint with why this config could be working:
let g:ctrlp_user_command = 'pwd && rg --files %s'

MAYBE... pwd is executed with wsl shell and the second command is executed with native windows shell....

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

No branches or pull requests

1 participant