2021-02-15 18:09:12 +00:00
|
|
|
-- Copyright (c) 2020-2021 shadmansaleh
|
2021-02-13 00:03:57 +00:00
|
|
|
-- MIT license, see LICENSE for more details.
|
2021-02-15 18:09:12 +00:00
|
|
|
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
|
2021-02-15 18:09:12 +00:00
|
|
|
|
|
|
|
return function()
|
|
|
|
local data
|
2021-02-20 15:59:28 +00:00
|
|
|
if not options.full_path then
|
2021-02-15 18:09:12 +00:00
|
|
|
data = vim.fn.expand('%:t')
|
2021-02-20 15:59:28 +00:00
|
|
|
elseif options.shorten then
|
2021-03-31 14:47:38 +00:00
|
|
|
data = vim.fn.expand('%:~:.')
|
2021-02-16 17:35:56 +00:00
|
|
|
else
|
|
|
|
data = vim.fn.expand('%:p')
|
2021-02-15 18:09:12 +00:00
|
|
|
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
|
2021-03-15 23:37:46 +00:00
|
|
|
if vim.bo.modified then
|
|
|
|
data = data .. '[+]'
|
2021-03-28 01:38:47 +00:00
|
|
|
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
|
2021-03-15 23:37:46 +00:00
|
|
|
data = data .. '[-]'
|
|
|
|
end
|
2021-02-15 18:09:12 +00:00
|
|
|
end
|
|
|
|
return data
|
|
|
|
end
|
2020-12-30 14:48:51 +00:00
|
|
|
end
|
|
|
|
|
2021-03-15 23:37:46 +00:00
|
|
|
return {init = function(options) return filename(options) end}
|