Giter VIP home page Giter VIP logo

sbt-scalariform's Introduction

sbt-scalariform

Welcome to sbt-scalariform, an sbt plugin adding support for source code formatting using Scalariform.

Installing sbt-scalariform

sbt-scalariform is a plugin for sbt 0.13 (and 0.12). Please make sure that you are using an appropriate sbt release. In order to download and install sbt, please refer to sbt Getting Started Guide / Setup.

As sbt-scalariform is a plugin for sbt, it is installed like any other sbt plugin, that is by mere configuration. For details about using sbt plugins, please refer to sbt Getting Started Guide / Using Plugins.

Most probably you can skip the details and just add sbt-scalariform to your local plugin definition. Local plugins are defined in a plugins.sbt file in the project/ folder of your project.

To add sbt-scalariform to your build using sbt 0.13, just add the below setting, paying attention to blank lines:

... // Other settings

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")

To add sbt-scalariform to your build using sbt 0.12:

... // Other settings

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.1")

After adding the sbt-scalariform plugin like this, you still have to configure it, i.e. add the relevant settings to your build definition. Please read on ...

Basic configuration

Add the scalariformSettings to your local build definition file build.sbt or scalariform.sbt:

... // Other settings

scalariformSettings

This will add the task scalariformFormat in the scopes compile and test and additionally run this task automatically when compiling; for more control see the section Advanced configuration below

Now you are ready to go. Either start sbt or, if it was already started, reload the current session by executing the reload command. If everything worked, you should have the new command scalariformFormat available as well automatic formatting on compile and test:compile activated.

Using sbt-scalariform

If you added the settings for this plugin like described above, you can either format your sources manually or automatically:

  • Whenever you run the tasks compile or test:compile, your source files will be automatically formatted by Scalariform

  • If you want to start formatting your source files explicitly, just run the task scalariformFormat or test:scalariformFormat

Advanced configuration

sbt-scalariform comes with various configuration options. Changing the formatting preferences and deactivating the automatic formatting on compile are probably the most important ones and described in detail.

You can provide your own formatting preferences for Scalariform via the setting key ScalariformKeys.preferences which expects an instance of IFormattingPreferences. Make sure you import all necessary members from the package scalariform.formatter.preferences. Let's look at an example:

import scalariform.formatter.preferences._

scalariformSettings

ScalariformKeys.preferences := ScalariformKeys.preferences.value
  .setPreference(AlignSingleLineCaseStatements, true)
  .setPreference(DoubleIndentClassDeclaration, true)
  .setPreference(PreserveDanglingCloseParenthesis, true)

If you don't want sbt to automatically format your source files when the tasks compile or test:compile, just add defaultScalariformSettings instead of scalariformSettings to your build definition.

Other useful configuration options are provided by common sbt setting keys:

  • includeFilter in format: Defaults to *.scala
  • excludeFilter in format: Using the default of sbt

Mailing list

Please use the sbt mailing list and prefix the subject with [sbt-scalariform].

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Before we can accept pull requests, you will need to agree to the Typesafe Contributor License Agreement online, using your GitHub account.

License

This code is open source software licensed under the Apache 2.0 License.

sbt-scalariform's People

Contributors

lvicentesanchez avatar myyk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.