romainl / vim-devdocs

Look up keyword on https://devdocs.io from Vim
MIT License
62 stars 3 forks source link

Plugin doesn't work on Windows #7

Closed romainl closed 3 years ago

romainl commented 3 years ago

Your devdocs kinda has issues with windows:

screenshot

If I copy the url from the cmd.exe: https://devdocs.io/#q=gdscript%20get_children it works for me, directly pasting to the browser but :DD just hangs with this cmd.exe opened

@habamax

romainl commented 3 years ago

This is vanilla GVim 8.1 in an almost vanilla (changed the language, installed the VirtualBox extensions, installed Vim a couple years ago) Windows 10 VM, after:

:source https://raw.githubusercontent.com/romainl/vim-devdocs/master/plugin/devdocs.vim
:set keywordprg=:DD

and:

:setf javascript
K on map

dd

and:

:setf godot (or :setf gdscript since it is an alias of Godot in DevDocs)
K on get_children

dd2

habamax commented 3 years ago

vim-devdocs-issue

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 13 2021 22:02:34)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-2850
Compiled by appveyor@APPVYR-WIN
Huge version with GUI.  Features included (+) or not (-):
+acl                +cscope             -hangul_input       +multi_byte_ime/dyn +scrollbind         +title
+arabic             +cursorbind         +iconv/dyn          +multi_lang         +signs              +toolbar
+autocmd            +cursorshape        +insert_expand      +mzscheme/dyn       +smartindent        +user_commands
+autochdir          +dialog_con_gui     +ipv6               +netbeans_intg      +sound              +vartabs
+autoservername     +diff               +job                +num64              +spell              +vertsplit
+balloon_eval       +digraphs           +jumplist           +ole                +startuptime        +virtualedit
-balloon_eval_term  +directx            +keymap             +packages           +statusline         +visual
+browse             -dnd                +lambda             +path_extra         -sun_workshop       +visualextra
++builtin_terms     -ebcdic             +langmap            +perl/dyn           +syntax             +viminfo
+byte_offset        +emacs_tags         +libcall            +persistent_undo    +tag_binary         +vreplace
+channel            +eval               +linebreak          +popupwin           -tag_old_static     -vtp
+cindent            +ex_extra           +lispindent         -postscript         -tag_any_white      +wildignore
+clientserver       +extra_search       +listcmds           +printer            +tcl/dyn            +wildmenu
+clipboard          -farsi              +localmap           +profile            -termguicolors      +windows
+cmdline_compl      +file_in_path       +lua/dyn            +python/dyn         +terminal           +writebackup
+cmdline_hist       +find_in_path       +menu               +python3/dyn        -termresponse       -xfontset
+cmdline_info       +float              +mksession          +quickfix           +textobjects        -xim
+comments           +folding            +modify_fname       +reltime            +textprop           +xpm_w32
+conceal            -footer             +mouse              +rightleft          -tgetent            -xterm_save
+cryptv             +gettext/dyn        +mouseshape         +ruby/dyn           +timers             
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
    system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /GF /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_SOUND -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL -DFEAT_IPV6   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /source-charset:utf-8 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_MSWIN -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python39.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DRUBY_VERSION=24 -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /Zi
Linking: link  /nologo /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:AMD64  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python39.lib   "C:\Tcl\lib\tclstub86.lib" winmm.lib WSock32.lib Ws2_32.lib xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug
habamax commented 3 years ago

This line is being executed:

C:\WINDOWS\system32\cmd.exe /c (^(cmd.exe /c start /b ^"https://devdocs.io/#q=gdscript%20get_children^"^) ^>C:\Users\maksim.kim\AppData\Local\Temp\VF35528.tmp 2^>^&1)  

see double cmd.exe /c there

romainl commented 3 years ago

Where did you get that Vim build? I will try with the same.

habamax commented 3 years ago
" works
call system("cmd.exe /c start /b https://devdocs.io/#q=gdscript%20get_children")
call system("start /b https://devdocs.io/#q=gdscript%20get_children")

" doesn't work (parse error)
call system("cmd.exe /c start /b 'https://devdocs.io/#q=gdscript%20get_children'")

" doesn't work (hangs)
call system('cmd.exe /c start /b "https://devdocs.io/#q=gdscript%20get_children"')

" whenever there is " -- it is shellescaped with (^ and stuff -- and doesnt' work...
C:\WINDOWS\system32\cmd.exe /c (^(cmd.exe /c start /b ^"https://devdocs.io/#q=gdscript%20get_children^"^) ^>C:\Users\maksim.kim\AppData\Local\Temp\VF35528.tmp 2^>^&1)  
habamax commented 3 years ago

Where did you get that Vim build? I will try with the same.

it is "official" nightly https://github.com/vim/vim-win32-installer/releases

romainl commented 3 years ago

I can reproduce with GVim started form PowerShell or Cmd: same issue with both.

GVim started from an icon doesn't have that issue.

My guess: something is set in those cases that is added to the executed command.

That said, it eventually stops hanging.

habamax commented 3 years ago

I can reproduce with GVim started form PowerShell or Cmd: same issue with both.

GVim started from an icon doesn't have that issue.

My guess: something is set in those cases that is added to the executed command.

I have it with gvim started from start panel...

habamax commented 3 years ago

Also

this works too -- when I have quotes and directly call a browser:

call system('start /b brave "https://devdocs.io/#q=gdscript%20get_children"')
call system('start /b chromium "https://devdocs.io/#q=gdscript%20get_children"')

So my guess, start doesn't understand escaped ^"https://... as url to call default browser (as it does when there is no ")

habamax commented 3 years ago

second answer to this SO question might be useful: https://stackoverflow.com/questions/3739327/launching-a-website-via-windows-commandline

explorer "https://google.com"

will launch default browser, and this:

call system('start /b explorer "https://devdocs.io/#q=gdscript%20get_children"')

works for me -- opens url in quotes with my brave browser.

habamax commented 3 years ago

so this works for windows:

image

Let me check WSL...

habamax commented 3 years ago

you gotta be kidding me... your as-is solution works for WSL but `explorer' one doesn't.

So another if probably should be added:

" What command to use
function! s:Cmd() abort
    " Windows WSL
    if exists("$WSLENV")
        return "cmd.exe /c start /b"
    " Windows
    elseif executable('cmd.exe')
        return "start /b explorer"
    " Linux/BSD
    elseif executable("xdg-open")
        return "xdg-open"
    " MacOS
    elseif executable("open")
        return "open"
    endif
endfunction

Works for me both with WSL and regular windows vim

romainl commented 3 years ago

OK, your last snippet works for me too. Thank you.