Projectile Hanami

Summary

Projectile Hanami is an Emacs minor mode, based on Projectile, for navigating Hanami projects. With Projectile Hanami, you can:

Projectile Hanami is based on Projectile Rails, but is not a complete port of all its functionality.

Installation

This guide assumes you have Projectile already set up.

MELPA

If you have MELPA set up, you can use package-install to install the projectile-hanami package.

Manual installation

You can manually install Projectile hanami by cloning the repository and adding it to your load-path:

(add-to-list 'load-path "/path/to/repo")
        (require 'projectile-hanami)
      

Setup

To have Projectile Hanami loaded whenever Projectile is loaded, you can add it as a hook:

(add-hook 'projectile-mode-hook 'projectile-hanami-on)
      

...but, this will most likely conflict with Projectile Rails. If you use both Ruby on Rails and Hanami, you will probably want something slightly more sophisticated. I use the following snippet:

(defun projectile-rails-or-hanami-on ()
        "Activate either `projectile-rails-mode` or `projectile-hanami-mode`."
        (if (projectile-hanami-applicable-p)
        (projectile-hanami-mode +1)
        (projectile-rails-on)))

        (add-hook 'projectile-mode-hook 'projectile-rails-or-hanami-on)
      

Since Projectile Rails cannot distinguish between Rails and Hanami projects, and Hanami can, we use Projectile Hanami's detection mechanism and fall back to Projectile Rails in case of no match.

Usage

Customization

You can define the Projectile Hanami keybinding prefix:

;; Defaults to C-c ;
        (setq projectile-hanami-keymap-prefix (kbd "C-c p C-q"))
      

To override how Hanami commands are invoked:

;; Defaults to `bundle exec hanami`
        (setq projectile-hanami-cmd "/path/to/hanami")
      

Commands

Command Keybinding Description
projectile-hanami-find-initializer C-c ; i Use projectile-completion-system to find initializers across apps.
projectile-hanami-find-lib C-c ; l Use projectile-completion-system to find project lib files.
projectile-hanami-find-controller C-c ; c Use projectile-completion-system to find controller actions across apps.
projectile-hanami-find-view C-c ; v Use projectile-completion-system to find views across apps.
projectile-hanami-find-template C-c ; t Use projectile-completion-system to find templates across apps.
projectile-hanami-find-presenter C-c ; p Use projectile-completion-system to find presenters across apps.
projectile-hanami-find-stylesheet C-c ; s Use projectile-completion-system to find stylesheets across apps.
projectile-hanami-find-javascript C-c ; j Use projectile-completion-system to find javascripts across apps.
projectile-hanami-find-config C-c ; g Use projectile-completion-system to find config files across apps.
projectile-hanami-find-routes C-c ; u Use projectile-completion-system to find routes files across apps.
projectile-hanami-find-entity C-c ; e Use projectile-completion-system to find entities.
projectile-hanami-find-repository C-c ; r Use projectile-completion-system to find repositories.
projectile-hanami-find-mailer C-c ; m Use projectile-completion-system to find mailers.
projectile-hanami-find-mailer-template C-c ; T Use projectile-completion-system to find mailer templates.
projectile-hanami-find-application C-c ; a Use projectile-completion-system to find main application files.
projectile-hanami-goto-related-controller C-c ; C Find the controller action related to the current view or template.
projectile-hanami-goto-related-template C-c ; T Find the template related to the current view or controller action.
projectile-hanami-goto-related-view C-c ; V Find the view related to the current template or controller action.
projectile-hanami-goto-entity C-c ; E Find the entity for the current repository.
projectile-hanami-goto-repository C-c ; R Find the repository for the current entity.
projectile-hanami-goto-mapping C-c ; g m Find the project's lib/config/mapping.rb file
projectile-hanami-goto-rakefile C-c ; g r Find the project's Rakefile.
projectile-hanami-goto-gemfile C-c ; g g Find the project's Gemfile.
projectile-hanami-rake C-c ; ! r Run a project Rake task.
projectile-hanami-console C-c ; ! c Run hanami console
projectile-hanami-server C-c ; ! s Run hanami server
projectile-hanami-generate C-c ; ! g Run hanami generate