- Refactored documentation.

This commit is contained in:
Shougo Matsushita 2012-11-03 12:33:18 +09:00
parent 8a2cc9f936
commit 5952b6e51d
3 changed files with 168 additions and 138 deletions

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: neosnippet.vim " FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 02 Nov 2012. " Last Modified: 03 Nov 2012.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -314,12 +314,23 @@ function! neosnippet#make_cache(filetype)"{{{
let s:snippets[filetype] = snippet let s:snippets[filetype] = snippet
endfunction"}}} endfunction"}}}
function! neosnippet#source_file(filename)"{{{
let neosnippet = neosnippet#get_current_neosnippet()
call s:parse_snippets_file(neosnippet.snippets, a:filename)
endfunction"}}}
function! s:parse_snippets_file(snippets, snippets_file)"{{{ function! s:parse_snippets_file(snippets, snippets_file)"{{{
let dup_check = {} let dup_check = {}
let snippet_dict = {} let snippet_dict = {}
let linenr = 1 let linenr = 1
if !filereadable(a:snippets_file)
call neosnippet#util#print_error(
\ printf('snippet file "%s" is not found.', a:filename))
return a:snippets
endif
for line in readfile(a:snippets_file) for line in readfile(a:snippets_file)
if line =~ '^\h\w*.*\s$' if line =~ '^\h\w*.*\s$'
" Delete spaces. " Delete spaces.

View File

@ -63,28 +63,31 @@ COMMANDS *neosnippet-commands*
:NeoSnippetMakeCache [filetype] :NeoSnippetMakeCache [filetype]
*:NeoSnippetMakeCache* *:NeoSnippetMakeCache*
Creates a cache for the given [filetype] snippets. It automatically Creates a cache for the given [filetype] snippets. It
choses the current buffer's file type unless you specify one by automatically choses the current buffer's file type unless you
[filetype]. specify one by [filetype].
*:NeoComplCacheCachingSnippets* *:NeoComplCacheCachingSnippets*
Note: |:NeoComplCacheCachingSnippets| is an obsolete name. Note: |:NeoComplCacheCachingSnippets| is an obsolete name.
:NeoSnippetEdit [{options}] [filetype] :NeoSnippetEdit [{options}] [filetype]
*:NeoSnippetEdit* *:NeoSnippetEdit*
Opens the [filetype] snippets to edit. It automatically selects Opens the [filetype] snippets to edit. It automatically
the current buffer's filetype unless you specify another one by [filetype]. selects the current buffer's filetype unless you specify
another one by [filetype].
If the path to [filetype] snippets is a directory, it automatically selects If the path to [filetype] snippets is a directory, it
the "[filetype].snip" in the [filetype] subdirectory. automatically selects the "[filetype].snip" in the [filetype]
subdirectory.
It edits a snippet file in |g:neosnippet#snippets_directory| It edits a snippet file in |g:neosnippet#snippets_directory|
with precedence. The snippets are re-cached automatically with precedence. The snippets are re-cached automatically
when you save the file after edit. when you save the file after edit.
*:NeoComplCacheEditSnippets* *:NeoComplCacheEditSnippets*
The following parameters can be used as {options} to modify the behavior of The following parameters can be used as {options} to modify
the command. Note: You must escape spaces with a backslash "\". the behavior of the command. Note: You must escape spaces with
a backslash "\".
*neosnippet-edit-options-vertical* *neosnippet-edit-options-vertical*
-vertical -vertical
@ -98,7 +101,8 @@ COMMANDS *neosnippet-commands*
*neosnippet-edit-options-direction* *neosnippet-edit-options-direction*
-direction={direction} -direction={direction}
Define the split position rule. The default value is "belowleft". Define the split position rule. The default value is
"belowleft".
*neosnippet-edit-options-split* *neosnippet-edit-options-split*
-split -split
@ -106,17 +110,17 @@ COMMANDS *neosnippet-commands*
*neosnippet-edit-options-runtime* *neosnippet-edit-options-runtime*
-runtime -runtime
Edit the runtime (built-in standard) snippets instead of the user Edit the runtime (built-in standard) snippets instead of the
snippets defined by 'g:neosnippet#snippets_directory'. user snippets defined by 'g:neosnippet#snippets_directory'.
Note: |:NeoComplCacheEditSnippets| is an obsolete name. Note: |:NeoComplCacheEditSnippets| is an obsolete name.
:NeoComplCacheEdit -runtime [filetype] :NeoComplCacheEdit -runtime [filetype]
Opens the [filetype] standard snippets to edit. It automatically Opens the [filetype] standard snippets to edit. It
selects the current buffer's file type snippets unless you specify automatically selects the current buffer's file type snippets
a file type by [filetype]. The snippets are re-cached automatically unless you specify a file type by [filetype]. The snippets are
when you save the file after edit. re-cached automatically when you save the file after edit.
*:NeoComplCacheEditRuntimeSnippets* *:NeoComplCacheEditRuntimeSnippets*
Note: |:NeoComplCacheEditRuntimeSnippets| is an obsolete name. Note: |:NeoComplCacheEditRuntimeSnippets| is an obsolete name.
@ -126,16 +130,16 @@ VARIABLES *neosnippet-variables*
g:neosnippet#snippets_directory *g:neosnippet#snippets_directory* g:neosnippet#snippets_directory *g:neosnippet#snippets_directory*
This variable appoints a path to user-defined snippet files. This variable appoints a path to user-defined snippet files.
You can set multiple values in comma-separated form. Non existing You can set multiple values in comma-separated form. Non
directories are ignored. existing directories are ignored.
User defined snippet files are read after the built-in snippet files. User defined snippet files are read after the built-in snippet
If redundant snippets occur they get overwritten and only the last files. If redundant snippets occur they get overwritten and
one remains. only the last one remains.
Note: The neosnippet plug-in loads file type snippets from several Note: The neosnippet plug-in loads file type snippets from
files if available. For example if you edit a "Vim" file then it loads the several files if available. For example if you edit a "Vim"
snippets from: file then it loads the snippets from:
- "vim.snip*" - "vim.snip*"
- "vim_*.snip*" - "vim_*.snip*"
@ -164,10 +168,11 @@ g:neosnippet#disable_runtime_snippets
This is a dictionary variable which uses file types as key. This is a dictionary variable which uses file types as key.
If you set the value of a file type entry to 1, this prevents If you set the value of a file type entry to 1, this prevents
loading all the file type specific built-in snippets. This is loading all the file type specific built-in snippets. This is
very useful to to prevent snippet conflicts between self defined very useful to to prevent snippet conflicts between self
snippet files and the built-in snippet files of neosnippet. defined snippet files and the built-in snippet files of
If you use a "_" as key for an entry this will treat the value of neosnippet. If you use a "_" as key for an entry this will
the entry as default value for all file types. treat the value of the entry as default value for all file
types.
Note: This dictionary must be set in your .vimrc. Note: This dictionary must be set in your .vimrc.
@ -203,8 +208,9 @@ KEY MAPPINGS *neosnippet-key-mappings*
*<Plug>(neosnippet_expand_or_jump)* *<Plug>(neosnippet_expand_or_jump)*
s_<Plug>(neosnippet_expand_or_jump) s_<Plug>(neosnippet_expand_or_jump)
*s_<Plug>(neosnippet_expand_or_jump)* *s_<Plug>(neosnippet_expand_or_jump)*
Expand a snippet in the current cursor position. If there is no snippet Expand a snippet in the current cursor position. If there is
available it jumps to the next placeholder of the buffer. no snippet available it jumps to the next placeholder of the
buffer.
*<Plug>(neocomplcache_snippets_expand)* *<Plug>(neocomplcache_snippets_expand)*
Note: |<Plug>(neocomplcache_snippets_expand)| is an obsolete Note: |<Plug>(neocomplcache_snippets_expand)| is an obsolete
@ -214,8 +220,9 @@ s_<Plug>(neosnippet_expand_or_jump)
*<Plug>(neosnippet_jump_or_expand)* *<Plug>(neosnippet_jump_or_expand)*
s_<Plug>(neosnippet_jump_or_expand) s_<Plug>(neosnippet_jump_or_expand)
*s_<Plug>(neosnippet_jump_or_expand)* *s_<Plug>(neosnippet_jump_or_expand)*
Jump to the next available placeholder in the buffer. If there is no Jump to the next available placeholder in the buffer. If there
placeholder it expands a snippet in the current cursor position. is no placeholder it expands a snippet in the current cursor
position.
*<Plug>(neocomplcache_snippets_jump)* *<Plug>(neocomplcache_snippets_jump)*
Note: |<Plug>(neocomplcache_snippets_jump)| is an obsolete Note: |<Plug>(neocomplcache_snippets_jump)| is an obsolete
@ -225,9 +232,9 @@ s_<Plug>(neosnippet_jump_or_expand)
*<Plug>(neosnippet_expand)* *<Plug>(neosnippet_expand)*
s_<Plug>(neosnippet_expand) s_<Plug>(neosnippet_expand)
*s_<Plug>(neosnippet_expand)* *s_<Plug>(neosnippet_expand)*
Expand a snippet in current cursor position. It only takes effect Expand a snippet in current cursor position. It only takes
if there is a snippet text to expand or if you have chosen one from effect if there is a snippet text to expand or if you have
the neocomplcache drop down menu. chosen one from the neocomplcache drop down menu.
*<Plug>(neocomplcache_snippets_force_expand)* *<Plug>(neocomplcache_snippets_force_expand)*
Note: |<Plug>(neocomplcache_snippets_force_expand)| is Note: |<Plug>(neocomplcache_snippets_force_expand)| is
@ -237,7 +244,8 @@ s_<Plug>(neosnippet_expand)
*<Plug>(neosnippet_jump)* *<Plug>(neosnippet_jump)*
s_<Plug>(neosnippet_jump) s_<Plug>(neosnippet_jump)
*s_<Plug>(neosnippet_jump)* *s_<Plug>(neosnippet_jump)*
Jump to the next placeholder key. It does not expand any snippets. Jump to the next placeholder key. It does not expand any
snippets.
*<Plug>(neocomplcache_snippets_force_jump)* *<Plug>(neocomplcache_snippets_force_jump)*
Note: |<Plug>(neocomplcache_snippets_force_jump)| is Note: |<Plug>(neocomplcache_snippets_force_jump)| is
@ -245,13 +253,13 @@ s_<Plug>(neosnippet_jump)
i_<Plug>(neosnippet_start_unite_snippet) i_<Plug>(neosnippet_start_unite_snippet)
*i_<Plug>(neosnippet_start_unite_snippet)* *i_<Plug>(neosnippet_start_unite_snippet)*
Starts the unite snippet source. You can expand a snippet by the Starts the unite snippet source. You can expand a snippet by
unite interface. the unite interface.
Note: The plug-in |unite.vim| is required for that feature. Note: The plug-in |unite.vim| is required for that feature.
*<Plug>(neocomplcache_start_unite_snippet)* *<Plug>(neocomplcache_start_unite_snippet)*
Note: |<Plug>(neocomplcache_start_unite_snippet)| is an obsolete Note: |<Plug>(neocomplcache_start_unite_snippet)| is an
name. obsolete name.
x_<Plug>(neosnippet_expand_target) x_<Plug>(neosnippet_expand_target)
*x_<Plug>(neosnippet_expand_target)* *x_<Plug>(neosnippet_expand_target)*
@ -269,9 +277,10 @@ x_<Plug>(neosnippet_register_oneshot_snippet)
neosnippet#expandable() neosnippet#expandable()
*neosnippet#expandable()* *neosnippet#expandable()*
You can use this function with imap <expr>. It checks whether the You can use this function with imap <expr>. It checks whether
cursor text is a snippet trigger or a placeholder. This is is useful the cursor text is a snippet trigger or a placeholder. This is
to save key mappings. The return values of the function are: is useful to save key mappings. The return values of the
function are:
0: not found 0: not found
1: the cursor text is a snippet trigger 1: the cursor text is a snippet trigger
@ -366,8 +375,8 @@ Snippet Keywords:
- abbr [name] (optional) - abbr [name] (optional)
Here you can define an abbreviation of the snippet which will be used in the Here you can define an abbreviation of the snippet which will be used in
drop down menu of neocomplcache. the drop down menu of neocomplcache.
- alias [aliases] (optional) - alias [aliases] (optional)
@ -417,9 +426,10 @@ The structure of a placeholder can be:
Here the number of the placeholder and the placeholder text that are Here the number of the placeholder and the placeholder text that are
seperated by a ":" are embraced by a pair of "{}". The text is displayed seperated by a ":" are embraced by a pair of "{}". The text is displayed
after the snippet expansion and gets replaced by your text. If you jump over after the snippet expansion and gets replaced by your text. If you jump
the snippet and do not insert any text in that position the placeholder text over the snippet and do not insert any text in that position the
remains there. This can be used as a standard value for a certain position. placeholder text remains there. This can be used as a standard value for a
certain position.
Example Example
@ -433,7 +443,8 @@ The structure of a placeholder can be:
- ${number:#:placeholder text} - ${number:#:placeholder text}
Here the number is followd by the "#" character. If you jump over this Here the number is followd by the "#" character. If you jump over this
placeholder and do not insert any text, the placeholder text will be removed. placeholder and do not insert any text, the placeholder text will be
removed.
Example Example
@ -447,8 +458,9 @@ The structure of a placeholder can be:
- ${number:TARGET} - ${number:TARGET}
This is the target placeholder which will be replaced by the text which is This is the target placeholder which will be replaced by the text which is
selected before snippet expansion. Note: You need to expand you snippet with selected before snippet expansion.
the key mapping below for this to work. Note: You need to expand you snippet with the key mapping below for this to
work.
|<Plug>(neosnippet_expand_target)|. |<Plug>(neosnippet_expand_target)|.
@ -483,11 +495,11 @@ The structure of a placeholder can be:
- $number - $number
This is a synchronized placeholder. Sometimes it is required to repat a value This is a synchronized placeholder. Sometimes it is required to repat a
in several places inside a snippet. If you set the number of this placeholder value in several places inside a snippet. If you set the number of this
to the same number as one of the other placeholders in the snippet it will placeholder to the same number as one of the other placeholders in the
repeat its content. $1 is synchronized to ${1} and so on. $0 will be the snippet it will repeat its content. $1 is synchronized to ${1} and so on.
final jump placeholder. $0 will be the final jump placeholder.
Example Example
@ -500,8 +512,8 @@ The structure of a placeholder can be:
${3} ${3}
< <
Note: If you like to include characters in snippets that already have a special Note: If you like to include characters in snippets that already have a
meaning to neosnippet you need to escape them with a backslash. special meaning to neosnippet you need to escape them with a backslash.
> >
snippet code snippet code
@ -655,6 +667,9 @@ A: Please try below settings. It defines snipMate function.
============================================================================== ==============================================================================
CHANGELOG *neosnippet-changelog* CHANGELOG *neosnippet-changelog*
2012-11-03
- Refactored documentation.
2012-11-02 2012-11-02
- Added g:neosnippet#enable_snipmate_compatibility option. - Added g:neosnippet#enable_snipmate_compatibility option.
- Used partial match for neocomplcache completion. - Used partial match for neocomplcache completion.

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: neosnippet.vim " FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 31 Oct 2012. " Last Modified: 03 Nov 2012.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -117,6 +117,10 @@ command! -nargs=? -complete=customlist,neosnippet#filetype_complete
command! -nargs=? -complete=customlist,neosnippet#filetype_complete command! -nargs=? -complete=customlist,neosnippet#filetype_complete
\ NeoComplCacheEditRuntimeSnippets \ NeoComplCacheEditRuntimeSnippets
\ NeoSnippetEdit -runtime <args> \ NeoSnippetEdit -runtime <args>
command! -nargs=1 -complete=file
\ NeoSnippetSource
\ call neosnippet#source_file(<q-args>)
"}}} "}}}
let g:loaded_neosnippet = 1 let g:loaded_neosnippet = 1