- Improved snippet sources.

This commit is contained in:
Shougo Matsushita 2013-02-17 14:58:57 +09:00
parent 38ba96ea91
commit 8fa2d27f62
3 changed files with 32 additions and 15 deletions

View File

@ -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() "{{{

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: neosnippet_file.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" 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 "}}}

View File

@ -675,6 +675,14 @@ snippet
>
imap <C-s> <Plug>(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.