alpaca_complete 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +20 -0
- data/README.md +107 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/alpaca_complete.gemspec +52 -0
- data/autoload/neocomplcache/sources/locale_complete.vim +108 -0
- data/autoload/neocomplcache/sources/yaml_complete +112 -0
- data/bin/alpaca_complete +13 -0
- data/lib/AlpacaComplete/detect.rb +40 -0
- data/lib/AlpacaComplete/locale_complete.rb +105 -0
- data/lib/AlpacaComplete/utils.rb +71 -0
- data/lib/AlpacaComplete/version.rb +5 -0
- data/lib/AlpacaComplete.rb +21 -0
- data/spec/detect_spec.rb +44 -0
- data/spec/locale_complete_spec.rb +81 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/supports/dict/existent.yml +2 -0
- data/spec/supports/dict/migration.yml +45 -0
- data/spec/supports/rails_complete/.gitignore +15 -0
- data/spec/supports/rails_complete/Gemfile +38 -0
- data/spec/supports/rails_complete/README.rdoc +261 -0
- data/spec/supports/rails_complete/Rakefile +7 -0
- data/spec/supports/rails_complete/app/assets/images/rails.png +0 -0
- data/spec/supports/rails_complete/app/assets/javascripts/application.js +15 -0
- data/spec/supports/rails_complete/app/assets/stylesheets/application.css +13 -0
- data/spec/supports/rails_complete/app/controllers/application_controller.rb +3 -0
- data/spec/supports/rails_complete/app/helpers/application_helper.rb +2 -0
- data/spec/supports/rails_complete/app/mailers/.gitkeep +0 -0
- data/spec/supports/rails_complete/app/models/.gitkeep +0 -0
- data/spec/supports/rails_complete/app/views/layouts/application.html.erb +14 -0
- data/spec/supports/rails_complete/config/application.rb +62 -0
- data/spec/supports/rails_complete/config/boot.rb +6 -0
- data/spec/supports/rails_complete/config/database.yml +25 -0
- data/spec/supports/rails_complete/config/environment.rb +5 -0
- data/spec/supports/rails_complete/config/environments/development.rb +37 -0
- data/spec/supports/rails_complete/config/environments/production.rb +67 -0
- data/spec/supports/rails_complete/config/environments/test.rb +37 -0
- data/spec/supports/rails_complete/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/supports/rails_complete/config/initializers/inflections.rb +15 -0
- data/spec/supports/rails_complete/config/initializers/mime_types.rb +5 -0
- data/spec/supports/rails_complete/config/initializers/secret_token.rb +7 -0
- data/spec/supports/rails_complete/config/initializers/session_store.rb +8 -0
- data/spec/supports/rails_complete/config/initializers/wrap_parameters.rb +14 -0
- data/spec/supports/rails_complete/config/locales/active_admin.ja.yml +87 -0
- data/spec/supports/rails_complete/config/locales/devise.ja.yml +59 -0
- data/spec/supports/rails_complete/config/locales/ja.yml +5 -0
- data/spec/supports/rails_complete/config/routes.rb +58 -0
- data/spec/supports/rails_complete/config.ru +4 -0
- data/spec/supports/rails_complete/db/seeds.rb +7 -0
- data/spec/supports/rails_complete/lib/assets/.gitkeep +0 -0
- data/spec/supports/rails_complete/lib/tasks/.gitkeep +0 -0
- data/spec/supports/rails_complete/log/.gitkeep +0 -0
- data/spec/supports/rails_complete/public/404.html +26 -0
- data/spec/supports/rails_complete/public/422.html +26 -0
- data/spec/supports/rails_complete/public/500.html +25 -0
- data/spec/supports/rails_complete/public/favicon.ico +0 -0
- data/spec/supports/rails_complete/public/index.html +241 -0
- data/spec/supports/rails_complete/public/robots.txt +5 -0
- data/spec/supports/rails_complete/script/rails +6 -0
- data/spec/supports/rails_complete/test/fixtures/.gitkeep +0 -0
- data/spec/supports/rails_complete/test/functional/.gitkeep +0 -0
- data/spec/supports/rails_complete/test/integration/.gitkeep +0 -0
- data/spec/supports/rails_complete/test/performance/browsing_test.rb +12 -0
- data/spec/supports/rails_complete/test/test_helper.rb +13 -0
- data/spec/supports/rails_complete/test/unit/.gitkeep +0 -0
- data/spec/supports/rails_complete/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/supports/rails_complete/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/supports/rails_complete/vendor/plugins/.gitkeep +0 -0
- data/spec/utils_spec.rb +25 -0
- data/spec/version_spec.rb +5 -0
- metadata +207 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.8.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler"
|
12
|
+
gem "jeweler", "~> 1.8.4"
|
13
|
+
gem 'simplecov'
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.8.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rdoc
|
11
|
+
json (1.7.5)
|
12
|
+
multi_json (1.3.6)
|
13
|
+
rake (0.9.2.2)
|
14
|
+
rdoc (3.12)
|
15
|
+
json (~> 1.4)
|
16
|
+
rspec (2.8.0)
|
17
|
+
rspec-core (~> 2.8.0)
|
18
|
+
rspec-expectations (~> 2.8.0)
|
19
|
+
rspec-mocks (~> 2.8.0)
|
20
|
+
rspec-core (2.8.0)
|
21
|
+
rspec-expectations (2.8.0)
|
22
|
+
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-mocks (2.8.0)
|
24
|
+
simplecov (0.6.4)
|
25
|
+
multi_json (~> 1.0)
|
26
|
+
simplecov-html (~> 0.5.3)
|
27
|
+
simplecov-html (0.5.3)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler
|
34
|
+
jeweler (~> 1.8.4)
|
35
|
+
rdoc (~> 3.12)
|
36
|
+
rspec (~> 2.8.0)
|
37
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Hiroyuki Ishii
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# alpaca_complete
|
2
|
+
|
3
|
+
そう、それは季節が秋へと差し掛かるちょっと肌寒い時期でした。
|
4
|
+
railsを使っていて気が遠くなるくらいの単語数に嫌気がさし、
|
5
|
+
僕はエディタを乗り換えてIDEを使おうか迷っていました。
|
6
|
+
|
7
|
+
そんなとき出会ったのが、[RubyMine]( http://www.jetbrains.com/ruby/ )。
|
8
|
+
|
9
|
+
「RubyMineすげぇ。やべぇ。vim敵わん。。」
|
10
|
+
さすが、IDE。補完からビジュアルから、素晴らしい機能が満載でした。
|
11
|
+
それからというもの、RubyMineの虜になっていました。
|
12
|
+
|
13
|
+
しかし、IDE。vimキーバインドはガラクタでした。
|
14
|
+
vim病が再発しそうなころ、神の声が聞こえました。
|
15
|
+
|
16
|
+
**「それ、vimで出来るよ」**
|
17
|
+
|
18
|
+
さぁ、楽しい開発の始まりです。
|
19
|
+
|
20
|
+
RoR & vimユーザーの為の最強補完プラグインを作成しております。
|
21
|
+
目標はRubyMineの補完機能を超えることです。
|
22
|
+
|
23
|
+
## install
|
24
|
+
|
25
|
+
neocomplcacheを未インストールの方はさきにこちらをインストールしてください。
|
26
|
+
|
27
|
+
```vim:.vimrc
|
28
|
+
NeoBundle 'taichouchou2/alpaca_complete'
|
29
|
+
```
|
30
|
+
|
31
|
+
以下は登録したけど、まだ動かないかも。
|
32
|
+
|
33
|
+
```shell
|
34
|
+
`gem install alpaca_complete`
|
35
|
+
```
|
36
|
+
|
37
|
+
代わりに、以下のコマンドを打ってください
|
38
|
+
|
39
|
+
```shell
|
40
|
+
rake build
|
41
|
+
rake install
|
42
|
+
```
|
43
|
+
|
44
|
+
こういう表示になるはずです
|
45
|
+
|
46
|
+
```shell
|
47
|
+
rake build
|
48
|
+
Successfully built RubyGem
|
49
|
+
Name: alpaca_complete
|
50
|
+
Version: 0.1.0
|
51
|
+
File: alpaca_complete-0.1.0.gem
|
52
|
+
taichou@tai-no-MacBook-Air:~/.bundle/alpaca_complete $
|
53
|
+
rake install
|
54
|
+
Successfully built RubyGem
|
55
|
+
Name: alpaca_complete
|
56
|
+
Version: 0.1.0
|
57
|
+
File: alpaca_complete-0.1.0.gem
|
58
|
+
Executing "ruby -S gem install ./pkg/alpaca_complete-0.1.0.gem":
|
59
|
+
ruby -S gem install ./pkg/alpaca_complete-0.1.0.gem
|
60
|
+
Successfully installed alpaca_complete-0.1.0
|
61
|
+
1 gem installed
|
62
|
+
Installing ri documentation for alpaca_complete-0.1.0...
|
63
|
+
Installing RDoc documentation for alpaca_complete-0.1.0...
|
64
|
+
```
|
65
|
+
|
66
|
+
### TODO
|
67
|
+
|
68
|
+
下記の機能を実装予定です。(優先順位順)
|
69
|
+
それぞれの補完は説明や引数付きで補完する予定です。
|
70
|
+
|
71
|
+
- locate(I18n.t)補完(完了)
|
72
|
+
- migrate補完
|
73
|
+
- view補完
|
74
|
+
- controller補完
|
75
|
+
- models補完
|
76
|
+
- validate
|
77
|
+
- 推奨構文
|
78
|
+
- chaching機能
|
79
|
+
|
80
|
+
### お願い
|
81
|
+
|
82
|
+
「こんな補完が欲しい」っていうのがあるかたは、
|
83
|
+
Issuesか、twitterに書き込んでください。
|
84
|
+
|
85
|
+
あと、コミッターも募集しています。
|
86
|
+
|
87
|
+
## and more
|
88
|
+
|
89
|
+
**FEATURES**
|
90
|
+
|
91
|
+
1. coloring function
|
92
|
+
|
93
|
+
**AUTHOR**
|
94
|
+
|
95
|
+
Hiroyuki Ishii \<alprhcp666@gmail.com\>
|
96
|
+
|
97
|
+
**COPYRIGHT**
|
98
|
+
|
99
|
+
Copyright (c) 2012, Hiroyuki Ishii \<alprhcp666@gmail.com\>
|
100
|
+
|
101
|
+
**LICENSE**
|
102
|
+
|
103
|
+
[MIT License][MIT]
|
104
|
+
|
105
|
+
[MIT]: http://www.opensource.org/licenses/mit-license.php
|
106
|
+
|
107
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= alpaca_complete
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to alpaca_complete
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Hiroyuki Ishii. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "alpaca_complete"
|
18
|
+
gem.homepage = "http://github.com/taichouchou2/alpaca_complete"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{rails complete for editor}
|
21
|
+
gem.description = %Q{rails complete for editor}
|
22
|
+
gem.email = "alprhcp666@gmail.com"
|
23
|
+
gem.authors = ["Hiroyuki Ishii"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "alpaca_complete #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
require 'lib/AlpacaComplete.rb'
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "alpaca_complete"
|
10
|
+
s.version = `cat VERSION`
|
11
|
+
|
12
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
|
+
s.authors = ["Hiroyuki Ishii"]
|
14
|
+
s.date = "2012-10-06"
|
15
|
+
s.description = "rails auto-complete for editor"
|
16
|
+
s.email = "alprhcp666@gmail.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.homepage = "http://github.com/taichouchou2/alpaca_complete"
|
23
|
+
s.licenses = ["MIT"]
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
s.rubygems_version = "1.8.23"
|
26
|
+
s.summary = "rails complete for editor"
|
27
|
+
|
28
|
+
if s.respond_to? :specification_version then
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
32
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
33
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
34
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
35
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
36
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
37
|
+
else
|
38
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
39
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
40
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
41
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
42
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
43
|
+
end
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
46
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
47
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
48
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
49
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
"=============================================================================
|
2
|
+
" FILE: locale_complete.Vim
|
3
|
+
" AUTHOR: Hiroyuki Ishii <alprhcp666@gmail.com>
|
4
|
+
" Last Modified: 2012-09-26
|
5
|
+
" License: MIT license {{{
|
6
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
" a copy of this software and associated documentation files (the
|
8
|
+
" "Software"), to deal in the Software without restriction, including
|
9
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
" the following conditions:
|
13
|
+
"
|
14
|
+
" The above copyright notice and this permission notice shall be included
|
15
|
+
" in all copies or substantial portions of the Software.
|
16
|
+
"
|
17
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
18
|
+
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
" }}}
|
25
|
+
"=============================================================================
|
26
|
+
|
27
|
+
let s:save_cpo = &cpo
|
28
|
+
set cpo&vim
|
29
|
+
|
30
|
+
let s:source = {
|
31
|
+
\ 'name' : 'locale_complete_locale',
|
32
|
+
\ 'kind' : 'ftplugin',
|
33
|
+
\ 'filetypes' : { 'ruby' : 1, 'eruby' : 1 },
|
34
|
+
\}
|
35
|
+
|
36
|
+
if !exists('g:source_alpaca_rails_length')
|
37
|
+
let g:source_alpaca_rails_length = 2
|
38
|
+
endif
|
39
|
+
|
40
|
+
if !exists('g:source_alpaca_rails_rank')
|
41
|
+
let g:source_alpaca_rails_rank = 200
|
42
|
+
endif
|
43
|
+
|
44
|
+
" TODO change
|
45
|
+
if !exists('g:source_alpaca_rails_bin')
|
46
|
+
endif
|
47
|
+
|
48
|
+
function! s:source.initialize()
|
49
|
+
call neocomplcache#set_completion_length('alpaca_rails', g:source_alpaca_rails_length)
|
50
|
+
call neocomplcache#set_dictionary_helper(g:neocomplcache_source_rank,
|
51
|
+
\ 'alpaca_rails', g:source_alpaca_rails_rank)
|
52
|
+
endfunction
|
53
|
+
|
54
|
+
function! s:source.finalize()
|
55
|
+
" TODO chaching
|
56
|
+
endfunction
|
57
|
+
|
58
|
+
function! s:source.get_keyword_pos(cur_text)
|
59
|
+
if a:cur_text =~ '.*I18n\.t.*'
|
60
|
+
let cur_pos = match(a:cur_text, '[a-zA-Z]\+[a-zA-Z._:]*$')
|
61
|
+
|
62
|
+
return cur_pos < 0 ? -1 : cur_pos
|
63
|
+
end
|
64
|
+
return -1
|
65
|
+
endfunction
|
66
|
+
|
67
|
+
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)
|
68
|
+
" TODO caching
|
69
|
+
let line = a:cur_keyword_str
|
70
|
+
|
71
|
+
let input_first = match(line, '[a-zA-Z._:]*$')
|
72
|
+
let input_obj = line[input_first :]
|
73
|
+
|
74
|
+
if input_obj ==# '' || input_obj ==# "\s"
|
75
|
+
return []
|
76
|
+
endif
|
77
|
+
|
78
|
+
" RoRの補完プラグインを使う
|
79
|
+
let mf0 = neocomplcache#system( 'alpaca_complete -l -f ' . expand("%:p") )
|
80
|
+
let mf_list = split(mf0, '\n')
|
81
|
+
|
82
|
+
let result = []
|
83
|
+
for locale_name in mf_list
|
84
|
+
let locale_setting = substitute(locale_name, '^\([a-zA-Z_]*\)\..*', '\1', 'g')
|
85
|
+
let complete_pos = strlen(locale_setting) + 1
|
86
|
+
let result = add(result, {
|
87
|
+
\ "word" : locale_name[complete_pos :],
|
88
|
+
\ "abbr" : locale_name[complete_pos :],
|
89
|
+
\ "kind" : "[alpL]",
|
90
|
+
\ "menu" : locale_setting
|
91
|
+
\})
|
92
|
+
endfor
|
93
|
+
|
94
|
+
return neocomplcache#keyword_filter(result, input_obj)
|
95
|
+
endfunction
|
96
|
+
|
97
|
+
function! neocomplcache#sources#locale_complete#define()
|
98
|
+
return s:source
|
99
|
+
endfunction
|
100
|
+
|
101
|
+
function! neocomplcache#sources#locale_complete#get_cur_text()
|
102
|
+
return [line('.')]
|
103
|
+
endfunction
|
104
|
+
|
105
|
+
let &cpo = s:save_cpo
|
106
|
+
unlet s:save_cpo
|
107
|
+
|
108
|
+
" vimfoldmethod=marker
|
@@ -0,0 +1,112 @@
|
|
1
|
+
"=============================================================================
|
2
|
+
" FILE: yaml_complete.Vim
|
3
|
+
" AUTHOR: Hiroyuki Ishii <alprhcp666@gmail.com>
|
4
|
+
" Last Modified: 2012-09-26
|
5
|
+
" License: MIT license {{{
|
6
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
" a copy of this software and associated documentation files (the
|
8
|
+
" "Software"), to deal in the Software without restriction, including
|
9
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
" the following conditions:
|
13
|
+
"
|
14
|
+
" The above copyright notice and this permission notice shall be included
|
15
|
+
" in all copies or substantial portions of the Software.
|
16
|
+
"
|
17
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
18
|
+
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
" }}}
|
25
|
+
"=============================================================================
|
26
|
+
|
27
|
+
let s:save_cpo = &cpo
|
28
|
+
set cpo&vim
|
29
|
+
|
30
|
+
let s:source = {
|
31
|
+
\ 'name' : 'yaml_complete_locale',
|
32
|
+
\ 'kind' : 'ftplugin',
|
33
|
+
\ 'filetypes' : { 'ruby' : 1, 'eruby' : 1 },
|
34
|
+
\}
|
35
|
+
if !exists('g:source_yaml_dir')
|
36
|
+
" TODO error
|
37
|
+
let g:source_yaml_dir = ''
|
38
|
+
endif
|
39
|
+
|
40
|
+
if !exists('g:source_yaml_complete_length')
|
41
|
+
let g:source_yaml_complete_length = 2
|
42
|
+
endif
|
43
|
+
|
44
|
+
if !exists('g:source_yaml_complete_rank')
|
45
|
+
let g:source_yaml_complete_rank = 200
|
46
|
+
endif
|
47
|
+
|
48
|
+
function! s:source.initialize()
|
49
|
+
" TODO chaching
|
50
|
+
call neocomplcache#set_completion_length('yaml_complete', g:source_alpaca_rails_length)
|
51
|
+
call neocomplcache#set_dictionary_helper(g:neocomplcache_source_rank,
|
52
|
+
\ 'yaml_complete', g:source_yaml_complete_rank)
|
53
|
+
endfunction
|
54
|
+
|
55
|
+
function! s:source.finalize()
|
56
|
+
" TODO chaching
|
57
|
+
endfunction
|
58
|
+
|
59
|
+
function! s:source.get_keyword_pos(cur_text)
|
60
|
+
if a:cur_text =~ '\s*[a-zA-Z._:]'
|
61
|
+
let cur_pos = match(a:cur_text, '[a-zA-Z:_]\+[a-zA-Z._:]*$')
|
62
|
+
|
63
|
+
return cur_pos < 0 ? -1 : cur_pos
|
64
|
+
end
|
65
|
+
return -1
|
66
|
+
endfunction
|
67
|
+
|
68
|
+
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)
|
69
|
+
let path = neocomplcache#system( 'alpaca_complete -d ' . expand("%:p") )
|
70
|
+
let line = a:cur_keyword_str
|
71
|
+
|
72
|
+
let input_first = match(line, '[a-zA-Z._:]*$')
|
73
|
+
let input_obj = line[input_first :]
|
74
|
+
|
75
|
+
if input_obj ==# '' || input_obj ==# "\s"
|
76
|
+
return []
|
77
|
+
endif
|
78
|
+
|
79
|
+
" RoRの補完プラグインを使う
|
80
|
+
let mf0 = s:get_dict_yaml(
|
81
|
+
let mf_list = split(mf0, '\n')
|
82
|
+
let result = []
|
83
|
+
for locale_name in mf_list
|
84
|
+
" s:get_locate() => ja + "."
|
85
|
+
let complete_pos = strlen(s:get_locate()) + 1
|
86
|
+
let result = add(result, {
|
87
|
+
\ "word" : locale_name[complete_pos :],
|
88
|
+
\ "abbr" : locale_name[complete_pos :],
|
89
|
+
\ "kind" : "[locale]"
|
90
|
+
\})
|
91
|
+
endfor
|
92
|
+
|
93
|
+
return neocomplcache#keyword_filter(result, input_obj)
|
94
|
+
endfunction
|
95
|
+
|
96
|
+
function! s:get_locate()
|
97
|
+
" TODO 自動取得
|
98
|
+
return 'ja'
|
99
|
+
endfunction
|
100
|
+
|
101
|
+
function! neocomplcache#sources#yaml_complete#define()
|
102
|
+
return s:source
|
103
|
+
endfunction
|
104
|
+
|
105
|
+
function! neocomplcache#sources#yaml_complete#get_cur_text()
|
106
|
+
return [line('.')]
|
107
|
+
endfunction
|
108
|
+
|
109
|
+
let &cpo = s:save_cpo
|
110
|
+
unlet s:save_cpo
|
111
|
+
|
112
|
+
" vimfoldmethod=marker
|
data/bin/alpaca_complete
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'AlpacaComplete'
|
4
|
+
|
5
|
+
opt = AlpacaComplete::Utils.option_parser ARGV
|
6
|
+
if opt[:locale] == true
|
7
|
+
locales = AlpacaComplete::LocaleComplete.complete opt[:path], opt[:word]
|
8
|
+
locales.each do |locale|
|
9
|
+
puts locale
|
10
|
+
end
|
11
|
+
elsif opt[:dict] == true
|
12
|
+
locales = AlpacaComplete::DictComplete.complete opt[:path], opt[:word]
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
module AlpacaComplete::Detect
|
3
|
+
|
4
|
+
@@rails_root = nil
|
5
|
+
|
6
|
+
# transport from rails.vim
|
7
|
+
def detect filename
|
8
|
+
fn = filename.gsub('\c^file://', '')
|
9
|
+
|
10
|
+
if File.readable?("#{fn}/config/environment.rb")
|
11
|
+
return fn
|
12
|
+
else
|
13
|
+
fn = File.dirname(fn)
|
14
|
+
end
|
15
|
+
|
16
|
+
# return rails_root_path if filename is config/environment.rb
|
17
|
+
if fn =~ /[\/]config[\/]environment\.rb$/
|
18
|
+
return fn[0, fn.length - 22]
|
19
|
+
end
|
20
|
+
|
21
|
+
ofn = nil
|
22
|
+
until fn == ofn || fn == nil do
|
23
|
+
return fn if File.readable?("#{fn}/config/environment.rb")
|
24
|
+
|
25
|
+
ofn = fn
|
26
|
+
rails_path = ofn.match( /^(.*)[\/](app|config|db|doc|extras|features|lib|log|public|script|spec|stories|test|tmp|vendor|publics|sdoc)($|[\/].*$)/)
|
27
|
+
|
28
|
+
if rails_path
|
29
|
+
fn = rails_path[1]
|
30
|
+
else
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
|
38
|
+
module_function :detect
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
# hash extend deep_merge
|
6
|
+
class Hash
|
7
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
8
|
+
def deep_merge(other_hash)
|
9
|
+
dup.deep_merge!(other_hash)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Same as +deep_merge+, but modifies +self+.
|
13
|
+
def deep_merge!(other_hash)
|
14
|
+
other_hash.each_pair do |k,v|
|
15
|
+
tv = self[k]
|
16
|
+
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
|
17
|
+
end
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def full_join( str = ".", key="" )
|
22
|
+
dup.full_join! str, key
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_join!( str = ".", key="")
|
26
|
+
res = {}
|
27
|
+
self.each do |k, v|
|
28
|
+
full_key = key.empty? ? k : "#{key}.#{k}"
|
29
|
+
if v.is_a?(Hash)
|
30
|
+
res.deep_merge!( v.full_join( str, full_key ) )
|
31
|
+
else
|
32
|
+
res[full_key] = v
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
res
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def join_to_str( list, str = "" )
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module AlpacaComplete::LocaleComplete
|
46
|
+
Version = "1.0"
|
47
|
+
LOCALE_PATH = 'config/locales'
|
48
|
+
|
49
|
+
extend AlpacaComplete::Detect
|
50
|
+
|
51
|
+
# return array of list to match word
|
52
|
+
def self.complete( path, word )
|
53
|
+
opt = { "path" => path}
|
54
|
+
comp = Regexp.new("^#{word}")
|
55
|
+
|
56
|
+
get_locale_list( opt ).select {|v|
|
57
|
+
v.match comp
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# return hash of locale list. hash key is full_name.
|
62
|
+
def self.get_locale_hash( opt={} )
|
63
|
+
get_locale( opt["path"] ).full_join(".")
|
64
|
+
end
|
65
|
+
|
66
|
+
# return array of locale list.
|
67
|
+
def self.get_locale_list( opt={} )
|
68
|
+
locales = get_locale_hash(opt)
|
69
|
+
|
70
|
+
res = []
|
71
|
+
locales.each do |k, v|
|
72
|
+
res << k
|
73
|
+
end
|
74
|
+
|
75
|
+
res
|
76
|
+
end
|
77
|
+
|
78
|
+
# return hash deep_merged config/locales/**/*.yml
|
79
|
+
def self.get_locale( file_path )
|
80
|
+
rails_root = detect( file_path )
|
81
|
+
locale_path = "#{rails_root}/#{LOCALE_PATH}"
|
82
|
+
|
83
|
+
# hash
|
84
|
+
locales = Hash.new
|
85
|
+
|
86
|
+
Dir.glob( "#{locale_path}/**/*.yml" ).each do |file|
|
87
|
+
locale_hash = YAML::load_file( file )
|
88
|
+
locales.deep_merge!(locale_hash)
|
89
|
+
end
|
90
|
+
|
91
|
+
locales
|
92
|
+
end
|
93
|
+
|
94
|
+
# return methods of i18n as string
|
95
|
+
def self.get_methods
|
96
|
+
require 'i18n'
|
97
|
+
concat = []
|
98
|
+
I18n.methods.each do |m|
|
99
|
+
concat << m.to_s
|
100
|
+
end
|
101
|
+
|
102
|
+
concat.join("\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|