kakoune: fix nix linting by using nix-linter

This commit is contained in:
Timothy DeHerrera 2020-07-20 18:03:08 -06:00
parent 34f27bd3f3
commit 8d7317bd57
No known key found for this signature in database
GPG key ID: 8985725DB5B0C122
3 changed files with 15 additions and 9 deletions

View file

@ -9,6 +9,7 @@
nixfmt
python3Packages.python-language-server
rustup
nix-linter
];
environment.etc = {

View file

@ -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 .* %{

View 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