mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
detect current by index
This commit is contained in:
parent
fef97d4439
commit
91666776ff
@ -32,20 +32,21 @@ end
|
|||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
function _G.tabline()
|
function _G.tabline()
|
||||||
local original_tabs = require('harpoon').get_mark_config().marks
|
local tabs = shorten_filenames(require('harpoon').get_mark_config().marks)
|
||||||
local tabs = shorten_filenames(original_tabs)
|
|
||||||
local tabline = ''
|
local tabline = ''
|
||||||
|
|
||||||
for i, tab in ipairs(original_tabs) do
|
local index = require('harpoon.mark').get_index_of(vim.fn.bufname())
|
||||||
local is_current = string.match(vim.fn.bufname(), tab.filename) or vim.fn.bufname() == tab.filename
|
|
||||||
|
for i, tab in ipairs(tabs) do
|
||||||
|
local is_current = i == index
|
||||||
|
|
||||||
local label
|
local label
|
||||||
|
|
||||||
if tabs[i].filename == "" or tabs[i].filename == "(empty)" then
|
if tab.filename == "" or tab.filename == "(empty)" then
|
||||||
label = "(empty)"
|
label = "(empty)"
|
||||||
is_current = false
|
is_current = false
|
||||||
else
|
else
|
||||||
label = tabs[i].filename
|
label = tab.filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
tabline = tabline .. label .. (opts.tabline_suffix or ' ') .. '%*'
|
tabline = tabline .. label .. (opts.tabline_suffix or ' ') .. '%*'
|
||||||
|
|
||||||
if i < #tabs then
|
if i < #tabs then
|
||||||
tabline = tabline .. '%T'
|
tabline = tabline .. '%T'
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user