chore: Refactor auto save to 3 lines of code

pull/156/head
nedia 2 years ago
parent 4e8a5fa7cd
commit fc9b3da633

@ -335,17 +335,9 @@ local on_attach = function(_, bufnr)
group = vim.api.nvim_create_augroup('AutoSave', { clear = true }),
buffer = bufnr,
callback = function()
-- We need to be able to save the buffer
if vim.fn.getbufvar(bufnr, '&modifiable') ~= 1 then
return
if vim.fn.getbufvar(bufnr, '&modifiable') == 1 and vim.api.nvim_buf_get_option(bufnr, 'modified') then
vim.cmd 'w'
end
-- If the buffer hasn't been modified, don't bother doing anything
if not vim.api.nvim_buf_get_option(bufnr, 'modified') then
return
end
vim.cmd 'w'
end,
})
end

Loading…
Cancel
Save