Skip to content

Instantly share code, notes, and snippets.

@madsmith
Last active December 18, 2015 22:09
Show Gist options
  • Save madsmith/5852450 to your computer and use it in GitHub Desktop.
Save madsmith/5852450 to your computer and use it in GitHub Desktop.
CTag Language Specification for Scala
--langdef=scala
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*class[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/c,classes/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*case[ \t]+class[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/c,classes/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*object[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/o,objects/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*trait[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/t,traits/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*def[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/m,methods/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*val[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/C,constants/
--regex-scala=/^[ \t]*(((private|protected)(\[[^]]*\])?|implicit|lazy|override|final|abstract|sealed)[ \t]*)*var[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\5/l,local variables/
--regex-scala=/^[ \t]*type[ \t]+([!#%&*-,\/-9<-Z\\^-z|~\-]+)/\1/T,types/
--regex-scala=/^[ \t]*package[ \t]+([a-zA-Z0-9_.]+)/\1/p,packages/

CTag Language Specification for Scala

Based off of instructions from http://codesanch.tumblr.com/post/1489753647/to-get-ctags-working-with-scala-and-vim

Expanded regex to handle modifiers as defined by Scala Language Specification and modified tag regex to attempt to match select operator characters between \u0020 and \u007F

Note, I took no care to validate that the modifiers are only used in the proper context (e.g. lazy should not be used with classes). This is meant to extract tags, not validate syntax so there's no gain in that additional level of pedantry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment