~removed lsp and better docs for oreodave/csharp/get-unit-test

This commit is contained in:
oreodave
2019-11-24 16:41:41 +00:00
parent 5102d03bdd
commit ebeb79cb5e
3 changed files with 38 additions and 39 deletions

View File

@@ -208,57 +208,57 @@ My docsets are stored in .docsets for ease of use
- Books - Books
- Weather - Weather
* Language Config * Language Config
** C# ** CSharp
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(after! csharp-mode (after! csharp-mode
(after! omnisharp (setq omnisharp-server-executable-path "~/bin/omnisharp/run")
(after! counsel-etags (defun oreodave/csharp/get-unit-test-in-project ()
(defun oreodave/csharp/get-unit-test-in-project () (interactive)
(interactive) (let* ((tags-file (counsel-etags-locate-tags-file))
(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
(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: "
(ivy-read "Choose test: " cands
cands :action
:action (lambda (item)
(lambda (item) ;; From the counsel-etags file-open-api function
;; From the counsel-etags file-open-api function (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item)
(when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item) (let* ((file (match-string-no-properties 1 item))
(let* ((file (match-string-no-properties 1 item)) (linenum (match-string-no-properties 2 item))
(linenum (match-string-no-properties 2 item)) ;; always calculate path relative to TAGS
;; always calculate path relative to TAGS (default-directory (counsel-etags-tags-file-directory)))
(default-directory (counsel-etags-tags-file-directory)))
(when counsel-etags-debug (when counsel-etags-debug
(message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file)) (message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file))
(counsel-etags-push-marker-stack (point-marker)) (counsel-etags-push-marker-stack (point-marker))
(find-file file) (find-file file)
(counsel-etags-forward-line linenum) (counsel-etags-forward-line linenum)
(omnisharp-unit-test-at-point)) (omnisharp-unit-test-at-point))
)) ))
:caller 'oreodave/csharp/get-unit-tests-in-project)))) :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)
(c-set-style "java"))) ; Hook for csharp setting variables
(after! lsp
(setq lsp-clients-csharp-language-server-path (expand-file-name "~/bin/omnisharp-lsp/artifacts/publish/OmniSharp.Stdio.Driver/mono/OmniSharp.exe")))
(add-hook! 'csharp-mode-hook '(lambda()
(omnisharp-mode)
(setq c-basic-offset 4)
(c-set-style "java"))) ; Hook for csharp setting variables
(map! ; CSharp Keybinds (map! ; CSharp Keybinds
:map csharp-mode-map :map csharp-mode-map
:localleader :localleader
:desc "Format buffer" "=" 'omnisharp-code-format-entire-file :desc "Format buffer" "=" 'omnisharp-code-format-entire-file
(:prefix "t" (:prefix "t"
:desc "Select Test in Project" "t" 'oreodave/csharp/get-unit-test-in-project)) :desc "Select Test in Project" "t" 'oreodave/csharp/get-unit-test-in-project)))
)
#+END_SRC #+END_SRC
- I have custom installed the omnisharp roslyn executable, so I'd rather use that - I have custom installed the omnisharp roslyn executable, so I'd rather use
- C# code is better at 4 space indents, but I indent most of my C code at 2 space indents because it looks nicer :) that
- C# code is better at 4 space indents, but I indent most of my C code at 2
space indents because it looks nicer :)
- Implemented my own function which piggy backs counsel etags to globally search - Implemented my own function which piggy backs counsel etags to globally search
tags for test specific context, then goes to it and uses an omnisharp test tags for test specific context, then goes to it and uses an omnisharp test
command to unit test it. Basically global test search in C# projects command to unit test it. Basically global test search in C# projects. To use
this, just make sure you have tags compiled and that all your tests are
written as some public void *name*\_Test (i.e. they are appended with _Test so
that the pattern can be matched_)
** Python ** Python
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(after! python (after! python

View File

@@ -104,7 +104,7 @@
;;common-lisp ; if you've seen one lisp, you've seen them all ;;common-lisp ; if you've seen one lisp, you've seen them all
;;coq ; proofs-as-programs ;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c ;;crystal ; ruby at the speed of c
(csharp +lsp) ; unity, .NET, and mono shenanigans (csharp) ; unity, .NET, and mono shenanigans
data ; config/data formats data ; config/data formats
;;erlang ; an elegant language for a more civilized age ;;erlang ; an elegant language for a more civilized age
;;elixir ; erlang done right ;;elixir ; erlang done right

View File

@@ -11,7 +11,6 @@
; Coding ; Coding
(package! counsel-etags) ; tags are cool (package! counsel-etags) ; tags are cool
(package! py-yapf) ; formatting (package! py-yapf) ; formatting
(package! omnisharp) ; unit testing
; Arduino ; Arduino
(package! arduino-mode) ; mandatory, though I might make my own module for this (package! arduino-mode) ; mandatory, though I might make my own module for this
(package! company-arduino) ; intellisense EVERYTHING (package! company-arduino) ; intellisense EVERYTHING