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.
- data/lib/soywiki.rb +1 -1
- data/lib/soywiki.vim +35 -25
- metadata +2 -2
data/lib/soywiki.rb
CHANGED
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
154
|
-
|
155
|
-
|
156
|
-
let
|
157
|
-
if
|
158
|
-
|
159
|
-
|
160
|
-
|
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:
|
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>
|
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>
|
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
|
|