+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.
This commit is contained in:
oreodave
2019-11-19 12:19:56 +00:00
parent 8715fb0762
commit 058c31edd6

View File

@@ -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)))
(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)))
(when counsel-etags-debug
(message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file))
(when counsel-etags-debug
(message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file))
(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")
(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)