If you don’t have an above amazing working memory or don’t possess an eidetic memory, having reference material at hand helps a lot to get coding or writing tasks done. There are a few solutions to this problem ranging from having an extra monitor to getting a brain tumor like George Malley.
In this post, however, I will discuss how I used Neovim and Lua to write a few functions that allow me to open a small floating window and either show the output of a cheatsheet from cht.sh or interact with a full-blown browser from which to reference any material. It is worth noting that the browsers support by this method are limited¹ to command line browsers such as Lynx, w3m etc.
Requirements
Demo
The Code
Most of the logic at the moment resides in a single function 😭. I’ve commented all the parts that may not be clear from my coding style.
First let’s get a few utility functions out of the way:
|
|
And now for the pièces de résistance:
|
|
Accessing The Shiny New Functionality
I have assumed that you are would place this code within an init.lua
config file or wrapping the above lua² with lua
tags.
Creating a keybinding using Lua, one could do one of the following:
The Vim Way
|
|
The Neovim Way
|
|
I hope this is helpful 🦾
Footnotes
- These perceived limitations that non-commandline acolytes refer to are ENTIRELY self-imposed ✊
- Simply surround the Lua with
lua
tags suchly:
1 2 3
lua <<EOF print('Some snazzy Lua code here 😎') EOF