Compare commits
2 Commits
be5e7007c9
...
6317d02148
Author | SHA1 | Date | |
---|---|---|---|
6317d02148 | |||
21502aadd6 |
@ -1,3 +1,4 @@
|
|||||||
vim.bo.commentstring = '//%s'
|
vim.opt.commentstring = '//%s'
|
||||||
|
vim.opt.matchpairs:append('<:>')
|
||||||
|
|
||||||
require('build').create_commands()
|
require('build').create_commands()
|
||||||
|
@ -15,17 +15,33 @@ end, { nargs = 1 })
|
|||||||
-- vim.loop.fs_rename
|
-- vim.loop.fs_rename
|
||||||
|
|
||||||
-- :Remove the file associated with the current buffer, then delete the buffer
|
-- :Remove the file associated with the current buffer, then delete the buffer
|
||||||
vim.api.nvim_create_user_command('Remove', function()
|
vim.api.nvim_create_user_command('Remove', function(opts)
|
||||||
local path = vim.fn.expand('%:p')
|
local path = vim.fn.expand('%:p')
|
||||||
vim.loop.fs_unlink(path, function(err, success)
|
-- Using opts.bang in the callback can cause a SEGFAULT, instead use it
|
||||||
if success then
|
-- before invoking the async unlink to select which callback should be called
|
||||||
vim.schedule(function()
|
-- on completion.
|
||||||
vim.api.nvim_buf_delete(vim.api.nvim_get_current_buf(), {})
|
local callback = nil
|
||||||
end)
|
if opts.bang then
|
||||||
else
|
-- Invoked as :Remove! so also delete the buffer.
|
||||||
error(err)
|
callback = 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
|
||||||
end)
|
else
|
||||||
end, {})
|
-- Invoked as :Remove so don't delete the buffer.
|
||||||
|
callback = function(err, success)
|
||||||
|
if not success then
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Actually remove the file using the selecte callback.
|
||||||
|
vim.loop.fs_unlink(path, callback)
|
||||||
|
end, { bang = true })
|
||||||
|
|
||||||
-- TODO: :Move
|
-- TODO: :Move
|
||||||
|
Loading…
x
Reference in New Issue
Block a user