Skip to content

Commit

Permalink
Merge pull request #85 from dstein64/signs
Browse files Browse the repository at this point in the history
Add support for signs
  • Loading branch information
dstein64 authored May 31, 2023
2 parents 4a04039 + 3b76cd7 commit b7a47d3
Show file tree
Hide file tree
Showing 18 changed files with 2,388 additions and 313 deletions.
65 changes: 24 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# nvim-scrollview

`nvim-scrollview` is a Neovim plugin that displays interactive vertical
scrollbars. The plugin is customizable (see `:help scrollview-configuration`).
scrollbars and signs. The plugin is customizable (see `:help
scrollview-configuration`).

<details open><summary>Demo</summary><br>

Expand All @@ -16,12 +17,14 @@ scrollbars. The plugin is customizable (see `:help scrollview-configuration`).
* Handling for folds
* Scrollbars can be dragged with the mouse
* Partially transparent scrollbars so that text is not covered
* Signs

## Requirements

* `nvim>=0.5`
* Scrollbar mouse dragging requires mouse support (see `:help 'mouse'`) and
`nvim>=0.6`
* Signs require `nvim>=0.7`

## Installation

Expand Down Expand Up @@ -53,50 +56,27 @@ A package manager can be used to install `nvim-scrollview`.
## Usage

* `nvim-scrollview` works automatically, displaying interactive scrollbars.
* The `:ScrollViewDisable` command disables scrollbars.
* The `:ScrollViewEnable` command enables scrollbars. This is only necessary
if scrollbars have previously been disabled.
* The `:ScrollViewRefresh` command refreshes the scrollbars. This is relevant
when the scrollbars are out-of-sync, which can occur as a result of some
window arrangement actions.
* The scrollbars can be dragged. This requires a corresponding mapping, which
is automatically configured when `scrollview_auto_mouse` is set (see
`:help scrollview-mouse-customization`).
* `:ScrollViewDisable` disables the plugin. When arguments are given,
the specified sign groups are disabled.
* `:ScrollViewEnable` enables the plugin. This is only necessary if
nvim-scrollview has previously been disabled. When arguments are given,
the specified sign groups are enabled.
`:ScrollViewToggle` toggles the plugin. When arguments are given, the
specified sign groups are toggled.
* `:ScrollViewRefresh` refreshes the scrollbars. This is relevant when the
scrollbars are out-of-sync, which can occur as a result of some window
arrangement actions.
* `:ScrollViewNext`, `:ScrollViewPrev`, `:ScrollViewFirst`, and
`ScrollViewLast` move the cursor to lines with signs. Arguments can specify
which sign groups are considered.
* The scrollbars can be dragged and signs can be clicked. This requires a
corresponding mapping, which is automatically configured when
`scrollview_auto_mouse` is set (see `:help scrollview-mouse-customization`).

## Configuration

There are various settings that can be configured. Please see the documentation
for details.
<details><summary>Settings</summary><br>

* Whether scrollbars are enabled or disabled on startup
- `scrollview_on_startup`
* File types for which scrollbars should not be displayed
- `scrollview_excluded_filetypes`
* Scrollbar color and transparency level
- `ScrollView` highlight group
- `scrollview_winblend`
* Whether scrollbars should be displayed in all windows, or just the current
window
- `scrollview_current_only`
* What the scrollbar position and size correspond to (i.e., how folds are
accounted for)
- `scrollview_mode`
* Scrollbar anchor column and offset
- `scrollview_base`
- `scrollview_column`
* Whether a mapping is automatically created for mouse support
- `scrollview_auto_mouse`
* Whether select workarounds are automatically applied for known issues
- `scrollview_auto_workarounds`
* Refresh time limit that triggers setting `scrollview_mode` to `simple`
- `scrollview_refresh_time`
* A character to display on scrollbars
- `scrollview_character`
* Whether each scrollbar becomes hidden when intersecting a floating window
- `scrollview_hide_on_intersect`

</details>

#### VimScript Example

Expand All @@ -107,6 +87,8 @@ let g:scrollview_winblend = 75
" Position the scrollbar at the 80th character of the buffer
let g:scrollview_base = 'buffer'
let g:scrollview_column = 80
" Enable all sign groups (defaults to ['diagnostics', 'search'])
let g:scrollview_signs_on_startup = ['all']
```

#### Lua Setup Example
Expand All @@ -117,7 +99,8 @@ require('scrollview').setup({
current_only = true,
winblend = 75,
base = 'buffer',
column = 80
column = 80,
signs_on_startup = {'all'}
})
```

Expand Down
58 changes: 41 additions & 17 deletions doc/scrollview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Web: https://github.com/dstein64/nvim-scrollview
4. Configuration |scrollview-configuration|
5. Issues |scrollview-issues|

|nvim-scrollview| is a plugin that displays interactive vertical scrollbars.
The plugin is customizable (see |scrollview-configuration|).
|nvim-scrollview| is a plugin that displays interactive vertical scrollbars and
signs. The plugin is customizable (see |scrollview-configuration|).

============================================================================
1. Requirements *scrollview-requirements*
Expand All @@ -28,22 +28,35 @@ Use |packages| or one of the various package managers.
============================================================================
3. Usage *scrollview-usage*

* |nvim-scrollview| works automatically, displaying interactive scrollbars.
* |nvim-scrollview| works automatically, displaying interactive scrollbars and
signs.

*scrollview-commands*
* The *:ScrollViewDisable* command disables scrollbars.
* The *:ScrollViewEnable* command enables scrollbars. This is only necessary
if scrollbars have previously been disabled.
* The *:ScrollViewRefresh* command refreshes the scrollbars. This is relevant
when the scrollbars are out-of-sync, which can occur e.g., as a result of
some window arrangement actions (see |scrollview-issues|).
* *:ScrollViewDisable* disables the plugin. When arguments are given, the
specified sign groups are disabled.
* *:ScrollViewEnable* enables the plugin. This is only necessary if
nvim-scrollview has previously been disabled. When arguments are given, the
specified sign groups are enabled.
* *:ScrollViewToggle* toggles the plugin. When arguments are given, the
specified sign groups are toggled.
* *:ScrollViewRefresh* refreshes the scrollbars. This is relevant when the
scrollbars are out-of-sync, which can occur e.g., as a result of some
window arrangement actions (see |scrollview-issues|).
* *:ScrollViewNext* *:ScrollViewPrev* *:ScrollViewFirst* and *:ScrollViewLast*
move the cursor to lines with signs. Arguments can specify which lines are
considered.

*scrollview-mappings*
The following |<Plug>| mappings are defined for convenience.

* `<Plug>(ScrollViewDisable)`
* `<Plug>(ScrollViewEnable)`
* `<Plug>(ScrollViewFirst)`
* `<Plug>(ScrollViewLast)`
* `<Plug>(ScrollViewNext)`
* `<Plug>(ScrollViewPrev)`
* `<Plug>(ScrollViewRefresh)`
* `<Plug>(ScrollViewToggle)`

The following (experimental) |<Plug>| mappings are defined for customizing
mouse functionality (see |scrollview-mouse-customization|).
Expand Down Expand Up @@ -81,6 +94,11 @@ scrollview_base |String| specifying where the scrollbar is anchored.
Possible values are `'left'` or `'right'` for corresponding
window edges, or `'buffer'`. Defaults to `'right'`.

*scrollview_byte_limit*
scrollview_byte_limit |Number| specifying the buffer size threshold (in
bytes) for entering restricted mode, to prevent slow
operation. Defaults to `1,000,000`. Use `-1` for no limit.

*scrollview_character*
scrollview_character |String| specifying a character to display on scrollbars.
Defaults to `''`. Considered only at global scope.
Expand All @@ -107,6 +125,11 @@ scrollview_hide_on_intersect *scrollview_hide_on_intersect*
becomes hidden (not shown) when it would otherwise
intersect with a floating window. Defaults to `0`.

*scrollview_line_limit*
scrollview_line_limit |Number| specifying the buffer size threshold (in
lines) for entering restricted mode, to prevent slow
operation. Defaults to `20,000`. Use `-1` for no limit.

*scrollview_mode*
scrollview_mode |String| specifying what the scrollbar position and size
correspond to. See |scrollview-modes| for details on the
Expand All @@ -117,13 +140,11 @@ scrollview_on_startup |Boolean| |Number| specifying whether scrollbars are
enabled on startup. Defaults to `1`. Considered only at
global scope, when the plugin is loaded.

scrollview_refresh_time *scrollview_refresh_time*
|Number| specifying the refresh limit. When scrollbar
refreshing takes more than this many milliseconds,
subsequent refreshing will use `simple` |scrollview_mode|.
Defaults to `100`. A value of `-1` corresponds to no limit.
Considered only at global scope. To reset the mode
behavior, set `g:scrollview_refresh_time_exceeded` to `0`.
scrollview_out_of_bounds_adjust *scrollview_out_of_bounds_adjust*
|Boolean| |Number| specifying whether scrollbars and
signs beyond the window boundary (out-of-bounds) are
adjusted to be within the window (as opposed to not
showing).

*scrollview_winblend*
scrollview_winblend |Number| specifying the level of transparency for
Expand All @@ -145,6 +166,8 @@ example.
" Position the scrollbar at the 80th character of the buffer
let g:scrollview_base = 'buffer'
let g:scrollview_column = 80
" Enable all sign groups (defaults to ['diagnostics', 'search'])
let g:scrollview_signs_on_startup = ['all']
Lua Setup ~

Expand All @@ -157,7 +180,8 @@ options (the 'scrollview_' prefix is omitted). For example:
winblend = 75,
-- Position the scrollbar at the 80th character of the buffer
base = 'buffer',
column = 80
column = 80,
signs_on_startup = {'all'}
})
Scrollview Modes ~
Expand Down
9 changes: 8 additions & 1 deletion doc/tags
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
:ScrollViewDisable scrollview.txt /*:ScrollViewDisable*
:ScrollViewEnable scrollview.txt /*:ScrollViewEnable*
:ScrollViewFirst scrollview.txt /*:ScrollViewFirst*
:ScrollViewLast scrollview.txt /*:ScrollViewLast*
:ScrollViewNext scrollview.txt /*:ScrollViewNext*
:ScrollViewPrev scrollview.txt /*:ScrollViewPrev*
:ScrollViewRefresh scrollview.txt /*:ScrollViewRefresh*
:ScrollViewToggle scrollview.txt /*:ScrollViewToggle*
nvim-scrollview scrollview.txt /*nvim-scrollview*
scrollview-color-customization scrollview.txt /*scrollview-color-customization*
scrollview-commands scrollview.txt /*scrollview-commands*
Expand All @@ -20,13 +25,15 @@ scrollview.txt scrollview.txt /*scrollview.txt*
scrollview_auto_mouse scrollview.txt /*scrollview_auto_mouse*
scrollview_auto_workarounds scrollview.txt /*scrollview_auto_workarounds*
scrollview_base scrollview.txt /*scrollview_base*
scrollview_byte_limit scrollview.txt /*scrollview_byte_limit*
scrollview_character scrollview.txt /*scrollview_character*
scrollview_column scrollview.txt /*scrollview_column*
scrollview_current_only scrollview.txt /*scrollview_current_only*
scrollview_excluded_filetypes scrollview.txt /*scrollview_excluded_filetypes*
scrollview_hide_on_intersect scrollview.txt /*scrollview_hide_on_intersect*
scrollview_line_limit scrollview.txt /*scrollview_line_limit*
scrollview_mode scrollview.txt /*scrollview_mode*
scrollview_on_startup scrollview.txt /*scrollview_on_startup*
scrollview_refresh_time scrollview.txt /*scrollview_refresh_time*
scrollview_out_of_bounds_adjust scrollview.txt /*scrollview_out_of_bounds_adjust*
scrollview_winblend scrollview.txt /*scrollview_winblend*
scrollview_zindex scrollview.txt /*scrollview_zindex*
Loading

0 comments on commit b7a47d3

Please sign in to comment.