Added support for C# using OmniSharp
This commit is contained in:
parent
239d61ddf0
commit
3b83124fc0
129
contrib/lang/csharp/README.md
Normal file
129
contrib/lang/csharp/README.md
Normal file
|
@ -0,0 +1,129 @@
|
|||
# C# contribution layer for Spacemacs
|
||||
|
||||
![logo](img/csharp.png)
|
||||
|
||||
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
|
||||
**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)
|
||||
|
||||
<!-- markdown-toc end -->
|
||||
|
||||
## 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
|
33
contrib/lang/csharp/extensions.el
Normal file
33
contrib/lang/csharp/extensions.el
Normal file
|
@ -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 <sylvain.benner@gmail.com>
|
||||
;; 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-<extension-csharp>
|
||||
;;
|
||||
;; (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
|
BIN
contrib/lang/csharp/img/csharp.png
Normal file
BIN
contrib/lang/csharp/img/csharp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
73
contrib/lang/csharp/packages.el
Normal file
73
contrib/lang/csharp/packages.el
Normal file
|
@ -0,0 +1,73 @@
|
|||
;;; packages.el --- csharp Layer packages File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; 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))
|
||||
))
|
Loading…
Reference in a new issue