Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/immoh/lein-nsorg
Leiningen plugin for organizing ns form
https://github.com/immoh/lein-nsorg
clojure code-style leiningen ns-forms
Last synced: about 1 month ago
JSON representation
Leiningen plugin for organizing ns form
- Host: GitHub
- URL: https://github.com/immoh/lein-nsorg
- Owner: immoh
- License: epl-1.0
- Created: 2018-03-26T14:31:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-25T17:19:30.000Z (about 5 years ago)
- Last Synced: 2024-12-08T05:25:04.676Z (about 2 months ago)
- Topics: clojure, code-style, leiningen, ns-forms
- Language: Clojure
- Size: 23.4 KB
- Stars: 48
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lein-nsorg
Leiningen plugin for organizing `ns` form in a way that whitespace and comments are preserved.
Rules to apply are fully customizable; the default implementation
* sorts `:require`, `:require-macros`, `:use` and `:use-macros` libspecs alphabetically and removes duplicates
* sorts `:import` class names alphabetically and removes duplicates
* sorts `:exclude`, `:only`, `:refer`, `:refer-macros` and `:rename` options alphabetically and removes duplicatesAlso available as Clojure library [nsorg](https://github.com/immoh/nsorg/)
and command line tool [nsorg-cli](https://github.com/immoh/nsorg-cli/).## Installation
Dependency information:
```clj
[lein-nsorg "0.3.0"]
```## Usage
```
lein nsorg
```Example output:
```
...
in ./src/perf/clojure/clojure/java/perf_jdbc.clj:
These test compare the raw performance (against an in-memory H2 database)
for hand-crafted Java JDBC calls and various `query` and `reducible-query`
calls."
- (:require [criterium.core :as cc]
- [clojure.java.jdbc :as sql])
- (:import (java.sql Connection PreparedStatement ResultSet Statement ResultSetMetaData)))
+ (:require [clojure.java.jdbc :as sql]
+ [criterium.core :as cc])
+ (:import (java.sql Connection PreparedStatement ResultSet ResultSetMetaData Statement)))(defn calibrate []
;; 840ms
...Checked 5 files, found problems in 3 files
```### Paths
Paths to check can be given as arguments to the plugin:
```
lein nsorg src dev/src
```If no locations are given default location is:
* `:source-paths` and `:test-paths` if plugin is run inside Leiningen project
* current directory if plugin is run outside Leiningen project### Ignoring files
You can ignore a specific file or directory by excluding it from command-line:
```
lein nsorg --exclude src/my-project/broken_file.clj --exclude test
```### Apply changes automatically
By default lein-nsorg prints diffs for suggested changes. Changes can be applied automatically to source files with the
following option:```
lein nsorg --replace
```### Interactive mode
Instead of applying changes automatically interactive mode asks for each file if suggestions should be applied or not:
```
lein nsorg --replace --interactive
```## License
Copyright © 2018 Immo Heikkinen
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.