Last active
June 26, 2018 15:14
-
-
Save tsdeng/7478579 to your computer and use it in GitHub Desktop.
let speed bar recognize scala file perfectly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. create ~/.ctags as follows(notice for regexps I used ^[ \t] to excactly match): | |
--langdef=Scala | |
--langmap=Scala:.scala | |
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/class \1/c,classes/ | |
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/object \1/o,objects/ | |
--regex-scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/trait \1/t,traits/ | |
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/case class \1/m,case-classes/ | |
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/abstract class \1/a,abstract-classes/ | |
--regex-Scala=/^[^\*\/]*def[ \t]*([a-zA-Z0-9_]+)[ \t]*.*[:=]/f \1/f,functions/ | |
#--regex-Scala=/^[^\*\/]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/ | |
#--regex-Scala=/^[^\*\/]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/ | |
#--regex-Scala=/^[^\*\/]*type[ \t]*([a-zA-Z0-9_]+)[ \t]*[\[<>=]/\1/T,types/ | |
2.0 make sure you installed exuberant ctags (brew install ctags-exuberant) | |
2.1 change your emacs setting as: | |
(speedbar-add-supported-extension ".scala") | |
;(setq speedbar-use-imenu-flag nil) | |
(setq speedbar-fetch-etags-command "ctags") | |
(setq speedbar-fetch-etags-arguments '("-e" "-f -")) | |
(add-to-list 'speedbar-fetch-etags-parse-list | |
'("\\.scala" . speedbar-parse-c-or-c++tag)) | |
PS: notice I changed the command to ctags, that's because emacs by default uses etags to generate tag and therefore will not utlize the .ctags file we customized on step 1 | |
3.0 enjoy | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment