mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat(lualine): show readonly icon (#3567)
Adds a configurable lock icon when a file is opened as read only. Mimics `vi -R <file>` status line.
This commit is contained in:
parent
f5dc867ac2
commit
21617a9d60
1 changed files with 8 additions and 2 deletions
|
@ -72,7 +72,7 @@ function M.format(component, text, hl_group)
|
||||||
return component:format_hl(lualine_hl_group) .. text .. component:get_default_hl()
|
return component:format_hl(lualine_hl_group) .. text .. component:get_default_hl()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts? {relative: "cwd"|"root", modified_hl: string?, directory_hl: string?, filename_hl: string?}
|
---@param opts? {relative: "cwd"|"root", modified_hl: string?, directory_hl: string?, filename_hl: string?, modified_sign: string?, readonly_icon: string?, length: number?}
|
||||||
function M.pretty_path(opts)
|
function M.pretty_path(opts)
|
||||||
opts = vim.tbl_extend("force", {
|
opts = vim.tbl_extend("force", {
|
||||||
relative = "cwd",
|
relative = "cwd",
|
||||||
|
@ -80,6 +80,7 @@ function M.pretty_path(opts)
|
||||||
directory_hl = "",
|
directory_hl = "",
|
||||||
filename_hl = "Bold",
|
filename_hl = "Bold",
|
||||||
modified_sign = "",
|
modified_sign = "",
|
||||||
|
readonly_icon = " ",
|
||||||
length = 3,
|
length = 3,
|
||||||
}, opts or {})
|
}, opts or {})
|
||||||
|
|
||||||
|
@ -120,7 +121,12 @@ function M.pretty_path(opts)
|
||||||
dir = table.concat({ unpack(parts, 1, #parts - 1) }, sep)
|
dir = table.concat({ unpack(parts, 1, #parts - 1) }, sep)
|
||||||
dir = M.format(self, dir .. sep, opts.directory_hl)
|
dir = M.format(self, dir .. sep, opts.directory_hl)
|
||||||
end
|
end
|
||||||
return dir .. parts[#parts]
|
|
||||||
|
local readonly = ""
|
||||||
|
if vim.bo.readonly then
|
||||||
|
readonly = M.format(self, opts.readonly_icon, opts.modified_hl)
|
||||||
|
end
|
||||||
|
return dir .. parts[#parts] .. readonly
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue