├── LICENSE ├── README ├── autoload ├── unite │ ├── kinds │ │ └── bundled_gem.vim │ └── sources │ │ ├── rails.vim │ │ └── rails │ │ ├── collector │ │ ├── asset.vim │ │ ├── bundle.vim │ │ ├── bundled_gem.vim │ │ ├── config.vim │ │ ├── controller.vim │ │ ├── db.vim │ │ ├── decorator.vim │ │ ├── destroy.vim │ │ ├── features.vim │ │ ├── gem.vim │ │ ├── gemfile.vim │ │ ├── generate.vim │ │ ├── git.vim │ │ ├── helper.vim │ │ ├── heroku.vim │ │ ├── initializer.vim │ │ ├── javascript.vim │ │ ├── job.vim │ │ ├── lib.vim │ │ ├── log.vim │ │ ├── mailer.vim │ │ ├── minitest.vim │ │ ├── model.vim │ │ ├── rake.vim │ │ ├── route.vim │ │ ├── schema.vim │ │ ├── spec.vim │ │ ├── stylesheet.vim │ │ ├── view.vim │ │ └── webpack.vim │ │ └── helper.vim └── unite_rails.vim └── doc └── unite-rails.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 basyura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | a unite.vim plugin for rails 2 | 3 | 4 | unite /app/models 5 | :Unite rails/model 6 | 7 | unite /app/controllers 8 | :Unite rails/controller 9 | 10 | unite /app/views 11 | :Unite rails/view 12 | 13 | unite /app/helpers 14 | :Unite rails/helper 15 | 16 | unite /app/jobs 17 | :Unite rails/job 18 | 19 | unite /app/mailers 20 | :Unite rails/mailer 21 | 22 | unite /lib 23 | :Unite rails/lib 24 | 25 | unite /db 26 | :Unite rails/db 27 | 28 | unite /config 29 | :Unite rails/config 30 | 31 | unite /log 32 | :Unite rails/log 33 | 34 | unite /public/javascripts 35 | :Unite rails/javascript 36 | 37 | unite /public/stylesheets 38 | :Unite rails/stylesheet 39 | 40 | unite bundle's commands 41 | :Unite rails/bundle 42 | 43 | unite bundled gems 44 | :Unite rails/bundled_gem 45 | 46 | unite /app/javascript 47 | :Unite rails/webpack 48 | 49 | 50 | == maybe == 51 | 52 | unite routes 53 | :Unite rails/route 54 | 55 | unite root 56 | :Unite rails/root 57 | 58 | unite command 59 | :Unite rails/command 60 | > rake db:migrate 61 | -------------------------------------------------------------------------------- /autoload/unite/kinds/bundled_gem.vim: -------------------------------------------------------------------------------- 1 | function! unite#kinds#bundled_gem#define() 2 | return s:kind 3 | endfunction 4 | 5 | let s:kind = { 6 | \ 'name' : 'bundled_gem', 7 | \ 'default_action' : 'file_rec', 8 | \ 'action_table' : {} 9 | \ } 10 | 11 | function! s:get_bundled_gem_path(gem_name) 12 | return substitute(unite#util#system('bundle show ' . a:gem_name), "\n", '', '') 13 | endfunction 14 | 15 | let s:kind.action_table.file_rec = { 16 | \ 'description' : "open this gem's directory by file_rec source" 17 | \ } 18 | 19 | function! s:kind.action_table.file_rec.func(candidate) 20 | let path = s:get_bundled_gem_path(a:candidate.word) 21 | call unite#start([['file_rec', path]]) 22 | endfunction 23 | 24 | let s:kind.action_table.file = { 25 | \ 'description' : "open this gem's directory by file source" 26 | \ } 27 | 28 | function! s:kind.action_table.file.func(candidate) 29 | let path = s:get_bundled_gem_path(a:candidate.word) 30 | call unite#start([['file', path]]) 31 | endfunction 32 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails.vim: -------------------------------------------------------------------------------- 1 | " 2 | " autoload/unite/sources/rails/model.vim 3 | " unite#sources#rails#model#candidates 4 | " [ 5 | " { 6 | " word : file_name, 7 | " kind : file , 8 | " action__path : path , 9 | " action__directory : fnamemodify(v:val.path , ":p:h") , 10 | " }, 11 | " { 12 | " word : command_name, 13 | " kind : command , 14 | " action__command : command_hoge 15 | " }, 16 | " ... 17 | " ] 18 | " 19 | " source name => model 20 | " 21 | 22 | call unite#util#set_default('g:unite_rails_execute_cmd' , 'VimShellExecute') 23 | 24 | let s:source = {} 25 | " 26 | " define sources 27 | " 28 | function! unite#sources#rails#define() 29 | 30 | let rel_path = 'autoload/unite/sources/rails/collector/*.vim' 31 | let names = map(split(globpath(&runtimepath, rel_path), "\") , 32 | \ 'fnamemodify(v:val , ":t:r")') 33 | let list = [] 34 | for val in names 35 | let source = copy(s:source) 36 | let source.description = "candidates from " . val . " list" 37 | let source.name = "rails/" . val 38 | call add(list , source) 39 | endfor 40 | return list 41 | endfunction 42 | " 43 | " gather candidates 44 | " 45 | function! s:source.gather_candidates(args, context) 46 | return s:gather_candidates(self) 47 | endfunction 48 | " 49 | " 50 | function! s:gather_candidates(source) 51 | let root = unite#sources#rails#helper#rails_root() 52 | if root == "" 53 | redraw 54 | echohl ErrorMsg | echo 'RailsRoot does not exist.' | echohl None | return [] 55 | end 56 | 57 | " TODO 58 | let a:source.source__rails_root = root 59 | 60 | let func_name = "unite#sources#rails#collector#" . 61 | \ substitute(a:source.name , 'rails/' , '' , '') . "#candidates" 62 | return {func_name}(a:source) 63 | endfunction 64 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/asset.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#asset#candidates(source) 5 | let target = a:source.source__rails_root . '/app/assets' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | 9 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/bundle.vim: -------------------------------------------------------------------------------- 1 | let s:arguments = [ 2 | \ {'word' : 'install' , 3 | \ 'abbr' : 'install - Install the gems specified by the Gemfile or Gemfile.lock'}, 4 | \ {'word' : 'update' , 5 | \ 'abbr' : 'update - Update dependencies to their latest versions'}, 6 | \ {'word' : 'package' , 7 | \ 'abbr' : 'package - Package the .gem files required by your application into the vendor/cache directory'}, 8 | \ {'word' : 'config' , 9 | \ 'abbr' : 'config - Specify and read configuration options for bundler'}, 10 | \ ] 11 | " 12 | " gather candidates 13 | " 14 | function! unite#sources#rails#collector#bundle#candidates(source) 15 | return unite#sources#rails#helper#gather_candidates_cmd('bundle' , s:arguments) 16 | endfunction 17 | 18 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/bundled_gem.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#bundled_gem#candidates(source) 5 | let gems = map( 6 | \ map( 7 | \ filter( 8 | \ split(unite#util#system("bundle list"), "\n"), 9 | \ 'v:val =~ "^\ *\\*"' 10 | \ ), ' 11 | \ substitute(v:val, "\ *\\*\ *", "", "")'), '{ 12 | \ "word" : matchstr(v:val, "[a-zA-Z0-9-_]*"), 13 | \ "abbr" : v:val 14 | \ }') 15 | 16 | return map(gems, '{ 17 | \ "word": v:val.word, 18 | \ "abbr": v:val.abbr, 19 | \ "kind": "bundled_gem", 20 | \ }') 21 | endfunction 22 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/config.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#config#candidates(source) 5 | let target = a:source.source__rails_root . '/config' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/controller.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#controller#candidates(source) 5 | let target = a:source.source__rails_root . '/app/controllers' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/db.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#db#candidates(source) 5 | let target = a:source.source__rails_root . '/db' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/decorator.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#decorator#candidates(source) 5 | let target = a:source.source__rails_root . '/app/decorators' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | 9 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/destroy.vim: -------------------------------------------------------------------------------- 1 | let s:arguments = [ 2 | \ {'word' : 'controller' }, 3 | \ {'word' : 'generator' }, 4 | \ {'word' : 'helper' }, 5 | \ {'word' : 'integration_test' }, 6 | \ {'word' : 'mailer' }, 7 | \ {'word' : 'migration' }, 8 | \ {'word' : 'model' }, 9 | \ {'word' : 'observer' }, 10 | \ {'word' : 'performance_test' }, 11 | \ {'word' : 'plugin' }, 12 | \ {'word' : 'resource' }, 13 | \ {'word' : 'scaffold' }, 14 | \ {'word' : 'scaffold_controller' }, 15 | \ {'word' : 'session_migration' }, 16 | \ {'word' : 'stylesheets' }, 17 | \ ] 18 | " 19 | " gather candidates 20 | " 21 | function! unite#sources#rails#collector#destroy#candidates(source) 22 | let destory_cmd = g:unite_rails#executable_prefix . ' ' . g:unite_rails#executable . ' ' . 'destroy' 23 | return unite#sources#rails#helper#gather_candidates_cmd_input(destory_cmd , s:arguments) 24 | endfunction 25 | 26 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/features.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#features#candidates(source) 5 | let target = a:source.source__rails_root . '/features' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/gem.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather gem's soruces 3 | " 4 | let s:arguments_cmd = [ 5 | \ {'word' : '--help' }, 6 | \ {'word' : '--version' }, 7 | \ {'word' : 'list' }, 8 | \ ] 9 | let s:arguments_input = [ 10 | \ {'word' : 'install' }, 11 | \ {'word' : 'build' }, 12 | \ {'word' : 'help' }, 13 | \ ] 14 | " 15 | " gather candidates 16 | " 17 | function! unite#sources#rails#collector#gem#candidates(source) 18 | let cmd = unite#sources#rails#helper#gather_candidates_cmd('gem' , s:arguments_cmd) 19 | let input = unite#sources#rails#helper#gather_candidates_cmd_input('gem' , s:arguments_input) 20 | return cmd + input 21 | endfunction 22 | 23 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/gemfile.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#gemfile#candidates(source) 5 | let target = a:source.source__rails_root . '/Gemfile' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/generate.vim: -------------------------------------------------------------------------------- 1 | let s:arguments_input = [ 2 | \ {'word' : 'controller' , 'abbr' : 'controller - name action'}, 3 | \ {'word' : 'generator' }, 4 | \ {'word' : 'helper' }, 5 | \ {'word' : 'integration_test' }, 6 | \ {'word' : 'mailer' }, 7 | \ {'word' : 'migration' }, 8 | \ {'word' : 'model' , 'abbr' : 'model - name field:type field:type'}, 9 | \ {'word' : 'observer' }, 10 | \ {'word' : 'performance_test' }, 11 | \ {'word' : 'plugin' }, 12 | \ {'word' : 'resource' }, 13 | \ {'word' : 'scaffold' }, 14 | \ {'word' : 'scaffold_controller' }, 15 | \ {'word' : 'session_migration' }, 16 | \ {'word' : 'stylesheets' }, 17 | \ ] 18 | let s:arguments_cmd = [ 19 | \ {'word' : 'jquery:install' }, 20 | \ {'word' : 'devise:install' }, 21 | \ {'word' : 'devise:views' }, 22 | \ ] 23 | " 24 | " gather candidates 25 | " 26 | function! unite#sources#rails#collector#generate#candidates(source) 27 | let generate_cmd = g:unite_rails#executable_prefix . ' ' . g:unite_rails#executable . ' ' . 'generate' 28 | let input = unite#sources#rails#helper#gather_candidates_cmd_input(generate_cmd, s:arguments_input) 29 | let cmd = unite#sources#rails#helper#gather_candidates_cmd(generate_cmd , s:arguments_cmd) 30 | return input + cmd 31 | endfunction 32 | 33 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/git.vim: -------------------------------------------------------------------------------- 1 | let s:arguments = [ 2 | \ ] 3 | " 4 | " gather candidates 5 | " 6 | function! unite#sources#rails#collector#git#candidates(source) 7 | return unite#sources#rails#helper#gather_candidates_cmd('git' , s:arguments) 8 | endfunction 9 | 10 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/helper.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#helper#candidates(source) 5 | let target = a:source.source__rails_root . '/app/helpers' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/heroku.vim: -------------------------------------------------------------------------------- 1 | let s:arguments = [ 2 | \ ] 3 | " 4 | " gather candidates 5 | " 6 | function! unite#sources#rails#collector#heroku#candidates(source) 7 | return unite#sources#rails#helper#gather_candidates_cmd('heroku' , s:arguments) 8 | endfunction 9 | 10 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/initializer.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#initializer#candidates(source) 5 | let target = a:source.source__rails_root . '/config/initializers' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/javascript.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#javascript#candidates(source) 5 | let target = a:source.source__rails_root . '/app/assets/javascripts' 6 | if !isdirectory(target) 7 | let target = a:source.source__rails_root . '/public/javascripts' 8 | endif 9 | return unite#sources#rails#helper#gather_candidates_file(target) 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/job.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#job#candidates(source) 5 | let target = a:source.source__rails_root . '/app/jobs' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/lib.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#lib#candidates(source) 5 | let target = a:source.source__rails_root . '/lib' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/log.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#log#candidates(source) 5 | let target = a:source.source__rails_root . '/log' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/mailer.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#mailer#candidates(source) 5 | let target = a:source.source__rails_root . '/app/mailers' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/minitest.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#minitest#candidates(source) 5 | let target = a:source.source__rails_root . '/test' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/model.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#model#candidates(source) 5 | let target = a:source.source__rails_root . '/app/models' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/rake.vim: -------------------------------------------------------------------------------- 1 | let s:arguments = [ 2 | \ {'word' : '--tasks' , 3 | \ 'abbr' : '--tasks - List rake tasks'}, 4 | \ {'word' : '--help' , 5 | \ 'abbr' : "--help - Display rake's help message"}, 6 | \ {'word' : '--version' , 7 | \ 'abbr' : "--version - Display rake's version"}, 8 | \ {'word' : 'about' , 9 | \ 'abbr' : "about - List versions of all Rails frameworks and the environment"}, 10 | \ {'word' : 'db:create' , 11 | \ 'abbr' : "db:create - Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)"}, 12 | \ {'word' : 'db:drop' , 13 | \ 'abbr' : "db:drop - Drops the database for the current Rails.env (use db:drop:all to drop all databases)"}, 14 | \ {'word' : 'db:fixtures:load' , 15 | \ 'abbr' : "db:fixtures:load - Load fixtures into the current environment's database."}, 16 | \ {'word' : 'db:migrate' , 17 | \ 'abbr' : "db:migrate - Migrate the database (options: VERSION=x, VERBOSE=false)."}, 18 | \ {'word' : 'db:migrate:status' , 19 | \ 'abbr' : "db:migrate:status - Display status of migrations"}, 20 | \ {'word' : 'db:rollback' , 21 | \ 'abbr' : "db:rollback - Rolls the schema back to the previous version (specify steps w/ STEP=n)."}, 22 | \ {'word' : 'db:schema:dump' , 23 | \ 'abbr' : "db:schema:dump - Create a db/schema.rb file that can be portably used against any DB supported by AR"}, 24 | \ {'word' : 'db:schema:load' , 25 | \ 'abbr' : "db:schema:load - Load a schema.rb file into the database"}, 26 | \ {'word' : 'db:seed' , 27 | \ 'abbr' : "db:seed - Load the seed data from db/seeds.rb"}, 28 | \ {'word' : 'db:setup' , 29 | \ 'abbr' : "db:setup - Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)"}, 30 | \ {'word' : 'db:structure:dump' , 31 | \ 'abbr' : "db:structure:dump - Dump the database structure to an SQL file"}, 32 | \ {'word' : 'db:version' , 33 | \ 'abbr' : "db:version - Retrieves the current schema version number"}, 34 | \ {'word' : 'doc:app' , 35 | \ 'abbr' : 'doc:app - Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")'}, 36 | \ {'word' : 'log:clear' , 37 | \ 'abbr' : "log:clear - Truncates all *.log files in log/ to zero bytes"}, 38 | \ {'word' : 'middleware' , 39 | \ 'abbr' : "middleware - Prints out your Rack middleware stack"}, 40 | \ {'word' : 'notes' , 41 | \ 'abbr' : "notes - Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"}, 42 | \ {'word' : 'notes:custom' , 43 | \ 'abbr' : "notes:custom - Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"}, 44 | \ {'word' : 'rails:template' , 45 | \ 'abbr' : "rails:template - Applies the template supplied by LOCATION=/path/to/template"}, 46 | \ {'word' : 'rails:update' , 47 | \ 'abbr' : "rails:update - Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs)"}, 48 | \ {'word' : 'routes' , 49 | \ 'abbr' : "routes - Print out all defined routes in match order, with names."}, 50 | \ {'word' : 'secret' , 51 | \ 'abbr' : "secret - Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."}, 52 | \ {'word' : 'stats' , 53 | \ 'abbr' : "stats - Report code statistics (KLOCs, etc) from the application"}, 54 | \ {'word' : 'test' , 55 | \ 'abbr' : "test - Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)"}, 56 | \ {'word' : 'test:recent' , 57 | \ 'abbr' : 'test:recent - Run tests for {:recent=>"test:prepare"} / Test recent changes'}, 58 | \ {'word' : 'test:uncommitted' , 59 | \ 'abbr' : 'test:uncommitted - Run tests for {:uncommitted=>"test:prepare"} / Test changes since last checkin (only Subversion and Git)'}, 60 | \ {'word' : 'time:zones:all' , 61 | \ 'abbr' : "time:zones:all - Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6"}, 62 | \ {'word' : 'tmp:clear' , 63 | \ 'abbr' : "tmp:clear - Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)"}, 64 | \ {'word' : 'tmp:create' , 65 | \ 'abbr' : "tmp:create - Creates tmp directories for sessions, cache, sockets, and pids"}, 66 | \ ] 67 | " 68 | " gather candidates 69 | " 70 | function! unite#sources#rails#collector#rake#candidates(source) 71 | let rake_cmd = g:unite_rails#executable_prefix . ' ' . 'rake' 72 | return unite#sources#rails#helper#gather_candidates_cmd(rake_cmd , s:arguments) 73 | endfunction 74 | 75 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/route.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#route#candidates(source) 5 | let target = a:source.source__rails_root . '/config/routes.rb' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/schema.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#schema#candidates(source) 5 | let target = a:source.source__rails_root . '/db/schema.rb' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/spec.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#spec#candidates(source) 5 | let target = a:source.source__rails_root . '/spec' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/stylesheet.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#stylesheet#candidates(source) 5 | let target = a:source.source__rails_root . '/app/assets/stylesheets' 6 | if !isdirectory(target) 7 | let target = a:source.source__rails_root . '/public/stylesheets' 8 | endif 9 | return unite#sources#rails#helper#gather_candidates_file(target) 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/view.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#view#candidates(source) 5 | let target = a:source.source__rails_root . '/app/views' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/collector/webpack.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather candidates 3 | " 4 | function! unite#sources#rails#collector#webpack#candidates(source) 5 | let target = a:source.source__rails_root . '/app/javascript' 6 | return unite#sources#rails#helper#gather_candidates_file(target) 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/unite/sources/rails/helper.vim: -------------------------------------------------------------------------------- 1 | " 2 | " gather file candidates 3 | " 4 | function! unite#sources#rails#helper#gather_candidates_file(path) 5 | 6 | if isdirectory(a:path) 7 | let files = [] 8 | for f in split(globpath(a:path, '**/*.*') , '\n') 9 | if isdirectory(f) | continue | endif 10 | call add(files , 11 | \ {'name' : substitute(f , a:path. "/" , "" , "") , 'path' : f }) 12 | endfor 13 | else 14 | let files = [{ 15 | \ "name" : fnamemodify(a:path, ":t") , 16 | \ "path" : a:path 17 | \ }] 18 | endif 19 | 20 | return map(files , '{ 21 | \ "word" : v:val.name , 22 | \ "kind" : "file" , 23 | \ "action__path" : v:val.path , 24 | \ "action__directory" : fnamemodify(v:val.path , ":p:h") , 25 | \ }') 26 | endfunction 27 | " 28 | " gather cmd candidates 29 | " 30 | function! unite#sources#rails#helper#gather_candidates_cmd(command, arguments) 31 | return map(a:arguments , '{ 32 | \ "word" : v:val.word , 33 | \ "abbr" : get(v:val , "abbr" , v:val.word) , 34 | \ "kind" : "command" , 35 | \ "action__command" : s:execute_cmd() . a:command . " " . v:val.word , 36 | \ }') 37 | endfunction 38 | " 39 | " gather cmd input candidates 40 | " 41 | function! unite#sources#rails#helper#gather_candidates_cmd_input(command, arguments) 42 | return map(a:arguments , '{ 43 | \ "word" : v:val.word , 44 | \ "abbr" : get(v:val, "abbr", v:val.word) , 45 | \ "kind" : "command" , 46 | \ "action__command" : s:create_cmd_input(a:command, v:val.word, get(v:val, "abbr", v:val.word)) , 47 | \ }') 48 | endfunction 49 | " 50 | " 51 | function! s:create_cmd_input(cmd, word, abbr) 52 | return "call unite#sources#rails#helper#execute_cmd_input('". a:.cmd . "','" . a:word . "','" . a:abbr . "')" 53 | endfunction 54 | " 55 | " 56 | function! unite#sources#rails#helper#execute_cmd_input(cmd, word, abbr) 57 | echohl PmenuSel | echo a:abbr | echohl None 58 | let msg = input(": ") 59 | if msg == '' 60 | echo 'abort' | return 61 | endif 62 | execute s:execute_cmd() . ' ' . a:cmd . ' ' . a:word . ' ' . msg 63 | endfunction 64 | " 65 | " 66 | function! s:execute_cmd() 67 | if g:unite_rails_execute_cmd == '!' 68 | return '!' 69 | else 70 | return g:unite_rails_execute_cmd . ' ' 71 | endif 72 | endfunction 73 | 74 | 75 | " 76 | " get rails root directory 77 | " 78 | function! unite#sources#rails#helper#rails_root() 79 | let dir = finddir("app" , ".;") 80 | if dir == "" | return "" | endif 81 | return dir . "/../" 82 | endfunction 83 | -------------------------------------------------------------------------------- /autoload/unite_rails.vim: -------------------------------------------------------------------------------- 1 | if !exists('g:unite_rails#executable_prefix') 2 | if executable('spring') 3 | let g:unite_rails#executable_prefix = 'spring' 4 | else 5 | let g:unite_rails#executable_prefix = 'bundle exec' 6 | end 7 | end 8 | 9 | if !exists('g:unite_rails#executable') 10 | let g:unite_rails#executable = 'rails' 11 | end 12 | -------------------------------------------------------------------------------- /doc/unite-rails.txt: -------------------------------------------------------------------------------- 1 | *unite-rails* unite plugin for rails 2 | 3 | Author : basyura 4 | License: MIT license {{{ 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | }}} 23 | 24 | unite /app/models 25 | :Unite rails/model 26 | 27 | unite /app/controllers 28 | :Unite rails/controller 29 | 30 | unite /app/views 31 | :Unite rails/view 32 | 33 | unite /app/helpers 34 | :Unite rails/helper 35 | 36 | unite /app/jobs 37 | :Unite rails/job 38 | 39 | unite /app/mailers 40 | :Unite rails/mailer 41 | 42 | unite /lib 43 | :Unite rails/lib 44 | 45 | unite /db 46 | :Unite rails/db 47 | 48 | unite /config 49 | :Unite rails/config 50 | 51 | unite /log 52 | :Unite rails/log 53 | 54 | unite /public/javascripts 55 | :Unite rails/javascript 56 | 57 | unite /public/stylesheets 58 | :Unite rails/stylesheet 59 | 60 | unite bundle's commands 61 | :Unite rails/bundle 62 | 63 | unite bundled gems 64 | :Unite rails/bundled_gem 65 | 66 | unite /app/javascript 67 | :Unite rails/webpack 68 | 69 | 70 | == maybe == 71 | 72 | unite routes 73 | :Unite rails/route 74 | 75 | unite root 76 | :Unite rails/root 77 | 78 | unite command 79 | :Unite rails/command 80 | > rake db:migrate 81 | 82 | vim:tw=78:ts=8:ft=help:norl:noet:ai 83 | --------------------------------------------------------------------------------