Skip to content

Commit

Permalink
Feat: Automatically open fold under cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubbortlik committed Sep 19, 2024
1 parent 87e224a commit 5c050c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/gitlab/reviewer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ M.jump = function(file_name, line_number, new_buffer)
line_number = number_of_lines
end
vim.api.nvim_win_set_cursor(0, { line_number, 0 })
u.open_fold_under_cursor()
end

---Get the data from diffview, such as line information and file name. May be used by
Expand Down
6 changes: 6 additions & 0 deletions lua/gitlab/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,10 @@ M.get_nested_field = function(table, field)
end
end

M.open_fold_under_cursor = function()
if vim.fn.foldclosed(vim.fn.line(".")) > -1 then
vim.cmd("normal! zo")
end
end

return M

0 comments on commit 5c050c5

Please sign in to comment.