From 1f4f64e4054d2ba5e88ec3ee00917eb4ee42329e Mon Sep 17 00:00:00 2001 From: Wesley Merkel Date: Mon, 2 Jan 2023 22:59:57 -0700 Subject: [PATCH] Make preview window follow cursor when scrolling --- lua/gitsigns/popup.lua | 8 ++++++++ teal/gitsigns/popup.tl | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lua/gitsigns/popup.lua b/lua/gitsigns/popup.lua index 4bd74a40..4cb925da 100644 --- a/lua/gitsigns/popup.lua +++ b/lua/gitsigns/popup.lua @@ -173,6 +173,14 @@ function popup.create0(lines, opts, id) end, }) + + api.nvim_create_autocmd({ 'WinScrolled' }, { + group = group, + callback = function() + api.nvim_win_set_config(winid, opts1) + end, + }) + return winid, bufnr end diff --git a/teal/gitsigns/popup.tl b/teal/gitsigns/popup.tl index a1dbf59b..04a496ad 100644 --- a/teal/gitsigns/popup.tl +++ b/teal/gitsigns/popup.tl @@ -173,6 +173,14 @@ function popup.create0(lines: {string}, opts: {string:any}, id: string): integer end }) + -- update window position to follow the cursor when scrolling + api.nvim_create_autocmd({'WinScrolled'}, { + group = group, + callback = function() + api.nvim_win_set_config(winid, opts1) + end + }) + return winid, bufnr end