--- Personal lua config files for NeoVim. -- Last Changed: 2019-01-27 -- Author: Federico Igne -- License: This file is placed in the public domain. -- Use name in `t:tablabel` or fall back to the name of the current -- working directory. local function tablabel(i, t) local ok, label = pcall(vim.api.nvim_tabpage_get_var, t, 'tablabel') if not ok then label = vim.fn.fnamemodify(vim.fn.getcwd(-1, i), ':t') end return label end --- Generate simple tabline that supports custom naming. -- -- To set the name for a specific tab run -- -- :let t:tablabel = -- -- This variable persists across sessions local function tabline() local line = '' local current = vim.api.nvim_get_current_tabpage() local tabpages = vim.api.nvim_list_tabpages() for i, t in pairs(tabpages) do local modified = false local windows = vim.api.nvim_tabpage_list_wins(t) local nwin = 0 for _,w in pairs(windows) do if vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(w), 'modified') then modified = true end nwin = nwin + 1 end if t == current then if modified then line = line .. '%4*' else line = line .. '%3*' end else line = line .. '%#TabLine#' end -- Start tabpage label with number indicator line = line .. '%' .. i .. 'T ' .. i -- Modified label if modified then line = line .. '+' end -- Get tabpage label line = line .. ' ' if t == current then line = line .. '▏' end line = line .. tablabel(i, t) .. ' [' .. nwin .. '] ' end -- Fill with TabLineFill and reset tabpage label line = line .. '%#TabLineFill#%T' return line end return tabline