diff options
author | max397574 <[email protected]> | 2021-10-19 18:20:46 +0200 |
---|---|---|
committer | max397574 <[email protected]> | 2021-10-19 18:20:46 +0200 |
commit | 1cfde5ae064fa2a7747ce3e959eff4fa0478b237 (patch) | |
tree | ced9dce2afb313ae45ac8d7cc1cc1b3351c6daff /lua/startup/utils.lua | |
parent | 4d85a514ad7a0fee4394643b90eacd87aae00c4b (diff) |
feat(utils): ✨added function for oldfiles of directory
Diffstat (limited to 'lua/startup/utils.lua')
-rw-r--r-- | lua/startup/utils.lua | 18 |
1 files changed, 17 insertions, 1 deletions
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 |