Skip to content

Commit 28f1317

Browse files
authored
feat(popups): Add title formatting option (#1603)
1 parent 4ba04f6 commit 28f1317

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Diff for: doc/neo-tree.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1792,9 +1792,11 @@ Popups will be created with a |filetype| of `neo-tree-popup`. You can use this
17921792
as the target for autocmds or to exclude them from being acted upon by other
17931793
plugins.
17941794

1795-
They can also be configured by setting the `popup_border_style` in your config,
1796-
and the colors of that border are controlled by the `NeoTreeFloatBorder`
1797-
highlight group. If you you use the special `NC` option for
1795+
They can also be configured by setting the `popup_border_style` in your config.
1796+
To modify the title bar text that appears on a popup window, use
1797+
the `window.popup.title` config option to define a function mapping the window
1798+
state to a string. The colors of the popup border are controlled by the
1799+
`NeoTreeFloatBorder` highlight group.If you you use the special `NC` option for
17981800
`popup_border_style`, the title bar of that popup uses the `NeoTreeTitleBar`
17991801
highlight group.
18001802

Diff for: lua/neo-tree/defaults.lua

+3
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ local config = {
356356
width = "50%",
357357
},
358358
position = "50%", -- 50% means center it
359+
title = function (state) -- format the text that appears at the top of a popup window
360+
return "Neo-tree " .. state.name:gsub("^%l", string.upper)
361+
end,
359362
-- you can also specify border here, if you want a different setting from
360363
-- the global popup_border_style.
361364
},

Diff for: lua/neo-tree/ui/renderer.lua

+8-2
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,14 @@ local function create_floating_window(state, win_options, bufname)
880880
local win
881881
state.force_float = nil
882882
-- First get the default options for floating windows.
883-
local sourceTitle = state.name:gsub("^%l", string.upper)
884-
win_options = popups.popup_options("Neo-tree " .. sourceTitle, 40, win_options)
883+
local title = utils.resolve_config_option(
884+
state,
885+
"window.popup.title",
886+
function (current_state)
887+
return "Neo-tree " .. current_state.name:gsub("^%l", string.upper)
888+
end
889+
)
890+
win_options = popups.popup_options(title, 40, win_options)
885891
win_options.win_options = nil
886892
win_options.zindex = 40
887893

0 commit comments

Comments
 (0)