From 4ace393a2e0907fb5d488d05b7db5c2ba5c376e7 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Fri, 19 Jul 2024 01:00:40 +0300 Subject: feat(neovim): auto-save buffers, Q keymap for closing buffer --- .config/nvim/lua/custom/plugins/utility.lua | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to '.config/nvim/lua/custom/plugins/utility.lua') diff --git a/.config/nvim/lua/custom/plugins/utility.lua b/.config/nvim/lua/custom/plugins/utility.lua index 4951f05..79982b4 100644 --- a/.config/nvim/lua/custom/plugins/utility.lua +++ b/.config/nvim/lua/custom/plugins/utility.lua @@ -1,4 +1,28 @@ return { + { + 'okuuva/auto-save.nvim', + cmd = 'ASToggle', -- optional for lazy loading on command + event = { 'InsertLeave', 'TextChanged' }, + opts = { + execution_message = { enabled = false }, + condition = function(buf) + local excluded_ft = {} + + if vim.fn.getbufvar(buf, '&buftype') ~= '' then + return false + end + + local filetype = vim.fn.getbufvar(buf, '&filetype') + for _, ft in ipairs(excluded_ft) do + if ft == filetype then + return false + end + end + + return true + end, + }, + }, { 'rmagatti/auto-session', config = function() @@ -52,4 +76,16 @@ return { -- Spectre has no undo, so it should be rarely used, -- which is why no keybindings are defined { 'nvim-pack/nvim-spectre' }, + { + 'echasnovski/mini.nvim', + version = false, + config = function() + vim.keymap.set('n', 'Q', function() + if vim.bo.modified then + vim.cmd.write() + end + require('mini.bufremove').delete(0) + end, { desc = '[Q]uit Buffer' }) + end, + }, } -- cgit v1.3.1