]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/fixers/generic.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / fixers / generic.vim
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: Generic functions for fixing files with.
3
4 function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
5     let l:end_index = len(a:lines) - 1
6
7     while l:end_index > 0 && empty(a:lines[l:end_index])
8         let l:end_index -= 1
9     endwhile
10
11     return a:lines[:l:end_index]
12 endfunction
13
14 " Remove all whitespaces at the end of lines
15 function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort
16     let l:index = 0
17     let l:lines_new = range(len(a:lines))
18
19     for l:line in a:lines
20         let l:lines_new[l:index] = substitute(l:line, '\s\+$', '', 'g')
21         let l:index = l:index + 1
22     endfor
23
24     return l:lines_new
25 endfunction