From 2d5471681d1afeb14ac567f6688ba03f53fb88cc Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Wed, 29 Jul 2020 23:39:24 -0600 Subject: [PATCH] kakoune: add dhall lint and format --- hosts/default.nix | 3 ++- profiles/develop/kakoune/default.nix | 1 + profiles/develop/kakoune/lint/dhall.kak | 9 +++++++++ profiles/develop/kakoune/lint/dhall.sh | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 profiles/develop/kakoune/lint/dhall.kak create mode 100755 profiles/develop/kakoune/lint/dhall.sh diff --git a/hosts/default.nix b/hosts/default.nix index c29bfd0a..7ea7e31a 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -39,7 +39,8 @@ let nixpkgs.overlays = [ (final: prev: with unstablePkgs; { - inherit starship element-desktop discord signal-desktop mpv; + inherit starship element-desktop discord signal-desktop mpv + dhall; }) ]; }; diff --git a/profiles/develop/kakoune/default.nix b/profiles/develop/kakoune/default.nix index 24e941ff..a2514f65 100644 --- a/profiles/develop/kakoune/default.nix +++ b/profiles/develop/kakoune/default.nix @@ -10,6 +10,7 @@ python3Packages.python-language-server rustup nix-linter + dhall ]; environment.etc = { diff --git a/profiles/develop/kakoune/lint/dhall.kak b/profiles/develop/kakoune/lint/dhall.kak new file mode 100644 index 00000000..dfd69fa3 --- /dev/null +++ b/profiles/develop/kakoune/lint/dhall.kak @@ -0,0 +1,9 @@ +hook -group lint global WinSetOption filetype=dhall %{ + set buffer lintcmd '/etc/xdg/kak/autoload/lint/dhall.sh $1' + lint-enable + set buffer formatcmd "dhall format" + hook buffer BufWritePre .* %{ + format + lint + } +} diff --git a/profiles/develop/kakoune/lint/dhall.sh b/profiles/develop/kakoune/lint/dhall.sh new file mode 100755 index 00000000..e12113a8 --- /dev/null +++ b/profiles/develop/kakoune/lint/dhall.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +dhall lint --inplace $1 2>&1 | < /dev/stdin > /tmp/lint.out +if head -2 /tmp/lint.out | grep Error &> /dev/null; then + sed -n 4p /tmp/lint.out | tr '\n' ' ' + sed -n 2p /tmp/lint.out | tr 'E' 'e' | tr '\n' ';' \ + | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" + + awk 'NR>7 {printf " %s", $0}' /tmp/lint.out +else + true +fi +rm -f /tmp/lint.out