neosnippet.vim/doc/neosnippet.txt

532 lines
15 KiB
Plaintext
Raw Normal View History

2012-09-27 12:17:07 +00:00
*neosnippet.txt*
neo-snippet plugin contains neocomplcache snippets source
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
Version: 3.0
2012-02-02 04:33:35 +00:00
Author : Shougo <Shougo.Matsu@gmail.com>
License: MIT license {{{
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}}
2012-09-27 12:17:07 +00:00
CONTENTS *neosnippet-contents*
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
Introduction |neosnippet-introduction|
Install |neosnippet-install|
Interface |neosnippet-interface|
Commands |neosnippet-commands|
Variables |neosnippet-variables|
Key mappings |neosnippet-key-mappings|
Functions |neosnippet-functions|
Examples |neosnippet-examples|
Snippet syntax |neosnippet-snippet-syntax|
Changelog |neosnippet-changelog|
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INTRODUCTION *neosnippet-introduction*
2012-02-02 04:33:35 +00:00
2012-05-05 15:19:01 +00:00
This source analyzes snippet files for completion, offers functionality
similar to snipMate.vim or snippetsEmu.vim. Since you can choose snippet with
neocomplcache interface, you might have less trouble learning it.
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INSTALL *neosnippet-install*
2012-02-02 04:33:35 +00:00
2012-09-30 08:23:02 +00:00
1: Extract the file and put files in your Vim directory
2012-02-02 04:33:35 +00:00
(usually ~/.vim/ or Program Files/Vim/vimfiles on Windows).
2012-09-30 08:23:02 +00:00
Note: If you want to complete snippets, you must install neocomplcache
(https://github.com/Shougo/neocomplcache).
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INTERFACE *neosnippet-interface*
2012-02-02 04:33:35 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
COMMANDS *neosnippet-commands*
2012-02-02 04:33:35 +00:00
2012-09-30 10:10:25 +00:00
:NeoSnippetMakeCache [filetype]
*:NeoSnippetMakeCache*
2012-09-22 19:24:01 +00:00
Makes cache of [filetype] snippets. It automatically selects
current buffer's filetype unless you specify [filetype].
2012-02-02 04:33:35 +00:00
*:NeoComplCacheCachingSnippets*
Note: |:NeoComplCacheCachingSnippets| is obsolute name.
:NeoSnippetEdit [{options}] [filetype]
*:NeoSnippetEdit*
Opens [filetype] snippets to edit. It automatically selects
current buffer's filetype unless you specify [filetype].
2012-10-04 03:35:07 +00:00
If [filetype] snippets has a directory, it automatically edit
"[filetype].snip" in [filetype] subdirectory.
If [filetype] snippet file doesn't exist, it creates one
automatically.
It edits a snippet file in |g:neosnippet#snippets_directory|
with precedence.
Re-make cache will be done automatically when you save the
file.
*:NeoComplCacheEditSnippets*
2012-09-30 10:10:25 +00:00
{options} are options for the command. You may give the
following parameters for a option; you must escape with "\"
when it contains spaces.
2012-05-05 15:19:01 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-vertical*
-vertical
Splits window vertically.
2012-05-05 15:19:01 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-horizontal*
-horizontal
Splits window horizontally.
The behavior is undefined when both options are defined.
2012-02-02 04:33:35 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-direction*
-direction={direction}
Defines split position rule. The default value is "belowleft".
*neosnippet-edit-options-split*
-split
Split buffer.
*neosnippet-edit-options-runtime*
-runtime
Edit runtime snippets instead of user snippets.
Note: |:NeoComplCacheEditSnippets| is obsolute name.
:NeoComplCacheEdit -runtime [filetype]
It edits a runtime snippet file with neosnippet.
Re-make cache will be done automatically when you save the
file.
*:NeoComplCacheEditRuntimeSnippets*
Note: |:NeoComplCacheEditRuntimeSnippets| is obsolute name.
2012-02-02 04:33:35 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
VARIABLES *neosnippet-variables*
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
g:neosnippet#snippets_directory *g:neosnippet#snippets_directory*
2012-05-05 15:19:01 +00:00
This variable appoints a path to user-defined snippet files.
2012-09-22 19:24:01 +00:00
You can set multiple values in comma-separated form.
2012-05-05 15:19:01 +00:00
If the directory doesn't exist, it is ignored.
User defined snippets were read after normal snippet files,
2012-09-23 05:03:20 +00:00
so redundant snippets will be overwritten.
2012-05-05 09:08:56 +00:00
2012-09-30 09:04:48 +00:00
*g:neocomplcache_snippets_dir*
Note: |g:neocomplcache_snippets_dir| is obsolute name.
2012-05-05 15:19:01 +00:00
This variable doesn't exist unless you declare it.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
g:neosnippet#disable_select_mode_mappings
*g:neosnippet#disable_select_mode_mappings*
2012-05-05 15:19:01 +00:00
This variable controls whether to disable Key-mappings in
|Select-mode| when snippets_complete performs. Usually you
had better enable it.
2012-10-04 08:17:42 +00:00
Note: It must be set in .vimrc.
2012-05-05 09:08:56 +00:00
2012-09-30 09:04:48 +00:00
*g:neocomplcache_disable_select_mode_mappings*
Note: |g:neocomplcache_disable_select_mode_mappings| is
obsolute name.
2012-02-02 04:33:35 +00:00
Default value is 1.
2012-09-30 09:04:48 +00:00
g:neosnippet#disable_runtime_snippets
*g:neosnippet#disable_runtime_snippets*
2012-09-23 05:03:20 +00:00
If this variable is 1, runtime snippets won't be loaded.
This variable is useful to avoid snippets conflictions.
2012-10-04 08:17:42 +00:00
Note: It must be set in .vimrc.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*g:neocomplcache_snippets_disable_runtime_snippets*
Note: |g:neocomplcache_snippets_disable_runtime_snippets| is
obsolute name.
2012-02-02 04:33:35 +00:00
Default value is 0.
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
KEY MAPPINGS *neosnippet-key-mappings*
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
<Plug>(neosnippet_expand_or_jump)
*<Plug>(neosnippet_expand_or_jump)*
2012-09-23 05:03:20 +00:00
Expands a cursor snippet of plural lines. When there is no
snippet, jumps to the next placeholder.
2012-05-05 09:08:56 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_expand)*
Note: |<Plug>(neocomplcache_snippets_expand)| is obsolute
name.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
<Plug>(neosnippet_jump_or_expand)
*<Plug>(neosnippet_jump_or_expand)*
2012-05-05 15:19:01 +00:00
Jump to next placeholder. If there is no placeholder, expand a
multiline cursor snippet.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_jump)*
Note: |<Plug>(neocomplcache_snippets_jump)| is obsolute
name.
<Plug>(neosnippet_expand)
2012-10-01 02:47:04 +00:00
*<Plug>(neosnippet_expand)*
2012-05-05 15:19:01 +00:00
Expand a cursor snippet. Does nothing if there is no snippet.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_force_expand)*
Note: |<Plug>(neocomplcache_snippets_force_expand)| is
obsolute name.
<Plug>(neosnippet_jump)
*<Plug>(neosnippet_jump)*
2012-05-05 15:19:01 +00:00
Jump to next place holder. Do not expand any snippet. When
you do not want to expand a snippet name, use this keymapping.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_force_jump)*
Note: |<Plug>(neocomplcache_snippets_force_jump)| is
obsolute name.
2012-10-04 05:21:05 +00:00
i_<Plug>(neosnippet_start_unite_snippet)
*i_<Plug>(neosnippet_start_unite_snippet)*
2012-02-02 09:17:45 +00:00
Start unite snippet source.
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_start_unite_snippet)*
Note: |<Plug>(neocomplcache_start_unite_snippet)| is obsolute
name.
2012-02-02 09:17:45 +00:00
2012-09-30 09:13:49 +00:00
neosnippet#expandable()
*neosnippet#expandable()*
2012-05-05 15:37:03 +00:00
Use this function with imap <expr>. It checks whether cursor
text is a snippet trigger or a placeholder exists in the
current buffer. It's useful for saving keymappings.
Return value is not just a boolean but either
0: not found
1: cursor text is a snippet trigger
2: a placeholder exists in the current buffer
3: both found
2012-02-02 04:33:35 +00:00
>
2012-09-30 09:13:49 +00:00
imap <expr><C-l> neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<C-n>"
2012-02-02 04:33:35 +00:00
<
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#expandable()*
2012-09-27 12:17:07 +00:00
*neocomplcache#sources#snippets_complete#force_expandable()*
2012-09-30 09:13:49 +00:00
Note:
|neocomplcache#sources#snippets_complete#expandable()|
and
|neocomplcache#sources#snippets_complete#force_expandable()|
is obsolute name.
neosnippet#jumpable()
*neosnippet#jumpable()*
2012-05-05 15:37:03 +00:00
Use this function with imap <expr>. It checks whether cursor
text is an existing placeholder in current buffer.
2012-05-05 15:19:01 +00:00
Useful for saving keymappings.
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#jumpable()*
Note: |neocomplcache#sources#snippets_complete#jumpable()| is
obsolute name.
2012-06-06 01:05:36 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
FUNCTIONS *neosnippet-functions*
2012-06-06 01:05:36 +00:00
2012-09-30 09:13:49 +00:00
neosnippet#get_snippets_directory()
*neosnippet#get_snippets_directory()*
2012-06-06 01:05:36 +00:00
Gets snippet directories. This directories contain runtime
2012-09-30 09:13:49 +00:00
snippets directories and |g:neosnippet#snippets_directory|
2012-06-06 01:05:36 +00:00
directories.
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#get_snippets_dir()*
Note:
|neocomplcache#sources#snippets_complete#get_snippets_dir()|
is obsolute name.
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
EXAMPLES *neosnippet-examples*
2012-02-02 04:33:35 +00:00
>
" Plugin key-mappings.
2012-09-30 09:13:49 +00:00
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
2012-05-05 09:08:56 +00:00
2012-02-02 04:33:35 +00:00
" SuperTab like snippets behavior.
2012-09-30 09:04:48 +00:00
"imap <expr><TAB> neosnippet#expandable() ?
2012-09-30 09:13:49 +00:00
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
2012-05-05 09:08:56 +00:00
2012-02-02 04:33:35 +00:00
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
<
==============================================================================
2012-09-27 12:17:07 +00:00
SNIPPET SYNTAX *neosnippet-snippet-syntax*
2012-02-02 04:33:35 +00:00
The snippet syntax is similar to |snipMate|.
2012-02-02 04:33:35 +00:00
Example:
>
snippet if
abbr if endif
prev_word '^'
if $<1:condition>
${2}
endif
<
2012-02-21 04:07:46 +00:00
snippet {snippet_name} syntax is the snippet name.
2012-09-27 12:17:07 +00:00
abbr {abbr_name} is the completion abbrevation (same to completion "abbr"
key).
2012-02-21 04:07:46 +00:00
prev_word '^' means this snippet is enabled only in line head.
2012-05-05 15:19:01 +00:00
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:
2012-02-02 04:33:35 +00:00
>
delete snippets_name
<
2012-05-05 15:19:01 +00:00
and redefine the snippet.
When including external files or other snippet file's snippets are overwrited,
you will not be warned.
2012-02-02 04:33:35 +00:00
Snippet include feature is available.
>
include c.snip
<
Eval snippet feature is available.
>
snippet hoge
prev_word '^'
`expand("%")`
<
2012-09-30 10:10:25 +00:00
If you use |:NeoSnippetEdit| command for easy snippet editing, the file will
be loaded automatically when you save the file.
2012-02-02 04:33:35 +00:00
2012-09-30 09:13:49 +00:00
Neosnippet doesn't map snippet-expand key by default. If you want to use
2012-05-05 15:19:01 +00:00
snippet feature, you can define below mappings in your .vimrc:
2012-02-02 04:33:35 +00:00
>
2012-09-30 09:13:49 +00:00
imap <C-l> <Plug>(neosnippet_expand_or_jump)
smap <C-l> <Plug>(neosnippet_expand_or_jump)
2012-02-02 04:33:35 +00:00
<
2012-05-05 15:19:01 +00:00
2012-02-02 04:33:35 +00:00
Placeholder feature is available.
>
snippet if
abbr if endif
prev_word '^'
if ${1:condition}
${2}
endif
<
'_' snippet feature is supported. '_' snippet is loaded in all filetypes.
2012-09-30 09:13:49 +00:00
And neosnippet can load snipMate snippets.
2012-02-02 04:33:35 +00:00
Alias feature is supported. Separator is ' ' or ','.
>
alias hoge hogera hogehoge
<
Synchronized placeholder feature is supported. $1 is synchronized to ${1}.
When you jump next, it is synchlonized. $0 is last jump placeholder.
2012-05-05 15:19:01 +00:00
The placeholder value can't contain new lines. Below snippet is illegal:
2012-02-02 04:33:35 +00:00
>
snippet test
${1:constructor: (${2:args\}) ->
${3:# do smth}}
<
Multi snippet feature is supported in snipMate.
2012-09-30 09:13:49 +00:00
neosnippet substitutes trigger and descriptions spaces to '_'.
2012-02-02 04:33:35 +00:00
>
snippet trigger description1
hoge
snippet trigger description2
piyo
<
You choose snippet <C-n> or <C-p> and expand it with
2012-09-30 09:13:49 +00:00
|<Plug>(neosnippet_expand_or_jump)| key-mappings.
2012-02-02 04:33:35 +00:00
Nested placeholder feature is supported.
But must escape inner '}'. '\' is eacape sequence.
>
snippet div
<div ${1:id="${2:someid\}"}>${3}</div>${4}
<
2012-09-30 09:13:49 +00:00
If you use hard tab for indentation in snippet file, neosnippet will use
2012-07-02 02:37:14 +00:00
'shiftwidth' instead of Vim indent plugin. This feature is useful while some
languages' indent files can not work very well (e.g.: PHP, Python).
2012-02-02 04:33:35 +00:00
>
snippet if
if (${1:/* condition */}) {
${2:// code...}
}
<
==============================================================================
2012-09-27 12:17:07 +00:00
UNITE SOURCES *neosnippet-unite-sources*
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
*neosnippet-unite-source-snippet*
2012-02-02 04:33:35 +00:00
snippet
2012-09-30 09:13:49 +00:00
The candidates are neosnippet snippets. The kinds are
2012-09-27 12:17:07 +00:00
"snippet". Normally used in
2012-09-30 09:13:49 +00:00
|<Plug>(neosnippet_start_unite_snippet)| mappings.
2012-05-05 15:19:01 +00:00
But you can execute it by ":Unite snippet".
2012-02-02 09:16:06 +00:00
You can edit snippet file in "edit" action.
Examples:
2012-02-02 04:33:35 +00:00
>
2012-09-30 09:13:49 +00:00
imap <C-s> <Plug>(neosnippet_start_unite_snippet)
2012-02-02 04:33:35 +00:00
<
source actions
2012-09-27 12:17:07 +00:00
snippet *neosnippet-unite-action-snippet*
2012-05-05 15:19:01 +00:00
expand Expand snippet (default action)
2012-02-02 04:33:35 +00:00
edit Edit snippet
preview View snippet definition
==============================================================================
2012-09-27 12:17:07 +00:00
CHANGELOG *neosnippet-changelog*
2012-10-04 01:22:35 +00:00
2012-10-04
- Refactored snippets filter.
2012-10-04 03:35:07 +00:00
- Changed :NeoSnippetEdit behavior.
2012-10-04 04:22:37 +00:00
- Added scala snip.
2012-10-04 05:28:37 +00:00
- Fixed s:get_cursor_snippet().
2012-10-04 01:22:35 +00:00
2012-10-01
- Deleted neosnippet#force_expandable().
2012-10-01 04:25:38 +00:00
- Improved python snippets.
2012-09-30 08:04:46 +00:00
2012-09-30
- Changed runtime directory.
2012-09-30 08:06:28 +00:00
- Vitalized.
- Deleted neocomplcache#util functions.
2012-09-30 08:17:31 +00:00
- Refactored variables.
- Deleted s:get_cursor_keyword_snippet().
2012-09-30 08:33:50 +00:00
- Improved for filetype.
2012-09-30 08:45:41 +00:00
- Improved filetype complete.
2012-09-30 09:13:49 +00:00
- Improved documentation.
- Changed neocomplcache source behavior.
2012-09-30 10:10:25 +00:00
- Renamed commands.
2012-09-30 14:16:26 +00:00
- Fixed snippet source errors.
2012-09-30 08:04:46 +00:00
2012-09-27 12:17:07 +00:00
2012-09-27
- Ver.3 development is started.
- Renamed documentation.
2012-09-27 12:30:33 +00:00
- Renamed keymappings.
2012-09-27 12:17:07 +00:00
------------------------------------------------------------------------------
ChangeLog 2.0:
2012-09-26 22:38:16 +00:00
2012-09-27
- Improved add placeholder behavior.
- Fixed wrong indentation when 'expandtab'.
2012-02-02 04:33:35 +00:00
2012-09-23 04:45:38 +00:00
2012-09-23
- Fixed substitute tab character.
2012-09-23 04:48:35 +00:00
- Improved cursor position.
2012-09-23 05:30:02 +00:00
- Fixed column in select mode.
- Added lua snip.
- Improved javascript snip.
2012-09-23 05:55:13 +00:00
- Improved ruby snip.
2012-09-23 04:45:38 +00:00
2012-09-06
- Added neocomplcache__convertable attribute.
2012-08-30
- Changed <Plug>(neocomplcache_snippets_expand) behavior.
2012-08-27
- Fixed neocomplcache#sources#snippets_complete#force_expandable().
2012-08-02 02:11:44 +00:00
2012-08-02
- Improved caching snippet files.
2012-06-06
- Added neocomplcache#sources#snippets_complete#get_snippets_dir().
2012-06-02 00:53:35 +00:00
2012-06-02
- Fixed exapnd indentation.
2012-05-17 13:16:04 +00:00
2012-05-16
- Added ftdetect file.
2012-05-11 23:41:49 +00:00
2012-05-12
- Improved c snip.
2012-05-03 01:59:56 +00:00
2012-05-03
- Released ver.2.0.
2012-04-05 00:53:52 +00:00
2012-04-05
- Fixed nested placeholder problem.
2012-03-23 03:14:13 +00:00
2012-03-23
- Fixed substitute pattern bug.
2012-03-18 15:56:24 +00:00
2012-03-19
- Fixed substitute marker.
2012-03-18 15:39:35 +00:00
2012-03-18
- Fixed for expandtab.
2012-03-17 13:53:56 +00:00
2012-03-17
- Fixed for echodoc.
2012-03-15 15:06:21 +00:00
2012-03-16
- Fixed snippets indentation.
2012-03-15
- Improved search snippet markers behavior.
2012-03-15 14:26:21 +00:00
- Don't conceal default codes.
2012-03-13 15:39:45 +00:00
2012-03-14
- Refactored expand snippet behavior.
2012-03-13 23:49:57 +00:00
- Fixed expand bug.
2012-03-14 00:35:41 +00:00
- Refactored substitute patterns.
2012-03-14 00:43:33 +00:00
- Changed marker patterns.
2012-03-13 15:39:45 +00:00
2012-03-08
- Use shiftwidth instead of softabstop.
2012-03-08 09:38:58 +00:00
- Fixed plugin indentation problem.
2012-03-06 23:19:01 +00:00
2012-03-07
- Added snippet source.
2012-03-06 23:39:08 +00:00
- Fixed snippet source behavior.
2012-03-07 01:05:00 +00:00
- Improved snippet source.
2012-03-06 23:19:01 +00:00
2012-03-06 08:04:37 +00:00
2012-03-06
- Improved ftplugin.
2012-03-03
- Added neocomplcache#sources#snippets_complete#force_expandable() and
neocomplcache#sources#snippets_complete#jumpable().
2012-02-25 14:05:10 +00:00
2012-02-25
- Improved split().
2012-02-24 04:42:12 +00:00
2012-02-24
- Improved a bit.
2012-02-22 03:59:57 +00:00
2012-02-22
- Fixed prev_word behavior.
2012-02-21 04:07:46 +00:00
2012-02-21
- Improved documentation.
2012-02-05 01:24:59 +00:00
2012-02-05
- Fixed variable name.
2012-02-02 04:33:35 +00:00
2012-02-02
- Initial version.
2012-02-02 09:16:06 +00:00
- Improved documentation.
2012-02-02 04:33:35 +00:00
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:noet: