lualine.nvim/lua/lualine/components/filename.lua

35 lines
1009 B
Lua
Raw Normal View History

-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local function filename(options)
-- setting defaults
local file_status, shorten, full_path = true, true, false
if options.file_status ~= nil then file_status = options.file_status end
if options.shorten ~= nil then shorten = options.shorten end
if options.full_path ~= nil then full_path = options.full_path end
return function()
local data
2021-02-16 17:35:56 +00:00
if not full_path then
data = vim.fn.expand('%:t')
2021-02-16 17:35:56 +00:00
elseif shorten then
data = vim.fn.expand('%')
2021-02-16 17:35:56 +00:00
else
data = vim.fn.expand('%:p')
end
if data == '' then
data = '[No Name]'
elseif vim.fn.winwidth(0) <= 84 or #data > 40 then
data = vim.fn.pathshorten(data)
end
if file_status then
if vim.bo.modified then data = data .. "[+]"
elseif vim.bo.modifiable == false then data = data .. "[-]" end
end
return data
end
2020-12-30 14:48:51 +00:00
end
return { init = function(options) return filename(options) end }