feat(nvim): make heirline format terminal fts better

This commit is contained in:
Price Hiller 2023-09-05 11:00:18 -05:00
parent 04bfe7e9b1
commit 3e707923a7
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -162,17 +162,21 @@ return {
local FileName = { local FileName = {
provider = function(self) provider = function(self)
-- first, trim the pattern relative to the current directory. For other local filename = ""
-- options, see :h filename-modifers if self.filename:match("^term://.*") then
local filename = vim.fn.fnamemodify(self.filename, ":.") local term_name = ""
if filename == "" then local subs = 0
return "[No Name]" term_name, subs = self.filename:gsub(".*;", "")
if subs == 0 then
term_name = self.filename:gsub(".*:", "")
end
filename = term_name .. ""
else
---@diagnostic disable-next-line: cast-local-type
filename = vim.fn.fnamemodify(self.filename, ":~:.")
end end
-- now, if the filename would occupy more than 1/4th of the available if filename == "" then
-- space, we trim the file path to its initials filename = "[No Name]"
-- See Flexible Components section below for dynamic truncation
if not conditions.width_percent_below(#filename, 0.25) then
filename = vim.fn.pathshorten(filename)
end end
return filename return filename
end, end,
@ -269,7 +273,11 @@ return {
-- we redefine the filename component, as we probably only want the tail and not the relative path -- we redefine the filename component, as we probably only want the tail and not the relative path
local StatusLineFileName = { local StatusLineFileName = {
init = function(self) init = function(self)
self.lfilename = vim.fn.fnamemodify(self.filename, ":~:.") if self.filename:match("^term://.*") then
self.lfilename = self.filename:gsub(".*:", "")
else
self.lfilename = vim.fn.fnamemodify(self.filename, ":~:.")
end
if self.lfilename == "" then if self.lfilename == "" then
self.lfilename = "[No Name]" self.lfilename = "[No Name]"
end end
@ -422,7 +430,7 @@ return {
StatusLineBufferBlock, StatusLineBufferBlock,
{ provider = "", hl = { fg = colors.katanaGray } }, -- left truncation, optional (defaults to "<") { provider = "", hl = { fg = colors.katanaGray } }, -- left truncation, optional (defaults to "<")
{ provider = "", hl = { fg = colors.katanaGray } } -- right trunctation, also optional (defaults to ...... yep, ">") { provider = "", hl = { fg = colors.katanaGray } } -- right trunctation, also optional (defaults to ...... yep, ">")
-- by the way, open a lot of buffers and try clicking them ;) -- by the way, open a lot of buffers and try clicking them ;)
) )
local Tabpage = { local Tabpage = {
@ -528,7 +536,7 @@ return {
bg = colors.sumiInk2 bg = colors.sumiInk2
end end
return { fg = colors.oniViolet, bg = bg} return { fg = colors.oniViolet, bg = bg }
end end
}, },
}, },
@ -556,7 +564,7 @@ return {
return { fg = colors.oniViolet2, bg = bg } return { fg = colors.oniViolet2, bg = bg }
end, end,
}, },
} }
}, },
{ {
condition = conditions.has_diagnostics, condition = conditions.has_diagnostics,