summaryrefslogtreecommitdiff
path: root/lua/lvim/utils
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lvim/utils')
-rw-r--r--lua/lvim/utils/functions.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/lvim/utils/functions.lua b/lua/lvim/utils/functions.lua
new file mode 100644
index 00000000..de46bc8a
--- /dev/null
+++ b/lua/lvim/utils/functions.lua
@@ -0,0 +1,19 @@
+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
+
+return M