diff options
Diffstat (limited to 'ftplugin/latex-box')
-rw-r--r-- | ftplugin/latex-box/common.vim | 32 | ||||
-rw-r--r-- | ftplugin/latex-box/complete.vim | 3 | ||||
-rw-r--r-- | ftplugin/latex-box/folding.vim | 4 | ||||
-rw-r--r-- | ftplugin/latex-box/motion.vim | 25 |
4 files changed, 48 insertions, 16 deletions
diff --git a/ftplugin/latex-box/common.vim b/ftplugin/latex-box/common.vim index bf6305cc..59cf95d6 100644 --- a/ftplugin/latex-box/common.vim +++ b/ftplugin/latex-box/common.vim @@ -64,14 +64,24 @@ setlocal efm+=%-G%.%# " Vim Windows {{{ -" Width of vertical splits +" Type of split, "new" for horiz. "vnew" for vert. +if !exists('g:LatexBox_split_type') + let g:LatexBox_split_type = "vnew" +endif + +" Length of vertical splits +if !exists('g:LatexBox_split_length') + let g:LatexBox_split_length = 15 +endif + +" Width of horizontal splits if !exists('g:LatexBox_split_width') let g:LatexBox_split_width = 30 endif -" Where vertical splits appear +" Where splits appear if !exists('g:LatexBox_split_side') - let g:LatexBox_split_side = "leftabove" + let g:LatexBox_split_side = "aboveleft" endif " Resize when split? @@ -229,12 +239,18 @@ endfunction " Default pdf viewer if !exists('g:LatexBox_viewer') - if has('win32') - " On windows, 'running' a file will open it with the default program - let g:LatexBox_viewer = '' - else - let g:LatexBox_viewer = 'xdg-open' + " On windows, 'running' a file will open it with the default program + let s:viewer = '' + if has('unix') + " echo -n necessary as uname -s will append \n otherwise + let s:uname = system('echo -n $(uname -s)') + if s:uname == "Darwin" + let s:viewer = 'open' + else + let s:viewer = 'xdg-open' + endif endif + let g:LatexBox_viewer = s:viewer endif function! LatexBox_View(...) diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim index 150b00e7..0ab8f974 100644 --- a/ftplugin/latex-box/complete.vim +++ b/ftplugin/latex-box/complete.vim @@ -459,7 +459,8 @@ function! s:GetLabelCache(file) if !has_key(s:LabelCache , a:file) || s:LabelCache[a:file][0] != getftime(a:file) " Open file in temporary split window for label extraction. - silent execute '1sp +let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file) + let main_tex_file = LatexBox_GetMainTexFile() + silent execute '1sp +let\ b:main_tex_file=main_tex_file|let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file) let s:LabelCache[a:file] = [ getftime(a:file), labels, inputs ] endif diff --git a/ftplugin/latex-box/folding.vim b/ftplugin/latex-box/folding.vim index 5d733c23..aedca8f6 100644 --- a/ftplugin/latex-box/folding.vim +++ b/ftplugin/latex-box/folding.vim @@ -75,8 +75,8 @@ if g:LatexBox_fold_automatic == 1 " augroup FastFold autocmd! - autocmd InsertEnter *.tex setlocal foldmethod=manual - autocmd InsertLeave *.tex setlocal foldmethod=expr + autocmd InsertEnter *.tex if !&diff | setlocal foldmethod=manual | endif + autocmd InsertLeave *.tex if !&diff | setlocal foldmethod=expr | endif augroup end else setl foldmethod=manual diff --git a/ftplugin/latex-box/motion.vim b/ftplugin/latex-box/motion.vim index 41605aea..7e5b0011 100644 --- a/ftplugin/latex-box/motion.vim +++ b/ftplugin/latex-box/motion.vim @@ -349,7 +349,7 @@ function! s:ReadTOC(auxfile, texfile, ...) if len(tree) > 3 && empty(tree[1]) call remove(tree, 1) endif - if len(tree) > 1 && tree[0] =~ '^\\\(numberline\|tocsection\)' + if len(tree) > 1 && type(tree[0]) == type("") && tree[0] =~ '^\\\(numberline\|tocsection\)' let secnum = LatexBox_TreeToTex(tree[1]) let secnum = substitute(secnum, '\\\S\+\s', '', 'g') let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g') @@ -379,6 +379,21 @@ function! LatexBox_TOC(...) " Check if window already exists let winnr = bufwinnr(bufnr('LaTeX TOC')) + " Two types of splits, horizontal and vertical + let l:hori = "new" + let l:vert = "vnew" + + " Set General Vars and initialize size + let l:type = g:LatexBox_split_type + let l:size = 10 + + " Size detection + if l:type == l:hori + let l:size = g:LatexBox_split_length + elseif l:type == l:vert + let l:size = g:LatexBox_split_width + endif + if winnr >= 0 if a:0 == 0 silent execute winnr . 'wincmd w' @@ -386,13 +401,12 @@ function! LatexBox_TOC(...) " Supplying an argument to this function causes toggling instead " of jumping to the TOC window if g:LatexBox_split_resize - silent exe "set columns-=" . g:LatexBox_split_width + silent exe "set columns-=" . l:size endif silent execute 'bwipeout' . bufnr('LaTeX TOC') endif return endif - " Read TOC let [toc, fileindices] = s:ReadTOC(LatexBox_GetAuxFile(), \ LatexBox_GetMainTexFile()) @@ -403,9 +417,10 @@ function! LatexBox_TOC(...) " Create TOC window and set local settings if g:LatexBox_split_resize - silent exe "set columns+=" . g:LatexBox_split_width + silent exe "set columns+=" . l:size endif - silent exe g:LatexBox_split_side g:LatexBox_split_width . 'vnew LaTeX\ TOC' + silent exe g:LatexBox_split_side l:size . l:type . ' LaTeX\ TOC' + let b:toc = toc let b:toc_numbers = 1 let b:calling_win = bufwinnr(calling_buf) |