summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ale/aaflags.vim9
-rw-r--r--plugin/ale/statusline.vim39
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