/Lunatic-Pages

latex notes w/ neovim

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

Hi there! Hope you find this useful! ✨


This is what I use to edit my notes using LaTex. I heavily depend on snippets and custom definitions to make my workflow somewhat usable (:satisfied:).

It's intended to be used in a certain way so if you plan on getting this for your note-taking activities be wary of that.


🌟 Showcase


😎 Information

Here is what I'm using:

As you see, not much is needed 😁. What is being done with these tools is what matters.


🔥 Usage

Many things here are in Spanish, it's in these 3 files where you are going to have to change certain words for the pretty stuff to be displayed in your language.


In your home directory there should be a folder with three files, should look something like this:

mi-preamble-latex
├── letterfonts.tex
├── macros.tex
└── preamble.tex

The names should somewhat tell you about what's where, but if you want to know more you can check these files, just make sure you can compile LaTeX documents after saving your changes.

Then make sure you have this in the preamble of your LaTeX document to be able to read these files.

\documentclass{report}

\input{\string ~/mi-preamble-latex/preamble.tex}
\input{\string ~/mi-preamble-latex/macros.tex}
\input{\string ~/mi-preamble-latex/letterfonts.tex}

\begin{document}

...

\end{document}

Of course you can change the directory structure as you wish, but make sure you are inputing the files back into your document. This is nothing different than a really big preamble, it's just to make it little more organized.


What really makes typing LaTeX easy is LuaSnips. This is a so-called snippets engine, it lets us focusing on typing the actual content of our files while it takes care of the boilerplate. How does it do it? It replaces usually short and easy to write strings of text into much more cumbersome ones. Here's an example with actually what I use as a Preamble-Generator for my documents:

I use Neovim + Lunarvim for this, just make sure you have something similar to this file structure in ~/.config/lvim/ after installing them both.

~/.config/lvim
├── config.lua
├── lua
│   └── user
│       ├── <anything-1>.lua
│       ├── <...>. lua
│       ├── <anything-n>.lua  
│       │
│       ├── luasnips.lua   #<- Here are the configurations
│       │                  #   of LuaSnips' setup as a plugin.
│       ├── <anything-1>.lua
│       ├── <...>. lua
│       └── <anything-m>.lua       
├── luasnippets
│   ├── lua.lua
│   └── tex
│       ├── <anything-1>.lua
│       ├── <...>. lua
│       └── <anything-n>.lua
└── stylua.toml

Basically what I tried to do with this awful notation is communicating that it's up to you to use these folders for whatever you want. Just make sure you divide your configs into as many files you need so you can keep track of what's being done in your head.

Our snippets in the luasnippets folder work after we specify where we want them to work. In this case for LaTeX it's

  • luasnippets/<filetype>.lua, we have a lua.lua file in the tree as example like this (but not in the actual repo), or
  • luasnippets/<filetype>/<anything>.lua. We are going to make use of this way to take advantage of more descriptive filenames.

If you have all of this, you should be able to use the snippets defined in ~/.config/lvim/luasnippets/. I'm not going to cover them, you can use the ones I already use or ask for help in the issues (I don't know much, but if I can help I will). Just make sure you learn how to create them using LuaSnips not anything else, since there are many snippet engines out there.

Here are some resources I found useful when learning how to make snippets:


If you read all this and have any suggestions on anything (wheter it's the readme or something code-related) feel free to make a push request, I'd appreciate it 😃.