Skip to content

Instantly share code, notes, and snippets.

@euoia
Created January 18, 2013 03:55
Show Gist options
  • Save euoia/4562219 to your computer and use it in GitHub Desktop.
Save euoia/4562219 to your computer and use it in GitHub Desktop.
let s:plugin_root_dir = expand("<sfile>:h")
function JsBeautifySimple () range
let s:plugin_lib_dir = s:plugin_root_dir . "/lib/"
if exists("g:JsBeautifySimple_engine")
let s:engine = g:JsBeautifySimple_engine
else
let s:engine = "node"
endif
echo mode()
return
if executable(s:engine)
if mode()=="v"
echom "vmode"
execute "'<,'>!". s:engine . " " . fnameescape(s:plugin_lib_dir . "/beautify.js") . " -"
else
echom "nvmode"
execute "%!" . s:engine . " " . fnameescape(s:plugin_lib_dir . "/beautify.js") . " -"
endif
else
" Executable bin doesn't exist
echoerr('Unable to run ' . s:engine . '.')
return 1
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment