37 lines
962 B
Lua
37 lines
962 B
Lua
local M = require("lualine.component"):extend()
|
|
|
|
function M:init(opts)
|
|
M.super.init(self, opts)
|
|
|
|
local color = opts.color or {}
|
|
local modified = { gui = "italic" }
|
|
|
|
self.custom_highlights = { -- [is_focused, modified]
|
|
[true] = {
|
|
[true] = self:create_hl(vim.tbl_extend("force", color, modified), "focus_modified"),
|
|
[false] = self:create_hl(color, "focus"),
|
|
},
|
|
[false] = {
|
|
[true] = self:create_hl(modified, "nofocus_modified"),
|
|
[false] = self:create_hl({}, "nofocus"),
|
|
},
|
|
}
|
|
end
|
|
|
|
local window = require("fschauen.window")
|
|
|
|
function M:update_status(is_focused)
|
|
self.options.color_highlight = self.custom_highlights[is_focused][vim.bo.modified]
|
|
|
|
local path = vim.fn.expand("%:~:.")
|
|
|
|
if window.is_wide() then
|
|
return path
|
|
elseif window.is_medium() then
|
|
return vim.fn.pathshorten(path) -- only first letter of directories
|
|
else
|
|
return vim.fn.fnamemodify(path, ":t") -- only tail
|
|
end
|
|
end
|
|
|
|
return M
|