Skip to content

Commit d3aa6e8

Browse files
authored
feat: enable title for floating terminals (#534)
1 parent e3805fe commit d3aa6e8

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ require("toggleterm").setup{
209209
height = <value>,
210210
winblend = 3,
211211
zindex = <value>,
212+
title_pos = 'left' | 'center' | 'right', position of the title of the floating window
212213
},
213214
winbar = {
214215
enabled = false,

doc/toggleterm.txt

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ what options are available. It is not written to be used as is.
195195
height = <value>,
196196
winblend = 3,
197197
zindex = <value>,
198+
title_pos = 'left' | 'center' | 'right', position of the title of the floating window
198199
},
199200
winbar = {
200201
enabled = false,

lua/toggleterm/config.lua

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ local function shade(color, factor) return colors.shade_color(color, factor) end
3434
--- @field highlights ToggleTermHighlights
3535
--- @field winbar WinbarOpts
3636
--- @field autochdir boolean
37+
--- @field title_pos '"left"' | '"center"' | '"right"'
3738

3839
---@type ToggleTermConfig
3940
local config = {
@@ -58,6 +59,7 @@ local config = {
5859
},
5960
float_opts = {
6061
winblend = 0,
62+
title_pos = 'left'
6163
},
6264
}
6365

lua/toggleterm/ui.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ function M._get_float_config(term, opening)
285285
row = vim.F.if_nil(M._resolve_size(opts.row, term), row)
286286
col = vim.F.if_nil(M._resolve_size(opts.col, term), col)
287287

288-
return {
288+
local version = vim.version()
289+
290+
local float_config = {
289291
row = row,
290292
col = col,
291293
relative = opts.relative or "editor",
@@ -295,6 +297,11 @@ function M._get_float_config(term, opening)
295297
border = opening and border or nil,
296298
zindex = opts.zindex or nil,
297299
}
300+
if version.major > 0 or version.minor >= 9 then
301+
float_config.title_pos = term.display_name and opts.title_pos or nil
302+
float_config.title = term.display_name
303+
end
304+
return float_config
298305
end
299306

300307
--- @param size number

0 commit comments

Comments
 (0)