From 15b99738c7af2e47dd134248448fe52eac745a6d Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 4 Aug 2022 16:09:38 -0500 Subject: [PATCH] partial clean support --- lua/nvim-haven/init.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lua/nvim-haven/init.lua b/lua/nvim-haven/init.lua index 4880c35..9a4aa71 100644 --- a/lua/nvim-haven/init.lua +++ b/lua/nvim-haven/init.lua @@ -12,6 +12,8 @@ local pfiletype = require("plenary.filetype") local pickers = require("telescope.pickers") local previewers = require("telescope.previewers") local putils = require("telescope.previewers.utils") +local scan = require("plenary.scandir") +local Path = require("plenary.path") local M = {} @@ -567,6 +569,30 @@ M.setup = function(config) setup_autocmds() end +M.clean = function() + local decode = function(str) + if str == nil then + return "" + end + + return str:gsub("+", " "):gsub( + "%%(%x%x)", + function(x) + return string.char(tonumber(x, 16)) + end + ) + end + + local files = scan.scan_dir(haven_config.haven_path, {hidden = true, depth = 1}) + for _, name in ipairs(files) do + name = decode(Path:new(name):make_relative(haven_config.haven_path)):sub(1, -6) + local p = Path:new(name) + if not p:exists() then + print(p:absolute()) + end + end +end + M.disable = function() if haven_config.enabled then haven_config.enabled = false