Neovim plugin

I made a Neovim plugin because I missed a feature from VSCode

by Pablo Varela on Wed Oct 04 2023

You know that feature in VSCode where the tabs are automatically closed when you leave them? Only modified files (or when you double-click on the tab) are kept in the tab list.

unclutter.nvim is a tabline that removes the clutter to help you focus on the files that matter to you.

You’re working on a large project and you’re jumping through function definitions and index files that endup cluttering your tabline. Then you wanna go back to the file you were working on but your tabline is full of useless files. Unclutter.nvim will:

Keep only the buffers you need

  • Buffers you made changes to.
  • Buffers visible in any window.
  • Buffers that were open on startup (neovim arguments, restored sessions…).
  • Buffers that are not files (file tree, quickfix, help, terminal…).
  • Buffers marked manually (read below).

Every other buffer will be closed at the time you leave it (BufLeave).

Sounds good? Go ahead and install it: github.com/pablopunk/unclutter.nvim

Just like VSCode, you can “mark” files by saving them. I use <c-s> to save a file and keep it in the list but you can use your own mappings without the need to save the file:

vim.keymap.set("n", "<leader>m", require('unclutter').toggle_current, { noremap = true })

To create the tabline I used mini.tabline as a starting point. It’s a great plugin and the one I was using before. The label/tabs implementation on tabline.lua is an adaptation of mini.tabline’s code.

Also this plugin was not only inspired by harpoon too, it’s the main reason behind it. I was trying to hack harpoon to get this behavior, but didn’t like the outcome. The plugin is great but I don’t like their tabs implementation and other small stuff. It was there when I realized I could just code my own.

Other plugins I’ve used to unclutter in the past:

Installation and documentation: github.com/pablopunk/unclutter.nvim. Also :help unclutter