Ctags with Swift
I always seems to end up in vim sooner or later and I use Tim Pope’s excellent Effortless Ctags with Git process to keep my ctags file up to date for my projects.
As I’m now coding in Swift too, I needed ctags to support Swift. This is what I’ve added to my .ctags file:
--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/
Any improvements, welcome!
vim.swift
As I’m writing about Swift and vim, I should also point out that the vim-swift plugin by Kevin Ballard is a must-have!
Have you looked at vim-gutentags? https://github.com/ludovicchabant/vim-gutentags
I'm not sure how it would work with swift, but for PHP and Python for me it does wonders. It basically creates tags for the entire project once, and after that it regenerates automatically only for the changed files.
Rob, thanks for the help. Made a couple mods to support struct and to keep ctags from indexing template params:
–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=/struct[ \t]+([^:\{<]+).*$/\1/,struct/
–regex-swift=/protocol[ \t]+([^:\{<]+).*$/\1/,protocol/