From 3b83124fc0b6c1240c6e3e032936078d6cc3becd Mon Sep 17 00:00:00 2001 From: Bjarke Vad Date: Wed, 28 Jan 2015 21:12:25 +0100 Subject: [PATCH] Added support for C# using OmniSharp --- contrib/lang/csharp/README.md | 129 +++++++++++++++++++++++++++++ contrib/lang/csharp/extensions.el | 33 ++++++++ contrib/lang/csharp/img/csharp.png | Bin 0 -> 6438 bytes contrib/lang/csharp/packages.el | 73 ++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 contrib/lang/csharp/README.md create mode 100644 contrib/lang/csharp/extensions.el create mode 100644 contrib/lang/csharp/img/csharp.png create mode 100644 contrib/lang/csharp/packages.el diff --git a/contrib/lang/csharp/README.md b/contrib/lang/csharp/README.md new file mode 100644 index 000000000..063d4d339 --- /dev/null +++ b/contrib/lang/csharp/README.md @@ -0,0 +1,129 @@ +# C# contribution layer for Spacemacs + +![logo](img/csharp.png) + + +**Table of Contents** + +- [C# contribution layer for Spacemacs](#c-contribution-layer-for-spacemacs) + - [Description](#description) + - [Packages Included](#packages-included) + - [Install](#install) + - [Key Bindings](#key-bindings) + - [Tests](#tests) + - [Navigation](#navigation) + - [Type information](#type-information) + - [Refactoring](#refactoring) + - [Solution/Project manipulation](#solutionproject-manipulation) + - [Compilation](#compilation) + - [Code manipulation](#code-manipulation) + - [OmniSharp server interaction](#omnisharp-server-interaction) + + + +## Description + +This layer adds experimental support for C# language using [OmniSharp](https://github.com/OmniSharp/omnisharp-emacs). +The layer requires the OmniSharp server, refer to the install section. + +## Packages Included + +- [OmniSharp-emacs](https://github.com/OmniSharp/omnisharp-emacs) +- [OmniSharp-server](https://github.com/OmniSharp/omnisharp-server) + +## Install + +To use this contribution add it to your `~/.spacemacs` + +```elisp +(setq-default dotspacemacs-configuration-layers '(csharp) + "List of contribution to load." +) +``` + +- Compile the OmniSharp server, following the instructions found here: https://github.com/OmniSharp/omnisharp-server + +- Then do one of: + + a) In `.spacemacs` add the path to OmniSharp to an Emacs variable `(setq omnisharp-server-executable-path "/PATH/TO/OMNISHARP/OmniSharpServer")` + + b) Ensure that the binary `OmniSharp` is available in Emacs' `exec-path`. + +OmniSharp should now automatically load and start a server when you open a `.cs` file. + +## Limitations +It's currently not possible to create C# solutions outside of IDEs such as MonoDevelop, +it's therefore recommended that you install a C# IDE and use that for creating a solution. + +Debugging is possible using [SDB](https://github.com/mono/sdb), or by using an IDE. + +## Key Bindings + +### Tests + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mta" | Run all tests in project + "mtb" | Run all tests in current file/fixture + "mtt" | Run test under cursor + +### Navigation + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mgg" | Go to definition + "mgG" | Go to definition in other window + "mgu" | Find usages of symbol under cursor using Helm + "mgs" | Find symbols using Helm + "mgi" | Find implementations + "mgr" | Go to region + "mgm" | Go to solution member + "mgM" | Go to solution member in other window + "mgf" | Go to solution file + "mgF" | Go to solution file then member + +### Type information + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mt" | Get type information for symbol under cursor + "mT" | Get type information for symbol under cursor and put it into kill-ring + +### Refactoring + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mrm" | Rename symbol under cursor + "mrr" | Refactor symbol under cursor + +### Solution/Project manipulation + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mpa" | Add the current file to solution + "mpA" | Add files selected in dired to solution + "mpr" | Remove the current file from solution + "mpR" | Removed files selected in dired from solution + "mpl" | Add reference to solution + +### Compilation + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mb" | Build the solution + +### Code manipulation + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mo" | Auto complete overrides + "mi" | Fix usings/imports + "m=" | Format the current buffer + +### OmniSharp server interaction + + Key Binding | Description +----------------------|------------------------------------------------------------ + "mss" | Start the OmniSharp server + "msS" | Stop the OmniSharp server + "msr" | Reload the solution diff --git a/contrib/lang/csharp/extensions.el b/contrib/lang/csharp/extensions.el new file mode 100644 index 000000000..2e44887f4 --- /dev/null +++ b/contrib/lang/csharp/extensions.el @@ -0,0 +1,33 @@ +;;; extensions.el --- csharp Layer extensions File for Spacemacs +;; +;; Copyright (c) 2012-2014 Sylvain Benner +;; Copyright (c) 2014-2015 Sylvain Benner & Contributors +;; +;; Author: Sylvain Benner +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(defvar csharp-pre-extensions + '( + ;; pre extension csharps go here + ) + "List of all extensions to load before the packages.") + +(defvar csharp-post-extensions + '( + ;; post extension csharps go here + ) + "List of all extensions to load after the packages.") + +;; For each extension, define a function csharp/init- +;; +;; (defun csharp/init-my-extension () +;; "Initialize my extension" +;; ) +;; +;; Often the body of an initialize function uses `use-package' +;; For more info on `use-package', see readme: +;; https://github.com/jwiegley/use-package diff --git a/contrib/lang/csharp/img/csharp.png b/contrib/lang/csharp/img/csharp.png new file mode 100644 index 0000000000000000000000000000000000000000..e4771a2a4499e9a82dfadc062d96e370487ced29 GIT binary patch literal 6438 zcmc&(hg%a{u%}6pCP;5e??UKBf>NZJfPlcIlc-3O0MZOC8bu($r3r$ND~encgh)q9 zqy!NpiXfqbG=Wg0goIGua^L^(-tPD9?ss-}&dhJhIWwE$0JY*iD|VKFfq~n`+QN~6 zfiVJjK4xbHuAk=@F9J7Kn4Ogc!^!FSPg{8oFv51<24cxJ%F1?5nIT0ax}JeSr=6p;v2AEj>KG*ezMe|1YFUMQBrhguCy59(^7=Qb(x?tHu zmog=nxPYqqaUokTh8tHcO3nVZ{QI0h7CR&Q%ICAUc>fALDG-Nr9!(u4>_7J(d|^1V zzox5E^>}$OV(@ED#GS!`q^JLXhjZn-Ri3A5_k1;cLw#j5Sw-4ziZkv8?-B2<2B{t# zN66Rkxv{9RN-+vC?Vv^~vd;-GGgyhkU$9iBe9IS^W@w!dnV-k6^Bp)U3+_BXvTAb2 z=pklZLhO67&0Gb{hwrPWxF^qCo}+5Zm(Y`xpCl$qZ4Fq*r_9OB>cBB6csSpI%+NDw zydORpWrt!*n#P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~iHLUxJ=BUeeyA%lFk{!Z!i6OvyK}tk9S^sT$%L<=hMh`8vbsHh7jwiFg{*$ zc5wx-Cr5}GqdGcAVv312q37N6M!$}Pd;s+zparAY2xwbMdR~*hUgjLZ@WB-+K{eVk z`$BVx(`>=*3S=uovVuBR|z)W5GcG^P7gO+LZ^=TUxVjo!x&8(o;gKgqwqJZMk$3>^@Z8n^g`T zjn$sBzsN)ZNZe5ZnIIvOuR^DgE5pK(Zq3CVKwY5_1GQ8~@3Z zEdlTG{aGBOw;lV%v$N%~1edJZ(=`x5lvfQGZFQwfEwX{Dsj508RB28X#eptA_#Pi3 zka)~&kQy>7S}CV?&;2UN=Z>MD{L-s| +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(defvar csharp-packages + '(omnisharp)) + +(defvar csharp-excluded-packages '() + "List of packages to exclude.") + +(defun csharp/init-omnisharp () + ;; Load omnisharp-mode with csharp-mode, this should start the omnisharp server automatically + (add-hook 'csharp-mode-hook 'omnisharp-mode) + (use-package omnisharp + :defer t + :config (evil-leader/set-key-for-mode 'csharp-mode + ;; Tests + "mta" 'omnisharp-unit-test-all + "mtb" 'omnisharp-unit-test-fixture + "mtt" 'omnisharp-unit-test-single + + ;; Navigation + "mgg" 'omnisharp-go-to-definition + "mgG" 'omnisharp-go-to-definition-other-window + "mgu" 'omnisharp-helm-find-usages + "mgs" 'omnisharp-helm-find-symbols + "mgi" 'omnisharp-find-implementations + "mgr" 'omnisharp-navigate-to-region + "mgm" 'omnisharp-navigate-to-solution-member + "mgM" 'omnisharp-navigate-to-solution-member-other-window + "mgf" 'omnisharp-navigate-to-solution-file + "mgF" 'omnisharp-navigate-to-solution-file-then-file-member + + ;; Type info + "mht" 'omnisharp-current-type-information + "mhT" 'omnisharp-current-type-information-to-kill-ring + + ;; Refactoring + "mrm" 'omnisharp-rename + "mrr" 'omnisharp-run-code-action-refactoring + + ;; Solution/project manipulation + "mfa" 'omnisharp-add-to-solution-current-file + "mfA" 'omnisharp-add-to-solution-dired-selected-files + "mfr" 'omnisharp-remove-from-project-current-file + "mfR" 'omnisharp-remove-from-project-dired-selected-files + "mpl" 'omnisharp-add-reference + + ;; Compile + "mcc" 'omnisharp-build-in-emacs ;; Only one compile command so use top-level + + ;; Code manipulation + "mu" 'omnisharp-auto-complete-overrides + "mi" 'omnisharp-fix-usings + "m=" 'omnisharp-code-format + + ;; Server manipulation, inspired spacemacs REPL bindings since C# does not provice a REPL + "mss" 'omnisharp-start-omnisharp-server + "msS" 'omnisharp-stop-server + "msr" 'omnisharp-reload-solution) + + ;; Init omnisharp company backend + (eval-after-load 'company + '(add-to-list 'company-backends 'company-omnisharp)) + ))