~decomposed C# config into several subheadings
Same reason as big keymap. Easier to work with.
This commit is contained in:
@@ -192,14 +192,26 @@ Emacs doesn't have the full range of styles that I want, so lemme just do it mys
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
Emacs doesn't have the full range of styles that I want, so lemme just do it myself.
|
Emacs doesn't have the full range of styles that I want, so lemme just do it myself.
|
||||||
** CSharp
|
** CSharp
|
||||||
|
- I have custom installed the omnisharp roslyn executable, so I'd rather use
|
||||||
|
that
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
(after! csharp-mode
|
(after! csharp-mode
|
||||||
(setq omnisharp-server-executable-path "~/bin/omnisharp-roslyn/run")
|
(setq omnisharp-server-executable-path "~/bin/omnisharp-roslyn/run"))
|
||||||
|
#+END_SRC
|
||||||
|
*** Unit test over whole projects
|
||||||
|
- 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
|
||||||
|
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)
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(after! (csharp-mode counsel-etags)
|
||||||
(defun oreodave/csharp/get-unit-test-in-project ()
|
(defun oreodave/csharp/get-unit-test-in-project ()
|
||||||
"Unit test anywhere using CTags or ETags and C#"
|
"Unit test anywhere using CTags or ETags and C#"
|
||||||
(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)))
|
||||||
(ivy-read
|
(ivy-read
|
||||||
"Choose test: "
|
"Choose test: "
|
||||||
cands
|
cands
|
||||||
@@ -217,7 +229,13 @@ Emacs doesn't have the full range of styles that I want, so lemme just do it mys
|
|||||||
(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))))
|
||||||
|
#+END_SRC
|
||||||
|
*** Redo omnisharp-emit-results
|
||||||
|
- Reimplemented omnisharp-emit-results to emit stdout regardless of whether the
|
||||||
|
test failed or not
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(after! (csharp-mode omnisharp)
|
||||||
(defun omnisharp--unit-test-emit-results (passed results)
|
(defun omnisharp--unit-test-emit-results (passed results)
|
||||||
"Emits unit test results as returned by the server to the unit test result buffer.
|
"Emits unit test results as returned by the server to the unit test result buffer.
|
||||||
PASSED is t if all of the results have passed. RESULTS is a vector of status data for
|
PASSED is t if all of the results have passed. RESULTS is a vector of status data for
|
||||||
@@ -245,19 +263,19 @@ each of the unit tests ran."
|
|||||||
'(:foreground "red" :weight bold)))
|
'(:foreground "red" :weight bold)))
|
||||||
(omnisharp--truncate-symbol-name method-name 76)))
|
(omnisharp--truncate-symbol-name method-name 76)))
|
||||||
|
|
||||||
(if error-stack-trace
|
(if error-stack-trace
|
||||||
(omnisharp--unit-test-message error-stack-trace))
|
(omnisharp--unit-test-message error-stack-trace))
|
||||||
|
|
||||||
(unless (= (seq-length stdout) 0)
|
(unless (= (seq-length stdout) 0)
|
||||||
(omnisharp--unit-test-message "Standard output:")
|
(omnisharp--unit-test-message "Standard output:")
|
||||||
(seq-doseq (stdout-line stdout)
|
(seq-doseq (stdout-line stdout)
|
||||||
(omnisharp--unit-test-message stdout-line)))
|
(omnisharp--unit-test-message stdout-line)))
|
||||||
|
|
||||||
(unless (= (seq-length stderr) 0)
|
(unless (= (seq-length stderr) 0)
|
||||||
(omnisharp--unit-test-message "Standard error:")
|
(omnisharp--unit-test-message "Standard error:")
|
||||||
(seq-doseq (stderr-line stderr)
|
(seq-doseq (stderr-line stderr)
|
||||||
(omnisharp--unit-test-message stderr-line)))
|
(omnisharp--unit-test-message stderr-line)))
|
||||||
))
|
))
|
||||||
|
|
||||||
(omnisharp--unit-test-message "")
|
(omnisharp--unit-test-message "")
|
||||||
|
|
||||||
@@ -269,31 +287,18 @@ each of the unit tests ran."
|
|||||||
(propertize "*** UNIT TEST RUN HAS SUCCEEDED ***"
|
(propertize "*** UNIT TEST RUN HAS SUCCEEDED ***"
|
||||||
'font-lock-face '(:foreground "green" :weight bold)))
|
'font-lock-face '(:foreground "green" :weight bold)))
|
||||||
)
|
)
|
||||||
nil)
|
nil))
|
||||||
|
#+END_SRC
|
||||||
(add-hook! 'csharp-mode-hook
|
*** Map for C# mode
|
||||||
'(lambda()
|
#+BEGIN_SRC elisp
|
||||||
(omnisharp-mode)
|
(after! csharp-mode
|
||||||
(c-set-style "C#"))) ; 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
|
|
||||||
- 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
|
|
||||||
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. 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
|
||||||
- I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3
|
- I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3
|
||||||
- Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
|
- Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
|
||||||
|
|||||||
Reference in New Issue
Block a user