Skip to content

Commit

Permalink
feat(popups): Add title formatting option (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywrayuk authored Nov 24, 2024
1 parent 4ba04f6 commit 28f1317
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 5 additions & 3 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1792,9 +1792,11 @@ Popups will be created with a |filetype| of `neo-tree-popup`. You can use this
as the target for autocmds or to exclude them from being acted upon by other
plugins.

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

Expand Down
3 changes: 3 additions & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ local config = {
width = "50%",
},
position = "50%", -- 50% means center it
title = function (state) -- format the text that appears at the top of a popup window
return "Neo-tree " .. state.name:gsub("^%l", string.upper)
end,
-- you can also specify border here, if you want a different setting from
-- the global popup_border_style.
},
Expand Down
10 changes: 8 additions & 2 deletions lua/neo-tree/ui/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,14 @@ local function create_floating_window(state, win_options, bufname)
local win
state.force_float = nil
-- First get the default options for floating windows.
local sourceTitle = state.name:gsub("^%l", string.upper)
win_options = popups.popup_options("Neo-tree " .. sourceTitle, 40, win_options)
local title = utils.resolve_config_option(
state,
"window.popup.title",
function (current_state)
return "Neo-tree " .. current_state.name:gsub("^%l", string.upper)
end
)
win_options = popups.popup_options(title, 40, win_options)
win_options.win_options = nil
win_options.zindex = 40

Expand Down

0 comments on commit 28f1317

Please sign in to comment.