From 058c31edd6a3003b31202616ba5e75cd44a4a440 Mon Sep 17 00:00:00 2001 From: oreodave Date: Tue, 19 Nov 2019 12:19:56 +0000 Subject: +after tags to lazy load OmniSharp testing Unless I need to test something right now, I won't load OmniSharp straight away. As a result, I'll just leave it as a 'on load' option: I intentionally have to turn on OmniSharp-mode myself before I get these testing features. --- doom.d/config.org | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'doom.d') diff --git a/doom.d/config.org b/doom.d/config.org index e1ff721..d40e32b 100644 --- a/doom.d/config.org +++ b/doom.d/config.org @@ -211,32 +211,33 @@ My docsets are stored in .docsets for ease of use ** C# #+BEGIN_SRC elisp (after! csharp-mode - (defun oreodave/csharp/get-unit-test-in-project () - (interactive) - (let* ((tags-file (counsel-etags-locate-tags-file)) - (cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name))) ; void.*Test assumes your tests are using something like XUnit and end with Test - (ivy-read "Choose test: " - cands - :action - (lambda (item) - ;; From the counsel-etags file-open-api function - (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item) - (let* ((file (match-string-no-properties 1 item)) - (linenum (match-string-no-properties 2 item)) - ;; always calculate path relative to TAGS - (default-directory (counsel-etags-tags-file-directory))) - - (when counsel-etags-debug - (message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file)) + (after! omnisharp + (after! counsel-etags + (defun oreodave/csharp/get-unit-test-in-project () + (interactive) + (let* ((tags-file (counsel-etags-locate-tags-file)) + (cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name))) ; void.*Test assumes your tests are using something like XUnit and end with Test + (ivy-read "Choose test: " + cands + :action + (lambda (item) + ;; From the counsel-etags file-open-api function + (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item) + (let* ((file (match-string-no-properties 1 item)) + (linenum (match-string-no-properties 2 item)) + ;; always calculate path relative to TAGS + (default-directory (counsel-etags-tags-file-directory))) - (counsel-etags-push-marker-stack (point-marker)) - (find-file file) - (counsel-etags-forward-line linenum) - (omnisharp-unit-test-at-point)) - )) - :caller 'oreodave/csharp/get-unit-tests-in-project))) + (when counsel-etags-debug + (message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file)) - (setq omnisharp-server-executable-path "~/bin/omnisharp/run") + (counsel-etags-push-marker-stack (point-marker)) + (find-file file) + (counsel-etags-forward-line linenum) + (omnisharp-unit-test-at-point)) + )) + :caller 'oreodave/csharp/get-unit-tests-in-project)))) + (setq omnisharp-server-executable-path "~/bin/omnisharp/run")) (add-hook 'csharp-mode-hook '(lambda() (setq c-basic-offset 4) -- cgit v1.2.3-13-gbd6f