A Quick Guide on Writing LaTeX in Neovim
In last post, I shared a minimal configuration of
Now, I would like to share something about setting
LuaSnip and auto-completion.
This may not be suitable for everyone, especially for those who are not familiar with TUI.
I am using
macOS, and these configurations should also work well on
Windows user, I recommend to install WSL.
Use a modern terminal, such as
On macOS, the next thing that I recommend you to do is installing
Here is the installation guide.
If you are using an M1 Mac,
please check here for more details,
/opt/homebrew/ to your
As in the last post, we need to install a
macOS users, you may download
Here is the official instructions for installing
Neovim on different platforms.
macOS users, you can install
Neovim 0.7 was released on April 15, 2022.
Please ensure that you have the correct version (>= 0.7).
Neovim is a fork of
Vim, the basic usage is the same.
Follow this repo to learn how to use
If you are new to Neovim, I suggest you to start with this configuration.
Here is my current configuration.
Lua is the first-class language in
Neovim, some basic knowledge of
Lua will be better.
If you want to costuming your own
Neovim, you may want to learn nvim-lua-guide.
VimTeX is a powerful tool to
LuaSnip is a snippet engine, which provides the actual snippets for various file types.
I will use the following examples to explain how to use
mk as the trigger for inline math environments.
Also, this is an auto-sinppet,
which means that you can just type
mk and it will be replaced with
| above is used to indicate the position of the cursor.
mk is typed,
you can type the math formulas you need and
Ctrl + j to escape the inline math environment.
Now the real magic is here.
After escaping the inline math environment,
you will see something like this:
| is the cursor as before.
LusSnip with insert
space when the next character after snippet is a letter.
Note that for
LusSnip will not insert
cite as the trigger for cross-references snippet.
Because cross-references are not often used in the text,
cite as a normal snippet:
you need to press
Ctrl + j to expand the snippet and get something like
Then you can input some text in the square brackets,
and then press
Ctrl + j to jump to the curly braces.
According to the settings,
you will see a dropdown with the list of all the references in the document.
This is a powerful feature,
When writing LaTeX source files, auto-completion is crucial for fast editing and improve our efficiency dramatically. VimTeX and LSP support auto-completion.
- finish Preparations
- finish VimTeX
- finish LuaSnip
- finish cmp
If you find this post helpful, please consider sponsoring.Sponsor