Skip to content

Commit 0535442

Browse files
authored
feat: add alejandra (#56)
1 parent add3cf3 commit 0535442

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Formatters
88

99
- `lsp` using `vim.lsp.buf.format`
10+
- [x] [alejandra](https://github.com/kamadorueda/alejandra)
1011
- [x] [autopep8](https://github.com/hhatto/autopep8)
1112
- [x] [black](https://github.com/psf/black)
1213
- [x] [biome](https://biomejs.dev)

lua/guard-collection/formatter.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ M.lsp = {
66
end,
77
}
88

9+
M.alejandra = {
10+
cmd = 'alejandra',
11+
args = { '--quiet' },
12+
stdin = true,
13+
}
14+
915
M.autopep8 = {
1016
cmd = 'autopep8',
1117
args = { '-' },

test/formatter/alejandra_spec.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('alejandra', function()
2+
it('can format', function()
3+
-- pre-test setup
4+
local ft = require('guard.filetype')
5+
ft('nix'):fmt('alejandra')
6+
-- Giving example input to the helper
7+
-- the helper creates a new buffer with it, formats, and returns the formatted output
8+
local formatted = require('test.formatter.helper').test_with('nix', {
9+
-- The input code should somewhat reflect the filetype
10+
[[{inputs={nixpkgs.url="github:NixOS/nixpkgs/nixos-unstable";};}]]
11+
})
12+
-- Show that the input is indeed formatted as intended
13+
assert.are.same({
14+
[[{inputs = {nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";};}]]
15+
}, formatted)
16+
end)
17+
end)

test/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ bin="$HOME/.local/bin"
1818
gh="https://github.com"
1919
mkdir -p $bin
2020

21+
# alejandra
22+
wget -q $gh"/kamadorueda/alejandra/releases/download/4.0.0/alejandra-x86_64-unknown-linux-musl"
23+
mv ./alejandra-x86_64-unknown-linux-musl $bin/alejandra
24+
chmod +x $bin/alejandra
25+
2126
# cbfmt
2227
wget -q $gh"/lukas-reineke/cbfmt/releases/download/v0.2.0/cbfmt_linux-x86_64_v0.2.0.tar.gz"
2328
tar -xvf cbfmt_linux-x86_64_v0.2.0.tar.gz

0 commit comments

Comments
 (0)