vim-gtfo
vim-gtfo copied to clipboard
cannot cmd in current file whose directory starts with r
If I have a file called d:\r\hello.txt
and use got
with let g:gtfo#terminals = { 'win' : 'cmd' }
setting. The cmd opens and closes.
I'm suspecting it has do to something with \r
being a special character.
This seems to open correctly.
!start cmd /k "cd /d "d:/r/hello.txt""
/k
in cmd says to remain in the terminal so it does not exit after the script is complete.
/d
in cd says to change current drive. This would avoid parsing drive letter.
gtfo.vim doesn't know the parameters for the numerous terminals in existence; they need to be provided explicitly. Try this instead:
let g:gtfo#terminals = { 'win' : 'cmd /k' }
That seems to solve it. Would be good if it would be added to readme and doc.
Worked in vim 8 on windows. But that doesn't seem to work on neovim on windows.
Here is what I get.
Yep, there are some problems with shell escaping with Nvim on Windows. Please wait until 0.2. is released before using Nvim on Windows :)
I saw that shell escaping PRs have been merged but when I got the latest master from neovim (https://github.com/neovim/neovim/commit/58d2ce9bdbb6feab7176f451ca0248c78606aa2e) I still see the same issue. I don't see any issues/PRs tagged with platform:windows
. Are there still issues with shell escapes?
I do have set shellslash
setting enabled.
set shellslash
with which 'shell' ?
I see that set shellslash
works in gvim even if the shell is cmd.exe, but that's going to confuse some plugins. That's something that probably should be "fixed" in nvim, but not a high priority. It's counter to the intended purpose of 'shellslash'...
Would be good if it would be added to readme and doc.
https://github.com/justinmk/vim-gtfo#settings does mention that, but I added a note to https://github.com/justinmk/vim-gtfo#platform-support also.
@justinmk I use set shellslash
with cmd to convert \
to /
so c:\windows\system32
looks like c:/windows/system32
. There are lot of plugin that handles this correctly. Even windows by default supports forward slashes.
@prabirshrestha I thought you indicated that it's only a problem in neovim. Is it a gtfo.vim problem, present in vim and neovim? When I checked it did not seem to be a problem with gtfo.vim + gvim.
There are lot of plugin that handles this correctly.
Almost certainly by accident, e.g. they just happen to not send a path constructed by fnamemodify()
to cmd.exe
.
Even windows by default supports forward slashes.
Mostly, yes. Try it with del
and other commands. Hence why Nvim has to continue the silly dance.
In gvim/vim it works correctly on windows with set shellslash
. The problem is only with neovim so I would consider it a bug. Let me know if you would like me to file a bug on neovim to track this.
del a/b.txt
doesn't work because some of windows commands uses /
as separator.
@prabirshrestha If you can come up with a minimal test case a bug report at neovim repo would be most welcome.
@justinmk Here is the minimal vimrc.
" clone in ~/.vimplugins/vim-gtfo
" git clone https://github.com/justinmk/vim-gtfo .vimplugins/vim-gtfo
set nocompatible
syntax on
filetype plugin indent on
if has('win32') || has('win64')
set shellslash
endif
set runtimepath+=~/.vimplugins/vim-gtfo
if has('win32') || has('win64')
let g:gtfo#terminals = { 'win' : 'cmd /k' }
endif
Vim8:
gvim -- -u minimal-vimrc.vim
:e ~/.vimrc
gof
got
gof
and got
works in Vim8. Now try the same in neovim-qt on windows and it fails nvim-qt -- -u minimal-vimrc.vim
. It errors with - The syntax of the command is incorrect.
and doesn't open terminal nor the windows explorer. If I remove set shellslash
it works in neovim.
@justinmk Still doesn't seem to work with latest neovim 2.2/2.3
@justinmk I think I finally figured out the problem.
This code doesn't work. set shell=$COMSPEC
func! s:force_cmdexe() abort
if &shell !~? "cmd" || &shellslash
let s:shell=&shell | let s:shslash=&shellslash | let s:shcmdflag=&shellcmdflag
set shell=$COMSPEC noshellslash shellcmdflag=/c
endif
endf
Changing it to the following code seems to work. exec 'set shell='.$COMSPEC
.
func! s:force_cmdexe() abort
if &shell !~? "cmd" || &shellslash
let s:shell=&shell | let s:shslash=&shellslash | let s:shcmdflag=&shellcmdflag
exec 'set shell='.$COMSPEC
set noshellslash shellcmdflag=/c
endif
endf
Would be possible to update the plugin to use this code in the meantime while we have a proper fix for neovim?