Skip to content

yutkat/confirm-quit.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

confirm-quit

This plugin will give you a confirmation message when you close the last window. It prevents Neovim from closing unexpectedly.

2021-04-07_22-15

Installation

Lazy

{
  "yutkat/confirm-quit.nvim",
  event = "CmdlineEnter",
  opts = {},
}

Packer

use {
  "yutkat/confirm-quit.nvim",
  event = "CmdlineEnter",
  config = function() require "confirm-quit".setup() end,
}

Default options

{
  overwrite_q_command = true, -- Replaces :q and :qa with :ConfirmQuit and :ConfirmQuitAll
}

Commands

You do not need to use those commands directly. :q and :qa are aliases to :ConfirmQuit and :ConfirmQuitAll if you didn't change the default config.

I also recommend you set vim.opt.confirm = true to get prompted if you want to save all the unsaved changes.

ConfirmQuit " Same as :q, unless it's the last window, in which case it prompts you before taking any action.
ConfirmQuitAll " Similar to :ConfirmQuit. Will always prompt you to quit 

ConfirmQuit! " An alias to :q!
ConfirmQuitAll! " An alias to :qa!

Lua interface

require "confirm-quit".confirm_quit()     -- :ConfirmQuit
require "confirm-quit".confirm_quit_all() -- :ConfirmQuitAll

require "confirm-quit".confirm_quit { bang = true }     -- ConfirmQuit!
require "confirm-quit".confirm_quit_all { bang = true } -- ConfirmQuitAll!

Keymaps

Here's an example of how you'd set up keymaps:

vim.keymap.set("n", "<leader>q", require "confirm-quit".confirm_quit)
vim.keymap.set("n", "<leader>Q", require "confirm-quit".confirm_quit_all)

About

Check and then exit from Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages