vimdb 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'boson', '>= 1.1.1'
16
16
  s.add_dependency 'hirb', '~> 0.6.0'
17
17
  s.add_development_dependency 'minitest', '~> 2.5.1'
18
- s.add_development_dependency 'bahia', '~> 0.3.0'
18
+ s.add_development_dependency 'bahia', '~> 0.5'
19
19
  s.add_development_dependency 'rake', '~> 0.9.2'
20
20
  s.files = Dir.glob(%w[{lib,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc,md} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec .travis.yml}
21
21
  s.files += Dir.glob(['spec/fixtures/*', 'spec/.vimdbrc'])
@@ -2,3 +2,5 @@ before_install: bundle init --gemspec=.gemspec
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ # disabled until bahia + rbx issues worked out
6
+ # - rbx-19mode
@@ -1,3 +1,7 @@
1
+ == 0.5.1
2
+ * Add windows support
3
+ * Explicit abort for < 1.9.2 ruby
4
+
1
5
  = 0.5.0
2
6
  * rename opts command to options
3
7
  * Upgrade boson to fix multi-word arg bug
data/README.md CHANGED
@@ -1,14 +1,23 @@
1
1
  Description
2
2
  ===========
3
3
 
4
- Improve your knowledge of vim by precise searching of vim items: keybindings, options and commands.
5
- For example, keys can be searched by keystroke, mode, description or where they came from. This gem
6
- creates a vimdb database, ~/.vimdb.pstore, from your vim documentation. Tested with vim >= 7.2 on a
7
- mac. Works only on ruby 1.9.x.
4
+ Increase the speed and amount of vim knowledge at your fingertips with precise
5
+ searching of vim's items: keys (keybindings), options and commands. vimdb is
6
+ aware of vim's default items, ones in your vimrc and ones in plugins. vimdb's
7
+ plugin detection works only if you're using a pathogen-like setup i.e. each
8
+ plugin has its own directory under ~/.vim/bundle/ (see Configuration below to
9
+ change the directory). Tested with vim >= 7.2 on a mac. Works only on ruby 1.9.x.
10
+
11
+ Install
12
+ =======
13
+
14
+ $ gem install vimdb
8
15
 
9
16
  Usage
10
17
  =====
11
18
 
19
+ Basic examples searching different vim items:
20
+
12
21
  # List keys with Ctrl
13
22
  $ vimdb keys C-
14
23
  +---------------+------+---------------------+------------------------------------------
@@ -21,6 +30,78 @@ Usage
21
30
  | <C-Home> | n | default | 1 same as "gg" |
22
31
  | <C-Left> | n | default | 1 same as "b" |
23
32
  ...
33
+ 262 rows in set
34
+
35
+
36
+ # List options that contain word 'window' in any field
37
+ $ vimdb options window -a
38
+ +----------------+--------+----------------------------------------------------+
39
+ | name | alias | desc |
40
+ +----------------+--------+----------------------------------------------------+
41
+ | autochdir | acd | change directory to the file in the current window |
42
+ | bufhidden | bh | what to do when buffer is no longer in window |
43
+ | cedit | | key used to open the command-line window |
44
+ | cmdwinheight | cwh | height of the command-line window |
45
+ | cscopequickfix | csqf | use quickfix window for cscope results |
46
+ | cursorbind | crb | move cursor in window as it moves in other windows |
47
+ | diff | | use diff mode for the current window |
48
+ | equalalways | ea | windows are automatically made the same size |
49
+ | guiheadroom | ghr | GUI: pixels room for window decorations |
50
+ | helpheight | hh | minimum height of a new help window |
51
+ | icon | | let Vim set the text of the window icon |
52
+ ...
53
+ 30 rows in set
54
+
55
+ # Search for commands from pathogen plugin
56
+ $ vimdb commands pathogen -f=from
57
+ +----------+-------+---------------------+-----------------------------------------------------+
58
+ | name | alias | from | desc |
59
+ +----------+-------+---------------------+-----------------------------------------------------+
60
+ | Helptags | | pathogen.vim plugin | :call pathogen#helptags() |
61
+ | Ve | | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,0) |
62
+ | Vedit | | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,0) |
63
+ | Vopen | | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,1) |
64
+ | Vpedit | | pathogen.vim plugin | :execute s:find(<count>,'pedit',<q-args>,<bang>1) |
65
+ | Vread | | pathogen.vim plugin | :execute s:find(<count>,'read',<q-args>,<bang>1) |
66
+ | Vsplit | | pathogen.vim plugin | :execute s:find(<count>,'split',<q-args>,<bang>1) |
67
+ | Vtabedit | | pathogen.vim plugin | :execute s:find(<count>,'tabedit',<q-args>,<bang>1) |
68
+ | Vvsplit | | pathogen.vim plugin | :execute s:find(<count>,'vsplit',<q-args>,<bang>1) |
69
+ +----------+-------+---------------------+-----------------------------------------------------+
70
+ 9 rows in set
71
+
72
+ # Info about how a vim item is made
73
+ $ vimdb info keys
74
+ Created using index.txt and :map
75
+
76
+ # For a list of all commands
77
+ $ vimdb
78
+
79
+ ## More Usage
80
+
81
+ As you can see from the last example, vimdb supports options for each command.
82
+ For a command's listing of options use --help or -h:
83
+
84
+ $ vimdb keys --help
85
+ Usage: vimdb keys [QUERY]
86
+
87
+ Options:
88
+ -a, --all search all fields
89
+ -f, --field field to query
90
+ -i, --ignore_case
91
+ -m, --mode search by mode, multiple modes are ORed
92
+ -n, --not return non-matching results
93
+ -r, --regexp query is a regexp
94
+ -R, --reload reloads items
95
+ --reverse_sort
96
+ -s, --sort sort by field
97
+ -t, --tab print tab-delimited table
98
+
99
+ Description:
100
+ List vim keys
101
+
102
+
103
+ As you can see, keys can be searched by keystroke, mode, description or from
104
+ (default, user or plugin name). Some examples:
24
105
 
25
106
  # List keys with Ctrl-A combo
26
107
  $ vimdb keys C-A
@@ -40,8 +121,6 @@ Usage
40
121
  # List keys I've defined in vimrc
41
122
  $ vimdb keys user -f=from
42
123
 
43
- # Plugins are assumed to be in ~/.vim/bundle/ i.e. for pathogen
44
- # Change with Vimdb.plugins_dir
45
124
  # List keys from my plugins
46
125
  $ vimdb keys plugin -f=from
47
126
 
@@ -51,25 +130,78 @@ Usage
51
130
  # List keys that contain completion in description
52
131
  $ vimdb keys completion -f=desc
53
132
 
54
- # List options that contain window in description
55
- $ vimdb options window -f=desc
56
-
57
- # List commands mentioning 'buffer' in any field
58
- $ vimdb commands buffer -a
59
-
60
- # Info about how vim items were made
61
- $ vimdb info keys
62
- $ vimdb info options
133
+ Advanced Usage
134
+ ==============
135
+
136
+ vimdb can be customized with your own commands thanks to its rc file and command
137
+ engine, [boson](http://github.com/cldwalker/boson). For example,
138
+ [my rc file](https://github.com/cldwalker/dotfiles/blob/master/.vimdbrc)
139
+ defines a command that detects conflicts between default keys and plugin keys:
140
+
141
+ $ vimdb conflict
142
+ +-------+------+---------------------+---------------------------------------------------------------------------------+
143
+ | key | mode | from | desc/action |
144
+ +-------+------+---------------------+---------------------------------------------------------------------------------+
145
+ | C-w o | n | default | close all but current window (like |:only|) |
146
+ | C-w o | n | zoomwin plugin | <Plug>ZoomWin |
147
+ | * | n | default | search forward for the Nth occurrence of the ident under the cursor |
148
+ | * | nos | tcomment_vim plugin | :TCommentRight<CR> |
149
+ | * | n | default | search forward for the Nth occurrence of the ident under the cursor |
150
+ | * | nos | tcomment_vim plugin | :TComment<CR> |
151
+ ...
63
152
 
64
- # For more
65
- $ vimdb help
153
+ If you look at conflict's implementation, you see it's only about a dozen lines.
154
+ Since vimdb stores vim items as array of hashes, you can use these within
155
+ commands for whatever purpose.
156
+
157
+ To illustrate creating a command, let's create one that lists the first
158
+ given number of vim commands. In your ~/.vimdbrc:
159
+
160
+ ```ruby
161
+ class Vimdb::Runner
162
+ desc "Prints first X options"
163
+ def first(num)
164
+ # Set item type we're retrieving
165
+ Vimdb.item('options')
166
+ puts Vimdb.user.items.first(num.to_i).map {|e| e[:name] }
167
+ end
168
+ end
169
+ ```
170
+
171
+ To test drive it:
172
+
173
+ $ vimdb first 5
174
+ aleph
175
+ allowrevins
176
+ altkeymap
177
+ ambiwidth
178
+ antialias
66
179
 
67
180
  Configuration
68
181
  =============
69
182
 
70
- Configure vimdb with a ~/.vimdbrc, which is loaded before every command request. Use it to define
71
- additional commands. For an example, [see my rc
72
- file](https://github.com/cldwalker/dotfiles/blob/master/.vimdbrc).
183
+ Configure vimdb with a ~/.vimdbrc (in ruby), which is loaded before every
184
+ command request. For example, to configure where plugins are stored:
185
+
186
+ # plugins stored in ~/.vim/plugins
187
+ Vimdb.plugins_dir = 'plugins'
188
+
189
+ For a more thorough example,
190
+ [see my rc file](https://github.com/cldwalker/dotfiles/blob/master/.vimdbrc).
191
+
192
+ Vim Mappings
193
+ ============
194
+
195
+ Since vimdb runs on ruby 1.9.x, there's a good chance you don't have vim
196
+ compiled against ruby 1.9.x. No worries, use rvm or rbenv to install a 1.9.x
197
+ version. Then to invoke vimdb within vim, set up a key to pipe out to vimdb
198
+ using rvm or rbenv:
199
+
200
+ ```vim
201
+ map <Leader>v :!rbenv exec vimdb
202
+ " or for rvm
203
+ map <Leader>v :!rvm 1.9.3 vimdb
204
+ ```
73
205
 
74
206
  Key Modes
75
207
  =========
@@ -92,11 +224,24 @@ The following modes from :map were altered to fit into the above modes:
92
224
  * x -> v
93
225
  * v -> vs
94
226
 
227
+ How It Works
228
+ ============
229
+
230
+ This gem creates a vimdb database, ~/.vimdb.pstore, by parsing your vim
231
+ documentation and outputs of vim commands. When an item is first searched it is
232
+ parsed. Subsequent searches are cached. To reload (and reparse) you database,
233
+ pass a --reload option to most commands.
234
+
95
235
  Motivation
96
236
  ==========
97
237
 
98
238
  Wanted to learn faster than :help would let me.
99
239
 
240
+ Credits
241
+ =======
242
+
243
+ * mattn for windows support
244
+
100
245
  Contributing
101
246
  ============
102
247
  [See here](http://tagaholic.me/contributing.html)
data/bin/vimdb CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ if RUBY_VERSION < '1.9.2'
4
+ abort "vimdb only runs on ruby >= 1.9.2. " +
5
+ "Use rbenv or rvm to install the latest 1.9 ruby."
6
+ end
7
+
3
8
  require 'vimdb'
4
9
  Vimdb::Runner.start
@@ -61,7 +61,12 @@ module Vimdb
61
61
  private
62
62
 
63
63
  def vim(*cmds)
64
- system %[#{Vimdb.vim} -c 'colorscheme default | #{cmds.join(' | ')} | qa']
64
+ quote = "'"
65
+ if RUBY_PLATFORM =~ /mswin(?!ce)|mingw|cygwin|bccwin/i
66
+ cmds = cmds.map{|x| x.gsub(/"/,'"""') }
67
+ quote = '"'
68
+ end
69
+ system %[#{Vimdb.vim} -N -u NONE --cmd #{quote}colorscheme default | #{cmds.join(' | ')} | qa#{quote}]
65
70
  end
66
71
 
67
72
  if ENV['VIMDB_FIXTURE_DIR']
@@ -1,3 +1,3 @@
1
1
  module Vimdb
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -1,3 +1,3 @@
1
1
  minitest ~>2.5.1
2
- bahia ~>0.3.0
2
+ bahia ~>0.5
3
3
  rake ~>0.9.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000 Z
12
+ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: boson
16
- requirement: &70144353831720 !ruby/object:Gem::Requirement
16
+ requirement: &70096513129620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70144353831720
24
+ version_requirements: *70096513129620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hirb
27
- requirement: &70144353831140 !ruby/object:Gem::Requirement
27
+ requirement: &70096513129060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70144353831140
35
+ version_requirements: *70096513129060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70144353830620 !ruby/object:Gem::Requirement
38
+ requirement: &70096513128420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,21 +43,21 @@ dependencies:
43
43
  version: 2.5.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70144353830620
46
+ version_requirements: *70096513128420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bahia
49
- requirement: &70144353830100 !ruby/object:Gem::Requirement
49
+ requirement: &70096513127180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: '0.5'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70144353830100
57
+ version_requirements: *70096513127180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70144353829640 !ruby/object:Gem::Requirement
60
+ requirement: &70096513126640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.9.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70144353829640
68
+ version_requirements: *70096513126640
69
69
  description: Search your vim keybindings precisely by keystroke, mode, description
70
70
  or where they came from. Search vim options by name, alias and description.
71
71
  email: gabriel.horner@gmail.com