Skip to content

Commit

Permalink
feat: allow clear cache without args
Browse files Browse the repository at this point in the history
  • Loading branch information
2KAbhishek committed Dec 1, 2024
1 parent 2ac6edd commit 77d9353
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ M.clear_cache = function(prefix)
return
end

if not prefix then
cache_dir:rm({ recursive = true })
M.queue_notification('Cache cleared successfully', nil, 'Utils')
return
end

local matching_files = vim.fn.globpath(cache_dir:absolute(), prefix .. '*', false, true)

if #matching_files == 0 then
Expand All @@ -228,7 +222,7 @@ M.clear_cache = function(prefix)
vim.fn.delete(file, 'rf')
end

M.queue_notification('Cleared cache items matching: ' .. prefix, nil, 'Utils')
M.queue_notification('Cleared cache items matching: ' .. prefix .. '*', nil, 'Utils')
end

return M
2 changes: 1 addition & 1 deletion plugin/utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vim.api.nvim_create_user_command('UtilsClearCache', function(opts)
require('utils').clear_cache(opts.args)
end, { nargs = 1 })
end, { nargs = '?' })

0 comments on commit 77d9353

Please sign in to comment.