Coder Social home page Coder Social logo

dstein64 / nvim-scrollview Goto Github PK

View Code? Open in Web Editor NEW
507.0 4.0 9.0 1.7 MB

A Neovim plugin that displays interactive vertical scrollbars and signs.

License: MIT License

Lua 87.47% Python 0.65% Vim Script 11.88%
neovim scrollbar scrollview vimscript

nvim-scrollview's Introduction

build

nvim-scrollview

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

(a scrollbar and signs can be seen near the right edge of the preceding image)

Features

  • Handling for folds
  • Scrollbars can be dragged with the mouse
  • Signs (e.g., diagnostics and search enabled by default, and marks too for nvim>=0.10)

Requirements

  • nvim>=0.6
  • Scrollbar mouse dragging requires mouse support (see :help 'mouse')
  • Signs require nvim>=0.9

Installation

A package manager can be used to install nvim-scrollview.

Examples
  • Vim8 packages:
    • git clone https://github.com/dstein64/nvim-scrollview ~/.local/share/nvim/site/pack/plugins/start/nvim-scrollview
  • Vundle:
    • Add Plugin 'dstein64/nvim-scrollview' to ~/.config/nvim/init.vim
    • :PluginInstall or $ nvim +PluginInstall +qall
  • Pathogen:
    • git clone --depth=1 https://github.com/dstein64/nvim-scrollview ~/.local/share/nvim/site/bundle/nvim-scrollview
  • vim-plug:
    • Add Plug 'dstein64/nvim-scrollview', { 'branch': 'main' } to ~/.config/nvim/init.vim
    • :PlugInstall or $ nvim +PlugInstall +qall
  • dein.vim:
    • Add call dein#add('dstein64/nvim-scrollview') to ~/.config/nvim/init.vim
    • :call dein#install()
  • NeoBundle:
    • Add NeoBundle 'dstein64/nvim-scrollview' to ~/.config/nvim/init.vim
    • Re-open Neovim or execute :source ~/.config/nvim/init.vim
  • packer.nvim:
    • Add use 'dstein64/nvim-scrollview' to the packer startup function
    • :PackerInstall

Usage

  • nvim-scrollview works automatically, displaying interactive scrollbars.
  • :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 and signs. This is relevant when the scrollbars or signs 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).

Signs

There is built-in support for various types of signs (referred to as "sign groups"), listed below. The functionality is similar to the sign column, but with the same positioning logic as the scrollbar.

  • conflicts: git merge conflicts
  • cursor: cursor position
  • diagnostics: errors, warnings, info, and hints
  • folds: closed folds
  • loclist: items on the location list
  • marks
  • quickfix: items on the quickfix list
  • search
  • spell: spell check items when the spell option is enabled
  • textwidth: line lengths exceeding the value of the textwidth option, when non-zero
  • trail: trailing whitespace, when the list option is enabled and the listchars option includes "trail"

search and diagnostics groups are enabled by default (marks too for nvim>=0.10). To modify which sign groups are enabled, set scrollview_signs_on_startup accordingly in your Neovim configuation (see :help scrollview_signs_on_startup), or use :ScrollViewEnable {group1} {group2} ... to enable sign groups in the current Neovim session.

The plugin was written so that it's possible to extend the sign functionality in a Neovim configuration file or with a plugin. See the documentation for details.

The contrib directory contains sign group implementations that are not built-in (e.g., coc, gitsigns), but may be useful to some users. The code there does not receive the same level of support as the main source code, and may be less stable. Use at your own risk. For installation instructions and other documentation, see the source code files.

Configuration

There are various settings that can be configured. Please see the documentation for details. The code below only shows a few of the possible settings.

Vimscript Example

let g:scrollview_excluded_filetypes = ['nerdtree']
let g:scrollview_current_only = v:true
" 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']).
" Set to the empty list to disable all sign groups.
let g:scrollview_signs_on_startup = ['all']
" Show diagnostic signs only for errors.
let g:scrollview_diagnostics_severities =
      \ [luaeval('vim.diagnostic.severity.ERROR')]

Lua Example

A Lua setup() function is provided for convenience, to set globally scoped options (the 'scrollview_' prefix is omitted).

require('scrollview').setup({
  excluded_filetypes = {'nerdtree'},
  current_only = true,
  base = 'buffer',
  column = 80,
  signs_on_startup = {'all'},
  diagnostics_severities = {vim.diagnostic.severity.ERROR}
})

Alternatively, configuration variables can be set without calling setup().

vim.g.scrollview_excluded_filetypes = {'nerdtree'},
vim.g.scrollview_current_only = true,
vim.g.scrollview_base = 'buffer',
vim.g.scrollview_column = 80,
vim.g.scrollview_signs_on_startup = {'all'},
vim.g.scrollview_diagnostics_severities = {vim.diagnostic.severity.ERROR}

Documentation

Documentation can be accessed with:

:help nvim-scrollview

The underlying markup is in scrollview.txt.

Issues

Documentation for issues, along with some workarounds, can be accessed with:

:help scrollview-issues

Some of the known issues are regarding scrollbar synchronization, error messages, session restoration, and scrollbar floating windows being included in the window count returned by winnr('$').

License

The source code has an MIT License.

See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.