detect current by index

This commit is contained in:
Otávio Schwanck dos Santos 2023-05-20 18:13:03 +01:00
parent fef97d4439
commit 91666776ff

View file

@ -32,20 +32,21 @@ end
function M.setup(opts)
function _G.tabline()
local original_tabs = require('harpoon').get_mark_config().marks
local tabs = shorten_filenames(original_tabs)
local tabs = shorten_filenames(require('harpoon').get_mark_config().marks)
local tabline = ''
for i, tab in ipairs(original_tabs) do
local is_current = string.match(vim.fn.bufname(), tab.filename) or vim.fn.bufname() == tab.filename
local index = require('harpoon.mark').get_index_of(vim.fn.bufname())
for i, tab in ipairs(tabs) do
local is_current = i == index
local label
if tabs[i].filename == "" or tabs[i].filename == "(empty)" then
if tab.filename == "" or tab.filename == "(empty)" then
label = "(empty)"
is_current = false
else
label = tabs[i].filename
label = tab.filename
end
@ -58,6 +59,7 @@ function M.setup(opts)
end
tabline = tabline .. label .. (opts.tabline_suffix or ' ') .. '%*'
if i < #tabs then
tabline = tabline .. '%T'
end