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

Windows NodeJS + Cygwin Vim #63

Closed
davidfmatheson opened this issue Aug 21, 2014 · 3 comments
Closed

Windows NodeJS + Cygwin Vim #63

davidfmatheson opened this issue Aug 21, 2014 · 3 comments
Labels

Comments

@davidfmatheson
Copy link

Not sure how many people fall into this bucket, but I had some trouble getting this to work in Cygwin because the Windows node.exe doesn't like the paths. I stuck some lines in

~/.vim/bundle/vim-jsbeautify/plugin/beautifier.vim (starting after line 403)

let beautify_absolute_path_windows = fnameescape(system("cygpath -w ".s:plugin_Root_directory."/beautify.min.js"))
let tmp_file_Beautifier_arg_windows = fnameescape(system("cygpath -w ".tmp_file_Beautifier_arg))
let path_Beautifier_arg_windows = fnameescape(system("cygpath -w ".path_Beautifier_arg))

let result = system(engine." ".beautify_absolute_path_windows." --js_arguments ".tmp_file_Beautifier_arg_windows." ".opts_Beautifier_arg." ".path_Beautifier_arg_windows)

That worked for me. Not sure how to test within the script if this is the scenario, but just in case there's some other Cygwin Vim user with the Windows NodeJS, there you go.

@maksimr
Copy link
Owner

maksimr commented Aug 21, 2014

@davidfmatheson Thanks!
Can you make pull request with this fix for window(using has("win32") and executable("cygpath") for checking)?

@matthewbednarski
Copy link
Contributor

I needed to get this to work as well. I'm adding this comment for the next guy who loses a few hours trying to get this to work and finds this issue. The key is the if has("win32unix")....

First, just to get node to work with cygwin you need to add an alias for node (and npm while you're at it). So in ~/.bashrc, ~/.zshrc or ~/.bash_aliases:

alias node='/cygdrive/c/Program\ Files/nodejs/node'
alias npm='/cygdrive/c/Program\ Files/nodejs/npm'

Then in vim-jsbeautify/plugins/jsbeautifier.vim beginning at the line 403 modify the conditional which resolves result to the following:

  let opts_Beautifier_arg = s:toJSON(string(opts))
  let path_Beautifier_arg = s:quote(path)
  let tmp_file_Beautifier_arg = s:quote(g:tmp_file_Beautifier)

  if has("win32unix")  && executable("cygpath")
    let beautify_absolute_path_windows = fnameescape(system("cygpath -w ".s:plugin_Root_directory."/beautify.js"))
    let tmp_file_Beautifier_arg_windows = fnameescape(system("cygpath -w ".tmp_file_Beautifier_arg))
    let path_Beautifier_arg_windows = fnameescape(system("cygpath -w ".path_Beautifier_arg))

    let result = system(engine." ".beautify_absolute_path_windows." --js_arguments ".tmp_file_Beautifier_arg_windows." ".opts_Beautifier_arg." ".path_Beautifier_arg_windows)
  elseif executable(engine)
    let result = system(engine." ".fnameescape(s:plugin_Root_directory."/beautify.min.js")." --js_arguments ".tmp_file_Beautifier_arg." ".opts_Beautifier_arg." ".path_Beautifier_arg)
  else
    " Executable bin doesn't exist
    call ErrorMsg('The '.engine.' is not executable!')
    return 1
  endif

@maksimr
Copy link
Owner

maksimr commented Jun 10, 2015

@matthewbednarski Thanks! How about PR which fix this issue?

matthewbednarski added a commit to matthewbednarski/vim-jsbeautify that referenced this issue Jun 10, 2015
maksimr added a commit that referenced this issue Jun 11, 2015
Fixes issue #63 - Windows NodeJS + Cygwin Vim
@maksimr maksimr closed this as completed Jun 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants