Update nvim
This commit is contained in:
1 parent
1349e3b76f
commit
f207707bc9
11 files changed
+115
-214
No files matched your search
@@ -1,31 +1,55 @@
|
||||
-- Pinned to the v2 rewrite branch until it replaces v1 on main (2026-11-16,
|
||||
-- see https://github.com/petertriho/nvim-scrollbar/issues/121). After that,
|
||||
-- switch to `version = vim.version.range("^2")`.
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/petertriho/nvim-scrollbar" },
|
||||
{ src = "https://github.com/petertriho/nvim-scrollbar", version = "refactor/v2" },
|
||||
})
|
||||
|
||||
-- Show illuminated word matches as scrollbar marks. nvim-scrollbar's render
|
||||
-- autocmds (BufWinEnter/WinEnter/TextChanged/VimResized/WinScrolled) do not fire
|
||||
-- on CursorMoved, which is when illuminate refreshes its references, so hook
|
||||
-- those events directly, mirroring how the built-in diagnostic handler works.
|
||||
-- illuminate also refreshes its own refs ~(delay 100ms) after CursorMoved, so
|
||||
-- re-run the highlight refresh on a small debounce for snappy bars.
|
||||
local utils = require("scrollbar.utils")
|
||||
local render = require("scrollbar").throttled_render
|
||||
require("scrollbar").setup({
|
||||
exclude = {
|
||||
filetypes = { ["neo-tree"] = true },
|
||||
},
|
||||
|
||||
local function update_illuminate_marks()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local config = require("scrollbar.config").get()
|
||||
if
|
||||
config.show == false
|
||||
or not vim.api.nvim_buf_is_valid(bufnr)
|
||||
or vim.tbl_contains(config.excluded_buftypes, vim.bo[bufnr].buftype)
|
||||
or vim.tbl_contains(config.excluded_filetypes, vim.bo[bufnr].filetype)
|
||||
then
|
||||
return
|
||||
end
|
||||
-- Search marks are native in v2 (no hlslens dependency like v1).
|
||||
providers = {
|
||||
search = true,
|
||||
gitsigns = true,
|
||||
},
|
||||
|
||||
marks = {
|
||||
Illuminate = { text = "≡", priority = 8, highlight = "Special" },
|
||||
Search = { highlight = "DiagnosticVirtualTextInfo" },
|
||||
Error = { highlight = "DiagnosticFloatingError" },
|
||||
Warn = { highlight = "DiagnosticFloatingWarn" },
|
||||
Info = { highlight = "DiagnosticFloatingInfo" },
|
||||
Hint = { highlight = "DiagnosticFloatingHint" },
|
||||
GitAdd = { highlight = "GitSignsAdd" },
|
||||
GitChange = { highlight = "GitSignsChange" },
|
||||
GitDelete = { highlight = "GitSignsDelete" },
|
||||
},
|
||||
|
||||
scrollbar = {
|
||||
-- Non-focusable so Ctrl+W w never lands on the float; also disables
|
||||
-- click/drag navigation on the scrollbar.
|
||||
mouse = false,
|
||||
-- v1 had no track; the explicit PmenuSbar handle highlight carried over
|
||||
-- would make the thumb indistinguishable from the v2 track, which also
|
||||
-- defaults to PmenuSbar. The v2 defaults (PmenuThumb thumb on a
|
||||
-- PmenuSbar track) give the same subtle-on-subtle look the v1 override
|
||||
-- was after.
|
||||
},
|
||||
})
|
||||
|
||||
-- Show illuminated word matches as scrollbar marks. The illuminate plugin
|
||||
-- refreshes its references after CursorMoved, so hook the events directly and
|
||||
-- publish through the provider API. `buffer = "provider"` ownership means the
|
||||
-- manager dispatches no automatic buffer refreshes; our autocmds own that.
|
||||
-- illuminate also refreshes its own refs ~100ms after CursorMoved, so re-run
|
||||
-- the refresh on a small debounce for snappy bars.
|
||||
local function get_illuminate_marks(bufnr)
|
||||
local ok, reference = pcall(require, "illuminate.reference")
|
||||
if not ok then
|
||||
return
|
||||
return {}
|
||||
end
|
||||
|
||||
-- illuminate stores refs as { {0-indexed line, col}, {0-indexed line, col} },
|
||||
@@ -40,47 +64,43 @@ local function update_illuminate_marks()
|
||||
line = line,
|
||||
text = "≡",
|
||||
type = "Illuminate",
|
||||
level = 1,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local marks = utils.get_scrollbar_marks(bufnr)
|
||||
marks.Illuminate = illuminate_marks
|
||||
utils.set_scrollbar_marks(bufnr, marks)
|
||||
|
||||
render()
|
||||
return illuminate_marks
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorHold", "TextChanged", "BufEnter", "WinEnter" }, {
|
||||
group = vim.api.nvim_create_augroup("scrollbar_illuminate", { clear = true }),
|
||||
callback = function(args)
|
||||
update_illuminate_marks()
|
||||
if args.event == "CursorMoved" or args.event == "TextChanged" then
|
||||
vim.defer_fn(update_illuminate_marks, 250)
|
||||
require("scrollbar.providers").register({
|
||||
name = "illuminate",
|
||||
refresh_owner = { buffer = "provider" },
|
||||
|
||||
refresh = function(bufnr)
|
||||
return get_illuminate_marks(bufnr)
|
||||
end,
|
||||
|
||||
setup = function(context)
|
||||
local function publish(bufnr)
|
||||
bufnr = (bufnr == nil or bufnr == 0) and vim.api.nvim_get_current_buf() or bufnr
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
if context.is_buffer_eligible(bufnr) then
|
||||
context.set_marks(bufnr, get_illuminate_marks(bufnr))
|
||||
else
|
||||
context.clear_marks(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorHold", "TextChanged", "BufEnter", "WinEnter" }, {
|
||||
group = context.create_augroup("illuminate"),
|
||||
callback = function(args)
|
||||
publish(args.buf)
|
||||
if args.event == "CursorMoved" or args.event == "TextChanged" then
|
||||
vim.defer_fn(function()
|
||||
publish(args.buf)
|
||||
end, 250)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
require("scrollbar").setup({
|
||||
excluded_filetypes = { "neo-tree" },
|
||||
handle = {
|
||||
highlight = "PmenuSbar",
|
||||
},
|
||||
marks = {
|
||||
Illuminate = { text = "≡", priority = 8, highlight = "Special" },
|
||||
Search = { highlight = "DiagnosticVirtualTextInfo" },
|
||||
Error = { highlight = "DiagnosticFloatingError" },
|
||||
Warn = { highlight = "DiagnosticFloatingWarn" },
|
||||
Info = { highlight = "DiagnosticFloatingInfo" },
|
||||
Hint = { highlight = "DiagnosticFloatingHint" },
|
||||
GitAdd = { highlight = "GitSignsAdd" },
|
||||
GitChange = { highlight = "GitSignsChange" },
|
||||
GitDelete = { highlight = "GitSignsDelete" },
|
||||
},
|
||||
handlers = {
|
||||
search = false, -- requires hlslens
|
||||
diagnostic = true,
|
||||
gitsigns = true,
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user