diff --git a/lib/extensions/ruby/init.el b/lib/extensions/ruby/init.el index 4a8037f..db746a1 100644 --- a/lib/extensions/ruby/init.el +++ b/lib/extensions/ruby/init.el @@ -8,6 +8,8 @@ (setup-inf-ruby) (setup-bundler) + (global-set-key (kbd "M-.") 'my-find-tag) + (with-ability rbenv (require 'rbenv) (global-rbenv-mode)) diff --git a/lib/extensions/ruby/setup.el b/lib/extensions/ruby/setup.el index eabe7fd..dfa9316 100644 --- a/lib/extensions/ruby/setup.el +++ b/lib/extensions/ruby/setup.el @@ -61,4 +61,30 @@ ;; Hack autocomplete so it treat :symbole and symbole the same way (modify-syntax-entry ?: ".")) + +;;;###autoload +(defun visit-project-tags () + (interactive) + (let ((tags-file (concat (projectile-project-root) "TAGS"))) + (visit-tags-table tags-file) + (message (concat "Loaded " tags-file)))) + +;;;###autoload +(defun build-ctag-file () + "Create the ctag of the ruby project" + (interactive) + (message "building project tags") + (let ((root (projectile-project-root))) + (shell-command (concat "ctags -e -R . $(bundle list --paths) --extra=+fq --exclude=db --exclude=test --exclude=.git --exclude=public -f " root "TAGS " root))) + (visit-project-tags) + (message "tags built successfully")) + +;;;###autoload +(defun my-find-tag () + (interactive) + (if (file-exists-p (concat (projectile-project-root) "TAGS")) + (visit-project-tags) + (build-ctags)) + (etags-select-find-tag-at-point)) + (provide 'extensions/ruby/setup)