From 336870a15a6e94cbbe011ecac959c5f9af16b314 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Sun, 17 Feb 2013 14:20:34 +0900 Subject: [PATCH] add unite-source. --- autoload/unite/sources/neosnippet_file.vim | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 autoload/unite/sources/neosnippet_file.vim diff --git a/autoload/unite/sources/neosnippet_file.vim b/autoload/unite/sources/neosnippet_file.vim new file mode 100644 index 0000000..a1da216 --- /dev/null +++ b/autoload/unite/sources/neosnippet_file.vim @@ -0,0 +1,75 @@ +"============================================================================= +" FILE: neosnippet_file.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 13 Dec 2012. +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + + +function! unite#sources#neosnippet_file#define() "{{{ + return [s:source_user, s:source_runtime] +endfunction "}}} + +" neosnippet source. +let s:source_user = { + \ 'name': 'neosnippet/user', + \ 'description' : 'neosnippet user file', + \ } + +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", +\ }') +endfunction "}}} + + +" neosnippet source. +let s:source_runtime = { + \ 'name': 'neosnippet/runtime', + \ 'description' : 'neosnippet runtime file', + \ } + +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", +\ }') +endfunction "}}} + + +function! s:snip_files(dirs) "{{{ + return eval(join(map(a:dirs, "split(globpath(v:val, '*.snip'), '\n')"),"+")) +endfunction "}}} + + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker