Skip to content
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
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Alisue, hashnote.net
Copyright (c) 2016 Alisue <lambdalisue@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# battery.vim

![Version 0.2.0](https://img.shields.io/badge/version-0.2.0-yellow.svg?style=flat-square)
![Support Neovim 0.2.0 or above](https://img.shields.io/badge/support-Neovim%200.2.0%20or%20above-green.svg?style=flat-square)
![Support Vim 8.0.0027 or above](https://img.shields.io/badge/support-Vim%208.0.0027%20or%20above-yellowgreen.svg?style=flat-square)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
Expand Down
50 changes: 40 additions & 10 deletions autoload/battery.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ endfunction

function! battery#graph() abort
let backend = battery#backend()
let nf = float2nr(round(backend.value / (100.0 / g:battery#graph_width)))
let nn = g:battery#graph_width - nf
return printf('%s%s',
\ repeat(g:battery#graph_symbol_fill, nf),
\ repeat(g:battery#graph_symbol_null, nn),
\)
let width = len(g:battery#graph_indicators)
let index = float2nr(floor(backend.value / (100.0 / width))) - 1
return g:battery#graph_indicators[index]
endfunction

function! battery#watch() abort
Expand Down Expand Up @@ -117,10 +114,43 @@ 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_symbol_fill': '█',
\ 'graph_symbol_null': '░',
\ 'graph_width': 5,
\ 'graph_indicators': [
\ '░░░░░',
\ '█░░░░',
\ '██░░░',
\ '███░░',
\ '████░',
\ '█████',
\ ],
\})

" DEPRECATED warning messages

function! s:deprecated(name, alternative) abort
if !exists(a:name)
return
endif
echohl WarningMsg
echomsg printf(
\ '[battery] "%s" is DEPRECATED and has no effect. Use "%s" instead.',
\ a:name,
\ a:alternative,
\)
echohl None
endfunction

call s:deprecated(
\ 'g:battery#graph_symbol_fill',
\ 'g:battery#graph_indicators',
\)
call s:deprecated(
\ 'g:battery#graph_symbol_null',
\ 'g:battery#graph_indicators',
\)
call s:deprecated(
\ 'g:battery#graph_width',
\ 'g:battery#graph_indicators',
\)
46 changes: 32 additions & 14 deletions doc/battery.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*battery.txt* A statusline/tabline component of Battery information

Version: 0.2.0
Author: Alisue <lambdalisue@hashnote.net>
Support: Neovim 0.1.6 or above
Support: Vim 8.0 or above
Expand Down Expand Up @@ -96,8 +95,7 @@ battery#graph()
Return a battery indicator bar looks like ██░░░.
Return a unicode graph indicating the value which looks like "██░░░".
Note that the graph is built from a cached value from |battery#update()|.
See also |g:battery#graph_symbol_fill|, |g:battery#graph_symbol_null|
or |g:battery#graph_width|.
See |g:battery#graph_indicators| to change looks of the graph.

Value Graph (Default)~
0 ░░░░░
Expand Down Expand Up @@ -182,22 +180,42 @@ g:battery#component_format
%x x
%% %

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

*g:battery#graph_symbol_fill*
g:battery#graph_symbol_fill
A character used to indicate a fill reagion in |battery#graph()|.
Default is "█"
*g:battery#graph_indicators*
g:battery#graph_indicators
A |List| of |String| that indicate the current battery status as a
graph.

Use the following with nerd font.
>
let g:battery#graph_indicators = [
\ '',
\ '',
\ '',
\ '',
\ '',
\]
<
Default value is the following
>
let g:battery#graph_indicators = [
\ '░░░░░',
\ '█░░░░',
\ '██░░░',
\ '███░░',
\ '████░',
\ '█████',
\]
<
*g:battery#graph_symbol_fill*
*g:battery#graph_symbol_null*
g:battery#graph_symbol_null
A character used to indicate a null reagion in |battery#graph()|.
Default is "░"

*g:battery#graph_width*
g:battery#graph_symbol_fill
g:battery#graph_symbol_null
g:battery#graph_width
The number of characters used in |battery#graph()|.
Default is 5
DEPRECATED:
These configuration does nothing due to |g:battery#graph_indicators|.


=============================================================================
Expand Down