This is a small Neovim plugin that emulates the behavior of the vscode-inline-fold plugin by moalamri.
Motivation
I had been using Tailwind CSS a lot lately, and one thing about Tailwind is you get some very long, clunky-looking class names scattered throughout your code. After seeing this Fireship YouTube video which nicely demonstrates the vscode plugin, I knew I wanted to figure something out for Neovim as well.
Process
After a bit of research, I learned a bit more about the Neovim Extended Marks (extmarks) api. This lets you display certain characters at a specified position without altering the file's contents. I also used nvim-treesitter expand and collapse the Treesitter node at the cursor.
Applications
As I mentioned, I mainly wanted to use this to show/hide Tailwind classes. So I added some logic in my config for when the TailwindCSS language server attaches to my Neovim buffer. When it attaches, I query the Treesitter API again (outside of the plugin this time) to find all class attributes. Then it's simply a matter of calling this plugin to collapse all the matching Treesitter nodes.