yeet
This commit is contained in:
43
.config/emacs/modules/lang/csharp/README.org
Normal file
43
.config/emacs/modules/lang/csharp/README.org
Normal file
@@ -0,0 +1,43 @@
|
||||
#+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).
|
||||
+ =+dotnet= Enables Dotnet transient interface with Sharper
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/josteink/csharp-mode][csharp-mode]]
|
||||
+ [[https://github.com/omajid/csproj-mode][csproj-mode]]
|
||||
+ [[https://github.com/OmniSharp/omnisharp-emacs][omnisharp]]* (not =+lsp=)
|
||||
+ [[https://github.com/midnightSuyama/shader-mode][shader-mode]]* (=+unity=)
|
||||
+ [[https://github.com/sebasmonia/sharper][sharper]] (=+dotnet=)
|
||||
|
||||
* 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)
|
||||
+ .NET Core 1.X - 3.X or .NET 5 for cross platform
|
||||
|
||||
** TODO MacOS
|
||||
** Arch Linux
|
||||
#+BEGIN_SRC sh
|
||||
sudo pacman --needed --noconfirm -S mono
|
||||
#+END_SRC
|
||||
** TODO NixOS
|
||||
15
.config/emacs/modules/lang/csharp/autoload.el
Normal file
15
.config/emacs/modules/lang/csharp/autoload.el
Normal file
@@ -0,0 +1,15 @@
|
||||
;;; 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)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +csharp-kill-omnisharp-server-h ()
|
||||
(unless (doom-buffers-in-mode 'csharp-mode (buffer-list))
|
||||
(omnisharp-stop-server)))
|
||||
74
.config/emacs/modules/lang/csharp/config.el
Normal file
74
.config/emacs/modules/lang/csharp/config.el
Normal file
@@ -0,0 +1,74 @@
|
||||
;;; lang/csharp/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package! csharp-mode
|
||||
:hook (csharp-mode . rainbow-delimiters-mode)
|
||||
:config
|
||||
(set-electric! 'csharp-mode :chars '(?\n ?\}))
|
||||
(set-rotate-patterns! 'csharp-mode
|
||||
:symbols '(("public" "protected" "private")
|
||||
("class" "struct")))
|
||||
(set-ligatures! 'csharp-mode
|
||||
;; Functional
|
||||
:lambda "() =>"
|
||||
;; Types
|
||||
:null "null"
|
||||
:true "true"
|
||||
:false "false"
|
||||
:int "int"
|
||||
:float "float"
|
||||
:str "string"
|
||||
:bool "bool"
|
||||
:list "List"
|
||||
;; Flow
|
||||
:not "!"
|
||||
:in "in"
|
||||
:and "&&"
|
||||
:or "||"
|
||||
:for "for"
|
||||
:return "return"
|
||||
:yield "yield")
|
||||
|
||||
(sp-local-pair 'csharp-mode "<" ">"
|
||||
:when '(+csharp-sp-point-in-type-p)
|
||||
:post-handlers '(("| " "SPC")))
|
||||
|
||||
(when (featurep! +lsp)
|
||||
(add-hook 'csharp-mode-local-vars-hook #'lsp!))
|
||||
|
||||
(defadvice! +csharp-disable-clear-string-fences-a (fn &rest args)
|
||||
"This turns off `c-clear-string-fences' for `csharp-mode'. When
|
||||
on for `csharp-mode' font lock breaks after an interpolated string
|
||||
or terminating simple string."
|
||||
:around #'csharp-disable-clear-string-fences
|
||||
(unless (eq major-mode 'csharp-mode)
|
||||
(apply fn args))))
|
||||
|
||||
|
||||
;; Unity shaders
|
||||
(use-package! shader-mode
|
||||
:when (featurep! +unity)
|
||||
:mode "\\.shader\\'"
|
||||
:config
|
||||
(def-project-mode! +csharp-unity-mode
|
||||
:modes '(csharp-mode shader-mode)
|
||||
:files (and "Assets" "Library/MonoManager.asset" "Library/ScriptMapper")))
|
||||
|
||||
|
||||
(use-package! sharper
|
||||
:when (featurep! +dotnet)
|
||||
:general ("C-c d" #'sharper-main-transient)
|
||||
:config
|
||||
(map! (:map sharper--solution-management-mode-map
|
||||
:nv "RET" #'sharper-transient-solution
|
||||
:nv "gr" #'sharper--solution-management-refresh)
|
||||
(:map sharper--project-references-mode-map
|
||||
:nv "RET" #'sharper-transient-project-references
|
||||
:nv "gr" #'sharper--project-references-refresh)
|
||||
(:map sharper--project-packages-mode-map
|
||||
:nv "RET" #'sharper-transient-project-packages
|
||||
:nv "gr" #'sharper--project-packages-refresh)
|
||||
(:map sharper--nuget-results-mode-map
|
||||
:nv "RET" #'sharper--nuget-search-install)))
|
||||
|
||||
|
||||
(use-package! sln-mode :mode "\\.sln\\'")
|
||||
7
.config/emacs/modules/lang/csharp/doctor.el
Normal file
7
.config/emacs/modules/lang/csharp/doctor.el
Normal file
@@ -0,0 +1,7 @@
|
||||
;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||
;;; lang/csharp/doctor.el
|
||||
|
||||
(when (and (require 'omnisharp nil t) (not (featurep! +lsp)))
|
||||
(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
.config/emacs/modules/lang/csharp/packages.el
Normal file
10
.config/emacs/modules/lang/csharp/packages.el
Normal file
@@ -0,0 +1,10 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/csharp/packages.el
|
||||
|
||||
(package! csharp-mode :pin "fe8a68e9849fc7617e0c870cacd6599b8a797638")
|
||||
(package! csproj-mode :pin "a7f0f4610c976a28c41b9b8299892f88b5d0336c")
|
||||
(package! sln-mode :pin "0f91d1b957c7d2a7bab9278ec57b54d57f1dbd9c")
|
||||
(when (featurep! +unity)
|
||||
(package! shader-mode :pin "d7dc8d0d6fe8914e8b6d5cf2081ad61e6952359c"))
|
||||
(when (featurep! +dotnet)
|
||||
(package! sharper :pin "08277b6c30568adfbe438c9f2a1d6c3db4b7ebeb"))
|
||||
Reference in New Issue
Block a user