Skip to content

Commit

Permalink
Way better performance
Browse files Browse the repository at this point in the history
- load time cut in half (setup was being called twice)
- don't load webicons until it's required
- setup is now required (readme)
  • Loading branch information
pablopunk committed Feb 28, 2024
1 parent 2c7cd86 commit 38ecbc3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
4 changes: 3 additions & 1 deletion lua/unclutter/tabline.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local buffer = require "unclutter.buffer"
local has_icons, icons = pcall(require, "nvim-web-devicons")
local config = require "unclutter.config"

local has_icons, icons -- init later (when needed)

---@class unclutter.tabline
local tabline = {}

Expand All @@ -16,6 +17,7 @@ vim.o.hidden = true

--- Set vim options and format tabline
function tabline.enable()
has_icons, icons = pcall(require, "nvim-web-devicons")
vim.o.showtabline = 2
tabline.create_highlight_groups()
tabline.create_clickable_tab_fn()
Expand Down
2 changes: 1 addition & 1 deletion lua/unclutter/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local buffer = require "unclutter.buffer"
local has_icons, icons = pcall(require, "nvim-web-devicons")

---@class unclutter.telescope
local telescope = {}
Expand Down Expand Up @@ -54,6 +53,7 @@ telescope.open = function(opts)
local previewers = require "telescope.previewers"
local entry_display = require "telescope.pickers.entry_display"
local action_state = require "telescope.actions.state"
local has_icons, icons = pcall(require, "nvim-web-devicons")

pickers
.new({
Expand Down
2 changes: 0 additions & 2 deletions plugin/unclutter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ if vim.g.loaded_unclutter == 1 then
return
end
vim.g.loaded_unclutter = 1

require("unclutter").setup {}
29 changes: 7 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

> Focus on what matters
*unclutter.nvim* is a **tabline that removes the clutter** to help you focus on the files that matter to **you**.
_unclutter.nvim_ is a **tabline that removes the clutter** to help you focus on the files that matter to **you**.

![before-after](./art/before-after-light.png#gh-light-mode-only)
![before-after](./art/before-after-dark.png#gh-dark-mode-only)


- [Installation](#installation)
- [Lazy.nvim](#lazynvim)
- [Packer.nvim](#packernvim)
Expand All @@ -18,10 +17,9 @@
- [Utils](#utils)
- [Inspiration](#inspiration)


## Installation

Use your favorite package manager. Calling the `setup()` function is optional.
Use your favorite package manager. Don't forget to call `setup`.

### Lazy.nvim

Expand All @@ -32,24 +30,13 @@ Use your favorite package manager. Calling the `setup()` function is optional.
"nvim-tree/nvim-web-devicons" -- optional, to show icons on tabs
"nvim-telescope/telescope.nvim" -- optional, to use the telescope integration
},
}
```

### Packer.nvim

```lua
use {
"pablopunk/unclutter.nvim",
requires = {
"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:
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

Expand Down Expand Up @@ -151,20 +138,18 @@ 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*](https://github.com/echasnovski/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`](./lua/unclutter/tabline.lua) is an adaptation of *mini.tabline*'s code.
To create the tabline I used [_mini.tabline_](https://github.com/echasnovski/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`](./lua/unclutter/tabline.lua) is an adaptation of _mini.tabline_'s code.

Also this plugin was not only inspired by [harpoon](https://github.com/ThePrimeagen/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:

* [nvim-early-retirement](https://github.com/chrisgrieser/nvim-early-retirement)
* [hbac.nvim](https://github.com/axkirillov/hbac.nvim)
- [nvim-early-retirement](https://github.com/chrisgrieser/nvim-early-retirement)
- [hbac.nvim](https://github.com/axkirillov/hbac.nvim)

![logo-light](./art/logo-light.png#gh-light-mode-only)
![logo-dark](./art/logo-dark.png#gh-dark-mode-only)

0 comments on commit 38ecbc3

Please sign in to comment.