Skip to content

Commit

Permalink
refactor(configs)!: don't reorient on jump or preview by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekaboo committed Jan 26, 2025
1 parent 36eca19 commit b27bb03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 75 deletions.
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 5 additions & 26 deletions doc/dropbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
<

..............................................................................
Expand Down
31 changes: 5 additions & 26 deletions lua/dropbar/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit b27bb03

Please sign in to comment.