GithubHelp home page GithubHelp logo

pl-clojure-style's Introduction

pl-clojure-style

Centralized clojure style settings for puppetlabs projects

Usage

This is meant to be used from source as a parent project using lein-parent. Check this out next to the project you want to format. Merge into your project.clj:

  :profiles {:cljfmt {:plugins [[lein-cljfmt "0.3.0"]
                                [lein-parent "0.2.1"]]
                      :parent-project {:path "../pl-clojure-style/project.clj"
                                       :inherit [:cljfmt]}}}
  :aliases {"cljfmt" ["with-profile" "+cljfmt" "cljfmt"]}

Using a profile makes it possible to run normal lein commands without having this repository present.

Then run

lein cljfmt check

to get a report of the formatting issues, and

lein cljfmt fix

to fix the formatting.

Both of these commands take an optional argument of a file path, to check or fix a specific file.

For more information, see the documentation for cljfmt, the library this uses.

Other style considerations

There are a few things that aren't automatically enforced by cljfmt.

Line length

Not a hard rule, but try to keep it under 80 characters.

Aligning values in maps and lets

Don't.

Good:

{:key "some stuff"
 :another_much_longer_key "other stuff"}

Bad:

{:key                     "some stuff"
 :another_much_longer_key "other stuff"}

Editor specific settings

Vim

Add the settings from indents.vim to your .vimrc.

Emacs

Add the settings from indents.el to your emacs configuration.

Cursive Clojure in IntelliJ

You should set the general indentation settings as shown:

IntelliJerks

To set indentation parameters for custom macros, place the cursor on a call to the macro, and wait for the light-bulb icon to appear. Click it and then click on "Configure Indentation parameters":

IntelliJerks2

After that your custom form should appear in the 'Form Parameters' settings, so you can modify the indentation rules there if you choose:

IntelliJerks3

Also... it's possible to export these settings from Cursive as a jar file that others can import. Once we get some mileage on this stuff, we should probably do that and include the jar here.

pl-clojure-style's People

Contributors

justinstoller avatar pcarlisle avatar rlinehan avatar scottyw 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.