diff options
| author | Abouzar Parvan <[email protected]> | 2022-05-03 19:01:53 +0430 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2022-05-03 19:01:53 +0430 | 
| commit | e1d32ca42ee6fdef8c724e3f391e548895f0bdcf (patch) | |
| tree | 3dd52f16dc043e7e2db92b6b98f0ed58b8689898 /lua/lvim/utils/functions.lua | |
| parent | 5566076ebb539a7d72dd64af257413fd4dde6157 (diff) | |
feat(quit): make sure to ask before discarding changes (#2554)
Diffstat (limited to 'lua/lvim/utils/functions.lua')
| -rw-r--r-- | lua/lvim/utils/functions.lua | 19 | 
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 | 
