Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix position of preview window #413

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/dashboard/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function view:open_preview(opt)
})

self:preview_events()
return self.preview_bufnr, self.preview_winid
end

return view
2 changes: 1 addition & 1 deletion lua/dashboard/theme/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ local function generate_header(config)
local empty_table = utils.generate_empty_table(config.file_height + 4)
api.nvim_buf_set_lines(config.bufnr, 0, -1, false, utils.center_align(empty_table))
local preview = require('dashboard.preview')
preview:open_preview({
return preview:open_preview({
width = config.file_width,
height = config.file_height,
cmd = config.command .. ' ' .. config.file_path,
Expand Down
10 changes: 9 additions & 1 deletion lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ local function theme_instance(config)
if config.disable_move then
utils.disable_move_key(config.bufnr)
end
require('dashboard.theme.header').generate_header(config)
local _, preview_winid = require('dashboard.theme.header').generate_header(config)
gen_shortcut(config)
load_packages(config)
gen_center(plist, config)
Expand All @@ -499,6 +499,14 @@ local function theme_instance(config)
api.nvim_buf_set_lines(config.bufnr, 0, 0, false, fill)
vim.bo[config.bufnr].modifiable = false
vim.bo[config.bufnr].modified = false

-- re-set the position of preview window with top padding = size
if preview_winid then
local winconfig = api.nvim_win_get_config(preview_winid)
winconfig.row = size + 2
api.nvim_win_set_config(preview_winid, winconfig)
end

--defer until next event loop
vim.schedule(function()
api.nvim_exec_autocmds('User', {
Expand Down