diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:40:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:40:16 +0000 |
commit | 3f25952c13d5847d510c0cae22a8ba876638d570 (patch) | |
tree | 02f505f016ed5a1029277dcae520d5e2a75906fb /powerline/segments/vim/plugin/syntastic.py | |
parent | Initial commit. (diff) | |
download | powerline-upstream/2.8.3.tar.xz powerline-upstream/2.8.3.zip |
Adding upstream version 2.8.3.upstream/2.8.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'powerline/segments/vim/plugin/syntastic.py')
-rw-r--r-- | powerline/segments/vim/plugin/syntastic.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/powerline/segments/vim/plugin/syntastic.py b/powerline/segments/vim/plugin/syntastic.py new file mode 100644 index 0000000..5bef3c7 --- /dev/null +++ b/powerline/segments/vim/plugin/syntastic.py @@ -0,0 +1,43 @@ +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +try: + import vim +except ImportError: + vim = object() + +from powerline.segments.vim import window_cached +from powerline.bindings.vim import vim_global_exists + + +@window_cached +def syntastic(pl, err_format='ERR: {first_line} ({num}) ', warn_format='WARN: {first_line} ({num}) '): + '''Show whether syntastic has found any errors or warnings + + :param str err_format: + Format string for errors. + + :param str warn_format: + Format string for warnings. + + Highlight groups used: ``syntastic:warning`` or ``warning``, ``syntastic:error`` or ``error``. + ''' + if not vim_global_exists('SyntasticLoclist'): + return None + has_errors = int(vim.eval('g:SyntasticLoclist.current().hasErrorsOrWarningsToDisplay()')) + if not has_errors: + return + errors = vim.eval('g:SyntasticLoclist.current().errors()') + warnings = vim.eval('g:SyntasticLoclist.current().warnings()') + segments = [] + if errors: + segments.append({ + 'contents': err_format.format(first_line=errors[0]['lnum'], num=len(errors)), + 'highlight_groups': ['syntastic:error', 'error'], + }) + if warnings: + segments.append({ + 'contents': warn_format.format(first_line=warnings[0]['lnum'], num=len(warnings)), + 'highlight_groups': ['syntastic:warning', 'warning'], + }) + return segments |