Code Monkey home page Code Monkey logo

tabby.nvim's Introduction

tabby.nvim

A declarative, highly configurable, and neovim style tabline plugin. Use your nvim tabs as a workspace multiplexer!

To v1.x users

Tabby thinks it's essential to stay backward compatible! So even if Tabby releases a brand new 2.0, it will not break the 1.0 configuration. If needed, check out the Readme V1!

The reasons for making the 2.0, and the improvements in 2.0, can be found at #82.

Concept

A line for the vim tab page, not for buffers

A tab page in vim holds one or more windows(not buffers). You can easily switch between tab pages to have several collections of windows to work on different things.

Tabline can help you use multiple tabs. Meanwhile, the bufferline is simply an array of opened files. As a result, Bufferline limits the power of vim, especially when editing a large workspace with many opened files.

For example, you are writing a backend service:

- Tab1: nvim-tree, controller/user.go, entity/user.go
- Tab2: nvim-tree, pkg/cache.go, redis/client.go
- Tab3: Terminal
- Tab4: Neogit.nvim

Declarative, highly configurable

Tabby provides a declarative way to configure tabline. You can set the tabline to whatever neovim natively supports and complete the config with any lua code. At least that's the goal of tabby. And also, the tabby provides some presets to quick start or as your example.

Playground

Want to try your new config with no fear? Want to reproduct/debug a problem? Want to contribute? Use the playground!

  1. Clone this repository, or open the directory your plugin manager installed tabby.nvim.
  2. Put your config in 'playground/config.lua'
  3. Execute make play, into a temporary neovim to check the config.
  4. Use make clear-play to clean the change.

Install

Use your favorite plugin manager or script to installing 'nanozuki/tabby.com'. If you use lazy.nvim, you can refer the following example:

{
  'nanozuki/tabby.nvim',
  event = 'VimEnter',
  dependencies = 'nvim-tree/nvim-web-devicons',
  config = function()
    -- configs...
  end,
}

You don't need lazy load since 'tabby.nvim' is not slow. If you really want, you can use VimEnter or VeryLazy or anything else you like. Some of them (like VeryLazy) will make the raw tabline render first, and re-render to tabby's line quickly.

Setup

Tabline option

At default, neovim only display tabline when there are at least two tab pages. If you want always display tabline:

vim.o.showtabline = 2

Save and restore in session

You can save and restore tab layout and tab names in session, by adding word tabpages(for layout) and globals(for tab names) to vim.opt.sessionoptions. This is a valid sessionoptions:

vim.opt.sessionoptions = 'curdir,folds,globals,help,tabpages,terminal,winsize'

Setup tabby.nvim

And you can setup your own tabline like this (check Customize for more details):

local theme = {
  fill = 'TabLineFill',
  -- Also you can do this: fill = { fg='#f2e9de', bg='#907aa9', style='italic' }
  head = 'TabLine',
  current_tab = 'TabLineSel',
  tab = 'TabLine',
  win = 'TabLine',
  tail = 'TabLine',
}
require('tabby.tabline').set(function(line)
  return {
    {
      { '', hl = theme.head },
      line.sep('', theme.head, theme.fill),
    },
    line.tabs().foreach(function(tab)
      local hl = tab.is_current() and theme.current_tab or theme.tab
      return {
        line.sep('', hl, theme.fill),
        tab.is_current() and '' or '󰆣',
        tab.number(),
        tab.name(),
        tab.close_btn(''),
        line.sep('', hl, theme.fill),
        hl = hl,
        margin = ' ',
      }
    end),
    line.spacer(),
    line.wins_in_tab(line.api.get_current_tab()).foreach(function(win)
      return {
        line.sep('', theme.win, theme.fill),
        win.is_current() and '' or '',
        win.buf_name(),
        line.sep('', theme.win, theme.fill),
        hl = theme.win,
        margin = ' ',
      }
    end),
    {
      line.sep('', theme.tail, theme.fill),
      { '', hl = theme.tail },
    },
    hl = theme.fill,
  }
end)

Examples and Gallery

These are some awesome examples shared by tabby.nvim users! Also welcome to share your own!

Discussions: show and tell

Presets

If you want to quick start? That's fine, you can Use Preset Configs. And you can use theme of lualine in presets.

Commands

  • Tabby rename_tab <tabname>: Rename tab. Use name in line by tab.name() (ref: Tab). Config fallback name by Line-Option
  • Tabby pick_window: Open a selector to pick window in tabpages.

Key mapping example

Tabby uses native nvim tab, so you can directly use nvim tab operation. Maybe you want to map some operation. For example:

vim.api.nvim_set_keymap("n", "<leader>ta", ":$tabnew<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<leader>tc", ":tabclose<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<leader>to", ":tabonly<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<leader>tn", ":tabn<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<leader>tp", ":tabp<CR>", { noremap = true })
-- move current tab to previous position
vim.api.nvim_set_keymap("n", "<leader>tmp", ":-tabmove<CR>", { noremap = true })
-- move current tab to next position
vim.api.nvim_set_keymap("n", "<leader>tmn", ":+tabmove<CR>", { noremap = true })

And in fact, vim has some built-in keymapping, it's better to read :help tabline. Here are some useful mappings:

gt					*i_CTRL-<PageDown>* *i_<C-PageDown>*
		Go to the next tab page.  Wraps around from the last to the
		first one.
{count}gt	Go to tab page {count}.  The first tab page has number one.
g<Tab>		Go to previous (last accessed) tab page.
gT		Go to the previous tab page.  Wraps around from the first one
		to the last one.

The {count} is the number displayed in presets.

Customize

Customize tabby with require('tabby.tabline').set(fn, opt?):

tabline.set({fn}, {opt?})                                  *tabby.tabline.set()*
    Set tabline renderer function

    Parameters: ~
        {fn}    A renderer function, like "function(line)"
                - parameter: {line}, |tabby.object.line|, a Line object
                - return: renderer node. |tabby.object.node|
        {opt?}  |LineOption|. Option of line rendering

All you need is to provide a render function, that use the variable line (ref: Line) to complete tabline node (ref: Node). The line variable gathered all features the tabby provided. And you can use opt (ref: [Line Option](#Line Option)) to customize some behaviors.

The render function will be called every time the nvim redraws tabline. You can use any valid neovim lua code to contracture the Node in this function. For example, if you want display current directory in tabline, you can do like this:

require('tabby.tabline').set(function(line)
    local cwd = ' ' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':t') .. ' '
    return {
        {
            { cwd, hl = theme.head },
            line.sep('', theme.head, theme.line),
        },
        ".....",
    }
end, {})

Line

line.tabs().foreach({callback})                    *tabby.line.tabs().foreach()*
    Use callback function to renderer every tabs.

    Parameters: ~
        {callback}  Function, receive a Tab |tabby-tab|, return a
                    Node |tabby-node|. Skip render when return is empty string.

    Return: ~
        Node |tabby-node|, rendered result of all tabs.

line.wins({filter...}).foreach({callback})         *tabby.line.wins().foreach()*
    Use callback function to renderer every wins.

    Parameters: ~
        {filter...}  Filter functions. Each function receive a |tabby-win| and
                     return a boolean. If filter return false, this window won't
                     be displayed in tabline.
        {callback}   Function, receive a Win |tabby-win|, return a
                     Node |tabby-node|. Skip render when return is empty string.

    Return: ~
        Node |tabby-node|, rendered result of all wins.

    Example: ~
      - Don't display NvimTree: >
            local function no_nvimtree(win)
              return not string.match(win.buf_name(), 'NvimTree')
            end
            ...
            line.wins(no_nvimtree).foreach(function
              ...
            end)
<

                                            *tabby.line.wins_in_tab().foreach()*
line.wins_in_tab({tabid}, {filter...}).foreach({callback})
    Use callback function to renderer every wins in specified tab.

    Parameters: ~
        {tabid}      Number, tab id
        {filter...}  Filter functions. Each function receive a |tabby-win| and
                     return a boolean. If filter return false, this window won't
                     be displayed in tabline.
        {callback}   Function, receive a Win |tabby-win|, return a
                     Node |tabby-node|. Skip render when return is empty string.

    Return: ~
        Node |tabby-node|, rendered result of all wins in specified tab.

    Example: ~
        - Don't display NvimTree: See |tabby.line.wins().foreach()|.

line.spacer()                                              *tabby.line.spacer()*
    Separation point between alignment sections. Each section will be separated
    by an equal number of spaces.

    Return: ~
        Node |tabby-node|, spacer node.

line.truncate_point()                              *tabby.line.truncate_point()*
    Separation point between alignment sections. Each section will be separated
    by an equal number of spaces.

    Return: ~
        Node |tabby-node|, spacer node.

line.sep({symbol}, {hl}, {back_hl})            *tabby.line.sep()*
    Make a separator, and calculate highlight.

    Parameters: ~
        [  ██████████████   ]
           |          |     |
           symbol     hl    back_hl
        {symbol}    string, separator symbol
        {hl}        Highlight |tabby-highlight|, current highlight
        {back_hl}   Highlight |tabby-highlight|, highlight in back

    Return: ~
        Node |tabby-node|, sep node.

line.api                                                        *tabby.line.api*
    Tabby gathered some neovim lua api in this object. Maybe help you to build
    lines. Details: |tabby-api|.

Line Option

{
    tab_name = {
        name_fallback = function(tabid)
            return "fallback name"
        end
    },
    buf_name = {
        mode = "'unique'|'relative'|'tail'|'shorten'",
    }
}

tab_name

Use command Tabby rename_tab <tabname> to rename tab. Use tab.name() (ref: Tab) to add in your config. If no name provided, tab.name() will display fallback name. The default fallback name is current window's buffer name.

You can change the fallback by provide a function in opt.tab_name.name_fallback.

buf_name

There are four mode of buffer name. If current directory is "~/project" and there are three buffers:

  • "~/project/a_repo/api/user.py"
  • "~/project/b_repo/api/user.py"
  • "~/project/b_repo/api/admin.py"

the result of every mode are:

  • unique: "a_repo/api/user.py", "b_repo/api/user.py", "admin.py"
  • relative: "a_repo/api/user.py", "b_repo/api/user.py", "b_repo/api/admin.py"
  • tail: "user.py", "user.py", "admin.py"
  • shorten: "r/a/user.py", "r/b/user.py", "r/b/admin.py"

Tab

tab.id                                                            *tabby.tab.id*
    id of tab, tab handle for nvim api.

tab.current_win()                                       *tabby.ab.current_win()*

    Return: ~
        Win |tabby-win|, current window.

tab.wins()                                                    *tabby.tab.wins()*

    Return: ~
        An Array of Win |tabby-win|, current window.

tab.wins().foreach({callback})                      *tabby.tab.wins().foreach()*
    See |tabby.line.wins().foreach()|.

tab.number()                                                *tabby.tab.number()*

    Return: ~
        Number, tab's order, start from 1.

tab.is_current()                                        *tabby.tab.is_current()*

    Return: ~
        Boolean, if this tab is current tab.

tab.name()                                               *tabby.tabby.tab.name()*

    Return: ~
        String, tab name. If name is not set, use option
        ".tab_name.name_fallback()" in LineOption |tabby-line-option|.

tab.close_btn({symbol})                                  *tabby.tab.close_btn()*
    Make a close button of this tab.

    Parameters: ~
        {symbol}  String, a symbol of close button.

    Return: ~
        Node |tabby-node|, close button node.

Win

win.id                                                            *tabby.win.id*
    id of window, win handle for nvim api.

win.tab()                                                      *tabby.win.tab()*

    Return: ~
        Tab |tabby-tab|, tab of this window.

win.buf()                                                      *tabby.win.buf()*

    Return: ~
        Buf |tabby-buf|, buf of the window.

win.is_current()                                        *tabby.win.is_current()*

    Return: ~
        Boolean, if this window is current.

win.file_icon()                                          *tabby.win.file_icon()*
    Get file icon of filetype. You need to installed plugin
    'kyazdani42/nvim-web-devicons'.

    Return: ~
        Node |tabby-node|, file icon.

win.buf_name()                                                *tabby.win.name()*

    Return: ~
        String, buffer name of this window. You can specify the form by using
        option ".buf_name.mode" in LineOption |tabby-line-option|.

Buf

Object for buffer.

buf.id                                                            *tabby.buf.id*
    id of buffer, buffer handle for nvim api.


buf.is_changed()                                        *tabby.buf.is_changed()*
    Get if buffer is changed.

    Return: ~
        boolean, true if there are unwritten changes, false if not
        <https://neovim.io/doc/user/options.html#'buftype'> for details.


buf.type()                                                    *tabby.buf.type()*
    Get buftype option.

    Return: ~
        buftype, normal buffer is an empty string. check |buftype| or
        <https://neovim.io/doc/user/options.html#'buftype'> for details.

Node

Node is the rendered unit for tabby. Node is a recursive structure. It can be:

  • A string: "nvim"

  • A Number: 12

  • A table containing a Node or an array of Node, with an optional property 'hl' to set highlight. Example:

    -- node 1
    {
      "tab1", 100
      hl = "TabLineSel"
    }
    -- node 2
    {
      "text 1"
      {
          "text 2",
          hl = "Info",
      },
      "text3",
      hl = "Fill",
    }

Highlight

There are two ways to declare a highlight:

  • Use the name of neovim highlight group: "TabLineSel"
  • Define "background", "foreground" and "style" in lua table: { fg = "#000000", bg = "#ffffff" style = "bold" } . The "style" can be:
    • bold
    • underline
    • underlineline, double underline
    • undercurl, curly underline
    • underdot, dotted underline
    • underdash, dashed underline
    • strikethrough
    • italic

API

api.get_tabs()                                            *tabby.api.get_tabs()*
    Get all tab ids

api.get_tab_wins({tabid})                             *tabby.api.get_tab_wins()*
    Get an winid array in specified tabid.

api.get_current_tab()                              *tabby.api.get_current_tab()*
    Get current tab's id.

api.get_tab_current_win({tabid})               *tabby.api.get_tab_current_win()*
    Get tab's current win's id.

api.get_tab_number({tabid})                         *tabby.api.get_tab_number()*
    Get tab's number.

api.get_wins()                                            *tabby.api.get_wins()*
    Get all windows, except floating window.

api.get_win_tab({winid})                               *tabby.api.get_win_tab()*
    Get tab id of specified window.

api.is_float_win({winid})                             *tabby.api.is_float_win()*
    Return true if this window is floating.

api.is_not_float_win({winid})                     *tabby.api.is_not_float_win()*
    Return true if this window is not floating.

Use Presets

You can use presets for a quick start. The preset config uses nerdfont, and you should use a nerdfont-patched font to display that correctly.

To use preset, you can use use_preset({name}, {opt?}), for example:

require('tabby.tabline').use_preset('active_wins_at_tail', {
  theme = {
    fill = 'TabLineFill',       -- tabline background
    head = 'TabLine',           -- head element highlight
    current_tab = 'TabLineSel', -- current tab label highlight
    tab = 'TabLine',            -- other tab label highlight
    win = 'TabLine',            -- window highlight
    tail = 'TabLine',           -- tail element highlight
  },
  nerdfont = true,              -- whether use nerdfont
  lualine_theme = nil,          -- lualine theme name
  tab_name = {
    name_fallback = function(tabid)
      return tabid
    end,
  },
  buf_name = {
    mode = "'unique'|'relative'|'tail'|'shorten'",
  },

})

The {opt} is an optional parameter, including all option in Line Option. And has some extending options:

  • {theme}, the example shows the default value.
  • {nerdfont}, whether use nerdfont, default is true.
  • {lualine_theme}, use lualine theme to make theme. if theme is set, this option will be ignored. default is empty.

There are five {name} of presets:

  • active_wins_at_tail

    Put all windows' labels in active tabpage at end of whold tabline.

  • active_wins_at_end

    Put all windows' labels in active tabpage after all tags label. In-active tabpage's window won't display.

  • tab_with_top_win

    Each tab lab with a top window label followed. The top window is the focus window when you enter a tabpage.

  • active_tab_with_wins

    Active tabpage's windows' labels is displayed after the active tabpage's label.

  • tab_only

    No windows label, only tab. and use focus window to name tab

TODO

  • Custom click handler
  • Telescope support
  • Style option for presets
  • Expand tabby to support statusline and winbar
  • Git info and lsp info

tabby.nvim's People

Contributors

007psycho007 avatar anstadnik avatar chasinglogic avatar giluis avatar laxect avatar nanozuki avatar prince213 avatar pumpedsardines avatar ronitkrshah avatar vkondakoff avatar wvell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tabby.nvim's Issues

Tab label provider

  tab = {
    hl = tabby.hl:from('TabLine'),
    label = { '', tabby.tab.number, tabby.tab.name, tabby.tab.close_btn('x') },
    join = ' ',

Have buffers inside the tabline

I know that in the README, tabby.nvim is not supposed to be a buffers list but it also says that it is possible with low-level api...

Tabby.nvim focuses on a vim-style tab instead of buffers list, so tabby only displays the buffers in tabpage(although you can use low-level API to write a bufferline)

What would the configuration for this look like (assuming it's possible)?

Here's my config btw...

local filename = require('tabby.filename')
local util = require('tabby.util')

local hl_tabline = util.extract_nvim_hl('TabLine')
local hl_normal = util.extract_nvim_hl('Normal')
local hl_tabline_sel = util.extract_nvim_hl('TabLineSel')

local active_tab_hl = { fg = hl_normal.fg, bg = hl_normal.bg, style = 'bold' }
local inactive_tab_hl = { fg = hl_tabline.fg, bg = hl_tabline.bg }

local tabline = {
  hl = 'TabLineFill',
  layout = 'active_wins_at_tail',
  head = {
      { '', hl = { fg = hl_tabline_sel.fg, bg = hl_tabline_sel.bg, style = 'bold' } },
      { ' ', hl = 'TabLineFill' }
  },
  active_tab = {
    label = function(tabid)
      return {
        '' .. tabid .. '  ',
        hl = active_tab_hl,
      }
    end,
  },
  inactive_tab = {
    label = function(tabid)
      return {
        '' .. tabid .. '  ',
        hl = inactive_tab_hl,
      }
    end,
  },
  top_win = {
    label = function(winid)
      return {
          '' .. filename.unique(winid) .. ' ',
        hl = active_tab_hl
      }
    end,
    left_sep = { ' ', hl = 'TabLineFill' },
  },
  win = {
    label = function(winid)
      return {
          '' .. filename.unique(winid) .. ' ',
        hl = 'TabLine',
      }
    end,
    left_sep = { ' ', hl = 'TabLineFill' },
	},
}

require('tabby').setup{
	tabline = tabline,
}

It seems that the `line.spacer()` doesn't work correctly

DEMO

no_align.mov

Description

Notice that when I toggled between tabs 1 and 2, the position of 1 and 2 changed. I think the culprit is that when the length of the current buffername changed, the spacer seems to still add the same number of spaces. In the demo, since the buffername plugins.lua is longer than [No Name], both 1 and 2 were pushed more to the right.

The tab icon is incorrect

The icons in lualine and nvimtree is correct, but tabby not.

image

Another problem is, if enable ctrlspace plugin, no any icon show, like this:

image

Why it's `win.buf().id` not `win.buf.id`?

As title. First, I appreciate this beautiful plugin and have a good time doing the customization. But regarding the coding part, It took me some time debugging to realize that tabbywin.buf is actually a function instead of a field. That is, the working code looks kinda cumbersome:

line.wins_in_tab(line.api.get_current_tab()).foreach(function(win)
  if not vim.api.nvim_buf_get_option(win.buf().id, 'buflisted') then return {} end
--                                        ^here

(In this code I assumed win should mean tabby-win as per your documentation)


At first, this is more of an aesthetic problem with the code. But then I notice that your documentation also said tabby.buf.id. Could you elaborate more on this part?

Custom tab names don't persist across sessions

When renaming a tab through :TabRename, it won't persist after closing the editor and recovering the previous session. Instead, the default behavior is back, with the focused buffer's name as the tab name.

I don't actually know if it's possible to persist this information, I have very little insight into how vim sessions work.

Weird redraw issue when entering command mode

When entering command mode, the characters used for line.sep are all drawn with broken highlights until some sort of event later on causes it to get redrawn. Cannot figure out what could be causing this.
vim_normal
vim_command

Help: could not install Tabby properly

Hi!

I'm trying to install Tabby using the instructions (macOS, iTerm2, Neovim nightly, Packer).
Here is what I see after running :PackerInstall and :PackerCompile:
Снимок экрана 2021-10-06 в 13 11 07

And here is what I see after restarting Neovim:
Снимок экрана 2021-10-06 в 13 11 25

What am I doing wrong? (Quite a newbie here.)
Thanks!

Add a close tab icon

It would be nice to be able to close tabs using a close button, similar to how bufferline does it.

Here's an example showing what it looks like in bufferline (not my config):

image

Tabby + Treesitter: wrong tabs highlighting

Hi!

There is a wrong Tabby tabs highlighting if Treesitter is installed:
Снимок экрана 2021-10-10 в 01 30 39

If I comment out the Treesitter and recompile the Packer script the tabs are looking as usual:
Снимок экрана 2021-10-10 в 01 32 53

(macOS, iTerm2, Neovim nightly)

Backwards compatibility

Hello,

Thanks for the Tabby plugin 🙏

I created a custom tabline in my config but it no longer works with v2.
I do plan on upgrading to v2 eventually but I saw the readme mentions:

Tabby thinks it's essential to stay backward compatible! So even if Tabby releases a brand new 2.0, it will not break the 1.0 configuration.

I thought I might be missing something simple so until I have the time to learn the new API and upgrade my code, is there an easy way to make my config work with the new version?
Or should I just lock the plugin to v1 until I update my tabline code?

Thanks?

Hide windows showing non-file buffers

There are certain tool windows, like file browsers and issues lister, that show up in the window list but don't represent actual documents. It might make more sense to hide them from the window list. It could be an option. What do you think?


screenshot

In the preset, the color of the tab and the border color are inconsistent

image

enviroment:

Iterm2
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3

config:

  use {
      "nanozuki/tabby.nvim",
      config = function()
          require("tabby").setup({
                  tabline = require("tabby.presets").active_wins_at_tail,
              })
      end,
  }
-- theme
  use {
      "sainnhe/sonokai",
      requires = {
          'nvim-treesitter/nvim-treesitter'
      },
      config = function()
          vim.g.sonokai_style = "default"
          vim.g.sonokai_enable_italic = 1
          vim.cmd('colorscheme sonokai')
      end
  }

[Feature] Functions to expose window manager mappings

First off great plugin!

As a window manager user I see these tabs like workspaces. It would be great to have functions to manipulate tabs. For example selecting a tab based on a number. So you can map something like <leader>1 to jump to the first workspace. What are your thoughts on this?

Error when installing

When I run :PackerSync I get the following error.
packer.nvim: Error running config for tabby.nvim: vim/shared.lua:0: after the second argument: expected table, got nil

Here is my config.

  use { "nanozuki/tabby.nvim",
    requires = "kyazdani42/nvim-web-devicons",
    after = "nightfox.nvim",
    config = function()
      require("tabby").setup({})
    end
  }

Rename tabpage

Rename a tab page, and provide a tool function to get it.

Add buffer filter

Bufferline.nvim (docs) has filter option. Also it filter when you navigate between buffers (because of custom :BufferLineCycleNext command).
I know it's easy to make it. But I think it will really useful to make ready custom command and filter. I personally use it for nvim-dap (it create repl as buffer).

missing argument guibg=

Today after updating I got these error message:
Snipaste_2022-05-11_08-16-28

The error also appears with the default style.

Figured out, that hl.bg passes the vim.validate function (not nil) but is an empty string. Maybe we should check that too:

  if hl.bg ~= nil and hl.bg ~= "" then
    table.insert(cmd, 'guibg=' .. hl.bg)
  end

Doesn't use colours from Dracula theme

Somewhat surprisingly given how mature the Dracula theme is, it seems that tabby doesn't use colours from that theme, instead my tab bar has no selected tab highlights etc

Can confirm other themes work fine (e.g onedarkhalf).

Screenshot

Default tab style looks broken

The image shows the problem.

image

I'm using the nerd-fonts-jetbrains-mono font from the Arch User Repository, this same problem occurs in VTE based terminals, as well as in alacritty and konsole.

Using ttf-nerd-fonts-symbols from the Arch repos shows a similar problem with the glyphs:

image

Using other nerd font patched fonts like hack shows yet the same problem.

File icon

How can I config to show file icon on tabs.

Add option to choose truncate mode

Thanks for the great plugin, really enjoy it.

Currently when the screen width is too short the tabline is truncated on the left side, hiding the tabs. I would prefer to truncate the windows list instead. Is it possible? If not, can it be added?
A more global solutions, I'm thinking about, would be giving each tabline chunk some truncation priority field.
What do you think?

Utils library

Provide a easy way to get useful information to render tabline.

Move assets folder into Wiki section

Since most plugin managers clone the git repository they should not have to download the assets of the plugin.

One solution is to move the assets to the built in wiki section of the GitHub repository. Since this is a separate repo the users don't have to download the assets, and you can still link to the files in the readme.

Either that or open an issue/pr and use that to upload images there and link to them.

Great plugin and it was an instant add to my config. Was thinking of writing one glad you did!

no-nerd-font-example.lua: wrong tabs renumbering

Hi!

It seems there is wrong tab renumbering when using the 'no-nerd-font-example.lua' example.
Here are the screenshots:

  1. I'm opening an empty Neovim (the tab 1 was added automatically):

Снимок экрана 2021-10-11 в 02 08 44

  1. I'm creating second tab with :tabnew:

Снимок экрана 2021-10-11 в 02 09 18

  1. I'm switching back to the tab 1 using 'gt':

Снимок экрана 2021-10-11 в 02 09 41

  1. I'm deleting the tab 1 using :tabc. Note, the tab 2 was not renamed to 1:

Снимок экрана 2021-10-11 в 02 09 52

  1. I'm creating another tab with :tabnew. Now there are tabs 2 and 3, while I'm expecting to see tabs 1 and 2:

Снимок экрана 2021-10-11 в 02 10 03

As far as I remember this issue is not reproducible when you use the 'Nerd-fonts' Tabby. Is this a specific 'no-nerd-font-example.lua' bug? Can you reproduce this?

Filter certain window labels / titles from appering in the bar

A filter config key for certain windows to hide from the bar would be an useful addition.

An example would be the 'index' window label, when opening fugitives git status with :G or terminal window labels the user does not deem as valuable.

2021-12-28-140450_1501x70_scrot

On this pic, only the '[No name]' window label is useful to me.

Scrollable?

Really love this pure tab plugin. I hate bufferline.

Are you planning to support scrollable feature just in case the tabs are too many or too long that cannot fit into the screen?

Thank you so much.

Small typo in README

Examples and Gallary

These are some awesome exmaples shared by tabby.nvim users! Also welcome to share your own!

[Bug] Not finding tabby modules

Upon running require('tabby.filename') and require('tabby.util'), I get the errors module 'tabby.filename' not found and module 'tabby.util' not found.

Is that a bug or were they removed?

Window label provider

  win = {
    hl = tabby.hl:from('TabLine'),
    label = { '', tabby.win.name:unique() },
  • improve win's name API to support chain calling

[Feature Request] Option to show tabline only if there are 'n' tabs open

Currently, tabby will show the tabline even when there's only one tab open. It'd be nice if you had the option to show it only when there are multiple tabs open, the same way it works with the vanilla one.

I think this could be implemented as an option like show_when_n_or_more_tabs. With the default 1, it'd always show the tabline. However when changed to 2, it'd only show the tabline when you have 2 or more tabs open, and changing to 3 would only show when there are 3 or more open.

[Bug] highlight group not found: TabbyHl___

I'm getting an error when starting tabby:

Error detected while processing function TabbyTabline:                                                                                          
line    1:                                                                                                                                      
E5108: Error executing lua ...packer/start/tabby.nvim/lua/tabby/internal/highlight.lua:29: Vim(highlight):E411: highlight group not found: TabbyHl___                                                                                                                                           
stack traceback:                                                                                                                                
        [C]: in function 'cmd'                                                                                                                  
        ...packer/start/tabby.nvim/lua/tabby/internal/highlight.lua:29: in function 'register'                                                  
        ...ck/packer/start/tabby.nvim/lua/tabby/internal/render.lua:93: in function 'highlight'                                                 
        ...ck/packer/start/tabby.nvim/lua/tabby/internal/render.lua:67: in function 'frag'                                                      
        ...ck/packer/start/tabby.nvim/lua/tabby/internal/render.lua:24: in function 'node'                                                      
        ...ck/packer/start/tabby.nvim/lua/tabby/internal/render.lua:65: in function
<...ck/packer/start/tabby.nvim/lua/tabby/internal/render.lua:57>                                                                                                                                            
        vim/shared.lua: in function 'tbl_map'                                                                                                   
        .../site/pack/packer/start/tabby.nvim/lua/tabby/tabline.lua:146: in function 'update'                                                   
        [string "luaeval()"]:1: in main chunk

It's quite inconsistent. It only happens on some startups, in others it just runs fine (feels like 50/50 chance). When the error happens, the tabline does not load correctly. Here's some screenshots of how the tab normally looks like, and how it looks like with the error:
normal
buggy

This is my full config:

local filename = require('tabby.filename')
local util = require('tabby.util')

local hl_tabline = util.extract_nvim_hl('TabLine')
local hl_tabline_sel = util.extract_nvim_hl('TabLineSel')
local hl_tabline_fill = util.extract_nvim_hl('TabLineFill')

local function tab_label(tabid, active)
	local icon = active and '' or ''
	local number = vim.api.nvim_tabpage_get_number(tabid)
local name = util.get_tab_name(tabid)
	if active then
		return string.format(' %s %d: %s ', icon, number, name)
	else
		return string.format(' %s %d ', icon, number)
	end
end

local tabline = {
	hl = 'TabLineFill',
	layout = 'tab_only',
	head = {
		{ '', hl = { fg = hl_tabline.fg, bg = hl_tabline.bg } },
		{ '', hl = { fg = hl_tabline.bg, bg = hl_tabline_fill.bg } },
	},
	active_tab = {
		label = function(tabid)
			return {
				tab_label(tabid, true),
				hl = { fg = hl_tabline_sel.fg, bg = hl_tabline_sel.bg, style = 'bold' },
			}
		end,
		left_sep = { '', hl = { fg = hl_tabline_sel.bg, bg = hl_tabline_fill.bg } },
		right_sep = { '', hl = { fg = hl_tabline_sel.bg, bg = hl_tabline_fill.bg } },
	},
	inactive_tab = {
		label = function(tabid)
			return {
				tab_label(tabid, false),
				hl = { fg = hl_tabline.fg, bg = hl_tabline.bg, style = 'bold' },
			}
		end,
		left_sep = { '', hl = { fg = hl_tabline_fill.bg, bg = hl_tabline_fill.bg } },
		right_sep = { '', hl = { fg = hl_tabline_fill.bg, bg = hl_tabline_fill.bg } },
	},
	top_win = {
		label = function(winid)
			return {
				--' > ' .. filename.unique(winid) .. ' ',
				'',
				hl = 'TabLine',
			}
		end,
		left_sep = { ' ', hl = 'TabLineFill' },
	},
	win = {
		label = function(winid)
			return {
				--' - ' .. filename.unique(winid) .. ' ',
				'',
				hl = 'TabLine',
			}
		end,
		left_sep = { ' ', hl = 'TabLineFill' },
	},
}

require('tabby').setup({
	tabline = tabline,
})

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.