Working with Neovim from Obsidan
Introduction
With Obsidian slowly taking more and more space in my workflow, the "Emacs is a great OS but lacks a decent editor" meme remains true.
But one of the many lesson I have leartn from Emacs/Orgmode is to stop fighting with evil.
Sometime there's just no emulating the real thing especially when it launches in a fraction of a second.
Opening Neovim from Obsidan
Opens the current file.
As a QuickAdd macro, assuming Kitty as a terminal.
Macro
module.exports = async (params) => {
const { app, quickAddApi } = params;
async function main() {
const path = app.workspace.getActiveFile().path;
const vault = app.vault.adapter.basePath;
const command = `kitty --class nvim-obsidian nvim --cmd "cd ${vault}" "${vault}/${path}"`;
console.log(command);
require("child_process").exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
return;
}
console.log(`File opened in Neovim: ${path}`);
});
}
await main().catch(console.error);
};
Desktop environment
Using a tiling window manager, we would probably prefer the new terminal window containing neovim to be on top of the current obsidian window it has been called from
With BSPWM:
bspc rule -a nvim-obsidian state=floating
With Hyprland:
windowrulev2 = float,class:^(nvim-obsidian)$
Going further
Something like Devour could probably help make the transitin between Obsidian and Neovim although Electron's windowing system has been notably difficult to deal with.
There could also be a use for Nvim's remotes