Updated docs for imaps feature

This commit is contained in:
Karl Yngve Lervåg 2015-10-22 13:33:45 +02:00
parent 9451bdee5d
commit ba0bc2cf2e
2 changed files with 28 additions and 18 deletions

View File

@ -17,9 +17,9 @@ function! vimtex#imaps#init_script() " {{{1
let s:has_ultisnips = exists('*UltiSnips#Anon') let s:has_ultisnips = exists('*UltiSnips#Anon')
try try
silent! call neosnippet#annonymous('') silent! call neosnippet#anonymous('')
endtry endtry
let s:has_neosnippet = exists('*neosnippet#annonymous') let s:has_neosnippet = exists('*neosnippet#anonymous')
endfunction endfunction
" }}}1 " }}}1
@ -72,7 +72,7 @@ endfunction
" }}}1 " }}}1
function! s:wrap_snippet(lhs, rhs) " {{{1 function! s:wrap_snippet(lhs, rhs) " {{{1
if g:vimtex_imaps_snippet_engine ==# 'neosnippet' if g:vimtex_imaps_snippet_engine ==# 'neosnippet'
return '<c-r>=neosnippet#annonymous(''' . a:rhs . ''')<cr>' return '<c-r>=neosnippet#anonymous(''' . a:rhs . ''')<cr>'
else else
return a:lhs . '<c-r>=UltiSnips#Anon(''' return a:lhs . '<c-r>=UltiSnips#Anon('''
\ . a:rhs . ''', ''' . a:lhs . ''', '''', ''i'')<cr>' \ . a:rhs . ''', ''' . a:lhs . ''', '''', ''i'')<cr>'
@ -82,7 +82,7 @@ endfunction
" }}}1 " }}}1
function! s:wrap_math_snippet(lhs, rhs) " {{{1 function! s:wrap_math_snippet(lhs, rhs) " {{{1
if g:vimtex_imaps_snippet_engine ==# 'neosnippet' if g:vimtex_imaps_snippet_engine ==# 'neosnippet'
return '<c-r>=<sid>is_math() ? neosnippet#annonymous(''' . a:rhs . ''')' return '<c-r>=<sid>is_math() ? neosnippet#anonymous(''' . a:rhs . ''')'
\ . ' : ' . string(a:lhs) . '<cr>' \ . ' : ' . string(a:lhs) . '<cr>'
else else
return a:lhs . '<c-r>=<sid>is_math() ? ' return a:lhs . '<c-r>=<sid>is_math() ? '

View File

@ -419,6 +419,12 @@ Options~
Default value: [] Default value: []
*g:vimtex_imaps_snippet_engine*
Snippet engine for advanced mappings. May be either 'neosnippet' or
'ultisnips'.
Default value: 'ultisnips'
*g:vimtex_imaps_list* *g:vimtex_imaps_list*
The list of mappings to generate on start up. The list of mappings to generate on start up.
@ -1034,13 +1040,16 @@ provides a list of such mappings that are enabled by default, see
|g:vimtex_imaps_leader|. Also, many of the mappings are only active inside |g:vimtex_imaps_leader|. Also, many of the mappings are only active inside
mathematical environments. mathematical environments.
Some of the default mappings utilize the function |UltiSnips#Anon| from Some of the default mappings utilize a snippet engine, either the function
|UltiSnips| in order to provide a more advanced snippet-like functionality. |UltiSnips#Anon| from |UltiSnips| or the function |neosnippet#anonymous| from
This is in no way intended to replace |UltiSnips|. It is instead meant to be |neosnippet|, in order to provide a more advanced snippet-like functionality.
used for very simple things. For instance, the sequence `((` expands directly This is meant to be used for very simple things. For instance, the sequence
to `\left(|\right)` (though only when inside a math environment). The `((` expands directly to `\left(|\right)` (though only when inside a math
|UltiSnipsJumpForward| trigger may then be used to conveniently move the environment). Both snippet engines then allow a trigger key to jump out of the
cursor out of the parantheses. snippet. Note that only |neosnippet| allows nested snippets. However, the
|neosnippet#anonymous| function was only very recently added to |neosnippet|,
and so it requires a recent version in order to work. See also the option
|g:vimtex_imaps_snippet_engine|.
It is of course possible to customize the list of mappings. First, one may It is of course possible to customize the list of mappings. First, one may
specifically disable a default mapping through |g:vimtex_imaps_disabled|. specifically disable a default mapping through |g:vimtex_imaps_disabled|.
@ -1097,14 +1106,15 @@ Explanation of the keys:
are available from |vimtex|: are available from |vimtex|:
`s:wrap_math` Only define `rhs` if inside a math environment. `s:wrap_math` Only define `rhs` if inside a math environment.
`s:wrap_ultisnips` Send `rhs` through `UltiSnips#Anon` in order `s:wrap_snippet` Send `rhs` through the chosen snippet engine in
to create an anonymous snippet. order to create an anonymous snippet. See
`s:wrap_math_ultisnips` Same as `s:wrap_ultisnips`, except it is only |g:vimtex_imaps_snippet_engine| for more details.
`s:wrap_math_snippet` Same as `s:wrap_snippet`, except it is only
expanded when inside a math environment. expanded when inside a math environment.
Of course, one may use custom wrapper functions. To write a custom wrapper Of course, one may use custom wrapper functions. To write a custom wrapper
function, please see how the |vimtex| wrappers are written for examples on function, please see the source for examples on how the |vimtex| wrappers
how it is done. are written.
============================================================================== ==============================================================================
COMPLETION *vimtex-completion* COMPLETION *vimtex-completion*