orrsella / sbt-sublime

An sbt plugin for generating Sublime Text projects with library dependencies sources
Other
137 stars 9 forks source link

sbt-sublime

An sbt (Simple Build Tool) plugin for generating Sublime Text 2 or 3 project files with library dependencies' sources. See example screenshot.

The main goal of this plugin is to make dependency source files easily available in the project's Sublime window. This enables the ability to simultaneously code and browse all your dependencies' source code, similar to functionality that IntelliJ and other IDEs provide you with. This also means that external library source code plays nice with Sublime's excellent Goto Anything feature. It could also be useful for split editing. Don't remember a method's signature in scala.collection.immutable.List? Just hit CMD+T, enter "List" and the source is right in front of you (the scala-library is always a dependency so you have the entire Scala language code base a click away).

See Functionality and Notes for more details, and this post for some background.

Add Plugin

To add sbt-sublime functionality to your project add the following to your project/plugins.sbt file:

addSbtPlugin("com.orrsella" % "sbt-sublime" % "1.1.2")

If you want to use it for more than one project, you can add it to your global plugins file, usually found at: ~/.sbt/0.13/plugins/plugins.sbt and then have it available for all sbt projects. See Using Plugins for additional information on sbt plugins.

If you'd like to configure the global plugin you'll need to add an sbt file in ~/.sbt/0.13/. In that file you need to import com.orrsella.sbtsublime.SublimePlugin.autoImport._ and then you can configure as normal.

Requirements

Troubleshooting

If you added the plugin globally but still don't have the gen-sublime command available, try:

$ sbt
> reload plugins
> clean
> reload return

Essentially, this enters the project project, cleans it, and returns back to your main project (remember that sbt is recursive – each project/ folder is an sbt project in itself!).

Example

As an example, here's the project file generated for Twitter's bijection project. The first folder, bijection, is the project's root as cloned from GitHub. The External Libraries folder is the generated external sources folder, showing all available dependencies' sources, readily available for you to browse or search (BTW, in case you're wondering, the theme I'm using is the immensely popular Soda Light):

alt text

Usage

To use sbt-sublime, simply enter the gen-sublime command in the sbt console to create the project file. When the command is done, open the new Sublime project created to see your own sources and external library sources.

Functionality

Configuration

The following custom sbt settings are used:

To change any/all of these settings (to these arbitrary alternative values), add the following to your build.sbt file:

sublimeExternalSourceDirectoryName := "ext-lib-src"

sublimeExternalSourceDirectoryParent <<= crossTarget

sublimeTransitive := true

sublimeProjectName := "MySublProjectFile"

sublimeProjectDir := new java.io.File("/Users/orr/Dev/Projects")

sublimeFileExcludePatterns := Seq("*.css")

sublimeFolderExcludePatterns := Seq("backup", "target")

Notes

Feedback

Any comments/suggestions? Let me know what you think – I'd love to hear from you. Send pull requests, issues or contact me: @orrsella and orrsella.com

License

This software is licensed under the Apache 2 license, quoted below.

Copyright (c) 2013 Orr Sella

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.