dense-analysis / dense-analysis/ale
Add support for IntelliJ IDEA code formatter
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
**Name:** Jetbrains IntelliJ IDEA
**URL:** https://www.jetbrains.com/idea/
IntelliJ IDEA is an IDE for many languages. It's often used e.g. for Java, but supports other languages, too. The installation contains a [command line formatter](https://www.jetbrains.com/help/idea/command-line-formatter.html). There is a script `format.sh` that can be used to format files on the command line. In my opinion, this would be perfect to format Java files because it's often used instead of external code formatters like the currently supported fixers (e.g. `google-java-format`).
When installed with [Jetbrains Toolbox](https://www.jetbrains.com/toolbox/) there is (most likely) a wrapper script `idea` on the path.
## Format
```shell
$ idea format src/main/java/io/reactivex/Maybe.java
IntelliJ IDEA 2019.1.1, build IC-191.6707.61 Formatter
Formatting /home/as/Dev/repository/RxJava/src/main/java/io/reactivex/Maybe.java...OK
1 file(s) formatted.
```
## Help
```shell
$ idea format -h
IntelliJ IDEA 2019.1.1, build IC-191.6707.61 Formatter
Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
-h|-help Show a help message and exit.
-s|-settings A path to Intellij IDEA code style settings .xml file.
-r|-R Scan directories recursively.
-m|-mask A comma-separated list of file masks.
path A path to a file or a directory.
```
# Implementation
The integration for basic usage is straight forward. `idea format` could be the default executable, but should be configured in case the installation is done differently.
## Slow execution
The tricky part is: The formatting of a single file is terribly slow. It takes around 15 seconds for me. I'm not sure if this makes the plugin problematic or unusable. If the implementation works, I'd still use the fixer in cases where I'm using Vim in a java project but don't want to break formatting of a team using Idea as default.
## For comparison
Usage as command.
```sh
autocmd FileType java command! -nargs=0 Format silent exec "!idea format %"
```
Contributor guide
Assessment
This issue has not been assessed yet.