rb_nav 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,12 +5,15 @@ modules, and methods in your Ruby project
5
5
 
6
6
  [screenshots]
7
7
 
8
- Benefits
8
+ Benefits:
9
9
 
10
10
  * navigate the classes and modules in your Ruby projects with less typing
11
11
  * jump to methods on current page more quickly
12
12
  * symbol-centric approach to navigation might suit you better than the file-centric approach
13
13
 
14
+ Please check out my related Vim plugin
15
+ [ri.vim](http://danielchoi.com/software/ri_vim.html) for Ruby
16
+ documentation-browsing features.
14
17
 
15
18
  ## Prerequisites
16
19
 
@@ -40,16 +43,13 @@ For the all the commands below, the mapleader is assumed to be `,`. If it is
40
43
  ### Invoking the plugin
41
44
 
42
45
  * `,N` navigate the classes and modules in your project
43
- * `,n` navigating the methods in the current file
46
+ * `,n` navigate the methods in the current file
44
47
 
45
- To change these keymappings, edit the two `nnoremap` lines at the end of
48
+ To change these keymappings, edit the two lines at the end of
46
49
  `~/.vim/plugin/rb_nav.vim`.
47
50
 
48
- Use the standard Vim autocompletion commands to move up and down the match
49
- list.
50
-
51
- * `CTRL-p` and `CTRL-n` let you navigate the drop-down matches. Press `ENTER` to select
52
- one.
51
+ * `CTRL-p` and `CTRL-n` let you navigate the drop-down matches
52
+ * `<TAB><ENTER>` selects an item
53
53
  * `CTRL-e` closes the match list and lets you continue typing
54
54
  * `CTRL-u`: when the match list is active, cycles forward through the match
55
55
  list and what you've typed so far; when the match list is inactive, erases
@@ -58,6 +58,8 @@ one.
58
58
  * `CTRL-y` selects the highlighted match without triggering ENTER
59
59
 
60
60
 
61
+
62
+
61
63
  ### The search path
62
64
 
63
65
  By default RbNav searches files using these `grep` command flags:
@@ -6,7 +6,7 @@
6
6
  xs = STDIN.readlines.
7
7
  map {|x|
8
8
  line, method = *x.strip.split(/:/)
9
- method = method.strip
9
+ method = method.strip.sub(/^\s*def\s*/, '')
10
10
  [method, line]
11
11
  }
12
12
 
@@ -7,6 +7,7 @@
7
7
  let g:RbNavPaths = " . --exclude-dir='\.git' --exclude-dir='vendor' --exclude-dir='db' --include='*.rb' "
8
8
 
9
9
  let s:last_class_search = ""
10
+ let s:selection_list = []
10
11
 
11
12
  func! RbNavClasses()
12
13
  endfunc
@@ -51,7 +52,8 @@ function! AutocompleteRbNavClasses(findstart, base)
51
52
  return start
52
53
  else
53
54
  let res = []
54
- for m in RbNavClasses()
55
+ let s:selection_list = RbNavClasses()
56
+ for m in s:selection_list
55
57
  " why doesn't case insensitive flag work?
56
58
  if m =~ substitute(a:base, '\*', '\\*', '')
57
59
  call add(res, m)
@@ -86,8 +88,8 @@ function! AutocompleteRbNavMethods(findstart, base)
86
88
  return start
87
89
  else
88
90
  let res = []
89
- for m in RbNavMethods()
90
- " why doesn't case insensitive flag work?
91
+ let s:selection_list = RbNavMethods()
92
+ for m in s:selection_list
91
93
  if m =~ '^\c.\?' . substitute(a:base, '\*', '\\*', '')
92
94
  call add(res, m)
93
95
  endif
@@ -110,6 +112,14 @@ func! s:open_class_file()
110
112
  endif
111
113
  let selection = s:trimString(getline(2))
112
114
  close
115
+ if len(split(selection, '\s\+')) == 1
116
+ " user pressed return without autocompleting, so find the first match
117
+ for x in s:selection_list
118
+ if get(split(x, '\s\+'), 0) == selection
119
+ let selection = x
120
+ endif
121
+ endfor
122
+ endif
113
123
  let query = get(split(selection, '\s\+'), 0)
114
124
  let location = get(split(selection, '\s\+'), -1)
115
125
  let path = get(split(location, ':'), 0)
@@ -131,6 +141,14 @@ func! s:jump_to_method()
131
141
  endif
132
142
  let selection = s:trimString(getline(2))
133
143
  close
144
+ if len(split(selection, '\s\+')) == 1
145
+ " user pressed return without autocompleting, so find the first match
146
+ for x in s:selection_list
147
+ if get(split(x, '\s\+'), 0) == selection
148
+ let selection = x
149
+ endif
150
+ endfor
151
+ endif
134
152
  let line = get(split(selection, '\s\+'), -1)
135
153
  exec 'normal '.line.'G'
136
154
  call feedkeys("z\<cr>", "t")
@@ -1,4 +1,4 @@
1
1
  module RbNav
2
2
 
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rb_nav
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Choi