From ba0bc2cf2e23a654cc1591fbbd2fa2ef5f583f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Thu, 22 Oct 2015 13:33:45 +0200 Subject: [PATCH] Updated docs for imaps feature --- autoload/vimtex/imaps.vim | 8 ++++---- doc/vimtex.txt | 38 ++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/autoload/vimtex/imaps.vim b/autoload/vimtex/imaps.vim index 9ba8914..7d77b8a 100644 --- a/autoload/vimtex/imaps.vim +++ b/autoload/vimtex/imaps.vim @@ -17,9 +17,9 @@ function! vimtex#imaps#init_script() " {{{1 let s:has_ultisnips = exists('*UltiSnips#Anon') try - silent! call neosnippet#annonymous('') + silent! call neosnippet#anonymous('') endtry - let s:has_neosnippet = exists('*neosnippet#annonymous') + let s:has_neosnippet = exists('*neosnippet#anonymous') endfunction " }}}1 @@ -72,7 +72,7 @@ endfunction " }}}1 function! s:wrap_snippet(lhs, rhs) " {{{1 if g:vimtex_imaps_snippet_engine ==# 'neosnippet' - return '=neosnippet#annonymous(''' . a:rhs . ''')' + return '=neosnippet#anonymous(''' . a:rhs . ''')' else return a:lhs . '=UltiSnips#Anon(''' \ . a:rhs . ''', ''' . a:lhs . ''', '''', ''i'')' @@ -82,7 +82,7 @@ endfunction " }}}1 function! s:wrap_math_snippet(lhs, rhs) " {{{1 if g:vimtex_imaps_snippet_engine ==# 'neosnippet' - return '=is_math() ? neosnippet#annonymous(''' . a:rhs . ''')' + return '=is_math() ? neosnippet#anonymous(''' . a:rhs . ''')' \ . ' : ' . string(a:lhs) . '' else return a:lhs . '=is_math() ? ' diff --git a/doc/vimtex.txt b/doc/vimtex.txt index c6f7ac2..bda0883 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -419,6 +419,12 @@ Options~ 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* 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 mathematical environments. -Some of the default mappings utilize the function |UltiSnips#Anon| from -|UltiSnips| in order to provide a more advanced snippet-like functionality. -This is in no way intended to replace |UltiSnips|. It is instead meant to be -used for very simple things. For instance, the sequence `((` expands directly -to `\left(|\right)` (though only when inside a math environment). The -|UltiSnipsJumpForward| trigger may then be used to conveniently move the -cursor out of the parantheses. +Some of the default mappings utilize a snippet engine, either the function +|UltiSnips#Anon| from |UltiSnips| or the function |neosnippet#anonymous| from +|neosnippet|, in order to provide a more advanced snippet-like functionality. +This is meant to be used for very simple things. For instance, the sequence +`((` expands directly to `\left(|\right)` (though only when inside a math +environment). Both snippet engines then allow a trigger key to jump out of the +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 specifically disable a default mapping through |g:vimtex_imaps_disabled|. @@ -1096,15 +1105,16 @@ Explanation of the keys: The name of a wrapper function that is applied to `rhs`. Three functions are available from |vimtex|: - `s:wrap_math` Only define `rhs` if inside a math environment. - `s:wrap_ultisnips` Send `rhs` through `UltiSnips#Anon` in order - to create an anonymous snippet. - `s:wrap_math_ultisnips` Same as `s:wrap_ultisnips`, except it is only - expanded when inside a math environment. + `s:wrap_math` Only define `rhs` if inside a math environment. + `s:wrap_snippet` Send `rhs` through the chosen snippet engine in + order to create an anonymous snippet. See + |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. 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 - how it is done. + function, please see the source for examples on how the |vimtex| wrappers + are written. ============================================================================== COMPLETION *vimtex-completion*