A modern Neovim plugin for safely deleting files with trash/recycle bin support.
- ποΈ Custom Commands: Use any UNIX command for file deletion
- β Confirmation Prompts: Configurable confirmation before deletion
- π§ Highly Configurable: Customize behavior to match your workflow
- π¦ Buffer Cleanup: Automatically closes deleted file buffers
- π Modern Lua API: Built with Neovim's latest Lua features
{
'babarot/rm.nvim',
opts = {
-- Optional: configure here
-- command = 'gomi',
},
}Or with lazy loading:
{
'babarot/rm.nvim',
cmd = 'Rm', -- Load when :Rm is executed
opts = {
command = 'gomi',
},
}use {
'babarot/rm.nvim',
config = function()
require('rm').setup()
end,
}Plug 'babarot/rm.nvim'
lua << EOF
require('rm').setup()
EOFFirst, call setup() in your Neovim configuration:
require('rm').setup()This creates the :Rm command by default.
:Rm- Delete current file with confirmation prompt:Rm!- Delete current file without confirmation
Note: Commands are only created after calling setup(). You can customize the command name or disable it entirely (see Configuration section).
-- Delete current file
require('rm').delete_current_file({ bang = false })
-- Delete multiple files
require('rm').delete_files({ 'file1.txt', 'file2.txt' }, { bang = false })
-- Get current configuration
local config = require('rm').get_config()Default configuration:
require('rm').setup({
-- Custom deletion command
-- If {file} placeholder is not present, file path is appended at the end
-- Examples:
-- 'gomi' -> 'gomi /path/to/file'
-- 'gomi {file}' -> 'gomi /path/to/file'
-- 'mv {file} ~/.Trash/' -> 'mv /path/to/file ~/.Trash/'
-- If nil, uses os.remove() for permanent deletion
command = nil,
-- Confirm before deletion by default
confirm = true,
-- Show notification after successful deletion
notify = true,
-- Notification level
notify_level = vim.log.levels.INFO,
-- Save file before deletion
save_before_delete = true,
-- Command creation settings
create_commands = true, -- Set to false to disable automatic command creation
-- Command names (only used when create_commands is true)
commands = {
delete = "Rm", -- Name of the delete command
},
})require('rm').setup({
command = 'gomi',
})require('rm').setup({
command = 'trash',
})require('rm').setup({
command = 'gio trash',
})require('rm').setup({
command = 'mv {file} ~/.Trash/',
})require('rm').setup({
command = 'gomi',
confirm = false,
})require('rm').setup({
notify = false,
})require('rm').setup({
commands = {
delete = "Delete", -- Use :Delete instead of :Rm
},
})require('rm').setup({
command = 'gomi',
create_commands = false, -- No :Rm command created
})
-- Use Lua API directly
vim.keymap.set('n', '<leader>fd', function()
require('rm').delete_current_file({ bang = false })
end, { desc = 'Delete current file' })You can use any command-line trash tool with this plugin:
By default (without configuration), the plugin uses os.remove() for permanent deletion.
You can set up custom keybindings for quick file deletion:
-- Delete current file with confirmation
vim.keymap.set('n', '<leader>fd', ':Rm<CR>', { desc = 'Delete current file' })
-- Delete current file without confirmation
vim.keymap.set('n', '<leader>fD', ':Rm!<CR>', { desc = 'Delete current file (no confirm)' })
-- Or use Lua API directly
vim.keymap.set('n', '<leader>fd', function()
require('rm').delete_current_file({ bang = false })
end, { desc = 'Delete current file' })MIT
babarot