diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index b677794..1b46221 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1035,6 +1035,8 @@ function! neosnippet#get_snippets() "{{{ return snippets endfunction"}}} function! neosnippet#get_snippets_directory() "{{{ + call s:check_initialize() + let snippets_dir = copy(s:snippets_dir) if !get(g:neosnippet#disable_runtime_snippets, \ neosnippet#get_filetype(), @@ -1045,9 +1047,13 @@ function! neosnippet#get_snippets_directory() "{{{ return snippets_dir endfunction"}}} function! neosnippet#get_user_snippets_directory() "{{{ + call s:check_initialize() + return copy(s:snippets_dir) endfunction"}}} function! neosnippet#get_runtime_snippets_directory() "{{{ + call s:check_initialize() + return copy(s:runtime_dir) endfunction"}}} function! neosnippet#get_filetype() "{{{ diff --git a/autoload/unite/sources/neosnippet_file.vim b/autoload/unite/sources/neosnippet_file.vim index a1da216..6977d54 100644 --- a/autoload/unite/sources/neosnippet_file.vim +++ b/autoload/unite/sources/neosnippet_file.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet_file.vim " AUTHOR: Shougo Matsushita -" Last Modified: 13 Dec 2012. +" Last Modified: 17 Feb 2013. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -39,12 +39,8 @@ let s:source_user = { \ } function! s:source_user.gather_candidates(args, context) "{{{ - let files = s:snip_files(neosnippet#get_user_snippets_directory()) - return map(files, '{ -\ "word" : v:val, -\ "action__path" : v:val, -\ "kind" : "file", -\ }') + return s:get_snippet_candidates( + \ neosnippet#get_user_snippets_directory()) endfunction "}}} @@ -55,17 +51,23 @@ let s:source_runtime = { \ } function! s:source_runtime.gather_candidates(args, context) "{{{ - let files = s:snip_files(neosnippet#get_runtime_snippets_directory()) - return map(files, '{ -\ "word" : v:val, -\ "action__path" : v:val, -\ "kind" : "file", -\ }') + return s:get_snippet_candidates( + \ neosnippet#get_runtime_snippets_directory()) endfunction "}}} -function! s:snip_files(dirs) "{{{ - return eval(join(map(a:dirs, "split(globpath(v:val, '*.snip'), '\n')"),"+")) +function! s:get_snippet_candidates(dirs) "{{{ + let _ = [] + for directory in a:dirs + let _ += map(split(unite#util#substitute_path_separator( + \ globpath(directory, '**/*.snip*')), '\n'), "{ + \ 'word' : v:val[len(directory)+1 :], + \ 'action__path' : v:val, + \ 'kind' : 'file', + \ }") + endfor + + return _ endfunction "}}} diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 46da404..89066c0 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -675,6 +675,14 @@ snippet > imap (neosnippet_start_unite_snippet) < + *neosnippet-unite-source-neosnippet/user* +neosnippet/user + The candidates of the user snippet files. + + *neosnippet-unite-source-neosnippet/runtime* +neosnippet/runtime + The candidates of the runtime snippet files. + source actions snippet *neosnippet-unite-action-snippet* @@ -722,6 +730,7 @@ CHANGELOG *neosnippet-changelog* 2013-02-17 - Improved :NeoSnippetEdit. +- Added neosnippet/runtime and neosnippet/user sources. 2013-02-16 - Added sh snippet.