diff options
author | w0rp <w0rp@users.noreply.github.com> | 2016-10-07 18:29:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 18:29:36 +0100 |
commit | f6e95586dd04fff1480b738ff989fcc114bc38eb (patch) | |
tree | eb2fe5a470568d9454bf12dd117a60ab5dd2bb43 /plugin | |
parent | d97e25a2601d58a1d7e8ae72fb787210f2588a69 (diff) | |
parent | c3ae8305b788fe3efba85d4e152727b10abecd41 (diff) | |
download | ale-f6e95586dd04fff1480b738ff989fcc114bc38eb.zip |
Merge pull request #58 from KabbAmine/statusline
Add an initial getStatuslineStr function with customizable output
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/ale/aaflags.vim | 9 | ||||
-rw-r--r-- | plugin/ale/statusline.vim | 39 |
2 files changed, 48 insertions, 0 deletions
diff --git a/plugin/ale/aaflags.vim b/plugin/ale/aaflags.vim index f0c0bb7c..10d82128 100644 --- a/plugin/ale/aaflags.vim +++ b/plugin/ale/aaflags.vim @@ -39,3 +39,12 @@ let g:ale_warn_about_trailing_whitespace = " This flag can be set to 1 to keep sign gutter always open let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) + +" String format for statusline +" Its a list where: +" * The 1st element is for errors +" * The 2nd element is for warnings +" * The 3rd element is when there are no errors +let g:ale_statusline_format = get(g:, 'ale_statusline_format', +\ ['%d error(s)', '%d warning(s)', 'OK'] +\) diff --git a/plugin/ale/statusline.vim b/plugin/ale/statusline.vim new file mode 100644 index 00000000..def7db6d --- /dev/null +++ b/plugin/ale/statusline.vim @@ -0,0 +1,39 @@ +" Author: KabbAmine <amine.kabb@gmail.com> +" Description: Statusline related function(s) + +function! ALEGetStatusLine() abort + " Returns a formatted string that can be integrated in the + " statusline + + let buf = bufnr('%') + let bufLoclist = g:ale_buffer_loclist_map + + if !has_key(bufLoclist, buf) + return '' + endif + + let errors = 0 + let warnings = 0 + for e in bufLoclist[buf] + if e.type ==# 'E' + let errors += 1 + else + let warnings += 1 + endif + endfor + + let errors = errors ? printf(g:ale_statusline_format[0], errors) : '' + let warnings = warnings ? printf(g:ale_statusline_format[1], warnings) : '' + let noErrors = g:ale_statusline_format[2] + + " Different formats if no errors or no warnings + if empty(errors) && empty(warnings) + let res = noErrors + elseif !empty(errors) && !empty(warnings) + let res = printf('%s %s', errors, warnings) + else + let res = empty(errors) ? warnings : errors + endif + + return res +endfunction |