Integrate cheat sheet into Neovim without any plugins.
I saw a video that showed how to integrate cheatsheet into Neovim using a combination of Tmux, fzf, and shell scripting. I used
alacrity + Tmux previously and moved away from this workflow after starting using wezterm which is also a GPU-accelerated cross-platform terminal emulator and multiplexer implemented in Rust.
Anyway, I need a simple solution to integrate cheatsheet into my development workflow. I tried to use
cheat.sh-vim but like I mentioned I just need a simple solution. There is also another plugin available but I don’t need a fancy UI.
It ends up pretty easy to implement this in just less than 50 lines of Lua code.
You can see it in action below. Now I can easily search for code snippets, documentation, or learn something in a particular programming language easily.
And below is the code you can use and improve on to fit into your development workflow.
Assuming your put this file in the
lua folder, run
:lua require(“cheatsheet”).cheatsheet()and it should work.
The script is pretty straightforward.
- Ask for user input. Blank to return, and
- Format the input to meet the requirements.
- Create a new terminal buffer. You can change it to fit your needs, e.g. using a split window or tab.
- Send the command to the terminal buffer, run it and exit the terminal mode.
- The cursor should now be at the top of the window and I…