mirror of
				https://github.com/tiyn/tidy.nvim.git
				synced 2025-10-31 03:01:22 +01:00 
			
		
		
		
	
			
				
					
						
					
					13a9db44cb74ef9ed42c4a5276996f36aba3b87d
				
			
			
		
	- add user configuration ability
    - add two new patterns
        - remove empty lines at top of buffer
        - condense all multiple empty lines into
          one
    - update README
        - GIFs displaying formatting options
        - default config and how to modify
        - new packer entry
        - credits
    - remove vim file and integrate aucmd into lua
		
	
tidy.nvim 🧹
A function and autocommand pair that removes all
- trailing whitespace
- empty lines at the end of the buffer
on every BufWritePre.
install
- Packer with default configuration and lazy-loading
use{
    "mcauley-penney/tidy.nvim",
     config = function()
        require "tidy".setup{}
    end,
    event  = "BufWritePre"
}
Configuration
default
Tidy comes with the below default configuration:
local M = {
    config = {
        eof_quant = -1,  -- the amount of empty lines to leave at the end of
                         -- the file; -1 = no lines, 0 = 1 line, no limit;
                         -- only applies if "eof" given to "fmts"
        fmts = {         -- the types of formattings to apply
            "eof",       -- removes lines at end of file
            "multi",     -- condenses multiple newlines into one
            "sof",       -- removes lines at start of file
            "ws"         -- removes trailing whitespace
        }
    }
}
how to customize
To customize which formattings will apply, give a list to the setup function:
use{
    "mcauley-penney/tidy.nvim",
    config = function()
        require "tidy".setup{
            fmts = {
                "eof",
                "ws"
            }
       }
   end,
   event  = "BufWritePre"
}
formatting styles
- eof: remove a variable amount of newlines at end of file
- multi: condenses multiple newlines into one
- sof: removes lines at start of file
- ws: remove whitespace
Credits:
- Vim Tips Wiki entry for removing unwanted spaces
- ib., the author of this stack overflow answer, for how to remove empty lines at the
end of the buffer
- @blackboardd for how to choose how many lines will be kept
 
- This line
in gpanders/editorconfig.nvim for exposing me to the keepjumpsandkeeppatternsmodifiers
- Vim Tips Wiki entry for condensing multiple empty lines
Description
				A small Neovim plugin to remove trailing whitespace and empty lines at end of file on every save 
						
						
						
					Languages
				
				
								
								
									Lua
								
								100%
							
						
					



