diff --git a/README.md b/README.md index a73a6896..57eb5644 100644 --- a/README.md +++ b/README.md @@ -988,35 +988,14 @@ the symbols: the source window `win` and the range of the symbol `range` - Default: ```lua - function(_, range) - local invisible = range['end'].line - vim.fn.line('w$') + 1 - if invisible > 0 then - local view = vim.fn.winsaveview() --[[@as vim.fn.winrestview.dict]] - view.topline = math.min( - view.topline + invisible, - math.max(1, range.start.line - vim.wo.scrolloff + 1) - ) - vim.fn.winrestview(view) - end - end + function() end ``` - `opts.symbol.jump.reorient`: `fun(win: integer, range: {start: {line: integer, character: integer}, end: {line: integer, character: integer}})` - Function to reorient the source window after jumping to symbol given the source window `win` and the range of the symbol `range` - Default: ```lua - function(win, range) - local view = vim.fn.winsaveview() - local win_height = vim.api.nvim_win_get_height(win) - local topline = range.start.line - math.floor(win_height / 4) - if - topline > view.topline - and topline + win_height < vim.fn.line('$') - then - view.topline = topline - vim.fn.winrestview(view) - end - end + function() end ``` #### Sources diff --git a/doc/dropbar.txt b/doc/dropbar.txt index 661d8509..29328471 100644 --- a/doc/dropbar.txt +++ b/doc/dropbar.txt @@ -914,35 +914,14 @@ the symbols: the source window `win` and the range of the symbol `range` - Default: >lua - function(_, range) - local invisible = range['end'].line - vim.fn.line('w$') + 1 - if invisible > 0 then - local view = vim.fn.winsaveview() --[[@as vim.fn.winrestview.dict]] - view.topline = math.min( - view.topline + invisible, - math.max(1, range.start.line - vim.wo.scrolloff + 1) - ) - vim.fn.winrestview(view) - end - end + function() end < - `opts.symbol.jump.reorient`: `fun(win: integer, range: {start: {line: integer, character: integer}, end: {line: integer, character: integer}})` - - Function to reorient the source window after jumping to symbol given - the source window `win` and the range of the symbol `range` - - Default: >lua + - Function to reorient the source window after jumping to symbol given + the source window `win` and the range of the symbol `range` + - Default: >lua - function(win, range) - local view = vim.fn.winsaveview() - local win_height = vim.api.nvim_win_get_height(win) - local topline = range.start.line - math.floor(win_height / 4) - if - topline > view.topline - and topline + win_height < vim.fn.line('$') - then - view.topline = topline - vim.fn.winrestview(view) - end - end, + function() end < .............................................................................. diff --git a/lua/dropbar/configs.lua b/lua/dropbar/configs.lua index 9dd8638e..6ac2a90d 100644 --- a/lua/dropbar/configs.lua +++ b/lua/dropbar/configs.lua @@ -252,35 +252,14 @@ M.opts = { end, preview = { ---Reorient the preview window on previewing a new symbol - ---@param _ integer source window id, ignored - ---@param range {start: {line: integer}, end: {line: integer}} 0-indexed - reorient = function(_, range) - local invisible = range['end'].line - vim.fn.line('w$') + 1 - if invisible > 0 then - local view = vim.fn.winsaveview() --[[@as vim.fn.winrestview.dict]] - view.topline = math.min( - view.topline + invisible, - math.max(1, range.start.line - vim.wo.scrolloff + 1) - ) - vim.fn.winrestview(view) - end - end, + ---@param win integer source window id, ignored + ---@param range { start: { line: integer }, end: { line: integer } } 0-indexed + reorient = function(win, range) end, -- luacheck: ignore 212 }, jump = { ---@param win integer source window id - ---@param range {start: {line: integer}, end: {line: integer}} 0-indexed - reorient = function(win, range) - local view = vim.fn.winsaveview() - local win_height = vim.api.nvim_win_get_height(win) - local topline = range.start.line - math.floor(win_height / 4) - if - topline > view.topline - and topline + win_height < vim.fn.line('$') - then - view.topline = topline - vim.fn.winrestview(view) - end - end, + ---@param range { start: { line: integer }, end: { line: integer } } 0-indexed + reorient = function(win, range) end, -- luacheck: ignore 212 }, }, bar = {