soywiki 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/soywiki.rb +1 -1
  2. data/lib/soywiki.vim +35 -25
  3. metadata +2 -2
data/lib/soywiki.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'string_ext'
2
2
 
3
3
  module Soywiki
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
6
6
 
7
7
  def self.run
data/lib/soywiki.vim CHANGED
@@ -112,28 +112,27 @@ func! s:link_under_cursor()
112
112
  let link = s:infer_namespace(link)
113
113
  endif
114
114
  if match(link, s:wiki_link_pattern) == -1
115
- if match(link, s:http_link_pattern) != -1
116
- call s:open_href()
117
- endif
118
115
  return ""
119
116
  else
120
117
  return link
121
118
  end
122
119
  endfunc
123
120
 
124
- " follows a camel case link to a new page
125
- func! s:follow_link(split)
126
- let link = s:link_under_cursor()
127
- if link == ""
128
- let link = s:find_next_wiki_link(0)
129
- if link == ""
130
- return ""
131
- endif
132
- endif
133
- call s:load_page(link, a:split)
121
+ func! s:find_next_wiki_link(backward)
122
+ let n = 0
123
+ " don't wrap
124
+ let result = search(s:wiki_link_pattern, 'W' . (a:backward == 1 ? 'b' : ''))
125
+ if (result == 0)
126
+ return ""
127
+ end
128
+ return s:link_under_cursor()
134
129
  endfunc
135
130
 
136
131
  func! s:follow_link_under_cursor(split)
132
+ if match(expand("<cWORD>>"), s:http_link_pattern) != -1
133
+ call s:open_href_under_cursor()
134
+ return
135
+ endif
137
136
  let link = s:link_under_cursor()
138
137
  if link == ""
139
138
  echom link . " is not a wiki link"
@@ -150,14 +149,18 @@ func! s:follow_link_under_cursor(split)
150
149
  endif
151
150
  endfunc
152
151
 
153
- func! s:find_next_wiki_link(backward)
154
- let n = 0
155
- " don't wrap
156
- let result = search(s:wiki_link_pattern, 'W' . (a:backward == 1 ? 'b' : ''))
157
- if (result == 0)
158
- return ""
159
- end
160
- return s:link_under_cursor()
152
+
153
+ " If no link under cursor, tries to find the next one
154
+ func! s:fuzzy_follow_link(split)
155
+ let link = s:link_under_cursor()
156
+ if link == ""
157
+ let link = s:find_next_wiki_link(0)
158
+ if link == ""
159
+ echom "No links found"
160
+ return
161
+ endif
162
+ endif
163
+ call s:load_page(link, a:split)
161
164
  endfunc
162
165
 
163
166
  " --------------------------------------------------------------------------------
@@ -527,13 +530,20 @@ func! s:expand(seamless, vertical)
527
530
  echom "Expanded " . (a:seamless == 0 ? 'seamfully' : 'seamlessly') . "."
528
531
  endfunc
529
532
  "------------------------------------------------------------------------
530
- func! s:open_href()
531
- let line = search(s:http_link_pattern, 'cw')
533
+ func! s:open_href_under_cursor()
532
534
  let href = expand("<cWORD>")
533
535
  let command = g:SoyWiki#browser_command . " '" . href . "' "
534
536
  call system(command)
535
537
  echom command
536
538
  endfunc
539
+
540
+ func! s:find_next_href_and_open()
541
+ let res = search(s:http_link_pattern, 'cw')
542
+ if res != 0
543
+ call s:open_href_under_cursor()
544
+ endif
545
+ endfunc
546
+
537
547
  " --------------------------------------------------------------------------------
538
548
  " HELP
539
549
  func! s:show_help()
@@ -545,7 +555,7 @@ endfunc
545
555
  func! s:global_mappings()
546
556
  noremap <leader>m :call <SID>list_pages()<CR>
547
557
  noremap <leader>M :call <SID>list_pages_linking_in()<CR>
548
- noremap <silent> <leader>o :call <SID>open_href()<cr>
558
+ noremap <silent> <leader>o :call <SID>find_next_href_and_open()<cr>
549
559
  nnoremap <silent> q :close<cr>
550
560
 
551
561
  " reflow text
@@ -575,7 +585,7 @@ func! s:prep_buffer()
575
585
  nnoremap <buffer> <cr> :call <SID>follow_link_under_cursor(0)<cr>
576
586
  nnoremap <buffer> <c-l> :call <SID>follow_link_under_cursor(2)<cr>
577
587
  nnoremap <buffer> <c-h> :call <SID>follow_link_under_cursor(1)<cr>
578
- noremap <buffer> <leader>f :call <SID>follow_link(0)<CR>
588
+ noremap <buffer> <leader>f :call <SID>fuzzy_follow_link(0)<CR>
579
589
  noremap <buffer> <c-j> :call <SID>find_next_wiki_link(0)<CR>
580
590
  noremap <buffer> <c-k> :call <SID>find_next_wiki_link(1)<CR>
581
591
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi