diff --git a/autoload/neosnippet/parser.vim b/autoload/neosnippet/parser.vim index c3c4cbd..0379914 100644 --- a/autoload/neosnippet/parser.vim +++ b/autoload/neosnippet/parser.vim @@ -81,7 +81,7 @@ function! s:parse(snippets_file) "{{{ if line =~ '^#' " Ignore. elseif line =~ '^include' - " Include snippets. + " Include snippets file. let filename = matchstr(line, '^include\s\+\zs.*$') for snippets_file in split(globpath(join( @@ -90,6 +90,13 @@ function! s:parse(snippets_file) "{{{ let snippets = extend(snippets, \ neosnippet#parser#_parse_snippets(snippets_file)) endfor + elseif line =~ '^source' + " Source Vim script file. + for file in split(globpath(join( + \ neosnippet#helpers#get_snippets_directory(), ','), + \ matchstr(line, '^source\s\+\zs.*$')), '\n') + execute 'source' fnameescape(file) + endfor elseif line =~ '^delete\s' let name = matchstr(line, '^delete\s\+\zs.*$') if name != '' && has_key(snippets, name) diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 6ad8bf4..6e4ab65 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -726,7 +726,12 @@ insert empty line in snippet end, you must insert placeholder. #!/usr/bin/env ruby +You can load a Vim script file for snippets. + +> + source go.vim < + ============================================================================== UNITE SOURCES *neosnippet-unite-sources* diff --git a/syntax/neosnippet.vim b/syntax/neosnippet.vim index bfb591a..8854a5c 100644 --- a/syntax/neosnippet.vim +++ b/syntax/neosnippet.vim @@ -52,7 +52,7 @@ syntax match neosnippetEscape \ '\\[`]' contained syntax match neosnippetKeyword - \ '^\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\|TARGET\)' contained + \ '^\%(include\|source\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\|TARGET\)' contained syntax keyword neosnippetOption \ head word indent contained syntax match neosnippetPrevWords @@ -75,6 +75,10 @@ syntax match neosnippetStatementInclude \ '^include\s.*$' contains=neosnippetInclude,neosnippetKeyword syntax match neosnippetInclude \ '\s\+.*$' contained +syntax match neosnippetStatementSource + \ '^source\s.*$' contains=neosnippetSource,neosnippetKeyword +syntax match neosnippetSource + \ '\s\+.*$' contained syntax match neosnippetStatementDelete \ '^delete\s.*$' contains=neosnippetDelete,neosnippetKeyword syntax match neosnippetDelete @@ -99,6 +103,7 @@ highlight def link neosnippetPlaceHolderComment Comment highlight def link neosnippetVariable Special highlight def link neosnippetComment Comment highlight def link neosnippetInclude PreProc +highlight def link neosnippetSource PreProc highlight def link neosnippetDelete PreProc highlight def link neosnippetOption PreProc highlight def link neosnippetAlias Identifier