Moving to Doom Emacs!

This commit is contained in:
Derek Taylor
2019-12-16 20:21:19 -06:00
parent d9f2f456f1
commit d4b4c33550
683 changed files with 51877 additions and 100 deletions
+39
View File
@@ -0,0 +1,39 @@
#+TITLE: :lang csharp
* Table of Contents :TOC:
- [[#description][Description]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
- [[#macos][MacOS]]
- [[#arch-linux][Arch Linux]]
- [[#nixos][NixOS]]
* Description
This module adds C# support to Emacs. Powered by omnisharp (directly or through
LSP).
** Module Flags
+ =+lsp= Enables omnisharp through LSP support (requires omnisharp).
+ =+unity= Enables special support for the [[https://unity.com/][Unity game engine]] (particularly,
support for HLSL shaders).
** Plugins
+ [[https://github.com/josteink/csharp-mode][csharp-mode]]
+ [[https://github.com/OmniSharp/omnisharp-emacs][omnisharp]]* (not =+lsp=)
+ [[https://github.com/midnightSuyama/shader-mode][shader-mode]]* (=+unity=)
* Prerequisites
This module needs:
+ omnisharp (with the ~+lsp~ flag, this must be installed externally. Without
it, use ~M-x omnisharp-install-server~)
+ .NET SDKs (on Windows)
+ Mono (on UNIX platforms)
** TODO MacOS
** Arch Linux
#+BEGIN_SRC sh
sudo pacman --needed --noconfirm -S mono
#+END_SRC
** TODO NixOS
+10
View File
@@ -0,0 +1,10 @@
;;; lang/csharp/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +csharp-sp-point-in-type-p (id action context)
"Return t if point is in the right place for C# angle-brackets."
(and (sp-in-code-p id action context)
(cond ((eq action 'insert)
(sp-point-after-word-p id action context))
((eq action 'autoskip)
(/= (char-before) 32)))))
+70
View File
@@ -0,0 +1,70 @@
;;; lang/csharp/config.el -*- lexical-binding: t; -*-
(after! csharp-mode
(add-hook 'csharp-mode-hook #'rainbow-delimiters-mode)
(when (featurep! +lsp)
(add-hook 'csharp-mode-local-vars-hook #'lsp!))
(set-electric! 'csharp-mode :chars '(?\n ?\}))
(set-rotate-patterns! 'csharp-mode
:symbols '(("public" "protected" "private")
("class" "struct")))
(sp-local-pair 'csharp-mode "<" ">"
:when '(+csharp-sp-point-in-type-p)
:post-handlers '(("| " "SPC"))))
(use-package! omnisharp
:unless (featurep! +lsp)
:hook (csharp-mode . omnisharp-mode)
:commands omnisharp-install-server
:preface
(setq omnisharp-auto-complete-want-documentation nil
omnisharp-cache-directory (concat doom-etc-dir "omnisharp"))
:config
(defun +csharp-cleanup-omnisharp-server-h ()
"Clean up the omnisharp server once you kill the last csharp-mode buffer."
(unless (doom-buffers-in-mode 'csharp-mode (buffer-list))
(omnisharp-stop-server)))
(add-hook! 'csharp-mode-hook
(add-hook 'kill-buffer-hook #'+csharp-cleanup-omnisharp-server-h nil t))
(set-company-backend! 'csharp-mode 'company-omnisharp)
(set-lookup-handlers! 'csharp-mode
:definition #'omnisharp-go-to-definition
:references #'omnisharp-find-usages
:documentation #'omnisharp-current-type-documentation)
(map! :localleader
:map omnisharp-mode-map
"b" #'omnisharp-recompile
(:prefix "r"
"u" #'omnisharp-fix-usings
"r" #'omnisharp-rename
"a" #'omnisharp-show-last-auto-complete-result
"o" #'omnisharp-show-overloads-at-point)
(:prefix "g"
"u" #'omnisharp-find-usages
"i" #'omnisharp-find-implementations
"f" #'omnisharp-navigate-to-current-file-member
"m" #'omnisharp-navigate-to-solution-member
"M" #'omnisharp-navigate-to-solution-file-then-file-member
"F" #'omnisharp-navigate-to-solution-file
"r" #'omnisharp-navigate-to-region
"ti" #'omnisharp-current-type-information
"td" #'omnisharp-current-type-documentation)
(:prefix "t"
"s" #'omnisharp-unit-test-at-point
"l" #'omnisharp-unit-test-last
"b" #'omnisharp-unit-test-buffer)))
;;;###package shader-mode
(when (featurep! +unity)
;; Unity shaders
(add-to-list 'auto-mode-alist '("\\.shader\\'" . shader-mode))
(def-project-mode! +csharp-unity-mode
:modes '(csharp-mode shader-mode)
:files (and "Assets" "Library/MonoManager.asset" "Library/ScriptMapper")))
+7
View File
@@ -0,0 +1,7 @@
;; -*- lexical-binding: t; no-byte-compile: t; -*-
;;; lang/csharp/doctor.el
(require 'omnisharp)
(let ((omnisharp-bin (or omnisharp-server-executable-path (omnisharp--server-installation-path t))))
(unless (file-exists-p omnisharp-bin)
(warn! "Omnisharp server isn't installed, completion won't work")))
+10
View File
@@ -0,0 +1,10 @@
;; -*- no-byte-compile: t; -*-
;;; lang/csharp/packages.el
(package! csharp-mode)
(unless (featurep! +lsp)
(package! omnisharp))
(when (featurep! +unity)
(package! shader-mode))