misc/importsort-d

README.md in master
Repositories | Summary | Log | Files | README.md

README.md (3069B) download


  1# Sort Imports for [D](https://dlang.org/)
  2
  3`sortimport-d` can sort your dozens of `import`'s in a `.d` file (no matter where)
  4
  5## Installation
  6
  7### Prerequisite
  8
  9- [`dub`](https://dub.pm/)
 10
 11### Building from HEAD
 12
 13Get the repository with `git` and compile everything with `dub`
 14```bash
 15$ git clone https://github.com/friedelschoen/importsort-d
 16$ cd importsort-d
 17$ dub build
 18```
 19
 20If everything went fine, there should be a binary at `bin/importsort-d`.
 21
 22Copy this into a directory included in `$PATH` (`/usr/bin` for example) to make this command work globally.
 23
 24```bash
 25$ sudo cp bin/importsort-d /usr/bin/
 26```
 27
 28or add this into your `.bashrc`, `.zshrc`, etc.
 29```bash
 30export PATH=$PATH:"<path/to/importsort-d>/bin/" # on bash or zsh
 31fish_add_path "<path/to/importsort-d>/bin/"     # on fish-shell
 32```
 33
 34### Building with DUB
 35
 36```bash
 37$ dub fetch importsort-d
 38$ dub run importsort-d -- --help
 39```
 40
 41This won't install the command globally, you always have to run `dub run importsort-d <args>`
 42
 43## Usage
 44
 45see
 46```bash
 47$ importsort-d --help
 48$ dub run importsort-d -- --help
 49```
 50
 51## Documentation
 52
 53Look at the documentation at [`dpldocs.info`](https://importsort-d.dpldocs.info/), if you want to use this project in code.
 54
 55## FAQ
 56
 57### How to add `importsort-d` to Visual Studio Code?
 58> There's a plugin called [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave). You can install it and set `importsort-d` as an onSave-hook: 
 59```json
 60...
 61"emeraldwalk.runonsave": {
 62    "commands": [
 63        {
 64            "cmd": "importsort-d --inplace ${file}",
 65            "match": "\\.d$"
 66        }
 67    ]
 68},
 69...
 70```
 71
 72### How to add `importsort-d` to VIM/NeoVIM?
 73> Just add this to your `.vimrc` or `init.vim`
 74```vim
 75:autocmd BufWritePost * silent !importsort-d --inplace <afile>
 76```
 77
 78### Are cats cool?
 79> Yes
 80
 81## ToDo's
 82
 83- [x] recursive searching (`v0.2.0`)
 84- [x] merge imports (`v0.3.0`)
 85- [ ] watch-mode (struggling with save-timings - can clear files)
 86  - you can add importsort-d into your onSave-hooks
 87- [ ] support multiple imports in one line (demilited by `;`)
 88- [ ] stripping unused imports (maybe)
 89
 90> you got some ideas? Issue them!
 91
 92## Changelog
 93
 94### `v0.1.0`
 95- the very first version
 96- not a lot is implemented
 97
 98### `v0.2.0`
 99- added `--recursive`
100- option `--keep` becomes disabling formatting
101- option `--inline` don't copy the original but creates a `*.new` and renames it afterwards
102- option `--original` becomes `--binding` and sorts by original by default
103- refactoring code
104
105### `v0.3.0`
106- added `--merge`
107
108### `v0.3.1`
109- added documentation for contributers (or people who really want to see my code)
110
111### `v0.3.2`
112- new argument-parsing
113- added `--ignore-case` (_pull-request #2_)
114- already sorted files won't be resorted and added `--force` (_issue #5_)
115- multiple `import` in one line will be split up in multiple lines
116- `--inline` is renamed to `--inplace`
117
118## License
119
120This whole project is licensed under the beautiful terms of the `zlib-license`.
121
122Further information [here](LICENSE).
123
124> made with love and a lot of cat memes