vim.api.nvim_create_user_command( "BufferDelete", function() ---@diagnostic disable-next-line: missing-parameter local file_exists = vim.fn.filereadable(vim.fn.expand("%p")) local modified = vim.api.nvim_buf_get_option(0, "modified")
if file_exists == 0and modified then local user_choice = vim.fn.input( "The file is not saved, whether to force delete? Press enter or input [y/n]:") if user_choice == "y"orstring.len(user_choice) == 0then vim.cmd("bd!") end return end
local force = not vim.bo.buflisted or vim.bo.buftype == "nofile"
vim.cmd(force and"bd!"orstring.format("bp | bd! %s", vim.api.nvim_get_current_buf())) end, { desc = "Delete the current Buffer while maintaining the window layout" })
if (vim.v.shell_error == 0) then localpath = string.sub(output, string.find(output, '~', 1, true), -1) vim.cmd(":e " .. path) else vim.notify("Failed creating new blog post" .. input.args, "error") end end
if (vim.v.shell_error == 0) then localpath = string.sub(output, string.find(output, '~', 1, true), -1) vim.cmd(":e " .. path) else vim.notify("Failed creating new blog post" .. input.args, "error") end end
localfunctionblogGenerateAndDeploy() vim.api.nvim_set_current_dir(blog_path) if (os.execute("hexo g && hexo s")) then vim.notify("Deploy the blog successfully", "info") else vim.notify("Deployment of blog failed", "error") end end
取消下一行注释
1 2 3 4 5 6 7
-- avoid comment when enter the new line vim.api.nvim_create_autocmd({ "BufEnter" }, { pattern = "*", callback = function() vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" } end, })