www-gem words

[Plugin] Writing and organizing your notes in neovim: mkdnflow

Published on

vim Due to my job I’ve always had to find a solution to write and organize my notes. Today, this topic has become incredibly popular and a lots of apps have invaded our apps stores and plugins/packages managers. Since note taking is a text editor job I naturally ignored all these apps and looked at (neo)vim. With no surprise, it has quite a few options to help you here.
I’ve started using vimwiki but - for a reason I couldn’t remember - I moved to mkdnflow.nvim . This neovim plugin checks all the boxes for my needs: scientific literature, ideas organization, rolegames scenari.

╭── What’s in mkdnflow for you?

This tool helps you take and manage notes written in markdown. For people out there who use Jekyll or Hugo for their blog, you can also use it to generate static sites from markdown documents.

mkdnflow has obviously the features you’d except to see in a notes taking/organizing tool plus some handy ones:

As a neovim plugins that uses markdown, it also comes with:

╭── I was still missing some features

With the hype for Obsidian, I’ve tried hard to get interested in it. I’ve spent time reading about it and watching videos but nothing was convincing enough to make me think it would be more efficient compare to neovim and mkdnflow. Nonetheless, two features were appealing enough that I spent 4 hours trying to find a way to implement them in my config.

By default, you can of course create links for one notebook to others but you have to know the title of the notebooks you want to link your current one to and this was something I was wasting time on by looking for the names I need.
Thanks to fzf and its integration in neovim (with the fzf-lua plugin in my case), I now have a keybinding that will list all my notebooks and automatically insert its path at the cursor position in my file. This is the code in my config file:

vim.cmd[[command! PathLink let @a=systemlist("fd --base-directory ~/vimwiki -e md . | fzf-tmux -h 100% -w 20% -x 220 --reverse --info=inline")[0]|norm! "ap]]

vim.keymap.set( 'i', '((', '(<Esc>:PathLink<CR>a) ')

Explanations:

I don’t know how “good” this code is but it works :)

I think it’s nice to be able to quickly know where a notebook is already referenced in your notes. Hence, this is the code I’ve added in my config file:

vim.cmd[[command! BackLink let @a=systemlist("fd --base-directory ~/notes -e md . | fzf-tmux -h 100% -w 30% -x 250 --reverse --info=inline --preview-window=down --preview='rga {} ~/notes/'")]]

vim.keymap.set( 'n', 'wb', ':BackLink<CR>')

This list all my notes in a fzf-tmux window. When I highlight a note, a preview window shows me where this note is referenced in my notebooks.

╭── That’s all folks !

Once again, simplicity is the big winner here ! For my needs, this approach offers all the features I need while being lighter than other popular apps, doesn’t require a subscription, makes me sure that my notes remain MY notes, ensures simple compatibility thanks to the markdown format, and has a lot of room for any future needs thanks to an active developer, and the power brought by the combination of fd, rga, fzf (learn more about these commands ), and maybe other tools.

I have to admit that I’m biased in the writing of this post because of the endorphins still flowing in my veins after having come up with these 2 extra features and especially the systemlist solution which I spent 3 hours to find. As I said earlier in this blog, most of these tools are not effortless at first but this is clearly outweighed by the time saved in future maintenance and improved efficiency.


Thanks for your read. Hope it's been useful to you.


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #(Neo)vim #(Neo)vim-Plugins