vim-tags 0.2.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/plugin/vim-tags.vim +18 -12
  3. data/plugins.rb +44 -13
  4. data/vim-tags.gemspec +3 -2
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24862170a8fd6195f07f07160c5c810336e859a5297712dac58b515cca323c60
4
- data.tar.gz: aab67522bb493fa0308d01b715030a0b66c3663471d121db9e54d4aeefb3c22c
3
+ metadata.gz: 1bcc25f608cacadab703bc61e47e1f78121c05c480aa8223c173681c383d9d30
4
+ data.tar.gz: c7068ed161d20bf0a6ba1ed90c31b71da494dd9c1f5ac4a369c38b8e53cff349
5
5
  SHA512:
6
- metadata.gz: '0890772903f0e49d8037c62c024742fb7b8c6a218e86b26c5f708c13a5fdecfccb428ddb4b04ec80a40043579d430d65026385505557ddc9b70d74f3626a5e61'
7
- data.tar.gz: 224d233cd91b633bc94967523665da3a2c4e8cfabd28b671c75f7064c914ad2b988e5b4fc67c09a7e9e3cc14a9f690209a326f7773523cb78a0d86bcc1c08c3b
6
+ metadata.gz: 00420db3434db31fee4b541cd8c8defb9b7cb4af3c43ea852c0c5862aed0aa6a6dc057307cd1186c162b1d817dc677767bb96234d62fb8f70e692b72984e6548
7
+ data.tar.gz: de684714ece1500611da22cbf1ab2d1f4b99236b8cef60260a0187584d6e1b006a596c348e57fc4b842a4b391bd674878227b3c5b7111e57525914b1d9c7f7cb
data/plugin/vim-tags.vim CHANGED
@@ -1,19 +1,25 @@
1
1
  function! LoadRubyTags()
2
- if exists("g:vim_tags_loaded")
3
- return
4
- endif
2
+ let l:project_directory = finddir('.git/..', expand('%:p:h').';')
5
3
 
6
- let s:load_ruby_tags_fp = finddir('.git/..', expand('%:p:h').';') . '/.bundle/.tag_files'
4
+ if !empty(l:project_directory)
5
+ let l:gem_tag_files_path = l:project_directory . '/.bundle/.gem_tag_files'
7
6
 
8
- if !filereadable(s:load_ruby_tags_fp)
9
- let s:install_response = system('bundler plugin install vim-tags')
10
- let s:command_response = system('bundler vim-tags')
11
- endif
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
12
11
 
13
- let s:comma_tags = system("cat " . s:load_ruby_tags_fp . " | paste -sd ',' -")
14
- let g:vim_tags_loaded = 1
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'))
15
14
 
16
- let &l:tags = &tags . ',' . s:comma_tags
15
+ let &l:tags = &tags . ',' . l:gems['tags'] . ',' . l:ruby['tags']
16
+ let &l:path = &path . ',' . l:gems['paths'] . ',' . l:ruby['paths']
17
+ endif
17
18
  endfunction
18
19
 
19
- autocmd FileType ruby :call LoadRubyTags()
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,33 +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
+ )
30
+ end
31
+
32
+ def ruby_tags
33
+ $:.select { |path| File.exist?(File.join(path, "tags")) }.join(",")
34
+ end
35
+
36
+ def gem_tags
37
+ gem_specs.filter_map do |spec|
38
+ tag_path = File.join(spec.full_gem_path, "tags")
39
+
40
+ next unless File.exist?(tag_path)
41
+
42
+ tag_path
43
+ end.sort.join(",")
18
44
  end
19
45
 
20
46
  def gem_paths
21
- Bundler.load.specs.filter_map do |spec|
22
- next if spec.name == "bundler" ||
23
- !File.exist?(File.join(spec.full_gem_path, "tags"))
47
+ gem_specs.map { |spec| File.join(spec.full_gem_path, "lib") }.sort.join(",")
48
+ end
24
49
 
25
- spec.full_gem_path
26
- end
50
+ def gem_specs
51
+ @gem_specs ||= Bundler.load.specs
27
52
  end
28
53
 
29
- def ruby_paths
30
- $:.select { |path| File.exist?(File.join(path, "tags")) }
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
31
62
  end
32
63
  end
33
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.2.0"
5
+ spec.version = "0.4.2"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vim-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza