From 659d74ae636c7c554d937f0fb4eb77e3931a7700 Mon Sep 17 00:00:00 2001 From: Caleb Hearth Date: Fri, 29 Jul 2022 12:09:34 -0500 Subject: [PATCH] Add projections.json for Rails.vim support Rails.vim allows gems to provide their own projections compatible with Projectionist.vim by placing them at lib/rails/projections.json. This configuration allows: - :A from a factory to alternate to the test file - :Efactory (and :{S,V,T}factory) to navigate to or create a new factory - highlights FactoryBot macros as Ruby macros - Sets up :{E,S,V,T}unittest for factories => model specs To use this, you'll need Rails.vim, Bundler.vim, and Projectionist.vim plugins. See `:help rails-projections` or [the file on GitHub](https://github.com/tpope/vim-rails/blob/6bc0c7826d68f8c44c8347a3012aa79ade4f0a22/doc/rails.txt#L611-L726) for more clarity on what specifically each config key is doing. Inspired and updated from [@henrik's Gist](https://gist.github.com/henrik/5676109#file-config-projections-json-L10-L15) --- lib/rails/projections.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/rails/projections.json diff --git a/lib/rails/projections.json b/lib/rails/projections.json new file mode 100644 index 0000000..d8c1084 --- /dev/null +++ b/lib/rails/projections.json @@ -0,0 +1,26 @@ +{ + "spec/factories/*.rb": { + "alternate": "app/models/{singular}.rb", + "collection": "model", + "command": "factory", + "template": [ + "FactoryBot.define do", + " factory :{singular} do", + " end", + "end" + ], + "test": "spec/models/{singular}_spec.rb" + }, + "test/factories/*.rb": { + "alternate": "app/models/{singular}.rb", + "collection": "model", + "command": "factory", + "template": [ + "FactoryBot.define do", + " factory :{singular} do", + " end", + "end" + ], + "test": "test/models/{singular}_test.rb" + } +}