LoginSignup
9
8

More than 5 years have passed since last update.

Emacs for Unity

Posted at

Introduction

Unity のコーディングを Emacs で行うための設定まとめ。

Setup

OmniSharpServer

OmniSharp/omnisharp-server

OSX の場合は Mono が必要になるため、Homebrew などでインストールしてからビルド。
生成した OmniSharp.exe を後ほど Emacs から実行する。

$ brew install mono
$ git clone https://github.com/OmniSharp/omnisharp-server.git
$ cd omnisharp-server
$ git submodule update --init --recursive
$ xbuild

Emacs Package

Cask などで各パッケージをインストールする。

(source melpa)
(depends-on "omnisharp")
(depends-on "flycheck")
(depends-on "csharp-mode")

omnisharp

OmniSharp/omnisharp-emacs

先ほどの OmniSharp.exe のパスを設定。

(require 'omnisharp)
(setq omnisharp-server-executable-path "*/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe")

自動補完など、キーの割り当てはお好みで。

(define-key omnisharp-mode-map (kbd "<C-tab>") 'omnisharp-auto-complete)
(define-key omnisharp-mode-map "." 'omnisharp-add-dot-and-auto-complete)

flycheck

flycheck/flycheck

OmniSharp が対応済みなので最低限。

(add-hook 'after-init-hook #'global-flycheck-mode)

csharp-mode

josteink/csharp-mode

C# モード時に OmniSharp と Flycheck を利用する。

(require 'csharp-mode)
(add-hook 'csharp-mode-hook '(lambda () (omnisharp-mode) (flycheck-mode)))

Usage

Emacs で *.cs を開く際にソリューションファイルを求められるので、
MonoDevelop が生成した *-csharp.sln を指定するだけ。

etags

タグを利用するなら ctags で生成する。

$ brew install ctags
$ ctags -Re

タグの更新は ctags-update を使うと便利。

(source melpa)
(depends-on "ctags-update")

Bonus

以上で C# については諸々解消するのだが、
Unity のコーディング時には Shader を扱う機会が多く、最適なモードが見当たらなかったため作った。

shader-mode

midnightSuyama/shader-mode

シンプルなインデントとシンタックスハイライトを提供。

(source melpa)
(depends-on "shader-mode")
(require 'shader-mode)

各仕様について、
ShaderLab は Shader Reference を、Cg は Cg_language を参考にした。
セマンティクスに関しては NVIDIA の Cg Profile Documentation を網羅し反映させた。

9
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8