Browse Source

nixpkgs/neovim: add force delete binding

Thomas Dy 2 years ago
parent
commit
40dc33c62c
2 changed files with 5 additions and 0 deletions
  1. 4 0
      .config/nixpkgs/neovim/autocmd.lua
  2. 1 0
      .config/nixpkgs/neovim/mappings.lua

+ 4 - 0
.config/nixpkgs/neovim/autocmd.lua

@@ -10,6 +10,10 @@ vim.api.nvim_create_autocmd('TermOpen', {
 -- preserve window structure when exiting terminal via C-d
 vim.api.nvim_create_autocmd('TermClose', {
   callback = function(opts)
+    -- don't trigger when force deleting
+    if vim.api.nvim_buf_get_option(opts.buf, 'modified') then
+      return
+    end
     MiniBufremove.delete(opts.buf)
   end,
   -- needed so statusline properly updates

+ 1 - 0
.config/nixpkgs/neovim/mappings.lua

@@ -45,6 +45,7 @@ vim.keymap.set('n', '<Leader>to', '<cmd>term<CR>', opts)
 
 -- delete buffer
 vim.keymap.set('n', '<Leader>q', '<cmd>lua MiniBufremove.delete()<CR>', opts)
+vim.keymap.set('n', '<Leader>Q', '<cmd>lua MiniBufremove.delete(0, true)<CR>', opts)
 
 -- split/join
 vim.keymap.set('n', '<Leader>s', '<cmd>TSJSplit<CR>', opts)