Merge branch 'master' of github.com:Shougo/neocomplcache-snippets-complete

This commit is contained in:
Shougo Matsushita 2012-05-12 08:43:12 +09:00
commit fa8cc3d935
2 changed files with 78 additions and 72 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
doc/tags

View File

@ -38,14 +38,14 @@ Changelog |neocomplcache-snippets-complete-changelog|
============================================================================== ==============================================================================
INTRODUCTION *neocomplcache-snippets-complete-introduction* INTRODUCTION *neocomplcache-snippets-complete-introduction*
This source analyzes snippet files for completion. The source offer a function This source analyzes snippet files for completion, offers functionality
similar with snipMate.vim and snippetsEmu.vim. Because you can search a snippet similar to snipMate.vim or snippetsEmu.vim. Since you can choose snippet with
with a function of neocomplcache, you may omit trouble to learn. neocomplcache interface, you might have less trouble learning it.
============================================================================== ==============================================================================
INSTALL *neocomplcache-snippets-complete-install* INSTALL *neocomplcache-snippets-complete-install*
1: Install neocomplcache(https://github.com/Shougo/neocomplcache). 1: Install neocomplcache (https://github.com/Shougo/neocomplcache).
2: Extract the file and put files in your Vim directory 2: Extract the file and put files in your Vim directory
(usually ~/.vim/ or Program Files/Vim/vimfiles on Windows). (usually ~/.vim/ or Program Files/Vim/vimfiles on Windows).
@ -56,43 +56,49 @@ INTERFACE *neocomplcache-snippets-complete-interface*
COMMANDS *neocomplcache-snippets-complete-commands* COMMANDS *neocomplcache-snippets-complete-commands*
:NeoComplCacheCachingSnippets [filetype] *:NeoComplCacheCachingSnippets* :NeoComplCacheCachingSnippets [filetype] *:NeoComplCacheCachingSnippets*
Caching [filetype] snippet file. Caching [filetype] snippets.
Select current buffer filetype when [filetype] omitted. Select current buffer's filetype when [filetype] was omitted.
:NeoComplCacheEditSnippets [filetype] *:NeoComplCacheEditSnippets* :NeoComplCacheEditSnippets [filetype] *:NeoComplCacheEditSnippets*
Edit [filetype] snippets. Edit current buffer's filetype Edit [filetype] snippets.
snippets when [filetype] omitted. When there is not Select current buffer's filetype when [filetype] was omitted.
[filetype] snippet file, it is generated newly. This
command edits a snippet file in g:neocomplcache_snippets_dir If [filetype] snippet file doesn't exist, create it
with precedence. It is done re-cache automatically when you automatically.
store a snippet file.
This command edits a snippet file in
|g:neocomplcache_snippets_dir| with precedence.
Re-cache will be automatically done when you save the file.
:NeoComplCacheEditRuntimeSnippets [filetype] *:NeoComplCacheEditRuntimeSnippets* :NeoComplCacheEditRuntimeSnippets [filetype] *:NeoComplCacheEditRuntimeSnippets*
Edit [filetype] snippets. Edit current buffer's filetype Edit [filetype] snippets.
snippets when [filetype] omitted. When there is not Select current buffer's filetype when [filetype] was omitted.
[filetype] snippet file, it is generated newly. This
command edits a runtime snippet file with snippets_complete. If [filetype] snippet file doesn't exist, create it
It is done re-cache automatically when you store a snippet automatically.
file.
This command edits a runtime snippet file with
snippets_complete.
Re-cache will be automatically done when you save the file.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
VARIABLES *neocomplcache-snippets-complete-variables* VARIABLES *neocomplcache-snippets-complete-variables*
g:neocomplcache_snippets_dir *g:neocomplcache_snippets_dir* g:neocomplcache_snippets_dir *g:neocomplcache_snippets_dir*
This variable appoints the pass of the snippet files which This variable appoints a path to user-defined snippet files.
user defined. It cuts the directory by plural appointment You can set multiple values in comma-serparted form.
in comma separated value. When there is not the directory If the directory doesn't exist, it is ignored.
which appointed here, neocomplcache will ignore. User
defined snippet files are read after having read a normal User defined snippets were read after normal snippet files,
snippet files. It is overwritten redundant snippet. redundant snippets will be overwritten.
There is not this variable unless a user defines it by oneself. This variable doesn't exist unless you declare it.
g:neocomplcache_disable_select_mode_mappings *g:neocomplcache_disable_select_mode_mappings* g:neocomplcache_disable_select_mode_mappings *g:neocomplcache_disable_select_mode_mappings*
This variable control whether you invalidate Key-mappings of This variable controls whether to disable Key-mappings in
Select-mode which snippets_complete performs. You had |Select-mode| when snippets_complete performs. Usually you
better usually validate it. had better enable it.
Default value is 1. Default value is 1.
g:neocomplcache_snippets_disable_runtime_snippets g:neocomplcache_snippets_disable_runtime_snippets
@ -106,26 +112,24 @@ g:neocomplcache_snippets_disable_runtime_snippets
KEY MAPPINGS *neocomplcache-snippets-complete-key-mappings* KEY MAPPINGS *neocomplcache-snippets-complete-key-mappings*
<Plug>(neocomplcache_snippets_expand) *<Plug>(neocomplcache_snippets_expand)* <Plug>(neocomplcache_snippets_expand) *<Plug>(neocomplcache_snippets_expand)*
Expand a cursor snippet of plural lines. When there is not Expand a cursor snippet of plural lines. When there is not a
snippet, jump to the next placeholder. snippet, jump to next placeholder.
Note: cursor snippet must be match keyword patterns. Note: cursor snippet must be match keyword patterns.
For example if snippet name is ".", snippets_complete don't expand it. For example if snippet name is ".", snippets_complete don't expand it.
If you expand snippet ".", Please use If you expand snippet ".", Please use
|<Plug>(neocomplcache_snippets_force_expand)|. |<Plug>(neocomplcache_snippets_force_expand)|.
<Plug>(neocomplcache_snippets_jump) *<Plug>(neocomplcache_snippets_jump)* <Plug>(neocomplcache_snippets_jump) *<Plug>(neocomplcache_snippets_jump)*
Jump to the next placeholder. If there is no Jump to next placeholder. If there is no placeholder, expand a
placeholder, expand a multiline cursor snippet. multiline cursor snippet.
<Plug>(neocomplcache_snippets_force_expand) *<Plug>(neocomplcache_snippets_force_expand)* <Plug>(neocomplcache_snippets_force_expand) *<Plug>(neocomplcache_snippets_force_expand)*
Expand a cursor snippet. Does nothing if there is not Expand a cursor snippet. Does nothing if there is no snippet.
snippet.
<Plug>(neocomplcache_snippets_force_jump) *<Plug>(neocomplcache_snippets_force_jump)* <Plug>(neocomplcache_snippets_force_jump) *<Plug>(neocomplcache_snippets_force_jump)*
Jump to the next place holder. Do not expand any snippet. When Jump to next place holder. Do not expand any snippet. When
you do not want to expand a snippet name, use this you do not want to expand a snippet name, use this keymapping.
keymapping.
<Plug>(neocomplcache_start_unite_snippet) *<Plug>(neocomplcache_start_unite_snippet)* <Plug>(neocomplcache_start_unite_snippet) *<Plug>(neocomplcache_start_unite_snippet)*
Start unite snippet source. Start unite snippet source.
@ -133,30 +137,28 @@ KEY MAPPINGS *neocomplcache-snippets-complete-key-mappings*
neocomplcache#sources#snippets_complete#expandable() neocomplcache#sources#snippets_complete#expandable()
*neocomplcache#sources#snippets_complete#expandable()* *neocomplcache#sources#snippets_complete#expandable()*
Use this function on inoremap <expr>. It check whether Use this function with imap <expr>. It checks whether cursor
cursor text is snippets trigger or exists placeholder in text is snippets trigger or existing placeholder in current
current buffer. This function is useful when saving buffer. Useful for saving keymappings.
keymappings.
Return value is Return value is
0 : not found 0 : not found
1 : cursor text is snippets trigger 1 : cursor text is snippets trigger
2 : exists placeholder in current buffer 2 : existing placeholder in current buffer
3 : both found. 3 : both found.
> >
imap <expr><C-l> neocomplcache#snippets_complete#expandable() ? imap <expr><C-l> neocomplcache#sources#snippets_complete#expandable() ?
\ "\<Plug>(neocomplcache_snippets_expand)" : "\<C-n>" \ "\<Plug>(neocomplcache_snippets_expand)" : "\<C-n>"
< <
neocomplcache#sources#snippets_complete#force_expandable() neocomplcache#sources#snippets_complete#force_expandable()
*neocomplcache#sources#snippets_complete#force_expandable()* *neocomplcache#sources#snippets_complete#force_expandable()*
Use this function on inoremap <expr>. It check whether cursor Use this function with imap <expr>. It checks whether cursor
text is snippets triggerThis function is useful when saving text is snippets trigger. Useful for saving keymappings.
keymappings.
neocomplcache#sources#snippets_complete#jumpable() neocomplcache#sources#snippets_complete#jumpable()
*neocomplcache#sources#snippets_complete#jumpable()* *neocomplcache#sources#snippets_complete#jumpable()*
Use this function on inoremap <expr>. It check whether exists Use this function with imap <expr>. It checks whether cursor
placeholder in current buffer. This function is useful when text is an existing placeholder in current buffer.
saving keymappings. Useful for saving keymappings.
============================================================================== ==============================================================================
EXAMPLES *neocomplcache-snippets-complete-examples* EXAMPLES *neocomplcache-snippets-complete-examples*
@ -164,18 +166,18 @@ EXAMPLES *neocomplcache-snippets-complete-examples*
" Plugin key-mappings. " Plugin key-mappings.
imap <C-k> <Plug>(neocomplcache_snippets_expand) imap <C-k> <Plug>(neocomplcache_snippets_expand)
smap <C-k> <Plug>(neocomplcache_snippets_expand) smap <C-k> <Plug>(neocomplcache_snippets_expand)
" SuperTab like snippets behavior. " SuperTab like snippets behavior.
"imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ?
" \ "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>" " \ "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
" For snippet_complete marker. " For snippet_complete marker.
if has('conceal') if has('conceal')
set conceallevel=2 concealcursor=i set conceallevel=2 concealcursor=i
endif endif
< <
============================================================================== ==============================================================================
SNIPPET SYNTAX *neocomplcache-snippets-complete-snippet-completion* SNIPPET SYNTAX *neocomplcache-snippets-complete-snippet-syntax*
neocomplcache has built-in snippet feature. The snippet syntax resembles neocomplcache has built-in snippet feature. The snippet syntax resembles
|snipMate|. |snipMate|.
@ -192,14 +194,16 @@ Example:
snippet {snippet_name} syntax is the snippet name. snippet {snippet_name} syntax is the snippet name.
abbr {abbr_name} is the completion abbrevation (same to completion "abbr" key). abbr {abbr_name} is the completion abbrevation (same to completion "abbr" key).
prev_word '^' means this snippet is enabled only in line head. prev_word '^' means this snippet is enabled only in line head.
By the way, it is warned that the snippet name is already defined by same
snippet file. When you want to overwrite explicitly, as follows: By the way, it is warned that the snippet name was already defined by other
snippet file. If you want to overwrite it explicitly, please use:
> >
delete snippets_name delete snippets_name
< <
And redefine snippet by snippet statement. and redefine the snippet.
When include external files or other snippet file's snippets are overwrited,
will not be warned. When including external files or other snippet file's snippets are overwrited,
you will not be warned.
Snippet include feature is available. Snippet include feature is available.
> >
@ -211,15 +215,16 @@ Eval snippet feature is available.
prev_word '^' prev_word '^'
`expand("%")` `expand("%")`
< <
If you use |:NeoComplCacheEditSnippets| command, edit snippet easily. If you use |:NeoComplCacheEditSnippets| command for easy snippet editing, the
When you saved a snippet file, the snippet file is loaded automatically. file will be loaded automatically when you save the file.
Neocomplcache don't mapping expand snippet key automatically. If you use Neocomplcache doesn't map snippet-expand key by default. If you want to use
neocomplcache snippet feature, define below mappings in your .vimrc. snippet feature, you can define below mappings in your .vimrc:
> >
imap <C-l> <Plug>(neocomplcache_snippets_expand) imap <C-l> <Plug>(neocomplcache_snippets_expand)
smap <C-l> <Plug>(neocomplcache_snippets_expand) smap <C-l> <Plug>(neocomplcache_snippets_expand)
< <
Placeholder feature is available. Placeholder feature is available.
> >
snippet if snippet if
@ -239,7 +244,7 @@ Alias feature is supported. Separator is ' ' or ','.
Synchronized placeholder feature is supported. $1 is synchronized to ${1}. Synchronized placeholder feature is supported. $1 is synchronized to ${1}.
When you jump next, it is synchlonized. $0 is last jump placeholder. When you jump next, it is synchlonized. $0 is last jump placeholder.
The placeholder value can't be contained new line. Below snippet is illegal. The placeholder value can't contain new lines. Below snippet is illegal:
> >
snippet test snippet test
${1:constructor: (${2:args\}) -> ${1:constructor: (${2:args\}) ->
@ -262,10 +267,10 @@ But must escape inner '}'. '\' is eacape sequence.
snippet div snippet div
<div ${1:id="${2:someid\}"}>${3}</div>${4} <div ${1:id="${2:someid\}"}>${3}</div>${4}
< <
If you indented by hard tab in snippet file, neocomplcache will use shiftwidth
instead of the original indent function provided by Vim. This feature is useful If you use hard tab for indentation in snippet file, neocomplcache will use
when you use the language whose indent file can not work very well(example: 'shiftwidth' instead of original Vim indent function. This feature is useful
PHP). while some languages' indent files can not work very well (e.g.: PHP).
> >
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
@ -278,8 +283,8 @@ UNITE SOURCES *neocomplcache-snippets-complete-unite-sources*
*neocomplcache-snippets-complete-unite-source-snippet* *neocomplcache-snippets-complete-unite-source-snippet*
snippet snippet
The candidates are neocomplcache snippets. The kinds are "snippet". The candidates are neocomplcache snippets. The kinds are "snippet".
Normally, used in |<Plug>(neocomplcache_start_unite_snippet)| mappings. Normally used in |<Plug>(neocomplcache_start_unite_snippet)| mappings.
But you can execute by ":Unite snippet". But you can execute it by ":Unite snippet".
You can edit snippet file in "edit" action. You can edit snippet file in "edit" action.
Examples: Examples:
> >
@ -288,7 +293,7 @@ snippet
source actions source actions
snippet *neocomplcache-snippets-complete-unite-action-snippet* snippet *neocomplcache-snippets-complete-unite-action-snippet*
expand Expand snippet(default action) expand Expand snippet (default action)
edit Edit snippet edit Edit snippet
preview View snippet definition preview View snippet definition