vim-tags 0.1.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7917206260619d145b895c9bffc78c8865c79f533e209f10bccb9a3cf52f226d
4
- data.tar.gz: bac9256a46314304b5522a1e65dd25d11c5e0af8218f9233818414baaf0baea3
3
+ metadata.gz: 54f07d46762d5b46e167a109c7db802774447fbd29ceb7647688b66318ab0555
4
+ data.tar.gz: bc1a66bf2898f280248e1201504b0081ba9b7be71929d9150aadc941fe714a23
5
5
  SHA512:
6
- metadata.gz: 8dae5e1dddaac6e64a59f1d340dab7f596d6f4dc27ca7d8eecb2af19ba3a0e0ad656407a92feb921d5725273bae2a7dc4ce9f59797a44d9767a336265d649e18
7
- data.tar.gz: 943cf02968de96b6e7114108cd4be9741925a550d241525f3d9de26f560512a1d1f66ee81c1fde507db5eafdca82fa5e212ba40f31fddbab7672646c6cbdb228
6
+ metadata.gz: adeed160156225ac249e50e37846ebb0fdfd54d78704fa866ac883784ea7f4146504535ae3cff08d4ab642d6d3dadb6409818400bf746444ba9cd2bb4863271b
7
+ data.tar.gz: 53725474a7183209df6ce8ccb0f4ecb7d5ba84bbe052e86cbb38f904478c057718055e08c85bab5238aa02b9eb42d448f6795feb280aaea5c84c866117291d34
@@ -0,0 +1,25 @@
1
+ function! LoadRubyTags()
2
+ let l:project_directory = finddir('.git/..', expand('%:p:h').';')
3
+
4
+ if !empty(l:project_directory)
5
+ let l:gem_tag_files_path = l:project_directory . '/.bundle/.gem_tag_files'
6
+
7
+ if !filereadable(l:gem_tag_files_path)
8
+ let l:install_response = system('bundler plugin install vim-tags')
9
+ let l:command_response = system('bundler vim-tags')
10
+ endif
11
+
12
+ let l:gems = json_decode(readfile(l:gem_tag_files_path))
13
+ let l:ruby = json_decode(readfile(l:project_directory . '/.bundle/.ruby_tag_files'))
14
+
15
+ let &l:tags = &tags . ',' . l:gems['tags'] . ',' . l:ruby['tags']
16
+ let &l:path = &path . ',' . l:gems['paths'] . ',' . l:ruby['paths']
17
+ endif
18
+ endfunction
19
+
20
+ augroup rubypath
21
+ autocmd!
22
+ autocmd FileType ruby setlocal suffixesadd+=.rb
23
+
24
+ autocmd FileType ruby :call LoadRubyTags()
25
+ augroup END
data/plugins.rb CHANGED
@@ -1,35 +1,64 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler"
4
+ require "json"
4
5
 
5
6
  class VimTagsCommand < Bundler::Plugin::API
6
7
  command "vim-tags"
7
8
 
8
9
  def exec(*)
9
- cache_file = File.join(Bundler.app_config_path, ".tag_files")
10
+ write_gem_file
11
+ write_ruby_file
12
+ end
10
13
 
11
- puts "\nWriting tag cache to #{cache_file}"
14
+ private
12
15
 
13
- File.open(cache_file, "w") do |f|
14
- f.truncate(0)
16
+ def write_gem_file
17
+ write_to_file(
18
+ File.join(Bundler.app_config_path, ".gem_tag_files"),
19
+ "\nWriting gem file tag cache",
20
+ { tags: gem_tags, paths: gem_paths }
21
+ )
22
+ end
15
23
 
16
- f.write (gem_paths + ruby_paths).uniq.join("\n")
17
- end
24
+ def write_ruby_file
25
+ write_to_file(
26
+ File.join(Bundler.app_config_path, ".ruby_tag_files"),
27
+ "Writing ruby tag cache to",
28
+ { tags: ruby_tags, paths: $:.join(",") }
29
+ )
18
30
  end
19
31
 
20
- def gem_paths
21
- Bundler.load.specs.filter_map do |spec|
22
- path = File.join(spec.full_gem_path, "tags")
32
+ def ruby_tags
33
+ $:.select { |path| File.exist?(File.join(path, "tags")) }.join(",")
34
+ end
23
35
 
24
- next if spec.name == "bundler" || !File.exist?(path)
36
+ def gem_tags
37
+ gem_specs.filter_map do |spec|
38
+ tag_path = File.join(spec.full_gem_path, "tags")
25
39
 
26
- path
27
- end
40
+ next unless File.exist?(tag_path)
41
+
42
+ tag_path
43
+ end.sort.join(",")
28
44
  end
29
45
 
30
- def ruby_paths
31
- $:.map { |path| File.join(path, "tags") }.
32
- select { |path| File.exist?(path) }
46
+ def gem_paths
47
+ gem_specs.map(&:full_gem_path).sort.join(",")
48
+ end
49
+
50
+ def gem_specs
51
+ @gem_specs ||= Bundler.load.specs
52
+ end
53
+
54
+ def write_to_file(file_path, description, payload)
55
+ puts "#{description} to #{file_path}"
56
+
57
+ File.open(file_path, "w") do |f|
58
+ f.truncate(0)
59
+
60
+ f.write payload.to_json
61
+ end
33
62
  end
34
63
  end
35
64
 
data/vim-tags.gemspec CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "vim-tags"
5
- spec.version = "0.1.0"
5
+ spec.version = "0.4.1"
6
6
  spec.authors = ["Nick Pezza"]
7
7
  spec.email = ["pezza@hey.com"]
8
8
 
9
- spec.summary = "Generate cache file of all paths to tags files of dependencies"
9
+ spec.summary =
10
+ "Generate cache file of all paths to tags files of dependencies"
10
11
  spec.license = "MIT"
11
12
  spec.required_ruby_version = ">= 2.7.0"
12
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vim-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debug
@@ -34,6 +34,7 @@ files:
34
34
  - ".rubocop.yml"
35
35
  - Gemfile
36
36
  - Rakefile
37
+ - plugin/vim-tags.vim
37
38
  - plugins.rb
38
39
  - vim-tags.gemspec
39
40
  homepage: