In one of my previous blog posts I introduced the concept of minimalist note taking as a note taking method and life style, that tries to improve informational self-determination by restricting oneself to a fully controlled hard and software environment. The presented method solely relies one some UTF-8 text editor application and optionally on a template system like Tp-Note. This note explains how to configure Tp-Note for Neovim1. In the following I presume, that you know about Neovim's qualities already, so I will rather focus on the technical details about how to integrate the template system Tp-Note with Neovim.
First, we start with an overview of the roles of the related applications:
Tp-Note is mainly a template system that collects data of its environment and
the clipboard and fills configurable templates to produce note files. Once
Tp-Note has created a new note file on disk, it opens it some external text
editor application (here Neovim), renders the contents of the note file and
opens in addition a web browser window as live (pre-) viewer. Tp-Note's
[viewer] startup_delay determines whether the text
editor or the web browser opens first. For example: the negative number
causes the web browser to start 1000 milliseconds before the text editor; the
1000 corresponds to an delay of 1000 milliseconds before the
web browser window opens. This way you control in a traditional window manager
which window will be placed on top. In a tiling window
manager, this setting will decide about the order of the windows on the desktop.
As a side effect,
[viewer] startup_delay = 500 also acts as a workaround for a
in bug in Neovim in relation
with the i3-window manager. Please refer to a more detailed
description about configuration below.
But, how does Tp-Note determine which file editor application it should start? Tp-Note comes with a configurable list of well known text editors and tries to launch every item in this list until it finds an installed text editor on the system. Hereby, the text editor must be configured in a way that it blocks the caller until the user finishes editing and closes the application. Once closed, Tp-Note synchronizes the notes metadata with its filename and terminates its internal renderer and live viewer thread.
Another difficulty derives from the fact that Neovim is a console program and Tp-Note expects a graphical user interface (GUI), when it runs in a graphical environment. One solution is to install one of numerous GUIs that are available for Neovim. Alternatively, another solution is to launch Neovim indirectly from within a terminal emulator. Because the latter does not need any additional software, it is explored further in this blog post. A typical command line looks like this:
$ xfce4-terminal --disable-server -x nvim -c 'colorscheme pablo'
In the above
xfce-terminal designates the terminal emulator, which is
--disable-server to open a new instance and a new window on
-x nvim starts Neovim. The optional parameter
-c 'colorscheme pablo' illustrates how to set some additional Neovim configuration commands.
Once you have tested your command line, you can add it on top of Tp-Note's
editor application search list, which is defined in its configuration file.
Before changing Tp-Note's configuration, it is recommended to first test the
invocation on the command line as shown above.
When Tp-Note starts, it first looks if it can read its configuration file
tpnote.toml from some “usual” location2. If it fails, it writes a
default configuration file. Tp-Note is best customized by starting it once,
and then modifying its default configuration. As
tpnote.toml is a text
file, you can modify it with any text editor. The configuration is simple:
Find the following line in the section
editor = [
and replace it with:
editor = [ [ 'xfce4-terminal', '--disable-server', '-x', 'nvim', '+colorscheme pablo', '+set syntax=markdown', ],
The change will take effect next time you run Tp-Note (see screenshot above):
If something goes wrong you can start Tp-Note in debugging mode:
$ tpnote --debug debug --edit
Here some more examples:
Neovim in LXTerminal:
[app_args] editor = [ [ 'lxterminal', '--no-remote', '-e', 'nvim', '-c', 'colorscheme pablo', '+set syntax=markdown', ], ]
Neovim in Xterm:
[app_args] editor = [ [ 'xterm', '-fa', 'DejaVu Sans Mono', '-fs', '12', '-e', 'nvim', '+set syntax=markdown', ], ]
Neovim and Tp-Note complement each other well and provide together a pleasant and efficient note taking experience. As shown, the simplest way to run Neovim in a graphic environment is to launch it indirectly in a terminal emulator.
A good start is Tp-Note's project page, the introductory video or other blog posts about Tp-Note. The source code is available on Gitlab - getreu/tp-note and some binaries and packages for Linux, Windows and Mac can be found here. To fully profit of Tp-note, I recommend reading Tp-Note's user manual. When you like Tp-Note, you probably soon want to customize it. How to do so, is explained in Tp-Note's manual page.
Tp-Note’s configuration file resides typically in
~/.config/tpnote/tpnote.toml on Unix or in
C:\Users\<LOGIN>\AppData\Roaming\tpnote\config\tpnote.toml on Windows.
When usure, start Tp-Note with
tpnote --version to display