From 1cfde5ae064fa2a7747ce3e959eff4fa0478b237 Mon Sep 17 00:00:00 2001 From: max397574 Date: Tue, 19 Oct 2021 18:20:46 +0200 Subject: =?UTF-8?q?feat(utils):=20=E2=9C=A8added=20function=20for=20oldfil?= =?UTF-8?q?es=20of=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/startup/utils.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua index 25b86f7..d62c413 100644 --- a/lua/startup/utils.lua +++ b/lua/startup/utils.lua @@ -25,7 +25,7 @@ function U.default_header() end function U.get_oldfiles(amount) - local oldfiles = {} + local oldfiles = { " " } local oldfiles_raw = vim.fn.execute "oldfiles" local oldfiles_amount = 0 for file in oldfiles_raw:gmatch "[^\n]+" do @@ -38,6 +38,22 @@ function U.get_oldfiles(amount) return oldfiles end +function U.get_oldfiles_directory(amount) + local oldfiles = { " " } + local oldfiles_raw = vim.fn.execute "oldfiles" + local oldfiles_amount = 0 + local directory = vim.api.nvim_exec([[!pwd]], true) + directory = string.sub(directory, 9, -2) + for file in oldfiles_raw:gmatch(directory .. "[^\n]+") do + if oldfiles_amount >= amount then + break + end + table.insert(oldfiles, (string.sub(file, 1, -1))) + oldfiles_amount = oldfiles_amount + 1 + end + return oldfiles +end + function U.longest_line(lines) local longest = 0 for _, line in ipairs(lines) do -- cgit v1.2.3