mirror of
https://github.com/ThePrimeagen/harpoon
synced 2024-09-16 21:44:02 +02:00
Merge pull request #290 from otavioschwanck/feat/redraw-tabline
feat: redraw tabline
This commit is contained in:
commit
21f4c47c68
2 changed files with 22 additions and 6 deletions
|
@ -11,10 +11,17 @@ local callbacks = {}
|
|||
-- need one event emitted
|
||||
local function emit_changed()
|
||||
log.trace("_emit_changed()")
|
||||
if harpoon.get_global_settings().save_on_change then
|
||||
|
||||
local global_settings = harpoon.get_global_settings()
|
||||
|
||||
if global_settings.save_on_change then
|
||||
harpoon.save()
|
||||
end
|
||||
|
||||
if global_settings.tabline then
|
||||
vim.cmd("redrawt")
|
||||
end
|
||||
|
||||
if not callbacks["changed"] then
|
||||
log.trace("_emit_changed(): no callbacks for 'changed', returning")
|
||||
return
|
||||
|
|
|
@ -32,14 +32,22 @@ 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())
|
||||
|
||||
local label = tabs[i].filename
|
||||
for i, tab in ipairs(tabs) do
|
||||
local is_current = i == index
|
||||
|
||||
local label
|
||||
|
||||
if tab.filename == "" or tab.filename == "(empty)" then
|
||||
label = "(empty)"
|
||||
is_current = false
|
||||
else
|
||||
label = tab.filename
|
||||
end
|
||||
|
||||
|
||||
if is_current then
|
||||
|
@ -51,6 +59,7 @@ function M.setup(opts)
|
|||
end
|
||||
|
||||
tabline = tabline .. label .. (opts.tabline_suffix or ' ') .. '%*'
|
||||
|
||||
if i < #tabs then
|
||||
tabline = tabline .. '%T'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue