feat(nvim): use terminal icon override in statusline

This commit is contained in:
Price Hiller 2023-09-05 11:48:39 -05:00
parent 3e707923a7
commit 72e9878db6
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -140,16 +140,30 @@ return {
init = function(self) init = function(self)
local filename = self.filename local filename = self.filename
local extension = vim.fn.fnamemodify(filename, ":e") local extension = vim.fn.fnamemodify(filename, ":e")
local buftype = vim.api.nvim_get_option_value("buftype", {
buf = self.bufnr
})
self.icon, self.icon_color = self.icon, self.icon_color =
require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) require("nvim-web-devicons").get_icon_color(filename, extension, { default = true })
local overrides = { local ft_overrides = {
["rs"] = "", ["rs"] = { icon = "", icon_color = self.icon_color },
} }
local override = overrides[extension] local buftype_overrides = {
if override ~= nil then ["terminal"] = { icon = "", icon_color = colors.roninYellow }
self.icon = override }
local ft_override = ft_overrides[extension]
if ft_override ~= nil then
self.icon = ft_override.icon
self.icon_color = ft_override.icon_color
end
local buftype_override = buftype_overrides[buftype]
if buftype_override ~= nil then
self.icon = buftype_override.icon
self.icon_color = buftype_override.icon_color
end end
end, end,
provider = function(self) provider = function(self)
@ -163,14 +177,15 @@ return {
local FileName = { local FileName = {
provider = function(self) provider = function(self)
local filename = "" local filename = ""
if self.filename:match("^term://.*") then local buftype = vim.api.nvim_get_option_value("buftype", {
local term_name = "" buf = self.bufnr
})
if buftype == "terminal" then
local subs = 0 local subs = 0
term_name, subs = self.filename:gsub(".*;", "") filename, subs = self.filename:gsub(".*;", "")
if subs == 0 then if subs == 0 then
term_name = self.filename:gsub(".*:", "") filename = self.filename:gsub(".*:", "")
end end
filename = term_name .. ""
else else
---@diagnostic disable-next-line: cast-local-type ---@diagnostic disable-next-line: cast-local-type
filename = vim.fn.fnamemodify(self.filename, ":~:.") filename = vim.fn.fnamemodify(self.filename, ":~:.")
@ -320,13 +335,7 @@ return {
return not vim.api.nvim_buf_get_option(self.bufnr, "modifiable") return not vim.api.nvim_buf_get_option(self.bufnr, "modifiable")
or vim.api.nvim_buf_get_option(self.bufnr, "readonly") or vim.api.nvim_buf_get_option(self.bufnr, "readonly")
end, end,
provider = function(self) provider = "",
if vim.api.nvim_buf_get_option(self.bufnr, "buftype") == "terminal" then
return ""
else
return ""
end
end,
hl = { fg = colors.roninYellow }, hl = { fg = colors.roninYellow },
}, },
} }