From 8842ae52a099f416b078b5e57de57c19ca58dd69 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Sun, 27 Dec 2020 17:38:22 -0700 Subject: [PATCH] kakoune: add dhall-lsp support --- profiles/develop/kakoune/default.nix | 8 ++++++++ profiles/develop/kakoune/lint/dhall.kak | 9 --------- profiles/develop/kakoune/lint/dhall.sh | 13 ------------- profiles/develop/kakoune/lsp/common.kak | 6 +++++- profiles/develop/kakoune/lsp/dhall.kak | 3 +++ 5 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 profiles/develop/kakoune/lint/dhall.kak delete mode 100755 profiles/develop/kakoune/lint/dhall.sh create mode 100644 profiles/develop/kakoune/lsp/dhall.kak diff --git a/profiles/develop/kakoune/default.nix b/profiles/develop/kakoune/default.nix index 458a468..24bfabb 100644 --- a/profiles/develop/kakoune/default.nix +++ b/profiles/develop/kakoune/default.nix @@ -11,9 +11,17 @@ rustup nix-linter dhall + dhall-lsp-server ]; environment.etc = { + "xdg/kak-lsp/kak-lsp.toml".text = '' + ${builtins.readFile "${pkgs.kak-lsp.src}/kak-lsp.toml"} + [language.dhall] + filetypes = ["dhall"] + roots = [".git"] + command = "dhall-lsp-server" + ''; "xdg/kak/kakrc".source = ./kakrc; "xdg/kak/autoload/plugins".source = ./plugins; "xdg/kak/autoload/lint".source = ./lint; diff --git a/profiles/develop/kakoune/lint/dhall.kak b/profiles/develop/kakoune/lint/dhall.kak deleted file mode 100644 index dfd69fa..0000000 --- a/profiles/develop/kakoune/lint/dhall.kak +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100755 index e12113a..0000000 --- a/profiles/develop/kakoune/lint/dhall.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 diff --git a/profiles/develop/kakoune/lsp/common.kak b/profiles/develop/kakoune/lsp/common.kak index 79e1e12..bf9253c 100644 --- a/profiles/develop/kakoune/lsp/common.kak +++ b/profiles/develop/kakoune/lsp/common.kak @@ -1,5 +1,5 @@ eval %sh{kak-lsp --kakoune -s $kak_session} -hook -group lsp global WinSetOption filetype=(elm|rust|c|cpp|python) %{ +hook -group lsp global WinSetOption filetype=(elm|rust|c|cpp|python|dhall) %{ lsp-auto-hover-enable # easily enter lsp mode @@ -7,4 +7,8 @@ hook -group lsp global WinSetOption filetype=(elm|rust|c|cpp|python) %{ set buffer lsp_hover_anchor true set buffer lsp_auto_highlight_references true + + hook buffer BufWritePre .* %{ + lsp-formatting + } } diff --git a/profiles/develop/kakoune/lsp/dhall.kak b/profiles/develop/kakoune/lsp/dhall.kak new file mode 100644 index 0000000..3206482 --- /dev/null +++ b/profiles/develop/kakoune/lsp/dhall.kak @@ -0,0 +1,3 @@ +hook -group lsp global WinSetOption filetype=dhall %{ + lsp-enable-window +}