From 395d7cbb69445b393ecae29e2eb7cd8adb11a0d9 Mon Sep 17 00:00:00 2001 From: Shadman Date: Tue, 16 Feb 2021 23:35:56 +0600 Subject: [PATCH] fix: filename component --- README.md | 5 +++-- doc/lualine.txt | 5 +++-- lua/lualine/components/filename.lua | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bd87fbd..258f923 100644 --- a/README.md +++ b/README.md @@ -257,11 +257,12 @@ lualine.sections.lualine_b = { { 'filename', full_name = true, - relative = true, + shorten = true, format = function(name) -- Capitalize first charecter of filename to capital. local path, fname = name:match('(.*/)(.*)') - rerurn path .. fname[1, 1]:upper() .. fname[2, #fname] + if not path then path = ''; fname = name end + return path .. fname:sub(1, 1):upper() .. fname:sub(2, #fname) end } } diff --git a/doc/lualine.txt b/doc/lualine.txt index c836387..c7440ee 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -293,11 +293,12 @@ Example:~ { 'filename', full_name = true, - relative = true, + shorten = true, format = function(name) -- Capitalize first charecter of filename to capital. local path, fname = name:match('(.*/)(.*)') - rerurn path .. fname[1, 1]:upper() .. fname[2, #fname] + if not path then path = ''; fname = name end + return path .. fname:sub(1, 1):upper() .. fname:sub(2, #fname) end } } diff --git a/lua/lualine/components/filename.lua b/lua/lualine/components/filename.lua index c951ead..a0ca979 100644 --- a/lua/lualine/components/filename.lua +++ b/lua/lualine/components/filename.lua @@ -10,12 +10,12 @@ local function filename(options) return function() local data - if shorten then + if not full_path then data = vim.fn.expand('%:t') - elseif full_path then - data = vim.fn.expand('%:p') - else + elseif shorten then data = vim.fn.expand('%') + else + data = vim.fn.expand('%:p') end if data == '' then data = '[No Name]'