Permalink
Browse files

Provide a :Java command

  • Loading branch information...
1 parent 4c9cb03 commit 450a25bbd54ffc7fbe4a5f381d508aa603b2f1e3 @tpope committed Jan 7, 2013
Showing with 14 additions and 1 deletion.
  1. +3 −0 README.markdown
  2. +5 −0 autoload/classpath.vim
  3. +4 −0 doc/classpath.txt
  4. +2 −1 plugin/classpath.vim
View
@@ -7,6 +7,9 @@ Currently, [Maven][] and [Leiningen][] are supported, with a fallback to
`$CLASSPATH` if neither applies. [Open an issue][GitHub issues] if you have
ideas for supporting another project management system.
+Included is a `:Java` command, which executes `java` (or `$JAVA_CMD`) with the
+current buffer's `'path'` as the class path.
+
[Maven]: http://maven.apache.org/
[Leiningen]: https://github.com/technomancy/leiningen
[GitHub issues]: https://github.com/tpope/vim-classpath/issues
View
@@ -130,4 +130,9 @@ function! classpath#detect(...) abort
endif
endfunction
+function! classpath#java_cmd(...)
+ let path = classpath#from_vim(a:0 ? a:1 : &path)
+ return (exists('$JAVA_CMD') ? $JAVA_CMD : 'java') . ' -cp '.shellescape(path)
+endfunction
+
" vim:set et sw=2:
View
@@ -12,4 +12,8 @@ This plugin automatically adjusts 'path' for languages that run on the JVM:
Java, Clojure, Scala, and Groovy. Said path is determined by querying Maven
or Leiningen for the class path. If neither is available, $CLASSPATH is used.
+ *classpath-:Java*
+:Java [args] Execute $JAVA_CMD (default: java) with a class path
+ derived from the current buffer's path.
+
vim:tw=78:et:ft=help:norl:
View
@@ -17,7 +17,8 @@ augroup classpath
\ let &l:path = getbufvar('#', '&path') |
\ else |
\ let &l:path = classpath#detect() |
- \ endif
+ \ endif |
+ \ command! -buffer -nargs=+ -complete=file Java execute '!'.classpath#java_cmd().' '.<q-args>
augroup END
" vim:set et sw=2:

0 comments on commit 450a25b

Please sign in to comment.