https://github.com/kuredoro/haisu
Align code on boundaries of commas, braces, (you name it).
https://github.com/kuredoro/haisu
aligner beautifier characters formatter tool
Last synced: about 1 year ago
JSON representation
Align code on boundaries of commas, braces, (you name it).
- Host: GitHub
- URL: https://github.com/kuredoro/haisu
- Owner: kuredoro
- License: bsd-3-clause
- Created: 2020-08-31T18:21:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-01T08:51:58.000Z (over 4 years ago)
- Last Synced: 2025-03-17T21:17:45.916Z (about 1 year ago)
- Topics: aligner, beautifier, characters, formatter, tool
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Haisu : a code aligner
Basically, turn this
```
{ TokenType::ForLoop, 1, 0, "for"}, { TokenType::Identifier, 1, 4, "i" },
{ TokenType::InRange, 1, 6, "in"}, { TokenType::ReverseRange, 1, 9, "reverse" },
{ TokenType::IntegerLiteral, 1, 17, "1" }, { TokenType::TwoDots, 1, 18, ".." },
{ TokenType::IntegerLiteral, 1, 20, "42" }, { TokenType::LoopBegin, 1, 23, "loop" },
{ TokenType::NewLine, 1, 27, "\n" },
```
into this
```
{ TokenType::ForLoop, 1, 0, "for"}, { TokenType::Identifier, 1, 4, "i"},
{ TokenType::InRange, 1, 6, "in"}, {TokenType::ReverseRange, 1, 9, "reverse"},
{TokenType::IntegerLiteral, 1, 17, "1"}, { TokenType::TwoDots, 1, 18, ".."},
{TokenType::IntegerLiteral, 1, 20, "42"}, { TokenType::LoopBegin, 1, 23, "loop"},
{ TokenType::NewLine, 1, 27, "\n"},
```
### Building
```
$ go build .
```
It will produce an executable inside the directory.
### Usage
To make any use of it, you need to supply a set of alignment characters. These characters will be vertically aligned in the output. The program reads lines via `stdin`.
```
$ printf "\t{Line one, two}\n\t{three, four}" | ./haisu "{,}"
{Line one, two}
{ three, four}
```
I have come with this hacky workflow: open a text file in vim, copy needed lines there, then type
```
:!cat file | ./haisu "{}," | xclip -selection clipboard
```
This will copy the transformed lines into the clipboard.