diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-03 16:51:34 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-03 16:51:34 +0100 |
commit | 160b9548eec13b3eb5ffb488a15964e079cb3ca0 (patch) | |
tree | bd6d125ea5e9445cc12bd1d503739b72bb4d480c /autoload | |
parent | fd6f05c9ea7e3ff0ce7a86354b170e954e2e05b6 (diff) | |
download | ale-160b9548eec13b3eb5ffb488a15964e079cb3ca0.zip |
Add a function for fixing the alignment of Vim help tags
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/help.vim | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 176baadf..191a827f 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -7,6 +7,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Add blank lines before control statements.', \ }, +\ 'align_help_tags': { +\ 'function': 'ale#fixers#help#AlignTags', +\ 'suggested_filetypes': ['help'], +\ 'description': 'Align help tags to the right margin', +\ }, \ 'autopep8': { \ 'function': 'ale#fixers#autopep8#Fix', \ 'suggested_filetypes': ['python'], diff --git a/autoload/ale/fixers/help.vim b/autoload/ale/fixers/help.vim new file mode 100644 index 00000000..b20740fe --- /dev/null +++ b/autoload/ale/fixers/help.vim @@ -0,0 +1,24 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: Generic fixer functions for Vim help documents. + +function! ale#fixers#help#AlignTags(buffer, lines) abort + let l:new_lines = [] + + for l:line in a:lines + if len(l:line) != 79 + let l:match = matchlist(l:line, '\v +(\*[^*]+\*)$') + + if !empty(l:match) + let l:start = l:line[:-len(l:match[0]) - 1] + let l:tag = l:match[1] + let l:spaces = repeat(' ', 79 - len(l:start) - len(l:tag)) + + let l:line = l:start . l:spaces . l:tag + endif + endif + + call add(l:new_lines, l:line) + endfor + + return l:new_lines +endfunction |