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 nixfmt
python3Packages.python-language-server python3Packages.python-language-server
rustup rustup
nix-linter
]; ];
environment.etc = { environment.etc = {

View File

@ -2,15 +2,7 @@ hook -group lint global WinSetOption filetype=nix %{
# remove '' for nix, annoying for string literals # remove '' for nix, annoying for string literals
set buffer auto_pairs ( ) { } [ ] '"' '"' ` ` set buffer auto_pairs ( ) { } [ ] '"' '"' ` `
set buffer lintcmd ' set buffer lintcmd '/etc/xdg/kak/autoload/lint/nix.sh $1'
run () {
nix-instantiate --parse $1 2>&1 >&- > /dev/null |
awk ''
{printf $NF ":" " "}
!($NF="") !($(NF-1)="") {sub(/, $/, "")}1
''
} && run \
'
lint-enable lint-enable
set buffer formatcmd "nixfmt" set buffer formatcmd "nixfmt"
hook buffer BufWritePre .* %{ 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