2022-05-03 19:01:53 +04:30
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.smart_quit()
|
|
|
|
local bufnr = vim.api.nvim_get_current_buf()
|
|
|
|
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
|
|
|
|
if modified then
|
|
|
|
vim.ui.input({
|
|
|
|
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
|
|
|
|
}, function(input)
|
|
|
|
if input == "y" then
|
|
|
|
vim.cmd "q!"
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
vim.cmd "q!"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-19 22:14:32 -04:00
|
|
|
function M.isempty(s)
|
|
|
|
return s == nil or s == ""
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.get_buf_option(opt)
|
|
|
|
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
|
|
|
|
if not status_ok then
|
|
|
|
return nil
|
|
|
|
else
|
|
|
|
return buf_option
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-03 19:01:53 +04:30
|
|
|
return M
|