LoginSignup
13
10

More than 5 years have passed since last update.

ctags を Swift に対応させる

Last updated at Posted at 2015-08-02

ATOM で Swift をいい感じに開発するため、オートコンプリート用とシンボルジャンプ用に Swift の tags ファイルを生成できるようにしたのでメモ。

.ctags ファイルを編集する

デフォルトで ctags は Swift に対応しておらず、また、いい感じのパーサを見つけることができなっかたので、自分でパーサを作成する必要があります。
がっつりパーサを作り込む方法もあるようですが、
そこまでちゃんと生成する必要はなかったので、今回はオプションファイルで対応させることにしました。

手順
1.~/.ctags ファイルに以下を追加する

~/.ctags
--langdef=Swift 
--langmap=Swift:+.swift 
--regex-swift=/(var|let)[ \t]+([^:=]+).*$/\2/,variable/ 
--regex-swift=/func[ \t]+([^\(\)]+)\([^\(\)]*\)/\1/,function/ 
--regex-swift=/class[ \t]+([^:\{]+).*$/\1/,class/ 
--regex-swift=/protocol[ \t]+([^:\{]+).*$/\1/,protocol/

2.対象のリポジトリでctags -R *を実行する

以上です。

これでクラスや変数は一通り出力されているのではないでしょうか。

参考

13
10
0

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
13
10