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

36 lines
976 B
Lua
Raw Normal View History

-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local function filename(options)
-- setting defaults
2021-02-20 15:59:28 +00:00
if options.file_status == nil then options.file_status = true end
if options.shorten == nil then options.shorten = true end
if options.full_path == nil then options.full_path = false end
return function()
local data
2021-02-20 15:59:28 +00:00
if not options.full_path then
data = vim.fn.expand('%:t')
2021-02-20 15:59:28 +00:00
elseif options.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
2021-02-20 15:59:28 +00:00
if options.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}