summaryrefslogtreecommitdiff
path: root/lua/lvim/utils/functions.lua
blob: de46bc8a7b7ee6ff86ad71911866a3ba054014be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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