GithubHelp home page GithubHelp logo

lervag / vimtex Goto Github PK

View Code? Open in Web Editor NEW
5.2K 36.0 386.0 11.24 MB

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.

License: MIT License

TeX 71.02% Python 0.14% Makefile 0.42% Perl 0.02% Dockerfile 0.03% Vim Script 28.15% Lua 0.21%
vim vim-plugin vimtex latex tex filetype-plugin neovim

vimtex's Introduction

VimTeX

VimTeX is a modern Vim and Neovim filetype and syntax plugin for LaTeX files.

Gitter CI tests Donate

Table of contents

Requirements

VimTeX requires Vim version 8.2.3995 or Neovim version 0.9.5. The requirements were updated in April 2024 after the release of VimTeX 2.15. If you are stuck on older versions of Vim or Neovim, then you should not use the most recent version of VimTeX, but instead remain at the v2.15 tag.

Some features require external tools. For example, the default compiler backend relies on latexmk. Users are encouraged to read the requirements section in the documentation (:h vimtex-requirements).

Installation

There are a lot of methods for installing plugins. The following explains the most common and popular approaches.

Note: Many plugin managers provide mechanisms to lazy load plugins. Please don't use this for VimTeX! VimTeX is already lazy loaded by virtue of being a filetype plugin and by using the autoload mechanisms. There is therefore nothing to gain by forcing VimTeX to lazily load through the plugin manager. In fact, doing it will break the inverse-search mechanism, which relies on a global command (:VimtexInverseSearch).

lazy.nvim

In Neovim, lazy.nvim is probably the most popular plugin manger. To install VimTeX, add a plugin spec similar to this:

{
  "lervag/vimtex",
  lazy = false,     -- we don't want to lazy load VimTeX
  -- tag = "v2.15", -- uncomment to pin to a specific release
  init = function()
    -- VimTeX configuration goes here
  end
}

vim-plug

If you use vim-plug, then add one of the following lines to your configuration. The first will use the latest versions from the master branch, whereas the second will pin to a release tag.

Plug 'lervag/vimtex'
Plug 'lervag/vimtex', { 'tag': 'v2.15' }

Other

There are many other plugin managers out there. They are typically well documented, and it should be straightforward to extrapolate the above snippets.

Note: If you use the built-in package feature, then:

  • Make sure to read and understand the package feature: :help package!
  • Use the /pack/foo/start subdirectory to make sure the filetype plugin is automatically loaded for the tex filetypes.
  • Helptags are not generated automatically. Run :helptags to generate them.
  • Please note that by default Vim puts custom /start/ plugin directories at the end of the &runtimepath. This means the built in filetype plugin is loaded, which prevents VimTeX from loading. See #1413 for two suggested solutions to this. To see which scripts are loaded and in which order, use :scriptnames.
  • For more information on how to use the Vim native package solution, see here and here.

Configuration

After installing VimTeX, you should edit your .vimrc file or init.vim file to configure VimTeX to your liking. Users should read the documentation to learn the various configuration possibilities, but the below is a simple overview of some of the main aspects.

PLEASE don't just copy this without reading the comments!

" This is necessary for VimTeX to load properly. The "indent" is optional.
" Note that most plugin managers will do this automatically.
filetype plugin indent on

" This enables Vim's and neovim's syntax-related features. Without this, some
" VimTeX features will not work (see ":help vimtex-requirements" for more
" info).
syntax enable

" Viewer options: One may configure the viewer either by specifying a built-in
" viewer method:
let g:vimtex_view_method = 'zathura'

" Or with a generic interface:
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'

" VimTeX uses latexmk as the default compiler backend. If you use it, which is
" strongly recommended, you probably don't need to configure anything. If you
" want another compiler backend, you can change it as follows. The list of
" supported backends and further explanation is provided in the documentation,
" see ":help vimtex-compiler".
let g:vimtex_compiler_method = 'latexrun'

" Most VimTeX mappings rely on localleader and this can be changed with the
" following line. The default is usually fine and is the symbol "\".
let maplocalleader = ","

Note: If the compiler or the viewer doesn't start properly, one may type <localleader>li to view the system commands that were executed to start them. To inspect the compiler output, use <localleader>lo.

Quick Start

The following video shows how to use VimTeX's main features (credits: @DustyTopology from #1946). The example LaTeX file used in the video is available under test/example-quick-start/main.tex and it may be instructive to copy the file and play with it to learn some of these basic functions.

Screencast.mp4

Tutorial

Both new and experienced users are encouraged to read the excellent guide by @ejmastnak: Getting started with the VimTeX plugin. The guide covers all the fundamentals of setting up a VimTeX-based LaTeX workflow, including usage of the VimTeX plugin, compilation, setting up forward and inverse search with a PDF reader, and Vimscript tools for user-specific customization.

Documentation

Users are of course strongly encouraged to read the documentation, at least the introduction, to learn about the different features and possibilities provided by VimTeX (see :h vimtex). Advanced users and potential developers may also be interested in reading the supplementary documents:

Screenshots

Here is an example of the syntax highlighting provided by VimTeX. The conceal feature is active on the right-hand side split. The example is made by @DustyTopology with the vim-colors-xcode colorscheme with some minor adjustments described here.

Syntax example

GIFs

See the file VISUALS.md for screencast-style GIFs demonstrating VimTeX's core motions, text-editing commands, and text objects.

Features

Below is a list of features offered by VimTeX. The features are accessible as both commands and mappings. The mappings generally start with <localleader>l, but if desired one can disable default mappings to define custom mappings. Nearly all features are enabled by default, but each feature may be disabled if desired. The two exceptions are code folding and formating, which are disabled by default and must be manually enabled.

  • Document compilation with latexmk, latexrun, tectonic, or arara
  • LaTeX log parsing for quickfix entries using
  • Compilation of selected part of document
  • Support for several PDF viewers with forward search
  • Completion of
    • citations
    • labels
    • commands
    • file names for figures, input/include, includepdf, includestandalone
    • glossary entries
    • package and documentclass names based on available .sty and .cls files
  • Document navigation through
    • table of contents
    • table of labels
    • proper settings for 'include', 'includexpr', 'suffixesadd' and 'define', which among other things
      • allow :h include-search and :h definition-search
      • give enhanced gf command
  • Easy access to (online) documentation of packages
  • Word count (through texcount)
  • Motions (link to GIF demonstrations)
    • Move between section boundaries with [[, [], ][, and ]]
    • Move between environment boundaries with [m, [M, ]m, and ]M
    • Move between math environment boundaries with [n, [N, ]n, and ]N
    • Move between frame environment boundaries with [r, [R, ]r, and ]R
    • Move between comment boundaries with [* and ]*
    • Move between matching delimiters with %
  • Text objects (link to GIF demonstrations)
    • ic ac Commands
    • id ad Delimiters
    • ie ae LaTeX environments
    • i$ a$ Math environments
    • iP aP Sections
    • im am Items
  • Other mappings (link to GIF demonstrations)
    • Delete the surrounding command, environment or delimiter with dsc/dse/ds$/dsd
    • Change the surrounding command, environment or delimiter with csc/cse/cs$/csd
    • Toggle starred command or environment with tsc/tse
    • Toggle inline and displaymath with ts$
    • Toggle between e.g. () and \left(\right) with tsd
    • Toggle (inline) fractions with tsf
    • Close the current environment/delimiter in insert mode with ]]
    • Add \left ... \right) modifiers to surrounding delimiters with <F8>
    • Insert new command with <F7>
    • Convenient insert mode mappings for faster typing of e.g. maths
    • Context menu on citations (e.g. \cite{...}) mapped to <cr>
  • Improved folding (:h 'foldexpr')
  • Improved indentation (:h 'indentexpr')
  • Syntax highlighting
    • A consistent core syntax specification
    • General syntax highlighting for several popular LaTeX packages
    • Nested syntax highlighting for several popular LaTeX packages
    • Highlight matching delimiters
  • Support for multi-file project packages

See the documentation for a thorough introduction to VimTeX (e.g. :h vimtex).

Other relevant plugins

Even though VimTeX provides a lot of nice features for working with LaTeX documents, there are several features that are better served by other, dedicated plugins. For a more detailed listing of these, please see :help vimtex-and-friends.

Linting and syntax checking

Snippets and templates

Tag navigation

Alternatives

The following are some alternative LaTeX plugins for Vim:

  • LaTeX-Suite

    The main difference between VimTeX and LaTeX-Suite (aka vim-latex) is probably that VimTeX does not try to implement a full fledged IDE for LaTeX inside Vim. E.g.:

    • VimTeX does not provide a full snippet feature, because this is better handled by UltiSnips or neosnippet or similar snippet engines.
    • VimTeX builds upon Vim principles: It provides text objects for environments, inline math, it provides motions for sections and paragraphs
    • VimTeX uses latexmk, latexrun, tectonic or arara for compilation with a callback feature to get instant feedback on compilation errors
    • VimTeX is very modular: if you don't like a feature, you can turn it off.
  • TexMagic.nvim

    "A simple, lightweight Neovim plugin that facilitates LaTeX build engine selection via magic comments. It is designed with the TexLab LSP server's build functionality in mind, which at the time of this plugin's inception had to be specified in init.lua/init.vim and could not be set on a by-project basis."

    This plugin should be combined with the TexLab LSP server, and it only works on neovim.

  • LaTeX-Box

    VimTeX currently has most of the features of LaTeX-Box, as well as some additional ones. See here for a relatively complete list of features.

    One particular feature that LaTeX-Box has but VimTeX misses, is the ability to do single-shot compilation with callback. This functionality was removed because it adds a lot of complexity for relatively little gain (IMHO).

  • AutomaticTexPlugin

  • vim-latex-live-preview

For more alternatives and more information and discussions regarding LaTeX plugins for Vim, see:

vimtex's People

Contributors

144026 avatar 927589452 avatar andymass avatar bertrandsim avatar doronbehar avatar greencourt avatar j1-lee avatar jingmatrix avatar jipolanco avatar kiryph avatar konfekt avatar krishnakumarg1984 avatar lervag avatar manu-mannattil avatar marcelrobitaille avatar matze-dd avatar mbrunnen avatar micbou avatar patnr avatar psvenk avatar rsekman avatar shivangp76 avatar shuber2 avatar tom-anders avatar tornaria avatar tornaxo7 avatar tpmkranz avatar vyasr avatar yongrenjie avatar znculee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vimtex's Issues

Get main file function

I'm trying to switch from Latex-Box to vim-latex. I use this function several times in a script I wrote in order to get the main file. Is there a similar function to specify the main file in vim-latex?
In general, how does vim-latex find the main file?
Thank you!

Error when opening input file

Hi,

I have the following file structure.

|--main.tex
|--sections
   |-- some_file.tex

I input some_file.tex in main.tex. When I open some_file.tex for editing, I get the following error:

Error detected while processing function latex#init..<SNR>130_init_environment..<SNR>130_get_main..<SNR>130_get_main_recurse:
line   25:
E118: Too many arguments for function: globpath
E15: Invalid expression: globpath(l:dirs, '*.tex', 0, 1)
line   30:
E121: Undefined variable: l:candidates
E15: Invalid expression: l:candidates

Any Idea what's going on?

Open folds from TOC

If a document is folded, and one selects an entry in the TOC then the cursor jumps to the corresponding entry in the document but it doesn't unfold the entry if it is folded. In the first image below I select a subsubsection, in the second image the cursor jumps to the document without unfolding and only If I manually unfold (third image) I reach the desired section.

This is similar to this issue in Latex-Box

screenshot-03-08-2014_19-46-19
screenshot-03-08-2014_19-46-24
screenshot-03-08-2014_19-46-34

inner environment begin pattern

Hello,

 let begin_pat = '\C\\begin\_\s*{[^}]*}\|\\\@<!\\\[\|\\\@<!\\('

does not account for text afterwards. For example , if there is label{..} after
begin{..}, then

vmap <buffer> ie <Plug>LatexBox_SelectCurrentEnvInner

(by the way should be xmap) erroneously assumes the opening \begin{..} line to belong to the inner environment.

How about allowing for this possibility?

Make init_errorformat() global function

Is it possible to make the s:init_errorformat() a global function? I like to use vim-latex's error format in a script and in order to do so I have to either run latex#init() (which is a global function) or copy the s:init_errorformat() function to my script.

If this is not possible, if there is another way of calling the init_function from outside the script, or if this breaks some behavior just ignore this request and close the issue.
Thank you!

Use conceal in TOC

Add option to use conceal to show greek letters and math as unicode symbols in TOC.

ViewRules seemingly ignored on Mac OS 10.9.5

Despite having the following settings in my .vimrc, it seems that they are all ignored — when using \ll, the output format remains PDF, and the generated PDFs always open in whatever program is the default for PDFs at the time (changing the default program before compiling confirms this). I have also confirmed via :echo that these variables really are set in Vim. Why aren't these being used when \ll is invoked?

    let g:tex_flavor='latex'
    let g:Tex_DefaultTargetFormat='dvi'
    let g:Tex_ViewRule_dvi='/Applications/TeXShop.app/Contents/MacOS/TeXShop *$.dvi'
    let g:Tex_ViewRule_pdf='/Applications/TeXShop.app/Contents/MacOS/TeXShop *$.pdf'
    let g:Tex_ViewRule_ps='/Applications/TeXShop.app/Contents/MacOS/TeXShop *$.ps'

Implement function that turns current word into command

I want to be able to do something like:

\section{Some section}
Some sentence with some text with a ref<F7>

where <F7> implies that I type the function key, in which case the above becomes

\section{Some section}
Some sentence with some text with a \ref{

Possibly also with a closing paranthesis.

Main tex file not found

The current method of finding the main tex file in projects with several tex files is not fool proof. At the moment, the plugin first checks whether the current tex file has the following code:

\begin{document}

If not, then it looks for all tex files in the current and the parent directory, then it checks if any of these has a file name that appears in the list g:latex_main_tex_filenames. If found, the first file that meets this criteria is chosen. If no such file is found, then the current file is accepted. This is as explained in the documentation.

A better way to do this would be to instead recursively search the current directory (and perhaps also the parent directory) for any files that has the current file included, and to select the main tex file that has the \begin{document} code.

Edit: Refined the description.

Disable indentation problem

Consider the following minimal vimrc

set nocompatible
let $ONEDRIVE_HOME = expand('C:/OD/Users/Pedro/')
let $DOTVIM = expand('$ONEDRIVE_HOME/vimfiles')
set runtimepath=$DOTVIM,$VIMRUNTIME,$DOTVIM/after/

if has('vim_starting')
    execute 'set runtimepath+=' . expand('$DOTVIM/bundle/neobundle')
endif
call neobundle#begin(expand('$DOTVIM/bundle/'))
NeoBundle 'lervag/vim-latex', {'name' : 'vim-latex' }
NeoBundleFetch 'Shougo/neobundle.vim', {'name' : 'neobundle'}
call neobundle#end()

filetype plugin indent on

let g:tex_flavor = 'latex'
let g:tex_indent_brace = 0
let g:latex_indent_enabled = 0

and in a tex file type { in a new line and then press <CR>. The resulting line will be indented (i.e that g:tex_indent_brace variable is ignored) . On the other hand if I remove vim-latex plugin by erasing this line from the minimal vimrc:

 NeoBundle 'lervag/vim-latex', {'name' : 'vim-latex' }

then braces are not indented as expected (i.e g:tex_indent_brace is active).

Maybe this is related to the runtimepath explanation you gave me here.

However neobundle docs state:

... set up a path to the repository directory.
set runtimepath+={path to neobundle directory}

If you believe this to be a problem in Neobundle I''ll report it to Shougo.

Question regarding latexmk and g:latex_build_dir

I have a LaTeX repository organized as follow:

proj (root)
  |---> src (*.tex, *.bib)
  |---> images
  |---> build (compilation/auxiliary files, resulting PDFs)

So if we consider src/example.tex, I would like the data dictionary to contain something like:

name: example
base: example.tex
root: proj
tex: proj/src/example.tex

I thought that the g:latex_build_dir option would allow me to achieve something closer to what I want, but apparently this option is not forwarded to latexmk with the -outdir option.

Adding the following line to latexmk_set_cmd seems to be partially working:

let cmd .= ' -outdir=' . g:latex_build_dir

The build directory is created in root, but root is currently proj/src, not proj, so that still needs to be resolved.

Can you confirm that I am on the right track, or enlighten me if this can already be achieved with the current code? Thanks! ;-)

Better documentation that explains ignored warnings

I don't understand what to put in the g:latex_ignored_warnings variable. Are the contained strings regexes or the full warning message? Regardless of what I tried, the warnings were not ignored. Explaining this would be very helpful.

I looked up the behavior in the code. Unfortunately, I don't understand vimscript, so this line is a mysterium for me (source):

exe 'setlocal efm+=%-G%.%#'. warning .'%.%#'

Language specific toc

The new TOC file is really great. The only thing that I miss about the implementation that used the aux files is that it detected the document language settings. This means that if one had a document like

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
\section{Spanish document}
\label{sec:spanish_document}
This is document will be written in spanish.
\nocite{shore}
\printbibliography
\end{document}

The TOC entry for the bibliography was correctly rendered as "Referencias" (spanish word for references).

With the current implementation the bibliography (and the Alphabetical Index) are shown in the TOC in english regardless of the document language (see image below).

I understand that this might be hard to implement. I believe that one way this could be achieved would be to parse the preamble looking for options to the babel package:

\usepackage[babel options]{babel}

If a language other than english is found in these options then the Bibliography and Alphabetical Index title should be given in that specific language. If no other language was found or babel was not found then default to english.

btw: If this ever gets implemented it would also be good that in article class the bibliography title would be "References" instead of "Bibliography" (and keep "Bibliography" only for the book class).

screenshot 157

Issue with compiling on Windows 7

I may be trying this out prematurely, but this plugin seems to have Windows support so here goes...

After loading a latex file the autoload scripts seem to run correctly - I have folding and keymappings. However, if I :call latex#info() I see that the pid for g:latex#data is zero. Should this hold the value of a pid of a running background service?

Compiling fails with following output:

Error detected while processing function latex#latexmk#compile..<SNR>69_latexmk_set_pid:
line    8:
E684: list index out of range: 0
E116: Invalid arguments for function strpart(pids[0], 10)
E15: Invalid expression: strpart(pids[0], 10)
latexmk started successfully

I have had a quick look through the code and the only thing that strikes me as suspicious is the use of Windows find.exe, as I also have a port of GNU find installed. I replaced find with \%WINDIR\%\System32\find to ensure the correct version was used but this didn't fix anything.

Edit: Updated formatting.

Bibliography and Alphabetical Index rendering in TOC

Consider the following MWE:

\documentclass{book}
\begin{document}
\frontmatter
  \tableofcontents
  \chapter{Preface}
\mainmatter
  \chapter{First chapter}
  \chapter{Second chapter}
  \chapter{Third chapter}
\backmatter
  \printbibliography
  \printindex
\end{document}

The \printbibliography and \printindex commands will respectively generate a bibliography and an alphabetical index that generally refers to the whole document and not just to the last chapter (Third Chapter in the example). However with the current TOC the "Bibliography" and "Alphabetical Index" are shown as a part or subset of the last chapter (and hence folded within it). I think they should be shown as independent entries (the same way that the "Preamble" and "Table of Contents" are shown)

screenshot-19-07-2014_13-51-53
screenshot-19-07-2014_13-51-58

SuperTab Chaining Completion Does not Initially Work with vim-latex

Thank you for developing vim-latex. I really like it so far!

When I was previously using Latex-Box, I used the following code in my .vimrc file to enable two types of completion: (1) the standard "next" completion that uses my dictionary and the current buffer to complete words and (2) Latex-Box for items in the bibliography and other labels in the paper.

autocmd FileType tex
            \ if &omnifunc != '' |
            \   call SuperTabChain(&omnifunc, "<c-n>") |
            \   call SuperTabSetDefaultCompletionType("<c-x><c-u>") |
            \ endif

However, using this "chaining" feature of SuperTab does not seem to work with vim-latex when I type a word llike "exam" and then type "tab".

Interestingly, it does work correctly if I directly type "ctrl-n" to do the completion.

Also, if I first use vim-latex to do tab completion of a \cite or a \ref -- which works correctly and is faster than Latex-Box -- then the tab completion of words will work correctly from that point forward. This means that "exam" would now display a box for words like "example" and "examination".

Did I configure something incorrectly? Any advice that you can provide is appreciated!

Ignore section command in preamble in the TOC

Consider the following MWE

\documentclass{article}
\begin{document}
\newcommand*{\secappendix}[1]{%
  \section{#1}}%
\section{Foo}
\label{sec:foo}
\end{document}

\section{#1} in the definition of secappendix command is shown in the TOC as another ordinary section. Section commands in the preamble should be ignored.

Is it possible to get correct line numbers in the errors when using \include?

I am compiling a document that uses \include to bring in other sections. After a compile, the errors in the quickfix all have the main tex file as their filename and have line numbers as if the the project was one big file with each file pasted in.

Is it possible to get the quickfix list to report line numbers and filenames that represent the actual file structure of the project?

Toc numbering with frontmatter and backmatter

The commands \frontmatter and \backmatter turn off chapter numbering (while \mainmatter turns them on). With the current toc if one has a main_file.tex like this:

\documentclass{book}
\begin{document}
\frontmatter
  \include{preface}
\mainmatter
  \include{foo}
\backmatter
  \printbibliography[]
\end{document}

where preface.tex is

\chapter{Preface}
\label{cha:preface}

and foo.tex is

\chapter{Foo}
\label{cha:foo}

The toc will number the unnumbered preface chapter as the first chapter and will add the bibliography inside the (wrongly) numbered foo chapter. Maybe it is possible to parse the main file for the commands \frontmatter, \mainmatter and \backmatter, and if they are present, number the toc accordingly.

screenshot-17-07-2014_11-25-15

vim-latex not loading mappings with new vundle?

Hello,

I just wanted to ask here first because I'm not yet sure whether this is a vundle or a vim-latex issue.

Since I upgraded to most recent vundle (526d390854f14bc5886ca0606b3be51f7379eacb) and did the interface change, vim-latex doesn't seem to be loaded when I open a tex file in vim or gvim.

It seems related to issue 430 of vundle. However, when I execute :scriptnames from the tex file, vim-latex is in the list:

 47: ~/.dotfiles/vim/bundle/vim-latex/ftplugin/tex.vim
 49: ~/.dotfiles/vim/bundle/vim-latex/indent/tex.vim
 52: ~/.dotfiles/vim/bundle/vim-latex/after/syntax/tex.vim: 

Yet, when I want to use \ll, I navigate up (due to my custom mappings) or with \li I get into insert mode. And that the mappings of a plugin weren't loaded, was peculiarly enough described by raghur here as well.

Can anyone else observe this behaviour?

Focus on TOC

When calling latex#toc#toggle() from a buffer, focus (cursor) stays in that buffer. Is it possible to switch focus to the TOC? Thanks!

TOC: Selecting a \(sub|subsub)section does not jump to the respective section but produces errors

Hey,

the TOC feature itself works quite well, however,it's impossible to select any section and jump to it (whether it is in the main or input file doesn't matter) by pressing <Enter>. This happens both in gvim and vim.

Here's a MWE:

main.tex

\documentclass{scrartcl}
\begin{document}
 \tableofcontents
  \section{Section in the main file}
  \subsection{Subsection in the main file}
 \input{input}
\end{document}

input.tex

%!Tex Root = main.tex
 \section{Section in the input file}
  This is the file that is being input via \\input
 \subsection{Subsection in the input file}

And here's the errors that I get when I want to switch to input.tex. If I want to switch to a section in main.tex the errors are a bit shorter, but I can't copy them.

Error detected while processing function <SNR>52_toc_activate:
line    3:
E121: Undefined variable: b:toc
E116: Invalid arguments for function len(b:toc)
E15: Invalid expression: n >= len(b:toc)
line    7:
E121: Undefined variable: b:toc
E15: Invalid expression: b:toc[n]
line    9:
E121: Undefined variable: entry
E116: Invalid arguments for function s:toc_escape_title(entry['text'])
E15: Invalid expression: s:toc_escape_title(entry['text'])
line   13:
E121: Undefined variable: entry
E15: Invalid expression: entry['level'].titlestr
line   16:
E121: Undefined variable: b:toc
E15: Invalid expression: b:toc[i]['level'].s:toc_escape_title(b:toc[i]['text'])
line   17:
E121: Undefined variable: i_hash
E15: Invalid expression: i_hash == entry_hash
line   25:
E121: Undefined variable: b:calling_win
E15: Invalid expression: b:calling_win . 'wincmd w'
line   27:
E121: Undefined variable: entry
E15: Invalid expression: [entry['file']]
line   28:
E121: Undefined variable: entry
E116: Invalid arguments for function readfile(entry['file']), 'v:val =~ ''\\input{''')
E116: Invalid arguments for function filter(readfile(entry['file']), 'v:val =~ ''\\input{''')
E15: Invalid expression: filter(readfile(entry['file']), 'v:val =~ ''\\input{''')
line   33:
E121: Undefined variable: entry
E116: Invalid arguments for function <SNR>52_toc_find_match

My vim-latex settings are as follows:

" Settings for vim-latex
  let g:latex_complete_close_braces = 1
  let g:latex_latexmk_quickfix = 1
  let g:latex_latexmk_options = '-xelatex'
  let g:latex_toc_enabled = 1
  let g:latex_toc_hide_help = 1

Am I missing some setting here or is the function broken and you know it already? This is by no means to put any pressure, I'm almost not using this feature, I just noticed it doesn't work here so wanted to let you know :)

Freezing when exiting insert mode in large files.

This is something I've noticed recently, if I edit a large latex file (several hundred lines, with no wrapping, so lines can be very long) I see a delay of 1-3s when exiting insert mode. CPU usage for gvim hits 50% (I'm using a dual-core) during this time.

Disabling folding and syntax highlighting doesn't change things. If I disable the plugin and edit the file using vim's default latex support it is instant again.

I see a similar delay when opening a large file for the first time - again, default vim works fine.

Here is the result of :au InsertLeave:

--- Auto-Commands ---
Undotree  InsertLeave
    *         call UndotreeUpdate()
unimpaired_paste  InsertLeave
    *         if exists('s:paste') |   let &paste = s:paste |   let &mouse = s:mouse |   unlet s:paste |   unlet s:mouse | endif
latex_fold  InsertLeave
    *.tex     call FdmRestore()

FdmRestore() just seems to track folding methods so I don't think this would be the problem.

It seems like some sort of processing of text that vim-latex is doing, for folding maybe? I do not even needed to make any changes, entering and immediately exiting insert mode will trigger a delay.

Better documentation about latexmk

I should add some more documentation with tips and tricks about how to set up vim-latex with latexmk in a best possible manner. In particular, I should explain how to make latexmk use the vimserver to open the errorwindow when there are errors.

Add alphabetical index to TOC

Maybe it is possible to add "Alphabetical Index" to the TOC. The command that prints this index at the end of a book (in the \backmatter and after the bibliography) is \printindex[optional argument]

<m-i> conflict with the "é" character

Hi,

Thanks for your work !

The mapping used to insert "\item" is in conflict with the "é" letter, at least for the french language. That is pressing "é" gives me "\item" instead of the letter itself.
As is probably here to stay, maybe it can be guarded behind a new option. Or the doc may gives an easy way to cancel that mapping, without disabling everything.

Sincerely,
Matth

Bib completion problem

Mmmm for some reason the bib completion sometimes fails if the current directory is not that of the working file. Maybe the cd part of the command doesn't work (at least on windows):

let cmd = 'cd ' . g:latex#data[b:latex.id].root . ' & ' . cmd

If I have a file in C:/Users/Pedro/Desktop/foo.tex like

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}

\end{document}

and I do cd C:/OD/Users/Pedro/vimfiles/bundle/vim-latex/autoload/latex/ and then type \cite{ then vim complains:

Error detected while processing function  latex#complete#omnifunc..latex#complete#bibtex..<SNR>176_bibtex_search:
line   33:
E484: Can't open file tmpfile.bbl

If from foo.tex I now run :lcd %:h, then bib completion works fine.
I''ll try to have a look at this problem when I have some spare time (but if you can fix it in the meantime that would be great).

Preamble isn't folded, although `let g:latex_fold_preamble = 1` is set

Heya,

time for my next term paper (there's actually 2 to come), so I was undusting vim-latex again and seem to have found a smaller annoyance here:

When I open a normal tex file, everything is folded except for the preamble. However, if the cursor is somewhere in the preamble and I hit za, it gets folded. So it seems the preamble is still properly detected, it's just automtic folding that doesn't happen.

This is my vim-latex config:

" Settings for vim-latex
  let g:latex_complete_close_braces = 1
  let g:latex_quickfix_mode = 0
  let g:latex_quickfix_open_on_warning = 0
  let g:latex_fold_preamble = 1

Hope we can find the source of this :)

Respect tex root specifier

The current generic method (see #3) of locating the main tex file seems good, and would probably work in most cases. However, it is easy to give examples where it would not work (again, see #3). Therefore it has been proposed (#3) to also allow the main tex file to be specified with %! Tex Root = <main-tex-file>.

add optional viewer arguments

Hello,

Being able to pass arguments to the VimLatexView Command allows for forward search (by SumatraPDF say) and is all that vim-latex is missing in comparison to Latex-Box.

Since this extra option doesn't do any harm (no exisiting setup has to be changed), why not adding it to vim-latex too?

Run bibtex in the background

Mmm I think a recent change (I'm not quite sure which) makes bibtex run in the foreground (or at least not "silently"). Consider the following MWE

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

\end{document}

Previously, when typing \textcite{, bibtex would run in the background and then automatically show the results in the popup menu. Now (as it can be seen in the image) one has to press a key to close the cmd.exe and return to vim.

I don't know if this has something to do with my own settings. If you cannot reproduce it I'll write a minimal vimrc. Thanks!

untitled

Unable to run on OS X

I found this plugin while tinkering with LaTeX-Box and I like where you're going with it. However, I am not able to get it up and running. Do you know of any issues with OS X in particular or how I may debug it effectively (not very familiar with VIM-plugin dev)?

When running \ll or call g:latex#latexmk#compile() it spits out started latexmk successfully, but nothing is produced. When successively running \lg it replies latexmk is not running.

I've tried invoking latexmk directly from the command line, using the the command string produced by the plugin (got it from \li) and it works just as expected.

For now, I'll stick with LaTeX-Box, but if you've any suggestion as how to get it spinning or how to determine what's going underneath, I'd be thankful.

Cheers, Oskar

Toc numbering of subsections in book class

Consider the following MWE

\documentclass{book}
\begin{document}
\chapter{Foo-bar-baz}
\section{Foo}
\subsection{Bar}
\subsubsection{Baz}
\end{document}

Latex doesn't number \subsubsection(s) in the book class (this can be seen in the PDF image). However vim-latex's TOC shows numbered subsubsections.

screenshot 159

Some problems with the TOC

Great work on the new toc that doesn't need aux files! There are a few thing I noticed:

i) Consider the case where without generating aux files one has a_main_file.tex:

\documentclass{book}
\begin{document}
  \include{bar}
  \include{foo}
\end{document}

where bar.tex is

\section{Bar section}
\label{sec:bar_section}

and foo.tex is

\section{Foo section}
\label{sec:foo_section}

If for instance I call latex#toc#toggle() on either bar.tex or foo.tex the TOC only shows the sections corresponding to each file and not both of them (maybe this is related to #16)

ii) the first time I call latex#toc#toggle() from the main file it complains that it cannot read the included files like this

Error in latex#toc s:parse_files:
File not readable: ..../foo.tex

but when called again it works

iii) if in the preamble I have some command that uses \section{#1} like:

\newcommand*{\secappendix}[1]{%
  \setcounter{section}{0}%
  \renewcommand*{\thesection}{\appendixname\space\thechapter.\Alph{section}}%
  \renewcommand*{\theHsection}{\thechapter.\Alph{section}}%
  \section{#1}\renewcommand*{\thesection}{\thechapter.\Alph{section}}%
}

it shows in the TOC as a new section. Section commands in the preamble should be ignored.

iv) When I open the TOC I want focus to be in the TOC buffer (i.e place cursor there). Is there a way to achieve that?

pid error

The docs state that

... the entry pid is only available if vim-latex-latexmk is enabled g:latex_latexmk_enabled.

I don't use latexmk so in my vimrc I set

let g:latex_latexmk_enabled = 0

However if I then run :echo latex#info() I get the following error

Error detected while processing function latex#info:
line   20:
E716: Key not present in Dictionary: pid
E15: Invalid expression: d.pid

Is it possible to suppress that error when g:latex_latexmk_enabled is set to 0?

Hide preamble in TOC

I understand that the TOC is just a means of navigation so it might be useful to have an entry for the "Preamble". Personally I like the TOC to reflect what eventually gets printed. So, is it possible to add a variable that controls whether the preamble is shown or hidden in the TOC? Something similar to g:latex_toc_hide_preamble?.
Thank you!

Indenting on `$` and `$$`

As far as I can tell, the indent/tex.vim files adds indent when (simple) equations are opened with \) and \], but not with $ and $$. Is this intended? If not, it would be most appreciated if it were fixed. Thanks a lot for this plugin, it really is amazing, and works surprisingly well on MS Windows.

Implement LatexLabels functionality

LaTeX-Box has a nice feature implemented as the :LatexLabels command, which essentially gives a ToC window with a list of labels that match a provided regexp.

I think a nice way to implement this is to add the labels directly to the ToC, and to add a simple filter function in the ToC window mapped to f. Another idea might be to somehow interface the ToC to CtrlP to get a nice fuzzy filtering of ToC contents.

Unfortunately, I don't have time to do this now, so I open this issue in order to mention the ideas for future implementation.

Window resize when opening toc

When I open the TOC, GUI Vim window gets resized (as seen in the images). This doesn't happen with Latex-Box (the plugin that I'm migrating from).

screenshot 153
screenshot 154

TOC window: Does not show all sections if some are folded in the tex file.

Ok, this is rather cosmetical, and somewhat fuzzy but I created a MWE where it should be reproducable. I should say that I couldn't reproduce it in gvim, but only vim.

Here it goes:

\documentclass{scrartcl}
\begin{document}
 \tableofcontents

  \section{Section in the main file}
  \subsection{Subsection in the main file}

 \section{Second section in main file}
 \subsection{Second subsection in main file}

  \section{Third section in main file}
  \subsection{Third subsection in main file}
\end{document}

These are my settings for vim-latex:

  let g:latex_complete_close_braces = 1
  let g:latex_latexmk_quickfix = 1
  let g:latex_latexmk_options = '-xelatex'
  let g:latex_toc_enabled = 1
  let g:latex_toc_hide_help = 1

Now: If I press \lt (after having compiled the document once), the TOC window pops up without help. But: Some of the last lines where the corresponding entries (Third section and subsection) should be are not legible but have the same color as folded lines and ------------------------------ as text. If I navigate down on them, i.e. move the cursor to them, they suddenly change bg color and become legible.

This only happens if I have one or all sections or subsections in the main file still folded. If the first or all of them are unfolded, this does not happen.

Here's a screen shot:
2013-11-29-130756_636x147_scrot

I tried to :redraw! or <C-L> but nothing of it worked…

I had to update the issue since my TOC was still corresponding to an older version of the MWE (\ll did not actually start up latexmk, but that's a separate issue again), but now it should be all right.

Add parent folder to parent folder of current file when searching for main file

The function to detect the main file

assumes that the main tex file lives in the same folder or the parent folder of the current file.

Consider a setting where the main file lives in directory and chapter files live in directory/chapters/chapter1/chapter1.tex, directory/chapters/chapter2/chapter2.tex and so on.
It is possible to add to the search a parent folder to the parent folder of the current file?

I think that something like this will do?

 let l:glob3 = expand('%:p:h:h:h') . '/*.tex'

Thanks!

windows support

Ok, so I am curious what is missing from the Windows support in vim-latex that latex-box has implemented.

As an independent suggestion: you provide a function, say *@:call latex#view() and a mapping to invoke it. How about a commands, say LatexView, so that the user can set up a command line alias such as Lv (by cnoreabbrev H <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "LatexView" : "Lv"<CR>) instead of having to create another mapping.

And regarding a structuring, how about a wrapper function for executing commands by a bang, that is,

Bang(cmd)
 if iswin
  execute '!start /b '.a:cmd.'> nul' ...
 else
  ... > dev/null'
 endif
return

Complete bibliography completion not working anymore

Not much going on in the office today, so I've got the time to deal with the issues I had with vim-latex lately.

Scenario: I want to complete a bibtex key by pressing <C-x-C-O>, but I get Pattern not found as a red error below vim's status bar.

Here's a MWE.

  1. Run latex on it once in order to get \jobname.bib created.
  2. Open the tex file, remove the % sign in line 17 (or 18, alternatively).
  3. Move cursor to je.
  4. Press <C-X-C-O>
  5. Get error message Pattern not found instead of completion to jeuk10.
\documentclass{scrartcl}
\usepackage{filecontents}
\usepackage[bibencoding=utf8,backend=biber]{biblatex}
   \addbibresource{\jobname.bib}
\begin{document}

\begin{filecontents}{\jobname.bib}
@Book{jeuk10,
  Title                    = {Deutsch als Zweitsprache in der Schule: Grundlagen - Diagnose - Foerderung},
  Author                   = {Stefan Jeuk},
  Year                     = {2010},
  Location                 = {Stuttgart},
  Publisher                = {Kohlhammer}
}
\end{filecontents}
Word
%\autocite[]{je
%\autocite[1]{je

\end{document}

This one is also quite strange, especially as I can't exactly say when it stopped working. I went back in the git repo until master25 (a661d86), but all the way I could still not complete the citation key. If trying to use it while master20 (587f560) is checked out, I get errors, but other than that all the time the same "pattern not found".

Note: I don't use any completion mechanism such as YCM or neocomplete. This also happens if I use a minimal vimrc

Continuous Build Toggle

Perhaps I missed it, but how about a toggle for the continuous build command? That is, stop if running, run if stopped.

Thanks for this great plugin.

`latex#latexmk#errors()` doesn't work if `g:latex_latexmk_quickfix` is set to 0

Heyho,

it seems that since a few commits ago, I can't qet the quickfix window to open by using <localleader>le (in my case \le).

Strangely, it sometimes seems to not work as long as I have g:latex_latexmk_quickfix = 0 in my config, and then changing its value to 1 or 2 does the trick. But not always, it seems.

Pressing \le (with quickfix set to 0) doesn't do anything while vim-latex throws this error if I do :execute latex#latexmk#errors():
quickfix

I also tried with a mini vimrc, but I get the same error.

As far as I understand the documentation this should not be the case but is rather a bug, isn't it?

Implement `LatexCloseCurEnv` (from LaTeX-Box)

Hey, this is more of a feature/discussion request than an issue really, but I'd like to hear your thoughts on that:

Latex-Box has a function called LatexCloseCurEnv that closes the last opened environment in a tex document.

Granted, when using snippets it rarely occurs that you open an environment without adding the \end{env} tag below, so maybe this is not as important a feature to be had, but I'd like to know how others deal with this?

Is there any of the big completion thingys (YCM, necomplete) that can do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.