show line numbers in errors
RonnyPfannschmidt opened this issue · comments
Ronny Pfannschmidt commented
when a error is encountered, instead of line number/column, character since start of file is shown
that makes it hard o figure where a mistake was
instead of
`Failed! 1 error found at:
- flake.nix: unexpected TOKEN_ASSIGN at 3344..3435, wanted any of [TOKEN_SEMICOLON]
Checking style in 5 files using 4 threads.``
id like to see
flake.nix: unexpected TOKEN_ASSIGN at line 124: 30-31, wanted any of [TOKEN_SEMICOLON]
Checking style in 5 files using 4 threads.``
a smaller example would be
#example.nix
{pkgs, lib}: {
mypkg = lib.test;
mypkg2 = lib.test2
mistake = {};
}
with an error of
/mistake.nix: unexpected TOKEN_ASSIGN at 80..92, wanted any of [TOKEN_SEMICOLON]
Checking style in 5 files using 4 threads.
im using alejandra via home manager vscode plugin and nix-pre-commit
Kevin Amado commented
I just opened: #365
With this Alejandra would do the following:
[kamadorueda@machine:/data/alejandra]$ cat -n test.nix
1 {pkgs, lib}: {
2 mypkg = lib.test;
3 mypkg2 = lib.test2
4 mistake = {};
5 }
[kamadorueda@machine:/data/alejandra]$ cargo run test.nix
Finished dev [optimized + debuginfo] target(s) in 0.03s
Running `target/debug/alejandra test.nix`
Checking style in 1 file using 4 threads.
Failed! 1 error found at:
- test.nix: syntax error, unexpected '='. Starts at line 4 column 11, ends at line 4 column 12
[kamadorueda@machine:/data/alejandra]$ nix-instantiate --parse test.nix
error: syntax error, unexpected '=', expecting ';'
at /data/alejandra/test.nix:4:11:
3| mypkg2 = lib.test2
4| mistake = {};
| ^
5| }
Will have to wait some time until it compiles on the different platforms though