feat: config option to customize floating window title (#482)

* replace cwd path in actual path

* move get_title to utils

* add documentation

* rename

* add method doc

* add comment

* fallback to 0 for winid

* add missing property definition for relative_win_title

* only replace when at the start of the path

* simplify

* minor change

* add entry point to customize floating window title for oil-buffer

* remove config parameter

* cleanup

* add documentation

* move get_win_title to top and pass winid as parameter

* add get_win_title to type definition for oil.setup

* remove empty line

* adjust comment

---------

Co-authored-by: Philipp Oeschger <philippoeschger@Philipps-Air.fritz.box>
This commit is contained in:
Philipp Oeschger 2024-10-16 04:22:31 +02:00 committed by GitHub
parent ccab9d5e09
commit 5d2dfae655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 27 deletions

View file

@ -288,19 +288,6 @@ M.open_float = function(dir)
})
)
---Recalculate the window title for the current buffer
local function get_title()
local src_buf = vim.api.nvim_win_get_buf(winid)
local title = vim.api.nvim_buf_get_name(src_buf)
local scheme, path = util.parse_url(title)
if config.adapters[scheme] == "files" then
assert(path)
local fs = require("oil.fs")
title = vim.fn.fnamemodify(fs.posix_to_os_path(path), ":~")
end
return title
end
table.insert(
autocmds,
vim.api.nvim_create_autocmd("BufWinEnter", {
@ -324,7 +311,7 @@ M.open_float = function(dir)
col = cur_win_opts.col,
width = cur_win_opts.width,
height = cur_win_opts.height,
title = get_title(),
title = util.get_title(winid),
})
end
end,