read_source 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 336cda1615c6ad734c6d8078a3a7841de8641a33
4
- data.tar.gz: 7fa35d043f09e885bb887fff8a7f3300a7fb38c9
3
+ metadata.gz: 0e5fae70c3b672c0a57efee7e021fa86c6ef1586
4
+ data.tar.gz: 302b6c3613a02d57db30d5afdfceda1a92c1e1a1
5
5
  SHA512:
6
- metadata.gz: d1156c517b8f865fcaed3bc66bf36d35073b579591349dbaf75b9c934f139abe24b7f7f0f5c5905277800a8a67b0f6daf6463689dceed6e3b11a42fb4eda8dfa
7
- data.tar.gz: 8d51cd63a5e7c72679dba678618b914d0cba0d09a95dcab08001fa63d13989f8e49f019fb54c470e60b2276cc5d8330bf3424be6ff72412fc2bda871ba7c60cd
6
+ metadata.gz: 9dd33d3fabc2fc0500cd5131d8561000318d4475ac8f6d41fee1a283b19a4e434350db09fd38bbc4f7071a4fe62efda389da593dedcf5d4a33d883e851b3bf60
7
+ data.tar.gz: 6591d7b75244cd9df7761f5e456144d128da03a260ff901ce0c1c7f676e01752a247810fbb4bedba96946c1d020120544471343818bb0ca5438ce3731f6e0b03
data/README.md CHANGED
@@ -89,6 +89,34 @@ NOTES:
89
89
  * If the source code is written in C then the `read_source` and `vim` methods only return nil.
90
90
  * If the file is in `GEM_HOME` path then VIM opens it in read only mode.
91
91
 
92
+ ## VIM
93
+
94
+ We now support VIM servers and can open code directly into your existing VIM session(s). If you've started
95
+ a VIM server with the name of "VIM" then any time you call the `vim` method it will open in there **unless**
96
+ you choose to specify another servername as a parameter to `vim`.
97
+
98
+ #### Start a VIM server with
99
+ ```ruby
100
+ # A default server
101
+ vim --servername VIM
102
+
103
+ # An alternate server
104
+ vim --servername SOMENAME
105
+ ```
106
+
107
+ Then to open the code in VIM you would do:
108
+
109
+ ```ruby
110
+ # If a server is named VIM (or else it will close current Ruby session and open vim in this terminal).
111
+ Gem::BasicSpecification.instance_method(:base_dir=).vim
112
+
113
+ # Using a named server
114
+ Gem::BasicSpecification.instance_method(:base_dir=).vim 'SOMENAME'
115
+ ```
116
+
117
+ This way you can keep your ruby code running and open the code in an existing VIM instance.
118
+
119
+
92
120
  ## Development
93
121
 
94
122
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,3 @@
1
1
  module ReadSource
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -3,10 +3,16 @@
3
3
  module ReadSource
4
4
  module VimSource
5
5
  def vim servername=nil
6
- file, line_num = send :source_location
6
+ (file, line_num = send :source_location) || return
7
7
  read_only = !!/#{ENV["GEM_HOME"]}/.match(file) ? "-M" : ""
8
8
  remote = "#{('--servername ' + servername.to_s) if servername} --remote-silent"
9
- exec("vim #{remote} %s +%s %s" % [read_only, line_num, file]) if file
9
+ serverlist = `vim --serverlist`.split("\n")
10
+ if serverlist.include?(servername.to_s) || serverlist.include?("VIM")
11
+ `#{"vim #{remote} %s +%s %s" % [read_only, line_num, file]}`
12
+ :success
13
+ else
14
+ exec("vim #{remote} %s +%s %s" % [read_only, line_num, file])
15
+ end
10
16
  end
11
17
  end
12
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: read_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark