lib/soywiki.vim in soywiki-0.5.8 vs lib/soywiki.vim in soywiki-0.5.9
- old
+ new
@@ -104,10 +104,16 @@
else
call s:page_list_window(pages, 'select-page', "Select page: ")
end
endfunc
+func! s:list_namespaces()
+ let s:search_for_link = ""
+ let pages = s:get_namespace_list()
+ call s:page_list_window(pages, 'select-page', "Select namespace: ")
+endfunc
+
func! s:trim_link(link)
let link = matchstr(a:link, s:wiki_link_pattern)
return link
endfunc
@@ -301,11 +307,11 @@
else
return a:page_list
endif
endfunc
-" This function both sets a script variable and returns the value.
+"
func! s:get_page_list()
" no file current in buffer
if len(bufname('')) == 0
let pages = split(system(s:ls_command), "\n")
elseif bufname('') == 'pages-linking-in'
@@ -316,11 +322,16 @@
let pages = split(system(s:ls_command), "\n")
endif
return pages
endfunction
+func! s:get_namespace_list()
+ let pages = split(system(s:ls_command . " -n"), "\n")
+ return pages
+endfunction
+
func! s:pages_in_this_namespace(pages)
let namespace = s:page_namespace()
let pages = filter( a:pages, 'v:val =~ "^' . namespace . '\."')
" strip leading namespace
return map(pages, "substitute(v:val, '^" . namespace . "\.', '', '') ")
@@ -383,11 +394,11 @@
endwhile
return start
else
let base = s:trimString(a:base)
if (base == '')
- return s:get_page_list()
+ return s:matching_pages
else
let res = []
if bufname('') == 'select-page'
let pages = s:get_page_list()
for m in pages
@@ -395,11 +406,11 @@
call add(res, m)
endif
endfor
else
" autocomplete inline
- let pages = base =~ '\C^[a-z]' ? s:get_page_list() : s:pages_in_this_namespace(s:get_page_list())
+ let pages = base =~ '\C^[a-z]' ? s:matching_pages : s:pages_in_this_namespace(s:matching_pages)
for m in pages
if m =~ '^\c' . base
call add(res, m)
endif
endfor
@@ -414,13 +425,17 @@
close
exe s:return_to_winnr . "wincmd w"
if (page == '') " no selection
return
end
- let match = ""
+ " if time is just a namespace, append .HomePage to it
+ if page =~ '^[a-z][[:alnum:]_]\+$'
+ let page = page . ".HomePage"
+ endif
+
for item in s:matching_pages
- if (item == page)
+ if (page =~ item)
call s:load_page(page, 0)
break
end
endfor
endfunction
@@ -579,9 +594,11 @@
"------------------------------------------------------------------------
func! s:global_mappings()
nnoremap <leader>m :call <SID>list_pages()<CR>
nnoremap <leader>M :call <SID>list_pages_linking_in()<CR>
+ nnoremap <leader>n :call <SID>list_namespaces()<CR>
+
nnoremap <silent> <leader>o :call <SID>find_next_href_and_open()<cr>
nnoremap <silent> q :close<cr>
" for netrw vertical split
nnoremap ,O :exec "silent botright vsplit ". expand("<cWORD>")<cr>