Git Product home page Git Product logo

nvim-scrollbar's Introduction

nvim-scrollbar

Extensible Neovim Scrollbar

diagnostics

Features

Requirements

Installation

vim-plug

Plug 'petertriho/nvim-scrollbar'

packer.nvim

use("petertriho/nvim-scrollbar")

Setup

require("scrollbar").setup()
Search

search

Setup (Packer)

use {
  "kevinhwang91/nvim-hlslens",
  config = function()
    -- require('hlslens').setup() is not required
    require("scrollbar.handlers.search").setup({
        -- hlslens config overrides
    })
  end,
}

OR

use {
  "kevinhwang91/nvim-hlslens",
  config = function()
    require("hlslens").setup({
       build_position_cb = function(plist, _, _, _)
            require("scrollbar.handlers.search").handler.show(plist.start_pos)
       end,
    })

    vim.cmd([[
        augroup scrollbar_search_hide
            autocmd!
            autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
        augroup END
    ]])
  end,
}

If you want to leave only search marks and disable virtual text:

require("scrollbar.handlers.search").setup({
    override_lens = function() end,
})
Git Signs
Peek.2022-11-11.12-24.gitsigns.sidebar.mp4

Display git changes in the sidebar. Requires gitsigns.nvim to be installed.

Setup (Packer)

use {
  "lewis6991/gitsigns.nvim",
  config = function()
    require('gitsigns').setup()
    require("scrollbar.handlers.gitsigns").setup()
  end
}

Config

Defaults
require("scrollbar").setup({
    show = true,
    show_in_active_only = false,
    set_highlights = true,
    folds = 1000, -- handle folds, set to number to disable folds if no. of lines in buffer exceeds this
    max_lines = false, -- disables if no. of lines in buffer exceeds this
    hide_if_all_visible = false, -- Hides everything if all lines are visible
    throttle_ms = 100,
    handle = {
        text = " ",
        blend = 30, -- Integer between 0 and 100. 0 for fully opaque and 100 to full transparent. Defaults to 30.
        color = nil,
        color_nr = nil, -- cterm
        highlight = "CursorColumn",
        hide_if_all_visible = true, -- Hides handle if all lines are visible
    },
    marks = {
        Cursor = {
            text = "",
            priority = 0,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "Normal",
        },
        Search = {
            text = { "-", "=" },
            priority = 1,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "Search",
        },
        Error = {
            text = { "-", "=" },
            priority = 2,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "DiagnosticVirtualTextError",
        },
        Warn = {
            text = { "-", "=" },
            priority = 3,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "DiagnosticVirtualTextWarn",
        },
        Info = {
            text = { "-", "=" },
            priority = 4,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "DiagnosticVirtualTextInfo",
        },
        Hint = {
            text = { "-", "=" },
            priority = 5,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "DiagnosticVirtualTextHint",
        },
        Misc = {
            text = { "-", "=" },
            priority = 6,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "Normal",
        },
        GitAdd = {
            text = "",
            priority = 7,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "GitSignsAdd",
        },
        GitChange = {
            text = "",
            priority = 7,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "GitSignsChange",
        },
        GitDelete = {
            text = "",
            priority = 7,
            gui = nil,
            color = nil,
            cterm = nil,
            color_nr = nil, -- cterm
            highlight = "GitSignsDelete",
        },
    },
    excluded_buftypes = {
        "terminal",
    },
    excluded_filetypes = {
        "cmp_docs",
        "cmp_menu",
        "noice",
        "prompt",
        "TelescopePrompt",
    },
    autocmd = {
        render = {
            "BufWinEnter",
            "TabEnter",
            "TermEnter",
            "WinEnter",
            "CmdwinLeave",
            "TextChanged",
            "VimResized",
            "WinScrolled",
        },
        clear = {
            "BufWinLeave",
            "TabLeave",
            "TermLeave",
            "WinLeave",
        },
    },
    handlers = {
        cursor = true,
        diagnostic = true,
        gitsigns = false, -- Requires gitsigns
        handle = true,
        search = false, -- Requires hlslens
        ale = false, -- Requires ALE
    },
})

Colors/Highlights

Color takes precedence over highlight i.e. if color is defined, that will be used to define the highlight instead of highlight.

Mark type highlights are in the format of Scrollbar<MarkType> and Scrollbar<MarkType>Handle. If you wish to define these yourself, add set_highlights = false to the setup.

  • ScrollbarHandle
  • ScrollbarCursorHandle
  • ScrollbarCursor
  • ScrollbarSearchHandle
  • ScrollbarSearch
  • ScrollbarErrorHandle
  • ScrollbarError
  • ScrollbarWarnHandle
  • ScrollbarWarn
  • ScrollbarInfoHandle
  • ScrollbarInfo
  • ScrollbarHintHandle
  • ScrollbarHint
  • ScrollbarMiscHandle
  • ScrollbarMisc
  • ScrollbarGitAdd
  • ScrollbarGitAddHandle
  • ScrollbarGitChange
  • ScrollbarGitChangeHandle
  • ScrollbarGitDelete
  • ScrollbarGitDeleteHandle

Example config with tokyonight.nvim colors

local colors = require("tokyonight.colors").setup()

require("scrollbar").setup({
    handle = {
        color = colors.bg_highlight,
    },
    marks = {
        Search = { color = colors.orange },
        Error = { color = colors.error },
        Warn = { color = colors.warning },
        Info = { color = colors.info },
        Hint = { color = colors.hint },
        Misc = { color = colors.purple },
    }
})

Custom Handlers

One can define custom handlers consisting of a name and a lua function that returns a list of marks as follows:

require("scrollbar.handlers").register(name, handler_function)

handler_function receives the buffer number as argument and must return a list of tables with line, text, type, and level keys. Only the line key is required.

Key Description
line The line number. Required.
text Marker text. Defaults to global settings depending on type.
type The marker type. Default is Misc.
level Marker level. Default is 1.

E.g. the following marks the first three lines in every buffer.

require("scrollbar.handlers").register("my_marks", function(bufnr)
    return {
        { line = 0 },
        { line = 1, text = "x", type = "Warn" },
        { line = 2, type = "Error" }
    }
end)

Acknowledgements

License

MIT

nvim-scrollbar's People

Contributors

adoyle-h avatar chuwy avatar coldspirit0 avatar dj95 avatar folke avatar gelio avatar isrothy avatar meijieru avatar mphe avatar olimorris avatar petertriho avatar scrooloose avatar tbodt avatar tbung avatar xiyaowong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-scrollbar's Issues

[Feature Request] Create API and clear interface to add new mark handlers

Is your feature request related to a problem? Please describe.
Since there are some issues now with people requesting different marks it might be a good idea to just provide a general api to register a new handler so people can extend the plugin in an easy fashion. Builtin handlers could then be just implemented on top of this api.

Describe the solution you'd like
Some restructuring of the code with a general handler interface to make adding handlers easy and a function or config option to register new handlers.

Describe alternatives you've considered
An alternative would be to add every requested handler into the project, which might exclude niche handlers that are out of scope or bloat the plugin.

Additional context
This relates to #2 and #17

Cause serious lagging on large files (>10,000 lines)

Describe the bug
As title.

To Reproduce
Just open a file with lines > 10,000.

Expected behavior
smooth scroll

Screenshots

Version Info (please complete the following information):

NVIM v0.8.0-dev+67-g0d41c4dee
Build type: Release
LuaJIT 2.1.0-beta3

Additional context

Highlight group for out of focus window

I use show_in_active_only currently, but I would like to be able to set a highlight group for the scrollbar in inactive windows instead of hiding it. There is already a highlight option to set the highlight group, maybe this can be expanded to be:

{
  handle = {
    highlight = "CursorLine",
    inactive_highlight = "CursorLine",
  }
}

Set highlights on ColorScheme autocmd

It seems that currently highlights are implemented just on setup and not with the ColorScheme autocmd. This means that they are likely to get cleared by most colorscheme.

For example, this is your highlights cleared (compared to non cleared highlights from other plugins above and below):

image

As an implementation example, this is how it is done in nvim-notify

vim.cmd([[
  augroup NvimNotifyRefreshHighlights
    autocmd!
    autocmd ColorScheme * lua require('notify.config.highlights').setup()
  augroup END
]])

When highlights are cleared, even if the scrollbar renders, it might not show up in the terminal.

Error: bad argument #2 to 'to_hex_color' (number expected, got nil)

Describe the bug

  • Error message occurs when enter neovim
  • Screenshot:
    image

To Reproduce
Steps to reproduce the behavior:

  • Enter Neovim

Expected behavior
No error message.

Version Info (please complete the following information):

NVIM v0.7.0-dev+926-g6006e15e7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Config

require("scrollbar").setup({})

Error in diff view

Lots of error when have diff view in fugitive as the following:

pretty-fold.nvim/lua/pretty-fold/init.lua:68: in function <...ack/packer/opt/pretty-fold.nvim/lua/pretty-fold/init.lua:61>

Conflicting settings with nvim-hlsens

Describe the bug

I have both nvim-scrollbar and nvim-hlslens installed. When I don't add any special configuration for nvim-hlslens everything works as described in README. However, when I add require('hlslens').setup { override_lens = function() ... end search marks disappear.

To Reproduce

  use {
    'kevinhwang91/nvim-hlslens',
    config = function()
      require('hlslens').setup {
        override_lens = function(render, plist, nearest, idx, r_idx)
          local sfw = vim.v.searchforward == 1
          local indicator, text, chunks
          local abs_r_idx = math.abs(r_idx)
          if abs_r_idx > 1 then
            indicator = sfw ~= (r_idx > 1) and '' or ''
          elseif abs_r_idx == 1 then
            indicator = sfw ~= (r_idx == 1) and '' or ''
          else
            indicator = ''
          end
    
          local lnum, col = unpack(plist[idx])
          if nearest then
            local cnt = #plist
            if indicator ~= '' then
              text = ('[%s %d/%d]'):format(indicator, idx, cnt)
            else
              text = ('[%d/%d]'):format(idx, cnt)
            end
            chunks = {{' ', 'Ignore'}, {text, 'HlSearchLensNear'}}
          else
            text = ('[%s %d]'):format(indicator, idx)
            chunks = {{' ', 'Ignore'}, {text, 'HlSearchLens'}}
          end
          render.set_virt(0, lnum - 1, col - 1, chunks, nearest)
        end
      }
    end
  }

  use {
    'petertriho/nvim-scrollbar',

    config = function()
      local colors = require("tokyonight.colors").setup { }

      require("scrollbar").setup {
        handle = {
          color = colors.bg_highlight,
        },
        marks = {
          Search = { color = colors.orange },
          Error = { color = colors.error },
          Warn = { color = colors.warning },
          Info = { color = colors.info },
          Hint = { color = colors.hint },
          Misc = { color = colors.purple },
        },
      }
    end
  }

Expected behavior

I expect hlslens' override_lens to work (virtual text is overriden) and get visible search marks.

Screenshots
If applicable, add screenshots to help explain your problem.

Version Info (please complete the following information):

NVIM v0.7.0-dev

Additional context
I use Packer.

[Bug Report] Bar first increases in size before moving

I noticed when scrolling, that the bar first increases in size in the scrolling direction before moving and decreasing to its previous size. I suspect this is not intended behavior and looks somewhat wanky, with the bar wobbeling along while scrolling. This may be due to scrolloff, but I didn't have time yet to narrow down the issue.

require('scrollbar.handlers.search').handler.hide() does not work

Describe the bug

require('scrollbar.handlers.search').handler.hide() -- doesn't work

To Reproduce
install both scrollbar and hlslens with packer and execute these two functions in order

function hlslens()
  local build_position_cb = nil

  -- forward search results to scrollbar if installed
  if is_mod_exists('scrollbar') then build_position_cb = function(plist, _, _, _) require('scrollbar.handlers.search').handler.show(plist.start_pos) end

  require 'hlslens'.setup {
    nearest_only = true,
    nearest_float_when = 'never',
    build_position_cb = build_position_cb
  }
end

function scrollbar()
  require 'scrollbar'.setup {
    set_highlights = false, -- highlights are set elsewhere
    handle = {
      hide_if_all_visible = true,
    },
    handlers = {
      diagnostic = true,
      -- setting search = true here overrides hlslens setup configs
    },
  }

  -- enable search marks if hlslens is installed
  if is_mod_exists('hlslens') then require'scrollbar.config'.get().handlers.search = true end
end

so far this all works great, now my issue is that I can't clear the search marks with

require('scrollbar.handlers.search').handler.hide()

mapping it to a key or executing it in the command line makes no difference

Suggested solution
I've looked up that function

    hide = function()
        if not vim.v.event.abort then
            local cmdl = vim.trim(vim.fn.getcmdline())
            if #cmdl > 2 then
                for _, cl in ipairs(vim.split(cmdl, "|")) do
                    if ("nohlsearch"):match(vim.trim(cl)) then
                        local bufnr = vim.api.nvim_get_current_buf()
                        local scrollbar_marks = utils.get_scrollbar_marks(bufnr)
                        scrollbar_marks.search = nil
                        utils.set_scrollbar_marks(bufnr, scrollbar_marks)
                        render()
                        break
                    end
                end
            end
        end
    end

and removed

if #cmdl > 2 then

and now it works fine, this single check has prevented me from using the whole hide() function.

Version Info
NVIM v0.6.1

[Feature request] Add function to allow custom ignoring from the user

Say I want to ignore the scrollbar in float windows, having something like:

  require("scrollbar").setup({
    exclude_func = function(winid, bufnr)
      if not vim.api.nvim_win_is_valid(winid) then
        return true
      end

      local is_floating = vim.api.nvim_win_get_config(winid).relative ~= ""

      local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
      local exclude_filetype = {
        TelescopePrompt = true,
        [""] = true,
      }

      local buftype = vim.api.nvim_buf_get_option(bufnr, "buftype")
      local exclude_buftype = {
        terminal = true,
        prompt = true,
      }

      return is_floating or exclude_buftype[buftype] or exclude_filetype[filetype]
    end,
  })

which is likely a bit more complicated and would require adding options for each kind of filtering the user wants to do. Having a function like this (can even provide some default options) seems a bit easier.

This would be in addition to exclude_filetypes or just replace it as that option would likely become redundant.

I will make a PR for this in a bit.

Option to hide scroll bar in buffers that fit on screen

I'd like the scroll bar to only be shown when I would need to scroll to see something that isn't on screen. This could probably be done with some clever configuration once #10 is implemented, but to me, this seems like a sensible option to bake in.

Better Default Colour

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

The scrollbar being white tends to stick out from most themes, and customising for several different themes doesn't seem very friendly.

Describe the solution you'd like
A clear and concise description of what you want to happen.

The default highlight group for ScrollBarHandle links to CursorLine (same as the example used in the README for TokyoNight). Perhaps even Diagnostic mark colours should link to the default Diagnostic* highlight groups as well! This makes it more consistent to individual ColorSchemes :)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Alternative solutions include manually finding and setting the colours by theme colour API's (as in the README), adding a custom highlight group override to every single theme configuration, or using an autocmd if this is not supported.

Additional context
Add any other context or screenshots about the feature request here.

Option to offset scrollbar from right edge

Is your feature request related to a problem? Please describe.
On ultra wide monitor - having scroll bar on the very right is bit hard to see.

Describe the solution you'd like
Offset scroll bar by eg. X parameter could be nice. It would move scrollbar closer to center. Or just move it by -1 to left (without introducing new parameter)

Describe alternatives you've considered
Tried custom font symbol that is offset ed to left, but its not enough -eg '▌'

Example of other scrollbar plug where plugin author moved it by default by 1 to left (used with symbol above, to make it more thin/modern looking) :
image

Sometimes throwing an error if incorrect code is detected

Quite often when I'm changing some code and in the middle of the change when the code is broken, it throws a random error.

It's not every time, just at some weird times.

Here it happens when I put 11.

Pretty much just enter the file, go to the line, go to insert at the beginning of the line, type 11, go to normal mode => throws an error.

image

Here is the code to try and repro:

-- Name: Scrollbar
-- Description: Scrollbar with diagnostics
-- Link: https://github.com/petertriho/nvim-scrollbar

local scrollbar = require("scrollbar")

local colors = require("utils.colors")

------------------------------------------------------------------------------------------
----------------------------------- CONFIG -----------------------------------------------
------------------------------------------------------------------------------------------

scrollbar.setup({
    excluded_filetypes = {
        "NvimTree",
        "alpha",
        "docker-term",
        "git-term",
    },
    handle = {
        color = colors.background_light,
    },
    marks = {
        Error = { text = { "" }, color = colors.red },
        Warn = { text = { "" }, color = colors.orange },
        Info = { text = { "" }, color = colors.blue },
        Hint = { text = { "" }, color = colors.yellow },
        Misc = { text = { "" }, color = colors.green },
    },
})

[Bug] Scrollbar disappears from split

Configuration

require("scrollbar").setup({
  handlers = {
    diagnostic = true,
    search = false,
  },
})

Version

NVIM v0.7.0-dev+839-g09d270bce

Behavior & reproduction

  1. Open a buffer
  2. Vertically split that buffer
  3. Change focus between the two splits
  4. Observe the below behavior:
scrollbar_disappears.mp4

Expected behavior

Scrollbar state should remain exactly the same when switching windows.

Hello, when there is an error in the code, the scroll bar will prompt. When I fix the code, it is still there. How can I make it disappear?

Describe the bug
Hello, when there is an error in the code, the scroll bar will prompt. When I fix the code, it is still there. How can I make it disappear?

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Version Info (please complete the following information):

  • nvim --version

Additional context
Add any other context about the problem here.

Override for search wont work

Describe the bug
I wanted to get thicker mark line for search result :
image

But nvim-scrollbar seems to be ignoring first entry in search.text table :
image
Notice the "𝝣" works ok, also "━", works ok for errors. It is just single Search mark that gets ignored.

To Reproduce

My marks setup
marks = {
						Search = { text = { "━", "𝝣" }, priority = 0, color = "orange" },
						Error = { text = { "━", "𝝣" }, priority = 1, color = "red" },
						Warn = { text = { "━", "𝝣" }, priority = 2, color = "yellow" },
						Info = { text = { "-","=" }, priority = 3, color = "blue" },
						Hint = { text = { "-","=" }, priority = 4, color = "green" },
						Misc = { text = { "━", "𝝣" }, priority = 5, color = "purple" },
					}, 

Expected behavior
Signle search mark should change to new symbol

Version Info (please complete the following information):
NVIM v0.7.0-dev+806-gf86039de1
Build type: Debug
LuaJIT 2.1.0-beta3

works incorrectly with nvim-cmp

Describe the bug
use nvim-cmp autocompletion, the first placeholder automatically changed to zj.

To Reproduce
Steps to reproduce the behavior:

  1. use nvim-cmp autocompletion, choose one item with placeholder.
  2. the first placeholder automatically changed to zj.

Expected behavior
the first placeholder should remain same.

Screenshots
output

Version Info (please complete the following information):

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.7.0/share/nvim"

[Feature Request] Show marks

I think it would be a good addition to also show marks a user has set (via m[a-zA-Z]). This could be opt in to avoid clutter, but should not be an issue since marks are set manually and there usually aren't that many.

Second search example in readme not showing marks

Describe the bug
https://github.com/petertriho/nvim-scrollbar#search
Second example of search setup not enabling search marks on scrollbar. I added this instead of require("scrollbar.handlers.search").setup():

require("hlslens").setup({
   build_position_cb = function(plist, _, _, _)
        require("scrollbar.handlers.search").handler.show(plist.start_pos)
   end,
})

vim.cmd([[
    augroup scrollbar_search_hide
        autocmd!
        autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
    augroup END
]])

Version Info (please complete the following information):

NVIM v0.8.0-1210-gd367ed9b2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az457-787

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

[Feature Request] Add interactivity

I don't know how hard this would be to implement, but a simple form of interactivity would be to make the bar clickable and scroll to the position that was clicked on. This would allow for fast and relevant navigation, especially if something like marks are added.

Works incorrectly when a line is too long and is split into multiple lines

Describe the bug

When a line is too long and is split into multiple lines, the scrollbar behaves incorrectly.

To Reproduce

  1. Fill the screen with long lines that don't fit into a single line.
  2. The scrollbar appears only when there are enough text lines, instead of enough visual lines.
  3. The scrollbar character only appears at the first visual line of each text line and seems broken. Some lines even don't have the scrollbar character.

Expected behavior

  1. The scrollbar appears when the screen is full, instead of when there are enough text lines.
  2. The scrollbar appearance should be continuous.

Screenshots

broken scrollbar

Version Info (please complete the following information):

  • nvim --version
NVIM v0.7.0-dev+1132-g15004473b5
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-git/src/build/config -I/build/neovim-git/src/neovim-git/src -I/usr/include -I/build/neovim-git/src/build/src/nvim/auto -I/build/neovim-git/src/build/include
Compiled by builduser

Features: +acl +iconv +tui

[Feature Request] Make search marks independent of hlslens

I think it would be quite possible to implement showing search results right in this plugin without requiring installing another plugin (that also overwrites n mappings). The only requirements I could imagine to do this would be plenary.nvim for async stuff (a plugin most people should have installed anyway, since a lot of plugins require it including telescope) and an external search program, preferably ripgrep but grep should do.

An example implementation could be how todo-comments.nvim does it: https://github.com/folke/todo-comments.nvim/blob/main/lua/todo-comments/search.lua

One could then use the / register to get the last searched pattern. Since this works asynchronously and potentially uses rg it should be reasonably fast without touching the native search functionality.

Get diagnostics from location list and quickfix list

Is your feature request related to a problem? Please describe.
Currently diagnostics only seem to be fetched from LSP. However, I also use ALE and all those diagnostics don't appear in the scrollbar.

Describe the solution you'd like
Include entries from the location and quckfix list into the sidebar.

I did a quick research on how to accomplish that.
You can call getloclist() and getqflist(), which will return a list of dicts. Each dict contains a "type" key that can be "I", "W", or "E", and an "lnum" key for the line number. For getqflist you probably also have to compare the "bufnr" key to the current buffer. getloclist accepts an argument to specifiy the current window.
Then proceed as usual to add a marker.

Doesn't work with folding

image

As in the above image, the scrollbar is in the wrong position.
Expanding all foldings solves this problem.

Bug: Having more than one Custom Handler disables all but last handling

Describe the bug
I played a bit with custom Handlers, and I noticed that when I register more than one custom handler, all but the last one seem to be disabled.

To Reproduce
create two handlers with require("scrollbar.handlers").register("foo", function(bufnr) ... end

Expected behavior
All custom handlers should work

Version Info (please complete the following information):

macOS 13.0.1 (M1)
neovim 0.8.0 (homebrew)

Change the width of the scrollbar handle

Is your feature request related to a problem? Please describe.
As title

Describe the solution you'd like
An option in the setup to setup the width of the handle

Describe alternatives you've considered
No.

Additional context
No.

Show gitsings in nivm-scrollbar

Is your feature request related to a problem? Please describe.
Its hard to spot places that were changed without having to scroll through whole file

Describe the solution you'd like
Would be great if nvim-scrollbar would allow have git-signs integration - where it would show modifier places on scroll view

Describe alternatives you've considered
I believe there is nothing like this

Additional context
I would imagine this would look something like this:
image

Investigate floating windows to contain scrollbar

Probably worth investigating if creating a floating window that is right aligned to the each window to contain the scrollbar is a viable solution.

The marks can instead just be text placed inside the buffer/window and scrollbar handle be extmarks, meaning rendering marks and the scrollbar handle can be separated

This should fix/make implementation simpler #6, #34 and #4

Scrollbar cut off when having overscroll (e.g. `zz` on last line)

Describe the bug
When having overscroll (scrolled beyond the last line of the file), the scrollbar is cut off at the top. This is relevant for people remapping j to jzz and similar stuff.

To Reproduce
Steps to reproduce the behavior:

  1. Go to last line of file
  2. zz

Now the top half of the scrollbar is missing.

Expected behavior
Scrollbar works correctly with overscroll

Screenshots
when somewhere in the editor
image

when at the last line, and then pressed zz
image

Version Info (please complete the following information):

macOS 13.0.1 (M1)
neovim 0.8.0 (homebrew)

[Feature Request] Add issue templates

It would be nice for community engagement if this repo had issue templates. These are easily set up with two clicks in the settings>options page, at least the defaults.

The Search Marks are still existed when :let @/ = ""

To Reproduce
Steps to reproduce the behavior:

  1. /word
  2. :let @/ = "" that cancel the searching
  3. The Search Marks are still existed

Expected behavior
The Search Marks are cleaned.

Screenshots
image

Version Info (please complete the following information):

  • NVIM: v0.7.0
  • nvim-scrollbar: commit 0a530f3
  • nvim-hlslens: commit 19440941

[Bug] Scrollbar moves in both windows when the same buffer is vertically split

Configuration

require("scrollbar").setup({
  handlers = {
    diagnostic = true,
    search = false,
  },
})

Version

NVIM v0.7.0-dev+839-g09d270bce

Behavior & reproduction

  1. Open a buffer
  2. Vertically split that buffer
  3. Scroll in one window (noting at this point there are two windows, one buffer)
  4. Observe the below behavior:
scrollbar_both_windows.mp4

Expected behavior

The scrollbar should remain static in windows that are not focused.

[Bug]: Editing a .h file makes nvim lag

Describe the bug
When I edit an .h file and scroll down, nvim is extremely laggy. I then tested all the plugins and found out that the scrollbar plugin is the problem. I have the following code in my "init.lua" file of nvim:

local colors = require("tokyonight.colors").setup()

require("scrollbar").setup({
handle = {
  color = colors.bg_highlight,
},
  marks = {
   Search = { colour = colors.orange },
   Error = { colour = colors.error },
   Warn = { colour = colors.warning },
   Info = { colour = colors.info },
   Hint = { colour = colors.hint },
   Misc = { colour = colors.purple },
  }
})

As soon as I comment out this part of the code and restart nvim. Everything is lag-free.

To Reproduce
Steps to reproduce the behavior:

  1. open an .h file (e.g. .config/dwm/config.h)
  2. scroll down to produce lag
  3. comment out the above code (.config/nvim/init.lua)
  4. restart nvim
  5. open the .h file again and see the difference

Expected behavior
If the problem is not with me, then it should lag with the program code when you scroll down and if you comment out the program code from above, then nvim should run normally again when editing the .h file.

Version:
Nvim v0.7.0

Using with coc.nvim diagnostics

Describe the bug
I'm not sure how to get coc-diagnostic's errors and warnings to show up in the scrollbar.

To Reproduce
Steps to reproduce the behavior:
I have the following setup config

require("scrollbar").setup({
    show = true,
    set_highlights = true,
    handle = {
        text = " ",
        color = "white",
        cterm = nil,
        highlight = "CursorColumn",
        hide_if_all_visible = true, -- Hides handle if all lines are visible
    },
    marks = {
        Search = {
            text = { "-", "=" },
            priority = 0,
            color = "orange",
            cterm = nil,
            highlight = "Search",
        },
        Error = {
            text = { "-", "=" },
            priority = 1,
            color = "red",
            cterm = "red",
            --highlight = "DiagnosticVirtualTextError",
            highlight = "CocErrorSign",
        },
        Warn = {
            text = { "-", "=" },
            priority = 2,
            color = "yellow",
            cterm = "yellow",
            highlight = "DiagnosticVirtualTextWarn",
        },
        Info = {
            text = { "-", "=" },
            priority = 3,
            color = "green",
            cterm = "green",
            --highlight = "DiagnosticVirtualTextInfo",
            highlight = "CocInfoVirtualText",
        },
        Hint = {
            text = { "-", "=" },
            priority = 4,
            color = "blue",
            cterm = "blue",
            highlight = "DiagnosticVirtualTextHint",
        },
        Misc = {
            text = { "-", "=" },
            priority = 5,
            color = "red",
            cterm = "red",
            highlight = "Normal",
        },
    },
    excluded_buftypes = {
        "terminal",
    },
    excluded_filetypes = {
        "prompt",
        "TelescopePrompt",
    },
    autocmd = {
        render = {
            "BufWinEnter",
            "TabEnter",
            "TermEnter",
            "WinEnter",
            "CmdwinLeave",
            "TextChanged",
            "VimResized",
            "WinScrolled",
        },
    },
    handlers = {
        diagnostic = true,
        search = true, -- Requires hlslens to be loaded, will run require("scrollbar.handlers.search").setup() for you
    },
})

Search marks show up in the scrollbar but not Coc diagnostics errors.
Screen Shot 2022-02-27 at 12 53 41 AM

Expected behavior
Expect to see the error mark in the scrollbar.

Screenshots
Please see above.

Version Info (please complete the following information):

  • nvim --version
:version
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.6.1/share/nvim"

Additional context
N/A

Search tags do not disappear

Describe the bug
I map to nohls, but while I press backspace, the search tags still exists on the scrollbar.

Screenshots
search
image
press backspace
image

Version Info (please complete the following information):
NVIM v0.8.0-dev+95-g07660193a
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Add "handler" for cursor position

I find it helpful to have the cursor displayed as a mark on the scrollbar (as VS Code does it), so I have an idea of exactly where it is in relation to the more interesting marks

Cannot see ScrollbarHandle in terminal neovim

Describe the bug
I'm unable to see the scrollbar handle.

To Reproduce
Steps to reproduce the behavior:

  1. Install this plugin.
  2. Setup etc.
  3. Open a long file (in terminal/non-GUI nvim).
  4. No scrollbar shown.

Expected behavior
I expect to see a scrollbar.

I noticed that this plugin highlights the scrollbar using the ScrollbarHandle highlight, which is defined here: https://github.com/petertriho/nvim-scrollbar/blob/main/lua/scrollbar/utils.lua#L29

However that does not set any terminal highlighting. It also clears my highlight link.

When I replace that line with a hardcoded string.format("highlight link %s StatusLine", M.get_highlight_name("", true)), I see the scrollbar. Though I'm not sure that's the best fix.

Version Info (please complete the following information):

:version
NVIM v0.6.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az32-74

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

I'm happy to suggest a PR if that's helpful.

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.