Git Product home page Git Product logo

unclutter.nvim's Introduction

unclutter.nvim

Focus on what matters

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

before-after before-after

Installation

Use your favorite package manager. Don't forget to call setup.

Lazy.nvim

{
  "pablopunk/unclutter.nvim",
  dependencies = {
    "nvim-tree/nvim-web-devicons"   -- optional, to show icons on tabs
    "nvim-telescope/telescope.nvim" -- optional, to use the telescope integration
  },
  config = true -- this will call require("unclutter").setup()
}

Features

You're working on a large project and you're jumping through function definitions and index files that endup cluttering your tabline. Unclutter.nvim will:

Only show the buffers you need

A minimal tabline with icons will show:

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

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

๐Ÿ”ญ telescope.nvim integration

If you use telescope.nvim, you can use it to list all your unclutter.nvim in a floating window:

require('unclutter.telescope').open()

Of course, you can map it to whatever you want:

vim.keymap.set("n", "<leader>b", require("unclutter.telescope").open, { noremap = true })

telescope integration

You can customize the format of the telescope results:

unclutter.telescope { format = "compact" } -- DEFAULT: folder/file.js
unclutter.telescope { format = "cwd" } -- path/folder/file.js
unclutter.telescope { format = "filename" } -- file.js

If you want to use the telescope integration without the tabline, you can disable it:

require('unclutter').setup {
  tabline = false,
}

Customization

Here's the default configuration:

require('unclutter').setup {
  clean_after = 3, -- number of tabs to start uncluttering. i.e don't hide until 4 tabs are open
  tabline = true, -- show tabline. You can set it to false and only use the [telescope integration](#telescopenvim-integration)
}

Utils

If you want to hack it or create your own mappings, you can use the following functions:

local unclutter = require("unclutter")
local tabline = require("unclutter.tabline")
local buffer = require("unclutter.buffer")
local plugin = require("unclutter.plugin")

tabline.keep_buffer(bufnr)          -- Show buffer in tabline
tabline.remove_buffer(bufnr)        -- Show buffer in tabline
tabline.toggle_buffer(bufnr)        -- Toggle buffer in tabline
tabline.list()                      -- List tabline buffers

-- If you want to get the current buffer you can use:
local bufnr = buffer.current()
tabline.keep(bufnr)

-- navigate tabline buffers (like :bnext and :bprev)
tabline.next()             -- Go to next buffer
tabline.prev()             -- Go to previous buffer

-- handle plugin (on/off)
plugin.enable()            -- Enable unclutter
plugin.disable()           -- Disable unclutter

Example mappings:

vim.keymap.set("n", "gn", unclutter.next, { noremap = true })
vim.keymap.set("n", "gp", unclutter.prev, { noremap = true })

I personally have a map to save a file to disk (<c-s> will :w) so the buffer will be kept in the tabline whenever I do <c-s>.

Help

Of course:

:help unclutter

Inspiration

This behavior was inspired by vscode (sorry), that won't keep your tabs open until you hit save (or double-click the tab).

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:

logo-light logo-dark

unclutter.nvim's People

Contributors

github-actions[bot] avatar imgbotapp avatar pablopunk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unclutter.nvim's Issues

Jumplist

Removing a buffer from the buffer list also removes it from the jumplist, which is a bit inconvenient.

Steps to reproduce

  • You're in a random file, not marked by unclutter.nvim, you jump to the definition of a function (on another file)
  • Then in that other file you also go to another definition from another file
  • The files are not kept in buffer list (that's good) but then you do <c-o> and it doesn't go back to any of those files (not even the original one)

Desired behavior

  • You jump through definitions and when you do <c-o> you go back to the previous def (or even the original jump)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.