Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(popups): Add title formatting option #1603

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading