Skip to content

Commit

Permalink
feat: add fallback file rename after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bottd committed Dec 31, 2024
1 parent 7df365a commit 0cf9efa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The archive module adds the following commands:
### `:Neorg archive current-file`
Moves the currently opened file to the archive: `archive-workspace/workspace-name/path-to-file`

### `:Neorg archive current-directory`
### TODO `:Neorg archive current-directory`
Moves the current file's directory to the archive: `archive-workspace/workspace-name/path-to-directory`
### `:Neorg archive restore`
### TODO `:Neorg archive restore`
Moves an archived file back to it's workspace from `archive-workspace/workspace/file,norg` to `workspace/file.norg`
10 changes: 8 additions & 2 deletions lua/neorg/modules/external/archive/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ module.public.archive_current_file = function()
local success = refactor.rename_file(current_path, new_path)
if (not success) then
log.error("Failed to archive " .. current_path)
else
log.info("Archived file under " .. new_path)
end

if (vim.fn.filereadable(current_path)) then
log.info("[neorg-archive] File not moved to archive, moving to" .. new_path)
os.rename(current_path, new_path)
end

vim.api.nvim_command('edit ' .. new_path)
log.info("Archived file under " .. new_path)
end

module.public.archive_current_directory = function()
Expand Down

0 comments on commit 0cf9efa

Please sign in to comment.