diff --git a/autoload/vimtex.vim b/autoload/vimtex.vim index 8a96d0238f..3e67ac70a5 100644 --- a/autoload/vimtex.vim +++ b/autoload/vimtex.vim @@ -140,6 +140,7 @@ function! vimtex#init_options() abort " {{{1 \ { 'lhs' : '>', 'rhs' : '\rangle' }, \ { 'lhs' : 'H', 'rhs' : '\hbar' }, \ { 'lhs' : '+', 'rhs' : '\dagger' }, + \ { 'lhs' : '/', 'rhs' : 'vimtex#imaps#feynmanslash()', 'expr' : 1 }, \ { 'lhs' : '[', 'rhs' : '\subseteq' }, \ { 'lhs' : ']', 'rhs' : '\supseteq' }, \ { 'lhs' : '(', 'rhs' : '\subset' }, diff --git a/autoload/vimtex/imaps.vim b/autoload/vimtex/imaps.vim index e9df7cef35..80c51df6fe 100644 --- a/autoload/vimtex/imaps.vim +++ b/autoload/vimtex/imaps.vim @@ -99,9 +99,12 @@ function! s:create_map(map) abort " {{{1 endif let b:vimtex_context[l:key] = a:map.context endif + if ! get(a:map, 'expr', 0) + let a:map.rhs = string(a:map.rhs) + endif silent execute 'inoremap ' l:lhs - \ l:wrapper . '("' . escape(l:lhs, '\') . '", ' . string(a:map.rhs) . ')' + \ l:wrapper . '("' . escape(l:lhs, '\') . '", ' . a:map.rhs . ')' let s:created_maps += [a:map] endfunction @@ -149,6 +152,11 @@ function! vimtex#imaps#wrap_environment(lhs, rhs) abort " {{{1 return l:return endfunction +function! vimtex#imaps#feynmanslash() + let l:c = getchar() + return '\slashed{' . nr2char(l:c) . '}' +endfunction + " }}}1 "