1# vim:fileencoding=utf-8:noet 2from __future__ import (unicode_literals, division, absolute_import, print_function) 3 4try: 5 import vim 6except ImportError: 7 vim = object() 8 9from powerline.bindings.vim import vim_func_exists 10from powerline.theme import requires_segment_info 11 12 13@requires_segment_info 14def capslock_indicator(pl, segment_info, text='CAPS'): 15 '''Shows the indicator if tpope/vim-capslock plugin is enabled 16 17 .. note:: 18 In the current state plugin automatically disables itself when leaving 19 insert mode. So trying to use this segment not in insert or replace 20 modes is useless. 21 22 :param str text: 23 String to show when software capslock presented by this plugin is 24 active. 25 ''' 26 if not vim_func_exists('CapsLockStatusline'): 27 return None 28 # CapsLockStatusline() function returns an empty string when plugin is 29 # disabled. If it is not then string is non-empty. 30 return text if vim.eval('CapsLockStatusline()') else None 31