Logging in neovim plugin

How to log from within neovim using plenary

While debugging blink-cmp-latex I needed access to log messages to see what was going on. This turned out to be easy enough using plenary but took me a second to find the incantation:

local log = require("plenary.log").new({
	plugin = "blink-cmp-latex",
	level = "info",
})

log.info("helpful info message")
log.debug("you get the idea")

It will write to ~/.local/state/nvim/plugin-name.log1 and supports the following log levels by default

If you need more info documentation can be found here or just read the source (it’s not bad, promise).


  1. At least on my system… if you have manually configured neovim to dump logs somewhere it will respect that. I figure at that point you don’t need my help figuring out where they are.↩︎