Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autoload/vimtex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
10 changes: 9 additions & 1 deletion autoload/vimtex/imaps.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer:

   if !get(a:map, 'expr') 

The 0 is default and the space after ! is unnecessary, IMHO.

let a:map.rhs = string(a:map.rhs)
endif

silent execute 'inoremap <expr><silent><nowait><buffer>' 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
Expand Down Expand Up @@ -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

"
Expand Down