derekwyatt / vim-scala

My work on integration of Scala into Vim - not a ton here, but useful for me.
http://derekwyatt.org
Apache License 2.0
1.09k stars 144 forks source link

Detecting scala script filetype can be quite involved #103

Closed valir closed 9 years ago

valir commented 9 years ago

See the comments inside the committed file for some examples. The scala scripts can start with multiline shebangs. These are needed when the script needs external libraries. These must be given on the classpath argument and the multiline shebangs allow users to specify these libraries.

ches commented 9 years ago

Thanks for your contribution.

Since Scala 2.10 the interpreter has handled the much simpler one-line env scala form. That trivially allows for options like classpath to be passed to scala and is more POSIX standards-friendly than the old multi-line #! / !#, so it probably causes fewer problems for tools like the Emacs complaint on the afore-linked thread. Unless we have a vocal group of users still using Scala 2.9 who want this, I would rather not bother with such complex file detection hoop-jumping and just urge people to use the modern approach. If you need to pass so many options to scala that it becomes cumbersome, it seems like it's probably a case where you should be using the SBT script runner mentioned on #102, building a fat jar as a standalone executable, or similar.

Do you have real-world use cases where the one-line env scala form isn't workable?

ches commented 9 years ago

We should update the current shebang check to allow for options being passed to scala and to match /bin/env in addition to /usr/bin/env, etc.—I'm definitely totally open to those smaller changes.

ches commented 9 years ago

Addressed my last comment, hope that helps a bit!

derekwyatt commented 9 years ago

I'm inclined to agree with @ches. This looks like a decent hack for your local config - i've got a number of them myself - but it's gonna be a little weird for the general case.

The PR is greatly appreciated, though. Thanks.