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
|
|
|
|
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
|
2021-02-15 18:09:12 +00:00
|
|
|
data = vim.fn.expand('%:t')
|
2021-02-16 17:35:56 +00:00
|
|
|
elseif shorten then
|
2021-02-15 18:09:12 +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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-02-15 18:09:12 +00:00
|
|
|
return { init = function(options) return filename(options) end }
|