LoginSignup
16
16

More than 5 years have passed since last update.

EmacsでSwiftを自動補完

Last updated at Posted at 2016-01-02

EmacsでSwiftをコーディングするときにメジャーモードのSwift-modeがあるけど
自動補完の機能は用意されてません。
探して見たとこ、ponpoko1968さんが自動補完機能を用意されてるようです
http://ponpoko1968.hatenablog.com/entry/2015/11/09/183855

用意されてるauto-complete-swfit.elを動作してみましたが
自分の環境では動かないようでした

# My Environment
swift --version
Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)
Target: x86_64-apple-darwin15.2.0

上記環境でも動くようにしたものをForkして用意しました。
2016/3/6
ponpoko1968さんより修正プルリクを取り込んでいただきました。

こんな感じになります
auto-complate-swift.gif

設定手順

sourcekittenをインストール

$ brew install sourcekitten 

以下からauto-complate-swift.elを落してelispのload-path先へ配置します
https://github.com/fujimisakari/auto-complete-swift
https://github.com/ponpoko1968/auto-complete-swift

init.elに以下の設定を追加します

(require 'auto-complete-swift)
(push 'ac-source-swift-complete ac-sources)

;; デフォルトのSDKは以下が設定されてます
;; /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
;; 異る場合は以下で再設定する必要があります
;; (setq swift-compiler-args "-sdk /path/to/sdk/")

auto-completeを有効にして、M-x ac-complete-swiftを実行すると補完できるようになります

16
16
2

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
16
16