Firstly, I posted a video about this on my Youtube channel a few months ago, but I plan to go a lot more in depth here. Secondly, this is not a “how to” kind of article – I’ll show you the tools I use and why I use them, but not specifically how to set them up. There’s plenty of documentation out there for that!
Hey! You! If you aren't a big fan of reading an article this long, you can check out the video here:
What this setup needs to do 🛠️
So what do I want out of my note taking setup? Well, in a general sense, I need to be able to quickly edit and view markdown and LaTeX files, and also transition between file types.
And why am I changing my note taking setup, you ask? Well, I used Obsidian for quite a while, but it feels clunky and slow (probably because it’s another Electron based program, ew), and it doesn’t allow me to work as efficiently as I’d like.
For instance, the search function in Obsidian sometimes just… bugs out? For example, using ripgrep in Neovim to search for “token” in my notes yields 7 results, but using the search function in Obsidian yields… 8 results? Even though there are only 7 results shown. It’s also kinda slow.
So now we know why I’m changing my note taking setup… but what does it need to do? That’s a really broad question that I kinda already answered, so let’s try and narrow it down a little bit. It needs to view Markdown and LaTeX files (plus LaTeX can compile to a PDF, so we need a PDF viewer as well), and as I mentioned, I’ve been taking notes in Obsidian, which takes notes in Markdown. Thus, because I want to take notes for Maths in LaTeX, I need to be able to transition between Markdown -> LaTeX -> PDF and LaTeX -> Markdown. These transitions might seem a little bit weird, but it’ll all make sense at the end of this article, I promise!
I also need to edit both Markdown and LaTeX files really fast. One of my biggest problems with Obsidian is that it’s slow as anything, so I want to completely fix that. Here’s what I’ve used to solve this:
- Vim motions
- Snippets
- A fuzzy finder
- A better file manager than netrw (Neovim’s built in file manager that I love dearly) might be nice.
- Spellchecker
- Integrated terminal
Let’s get into the specifics.
Viewing Markdown and LaTeX files 👀
…starting with viewing Markdown and LaTeX files. Neovim can of course open Markdown and LaTeX files, but it would be nice if they looked a bit better. Here’s what we’ll be using:
- Treesitter for syntax highlighting. 99% of configs have this already, I just thought I should mention it.
require("lazy").setup({
spec = {
{
"nvim-treesitter/nvim-treesitter",
},
}
})
- Image.nvim for viewing images in the terminal. How cool is that? Although you do need to be using the Kitty terminal, and it’s a little bit… silly at times. We also need to get the file path for those images, and I had to set up a function that returns the correct file path for image.nvim. I know I said that this wasn’t intended to be a tutorial, but I felt that this was important to mention.
require("lazy").setup({
spec = {
{
"3rd/image.nvim",
},
}
})
- Markview for Markdown. This just makes Markdown look a lot better. Also, I recently learned that this plugin has been almost entirely developed on a phone. You can read more about that here.
require("lazy").setup(
{
spec = {
{
"OXY2DEV/markview.nvim",
lazy = false,
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons"
}
}
}
}
)
- Vimtex for LaTeX. VimTex is incredibly useful for a lot of things, not just viewing LaTeX files. We’ll get to that later though. VimTex provides optional syntax highlighting – although we already have treesitter for that. In order to appropriately view LaTeX files, I do need to view the rendered output of LaTeX – a PDF (more on that later), so I need a PDF viewer. I could just use Firefox, but I want to use something a bit more dedicated. Thus, for my PDF viewer, I went with Zathura. It’s nothing fancy – it supports Vim bindings, and… yeah, it views PDFs.
require("lazy").setup(
{
spec = {
{
"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, e.g.
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_view_forward_search_on_start = false
vim.g.vimtex_compiler_latexmk = {
aux_dir = "/home/oscar/.texfiles/",
out_dir = "/home/oscar/.texfiles/"
}
end
}
}
}
)
Transitioning between different file types ↔️
As I previously mentioned, I originally took all of my notes in Obsidian, which takes notes in Markdown. However, I want to take notes for Maths in LaTeX, and notes for everything else in Markdown, so I’m going to want to transition all of my Math Markdown notes to LaTeX. Before I get any further, I want to mention that you can do all of this with a tool called pandoc.
I was going to write a script to convert all of the Markdown files in my Maths folder to LaTeX, but I’m not great at bash, so I decided that I’d rather just convert them on the fly with this command:
pandoc -f markdown -t latex -s myfile.md -o myfile.tex
I should note that pandoc does produce a significant amount of header in LaTeX (~40 lines). This doesn’t affect how the file looks though. Also, if you want to include images in your LaTeX files, you need to use the graphicx package and specify a file path for it like so:
\usepackage{graphicx}
\graphicspath{ {/home/oscar/obsidian-notes/Images/} }
Next, I did mention that I might want to convert from LaTeX back to Markdown. This is because I do use Windows about 10% of the time, and I don’t have a purpose built LaTeX viewer on Windows. So, on the off chance that I need to take notes on Windows, I want to be able to do so without having to use an online editor like OverLeaf.
So that gets us between Markdown and LaTeX (and vice versa). How about LaTeX to PDF? Well, this is where Vimtex really shines. You can just tell it what PDF viewer you want to use, hit “\ll”, and wait about a second for it to render.
However, the amount of things you need to configure or install for this process are a little bit obnoxious. Here’s the list off the top of my head — there are likely more:
- latexmk - the tool that Vimtex uses to compile LaTeX files to PDFS disabling default for forward search in Zathura - if you don’t disable this, you’ll get a bunch of green highlights – kinda annoying
- Zathura itself - this config is pretty simple, I just feel like it’s not that well documented
- the output directory for latexmk, so you don’t get a few dozen random-ish files littering your directory.
Editing both Markdown and LaTeX files REALLY fast ✏️
Finally, editing both Markdown and LaTeX files really fast. There’s not much to say about Markdown. I have a few little keybinds for general use, but at the end of the day… it’s just Markdown. Nothing fancy.
On the contrary, VimTex is incredibly useful for LaTeX. It comes with a bunch of super useful default motions. Also, I figured that I should mention snippets here. Snippets aren’t done with VimTex itself, but with the LuaSnip plugin. There’s nothing super fancy going on here, but there’s one little snippet I’ll show you.
ls.add_snippets("tex", {
s(
"basetext",
fmt(
[[
\documentclass{{article}}
\usepackage{{graphicx}}
\begin{{document}}
\end{{document}}
]],
{}
)
),
})
This just makes some of the more monotonous parts of LaTeX a bit quicker.
Next up, a fuzzy finder. Most Neovim users already have this installed, but I just thought I should mention it since it is a core part of my workflow. If you don’t use one, it just allows you to move between files really quickly.
After that, I’d like to add a better file manager. While I haven’t configured this in Neovim yet, I use n^3 as my file browser. Neovim’s default browser is netrw, and while I do love it, it’s not super efficient. Since I’m jumping between files a lot (with and without a fuzzy finder), a better file browser is quite important to me.
Second to last item on this list… a spell checker! This is already built into Neovim, and it’s super easy to use and enable. I had to set it to automatically toggle off on any open terminals (because I don’t need my terminal being spell checked – fdisk definitely isn’t a word in the English dictionary).
And finally, an integrated terminal. Neovim already provides a built-in terminal, but the ToggleTerm plugin allows us to toggle that on and off really quick, which is nice. My keybind for it is just “te” (my leader key is space).
On AI 🤖
Oh, and by the way, I’m sure someone’s going to ask if I utilize AI at all. So to get this out of the way, no, I really don’t like AI. The one really good use case that I have found though is taking screenshots of math stuff and using ChatGPT to convert that to LaTeX. I normally write LaTeX "by hand", but there’s certain situations where I have to ask myself: “What am I really getting out of this?”.
An example of a situation like the one mentioned...
To conclude… 🎁
And that’s about it! With this setup, I can view Markdown and LaTeX files in Neovim, edit them with ease, and transition between filetypes with pandoc.
If you’d like to see more content like this, consider following me and checking out my other socials:
Youtube
Github
Top comments (2)
I loved the video, it made me laugh (but in a good way). Really nice setup. 🙂
Thank you! Definitely feels like my first "full" video. There's so many improvements that I should've made though, looking back. Just part of it tho!