Add :Remove command, to remove file of current buffer
This commit is contained in:
parent
f93360d854
commit
77452d989d
1
init.lua
1
init.lua
@ -1,5 +1,6 @@
|
||||
require('settings')
|
||||
require('mappings')
|
||||
require('commands')
|
||||
require('netrw')
|
||||
require('autocmds')
|
||||
require('statusline')
|
||||
|
18
lua/commands.lua
Normal file
18
lua/commands.lua
Normal file
@ -0,0 +1,18 @@
|
||||
-- TODO: :Rename
|
||||
-- vim.loop.fs_rename
|
||||
|
||||
-- :Remove the file associated with the current buffer, then delete the buffer
|
||||
vim.api.nvim_create_user_command('Remove', function()
|
||||
local path = vim.fn.expand('%:p')
|
||||
vim.loop.fs_unlink(path, function(err, success)
|
||||
if success then
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_buf_delete(vim.api.nvim_get_current_buf(), {})
|
||||
end)
|
||||
else
|
||||
error(err)
|
||||
end
|
||||
end)
|
||||
end, {})
|
||||
|
||||
-- TODO: :Move
|
Loading…
x
Reference in New Issue
Block a user