summaryrefslogtreecommitdiffstats
path: root/autoload/vimtex/pos.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-04-25 21:30:46 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-04-25 21:30:46 +0200
commitd757bfd643cc73c2d495355c153ed0257f5d5b47 (patch)
treeff210950456938a779d98f6a2ba7321aca512897 /autoload/vimtex/pos.vim
parent8ec73a3a8974a62a613680a6b6222a77a7b99546 (diff)
downloadvim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.tar.gz
vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.zip
Change latex provider to luatex, closes #476
Diffstat (limited to 'autoload/vimtex/pos.vim')
-rw-r--r--autoload/vimtex/pos.vim97
1 files changed, 97 insertions, 0 deletions
diff --git a/autoload/vimtex/pos.vim b/autoload/vimtex/pos.vim
new file mode 100644
index 00000000..127fcd46
--- /dev/null
+++ b/autoload/vimtex/pos.vim
@@ -0,0 +1,97 @@
+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#pos#set_cursor(...) abort " {{{1
+ call cursor(s:parse_args(a:000))
+endfunction
+
+" }}}1
+function! vimtex#pos#get_cursor() abort " {{{1
+ return exists('*getcurpos') ? getcurpos() : getpos('.')
+endfunction
+
+" }}}1
+function! vimtex#pos#get_cursor_line() abort " {{{1
+ let l:pos = vimtex#pos#get_cursor()
+ return l:pos[1]
+endfunction
+
+" }}}1
+
+function! vimtex#pos#val(...) abort " {{{1
+ let [l:lnum, l:cnum; l:rest] = s:parse_args(a:000)
+
+ return 100000*l:lnum + min([l:cnum, 90000])
+endfunction
+
+" }}}1
+function! vimtex#pos#next(...) abort " {{{1
+ let [l:lnum, l:cnum; l:rest] = s:parse_args(a:000)
+
+ return l:cnum < strlen(getline(l:lnum))
+ \ ? [0, l:lnum, l:cnum+1, 0]
+ \ : [0, l:lnum+1, 1, 0]
+endfunction
+
+" }}}1
+function! vimtex#pos#prev(...) abort " {{{1
+ let [l:lnum, l:cnum; l:rest] = s:parse_args(a:000)
+
+ return l:cnum > 1
+ \ ? [0, l:lnum, l:cnum-1, 0]
+ \ : [0, max([l:lnum-1, 1]), strlen(getline(l:lnum-1)), 0]
+endfunction
+
+" }}}1
+function! vimtex#pos#larger(pos1, pos2) abort " {{{1
+ return vimtex#pos#val(a:pos1) > vimtex#pos#val(a:pos2)
+endfunction
+
+" }}}1
+function! vimtex#pos#equal(p1, p2) abort " {{{1
+ let l:pos1 = s:parse_args(a:p1)
+ let l:pos2 = s:parse_args(a:p2)
+ return l:pos1[:1] == l:pos2[:1]
+endfunction
+
+" }}}1
+function! vimtex#pos#smaller(pos1, pos2) abort " {{{1
+ return vimtex#pos#val(a:pos1) < vimtex#pos#val(a:pos2)
+endfunction
+
+" }}}1
+
+function! s:parse_args(args) abort " {{{1
+ "
+ " The arguments should be in one of the following forms (when unpacked):
+ "
+ " [lnum, cnum]
+ " [bufnum, lnum, cnum, ...]
+ " {'lnum' : lnum, 'cnum' : cnum}
+ "
+
+ if len(a:args) > 1
+ return s:parse_args([a:args])
+ elseif len(a:args) == 1
+ if type(a:args[0]) == type({})
+ return [get(a:args[0], 'lnum'), get(a:args[0], 'cnum')]
+ else
+ if len(a:args[0]) == 2
+ return a:args[0]
+ else
+ return a:args[0][1:]
+ endif
+ endif
+ else
+ return a:args
+ endif
+endfunction
+
+" }}}1
+
+endif