Permalink
Browse files

Implement source feature

  • Loading branch information...
1 parent 74a9c1e commit 49b1743d03e8a79e20f86dd68f8dcd4e92eabc29 @Shougo committed Dec 23, 2015
Showing with 19 additions and 2 deletions.
  1. +8 −1 autoload/neosnippet/parser.vim
  2. +5 −0 doc/neosnippet.txt
  3. +6 −1 syntax/neosnippet.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)
View
@@ -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*
@@ -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

0 comments on commit 49b1743

Please sign in to comment.