Neovim for Beginners — Cheatsheet and Coding Assistant

Create a cheatsheet and coding assistant to help us code faster.

alpha2phi

--

Neovim for Beginners — Cheatsheet and Coding Assistant

In this article, we will develop a Lua module to help us find code snippets, search for cheatsheets, and learn any programming languages.

This article is part of the Neovim for Beginners series.

The Neovim configuration files are available in this repository.

Getting Started

As developers, we need to learn and code constantly. As Neovim users we want to do it all from within Neovim.

cheat.shprovides unified access to the best community-driven cheatsheets repositories in the world. Using Lua, we can easily integrate it as part of our development workflow to help us learn and code faster.

Cheatsheet Module

cht.lua

Create the lua/utils/cht.lua module with the following code snippets.

  • We create a vertical split and open a terminal.
  • From the terminal, we use curl to query for cheatsheets.
  • We set the file type of the buffer to cheat.

Auto Command

In the after/plugin/autocmds.lua file, we create an auto command to make it easy to exit the cheatsheet window (line 14) by pressing q.

Which Key Mapping

In the lua/config/whichkey.lua file, we define a key mapping to invoke the Lua function.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.