diff options
| author | William Boman <william@redwill.se> | 2022-07-28 14:10:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-28 12:10:03 +0000 |
| commit | 86eb9f3662078ee58678cd4a2d533f982298e99d (patch) | |
| tree | e6b92bfcaf69d2b46f0ba22c8353795b38a94fc8 | |
| parent | chore: update generated code (#177) (diff) | |
| download | mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar.gz mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar.bz2 mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar.lz mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar.xz mason-86eb9f3662078ee58678cd4a2d533f982298e99d.tar.zst mason-86eb9f3662078ee58678cd4a2d533f982298e99d.zip | |
feat(ui): hoist cursor when switching tab (#178)
| -rw-r--r-- | lua/mason-core/ui/display.lua | 4 | ||||
| -rw-r--r-- | lua/mason/ui/components/tabs.lua | 1 | ||||
| -rw-r--r-- | lua/mason/ui/instance.lua | 6 |
3 files changed, 10 insertions, 1 deletions
diff --git a/lua/mason-core/ui/display.lua b/lua/mason-core/ui/display.lua index 2bae3d81..285a153a 100644 --- a/lua/mason-core/ui/display.lua +++ b/lua/mason-core/ui/display.lua @@ -511,6 +511,10 @@ function M.new_view_only_win(name, filetype) end end end, + get_win_config = function() + assert(win_id ~= nil, "Window has not been opened, cannot get config.") + return vim.api.nvim_win_get_config(win_id) + end, } end diff --git a/lua/mason/ui/components/tabs.lua b/lua/mason/ui/components/tabs.lua index dc1e1b52..be9a0232 100644 --- a/lua/mason/ui/components/tabs.lua +++ b/lua/mason/ui/components/tabs.lua @@ -34,5 +34,6 @@ return function(state) end return Ui.CascadingStyleNode({ "INDENT" }, { Ui.HlTextNode { tabs }, + Ui.StickyCursor { id = "tabs" }, }) end diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua index 695d25c9..7fcf2452 100644 --- a/lua/mason/ui/instance.lua +++ b/lua/mason/ui/instance.lua @@ -109,7 +109,7 @@ local function remove(list, item) return list end -local window = display.new_view_only_win("Installer Info", "mason.nvim") +local window = display.new_view_only_win("mason.nvim", "mason.nvim") local packages = _.sort_by(_.prop "name", registry.get_all_packages()) window.view( @@ -384,6 +384,10 @@ end local function set_view(event) local view = event.payload + local cursor_line = window.get_cursor()[1] + if cursor_line > (window.get_win_config().height * 0.75) then + window.set_sticky_cursor "tabs" + end mutate_package_visibility(function(state) state.view.current = view state.view.has_changed = true |
