forked from pub-solar/os
kakoune: fix nix linting by using nix-linter
This commit is contained in:
parent
34f27bd3f3
commit
8d7317bd57
|
@ -9,6 +9,7 @@
|
|||
nixfmt
|
||||
python3Packages.python-language-server
|
||||
rustup
|
||||
nix-linter
|
||||
];
|
||||
|
||||
environment.etc = {
|
||||
|
|
|
@ -2,15 +2,7 @@ hook -group lint global WinSetOption filetype=nix %{
|
|||
# remove '' for nix, annoying for string literals
|
||||
set buffer auto_pairs ( ) { } [ ] '"' '"' ` `
|
||||
|
||||
set buffer lintcmd '
|
||||
run () {
|
||||
nix-instantiate --parse $1 2>&1 >&- > /dev/null |
|
||||
awk ''
|
||||
{printf $NF ":" " "}
|
||||
!($NF="") !($(NF-1)="") {sub(/, $/, "")}1
|
||||
''
|
||||
} && run \
|
||||
'
|
||||
set buffer lintcmd '/etc/xdg/kak/autoload/lint/nix.sh $1'
|
||||
lint-enable
|
||||
set buffer formatcmd "nixfmt"
|
||||
hook buffer BufWritePre .* %{
|
||||
|
|
13
profiles/develop/kakoune/lint/nix.sh
Executable file
13
profiles/develop/kakoune/lint/nix.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
nix-linter $1 2>&1 | < /dev/stdin > /tmp/lint.out
|
||||
if head -1 /tmp/lint.out | grep Failure &> /dev/null; then
|
||||
sed -n 2p /tmp/lint.out | tr '\n' ' '
|
||||
printf "error: "
|
||||
awk 'NR>5 {printf "%s; ", $0}' /tmp/lint.out
|
||||
else
|
||||
awk '{$(NF-1)=""; print $NF ": warning: " $0}' /tmp/lint.out > /tmp/lint.2
|
||||
awk '{$NF="";gsub(/-[0-9]*:[0-9]*:*/, ":"); print $0}' /tmp/lint.2
|
||||
fi
|
||||
rm -f /tmp/lint.out
|
||||
rm -f /tmp/lint.2
|
Loading…
Reference in a new issue