Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add battery#component_escaped() and remove % escape from battery#component() #24

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autoload/battery.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function! battery#component() abort
return format
endfunction

function! battery#component_escaped() abort
let component = battery#component()
return substitute(component, '%', '%%', 'g')
endfunction

function! s:update_callback() abort
if g:battery#update_tabline
let &tabline = &tabline
Expand Down Expand Up @@ -114,7 +119,7 @@ call s:define('g:battery', {
\ 'update_interval': 30000,
\ 'update_tabline': 0,
\ 'update_statusline': 0,
\ 'component_format': '%s %v%%%% %g',
\ 'component_format': '%s %v%% %g',
\ 'symbol_charging': '♥',
\ 'symbol_discharging': '♡',
\ 'graph_indicators': [
Expand Down
20 changes: 14 additions & 6 deletions doc/battery.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
*battery.txt* A statusline/tabline component of Battery information

Author: Alisue <lambdalisue@hashnote.net>
Support: Neovim 0.1.6 or above
Support: Vim 8.0 or above
License: MIT license

=============================================================================
CONTENTS *battery-contents*

Expand Down Expand Up @@ -121,6 +116,19 @@ battery#component()
Return a battery component for |statusline| or |tabline| which looks
like "♥ 40% ██░░░".
Users can customize the format by |g:battery#component_format|.
>
set statusline=%{battery#component()}
<
See |battery#component_escaped()| for "%!" expression.

*battery#component_escaped()*
battery#component_escaped()
Return a "%" escaped battery component that is suite for "%!"
expression that like "♥ 40%% ██░░░".
>
set statusline=%!battery#component_escaped()
<
See |battery#component()| for "%{}" expression.

-----------------------------------------------------------------------------
VARIABLES *battery-variables*
Expand Down Expand Up @@ -180,7 +188,7 @@ g:battery#component_format
%x x
%% %

Default is "%s %v%%%% %g"
Default is "%s %v%% %g"

*g:battery#graph_indicators*
g:battery#graph_indicators
Expand Down