diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
commit | d757bfd643cc73c2d495355c153ed0257f5d5b47 (patch) | |
tree | ff210950456938a779d98f6a2ba7321aca512897 /autoload/vimtex/text_obj/cmdtargets.vim | |
parent | 8ec73a3a8974a62a613680a6b6222a77a7b99546 (diff) | |
download | vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.tar.gz vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.zip |
Change latex provider to luatex, closes #476
Diffstat (limited to 'autoload/vimtex/text_obj/cmdtargets.vim')
-rw-r--r-- | autoload/vimtex/text_obj/cmdtargets.vim | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/autoload/vimtex/text_obj/cmdtargets.vim b/autoload/vimtex/text_obj/cmdtargets.vim new file mode 100644 index 00000000..611285c7 --- /dev/null +++ b/autoload/vimtex/text_obj/cmdtargets.vim @@ -0,0 +1,85 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1 + +" vimtex - LaTeX plugin for Vim +" +" Maintainer: Karl Yngve LervÄg +" Email: karl.yngve@gmail.com +" + +function! vimtex#text_obj#cmdtargets#new(args) " {{{1 + return { + \ 'genFuncs': { + \ 'c': function('vimtex#text_obj#cmdtargets#current'), + \ 'n': function('vimtex#text_obj#cmdtargets#next'), + \ 'l': function('vimtex#text_obj#cmdtargets#last'), + \ }, + \ 'modFuncs': { + \ 'i': [function('vimtex#text_obj#cmdtargets#inner'), + \ function('targets#modify#drop')], + \ 'a': [function('targets#modify#keep')], + \ 'I': [function('vimtex#text_obj#cmdtargets#inner'), + \ function('targets#modify#shrink')], + \ 'A': [function('targets#modify#expand')], + \ }} +endfunction + +" }}}1 +function! vimtex#text_obj#cmdtargets#current(args, opts, state) " {{{1 + let target = s:select(a:opts.first ? 1 : 2) + call target.cursorE() " keep going from right end + return target +endfunction + +" }}}1 +function! vimtex#text_obj#cmdtargets#next(args, opts, state) " {{{1 + if targets#util#search('\\\S*{', 'W') > 0 + return targets#target#withError('no target') + endif + + let oldpos = getpos('.') + let target = s:select(1) + call setpos('.', oldpos) + return target +endfunction + +" }}}1 +function! vimtex#text_obj#cmdtargets#last(args, opts, state) " {{{1 + " Move to the last non-surrounding cmd + if targets#util#search('\\\S\+{\_.\{-}}', 'bWe') > 0 + return targets#target#withError('no target') + endif + + let oldpos = getpos('.') + let target = s:select(1) + call setpos('.', oldpos) + return target +endfunction + +" }}}1 +function! vimtex#text_obj#cmdtargets#inner(target, args) " {{{1 + if a:target.state().isInvalid() + return + endif + + call a:target.cursorS() + silent! normal! f{ + call a:target.setS() +endfunction + +" }}}1 + +function! s:select(count) " {{{1 + " Try to select command + silent! execute 'keepjumps normal v'.a:count."\<Plug>(vimtex-ac)v" + let target = targets#target#fromVisualSelection() + + if target.sc == target.ec && target.sl == target.el + return targets#target#withError('tex_cmd select') + endif + + return target +endfunction + +" }}}1 + +endif |