chore: Refactor auto save to 3 lines of code
This commit is contained in:
		
							parent
							
								
									4e8a5fa7cd
								
							
						
					
					
						commit
						fc9b3da633
					
				
							
								
								
									
										12
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										12
									
								
								init.lua
								
								
								
								
							| 
						 | 
				
			
			@ -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…
	
		Reference in New Issue