From 53fe5df6b569ca098f9857446d11b1b3b071536f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ellis=20Keny=C5=91?= Date: Tue, 16 Aug 2022 08:18:29 +0100 Subject: [PATCH] feat(format): add :lang csharp formatter --- modules/lang/csharp/config.el | 5 +++++ modules/lang/csharp/doctor.el | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/modules/lang/csharp/config.el b/modules/lang/csharp/config.el index d68e0a0eb..2a6cf7aa6 100644 --- a/modules/lang/csharp/config.el +++ b/modules/lang/csharp/config.el @@ -3,6 +3,11 @@ (use-package! csharp-mode :hook (csharp-mode . rainbow-delimiters-mode) :config + (when (and (file-exists-p (expand-file-name "~/.dotnet/tools/dotnet-csharpier")) + (file-exists-p ".config/dotnet-tools.json") + (eq 0 (call-process-shell-command + (format "grep -q 'dotnet-csharpier' %s" (expand-file-name ".config/dotnet-tools.json")) nil nil))) + (set-formatter! 'csharpier '("dotnet" "tool" "run" "dotnet-csharpier") :modes '(csharp-mode))) (set-electric! 'csharp-mode :chars '(?\n ?\})) (set-rotate-patterns! 'csharp-mode :symbols '(("public" "protected" "private") diff --git a/modules/lang/csharp/doctor.el b/modules/lang/csharp/doctor.el index e11ceb459..f816be957 100644 --- a/modules/lang/csharp/doctor.el +++ b/modules/lang/csharp/doctor.el @@ -9,3 +9,10 @@ (assert! (or (not (modulep! +tree-sitter)) (modulep! :tools tree-sitter)) "This module requires (:tools tree-sitter)") + +(when (modulep! :editor format) + (unless (and (file-exists-p (expand-file-name "~/.dotnet/tools/dotnet-csharpier")) + (file-exists-p ".config/dotnet-tools.json") + (eq 0 (call-process-shell-command + (format "grep -q 'dotnet-csharpier' %s" (expand-file-name ".config/dotnet-tools.json")) nil nil))) + (warn! "csharpier is not installed or setup as a local tool. Please see the module README. \nOtherwise, formatting will be disabled.")))