lab42_tmux2 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -2
- data/lib/lab42/tmux/plugins/conflict.rb +8 -0
- data/lib/lab42/tmux/plugins.rb +31 -0
- data/lib/lab42/tmux/version.rb +1 -1
- data/lib/lab42/tmux/vim_plugin.rb +38 -0
- data/lib/lab42/tmux.rb +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79993d86d50f7c16d0da14ae7b0f328e6cc4ecdf
|
4
|
+
data.tar.gz: ce574b34edc975cb667c7ebec4e848b65db6e3b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff696863217be3ba06ebae74000eaf979eddbfca3c9f142a71d59c635f7116cb6f14724ca752ed889b6c988bf8a5578000ab5f521846b0c2ee4c9222e427420
|
7
|
+
data.tar.gz: 0e4b95d44b3935d5567c7512e1f2b3f31a0616cf79f234d8a9fcc4832d9bb59f0987f729954dbea2ce5c552c6a8fb43bb76de2e30dfe04ed13d75c0cded78b47
|
data/README.md
CHANGED
@@ -134,8 +134,55 @@ end
|
|
134
134
|
Plugins are easy to write, just MP the `Lab42::Tmux::Session` class. However precise guidelines
|
135
135
|
how to do this will be available soon, also you might want to create some configuration.
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
However, the goal of plugins being to be combineable the `lab42_tmux2` gem offers a mechanism to
|
138
|
+
protect plugins from each other. This works as follows:
|
139
|
+
|
140
|
+
#### A Vim Plugin
|
141
|
+
|
142
|
+
##### Commands, The Easy One
|
143
|
+
|
144
|
+
Instead of MPatching Lab42::Tmux::Session::Commands you just write your own module of commands, e.g.
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
require 'lab42/tmux/auto_import'
|
148
|
+
module VimCommands
|
149
|
+
def vim_window name, **options
|
150
|
+
new_window name do
|
151
|
+
send_keys "vi #{options.fetch :dir, '.'}"
|
152
|
+
if options[:nerdtree]
|
153
|
+
send_keys_raw 'C-w', 'l'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
```
|
159
|
+
|
160
|
+
Now you _register_ the plugin via `Lab42::Tmux::Plugins.register VimCommands`, the benefit of doing this is, that
|
161
|
+
the plugin will not overwrite other plugins that might have implemented a `vim_window` command, and later plugins, that
|
162
|
+
on their account want to define a `vim_window` command will not be able to overwite yours.
|
163
|
+
|
164
|
+
##### Configuration, A Little Bit More Complicated
|
165
|
+
|
166
|
+
**Not yet implemented c.f. Issues**
|
167
|
+
|
168
|
+
Imagine, and it is quite useful as explained above, that whenever we use the plugin we want to have a changed default configuration.
|
169
|
+
In our case we want to set a `pre_waint_interval` and a `post_wait_interval` by default. We could simply invoke
|
170
|
+
`Lab42::Tmux::Session.config{ ... }` but we would be exposed to the same dangers as above, _breaking_ and _being broken_.
|
171
|
+
|
172
|
+
Although conflicts might still arise, it is much saver to wrap our methods in a `with_config` block, that adds temporary configuration
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
# ...
|
176
|
+
def vim_window name, **options
|
177
|
+
# config.pre_wait_interval.nil?
|
178
|
+
with_config pre_wait_interval: 0.1 do
|
179
|
+
# config.pre_wait_interval == 0.1
|
180
|
+
# other config values are unchanged
|
181
|
+
# ...
|
182
|
+
end
|
183
|
+
# config.pre_wait_interval.nil?
|
184
|
+
end
|
185
|
+
```
|
139
186
|
|
140
187
|
## Dev Notes
|
141
188
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'plugins/conflict'
|
2
|
+
module Lab42
|
3
|
+
module Tmux
|
4
|
+
module Plugins extend self
|
5
|
+
@registered = Set.new
|
6
|
+
attr_reader :registered
|
7
|
+
|
8
|
+
def register a_module, as: nil
|
9
|
+
if as
|
10
|
+
# Not yet implemented
|
11
|
+
raise ArgumentError 'as: is not yet implemented'
|
12
|
+
register_namespaced a_module, as
|
13
|
+
else
|
14
|
+
register_directly a_module
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def register_directly a_module
|
20
|
+
conflicts = []
|
21
|
+
a_module.instance_methods.each do | im_name |
|
22
|
+
conflicts << im_name if registered.include? im_name
|
23
|
+
registered << im_name
|
24
|
+
end
|
25
|
+
raise Conflict unless conflicts.empty?
|
26
|
+
|
27
|
+
Session.send :include, a_module
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end # module Tmux
|
31
|
+
end # module Lab42
|
data/lib/lab42/tmux/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'lab42/tmux/auto_import'
|
2
|
+
require 'lab42/core/hash'
|
3
|
+
|
4
|
+
module VimPlugin
|
5
|
+
|
6
|
+
def vim_command command, params
|
7
|
+
send_keys ":#{command} #{params}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def vim_new_window name, **options
|
11
|
+
new_window name do
|
12
|
+
send_keys "vi #{__vim_dir options}"
|
13
|
+
__vim_source options
|
14
|
+
__vim_colorscheme options
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def __vim_colorscheme options
|
21
|
+
options.with_present :colorscheme do | cs |
|
22
|
+
vim_command :colorscheme, cs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def __vim_dir options
|
27
|
+
options.fetch :dir, '.'
|
28
|
+
end
|
29
|
+
|
30
|
+
def __vim_source options
|
31
|
+
options.with_present :source do | source |
|
32
|
+
vim_command :source, source
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end # module VimPlugin
|
37
|
+
|
38
|
+
Lab42::Tmux::Plugins.register VimPlugin
|
data/lib/lab42/tmux.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_tmux2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lab42_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: forwarder2
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,11 +94,14 @@ files:
|
|
80
94
|
- lib/lab42/tmux/dry_run.rb
|
81
95
|
- lib/lab42/tmux/errors.rb
|
82
96
|
- lib/lab42/tmux/interface.rb
|
97
|
+
- lib/lab42/tmux/plugins.rb
|
98
|
+
- lib/lab42/tmux/plugins/conflict.rb
|
83
99
|
- lib/lab42/tmux/session.rb
|
84
100
|
- lib/lab42/tmux/session/commands.rb
|
85
101
|
- lib/lab42/tmux/session/hooks.rb
|
86
102
|
- lib/lab42/tmux/session/parameter_helpers.rb
|
87
103
|
- lib/lab42/tmux/version.rb
|
104
|
+
- lib/lab42/tmux/vim_plugin.rb
|
88
105
|
homepage: https://github.com/RobertDober/lab42_tmux2
|
89
106
|
licenses:
|
90
107
|
- MIT
|