Skip to content

Commit b52ddc7

Browse files
Joe Patersonnoscript
authored andcommitted
command to toggle scrollbar
fixes #4
1 parent e5a4cf5 commit b52ddc7

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

autoload/elevator.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if !exists('g:elevator#highlight')
1212
endif
1313

1414
var s_state = {
15+
enabled: true,
1516
scrolloff: -1,
1617
screenrow: -1,
1718
topline: -1,
@@ -36,7 +37,23 @@ def S__calculate_scale(winid__a: number): float
3637
return 1.0 * winheight / (line('$', winid__a) + winheight)
3738
enddef
3839

40+
export def Toggle()
41+
s_state.enabled = !s_state.enabled
42+
43+
if !s_state.enabled
44+
S__close()
45+
else
46+
Show(win_getid())
47+
endif
48+
49+
echo 'Elevator ' .. (s_state.enabled ? 'enabled' : 'disabled')
50+
enddef
51+
3952
export def Show(winid__a: number)
53+
if !s_state.enabled
54+
return
55+
endif
56+
4057
if s_state.dragging
4158
return
4259
endif

doc/elevator.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ Version: 0.2
99
CONTENTS *elevator-contents*
1010

1111
Intro...................................................|elevator-intro|
12-
Mappings.............................................|elevator-mappings|
13-
Mouse...................................................|elevator-mouse|
1412
Commands.............................................|elevator-commands|
15-
Functions...........................................|elevator-functions|
1613
Variables...........................................|elevator-variables|
1714

1815
================================================================================
@@ -23,6 +20,11 @@ VIM and GVIM.
2320

2421
Elevator works out of the box and does not require any configuration.
2522

23+
================================================================================
24+
COMMANDS *elevator-commands*
25+
26+
:ElevatorToggle Toggle scrollbar.
27+
2628
================================================================================
2729
VARIABLES *elevator-variables*
2830

plugin/elevator.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ augroup Elevator
1111
autocmd WinScrolled * elevator#Show(expand('<amatch>')->str2nr())
1212
autocmd WinEnter,BufWinEnter * timer_start(0, (_) => elevator#Show(win_getid()))
1313
augroup END
14+
15+
command! -nargs=0 -bar ElevatorToggle elevator#Toggle()

0 commit comments

Comments
 (0)