mirror of
https://github.com/mfussenegger/nvim-dap
synced 2024-09-16 14:24:03 +02:00
Allow passing window options for the repl in repl.open
This commit is contained in:
parent
7192104442
commit
254889c316
1 changed files with 23 additions and 1 deletions
|
@ -127,7 +127,14 @@ local function execute(text)
|
|||
end
|
||||
|
||||
|
||||
function M.open()
|
||||
--- Toggle the REPL
|
||||
--
|
||||
--@param winopts optional table which may include:
|
||||
-- `height` to set the window height
|
||||
-- `width` to set the window width
|
||||
-- Any other key/value pair, that will be treated as window
|
||||
-- option.
|
||||
function M.open(winopts)
|
||||
if win and api.nvim_win_is_valid(win) and api.nvim_win_get_buf(win) == buf then
|
||||
return
|
||||
end
|
||||
|
@ -160,6 +167,21 @@ function M.open()
|
|||
win = api.nvim_get_current_win()
|
||||
api.nvim_win_set_buf(win, buf)
|
||||
api.nvim_set_current_win(current_win)
|
||||
if winopts then
|
||||
assert(
|
||||
type(winopts) == 'table',
|
||||
'winopts must be a table, not ' .. type(winopts) .. ': ' .. vim.inspect(winopts)
|
||||
)
|
||||
for k, v in pairs(winopts) do
|
||||
if k == 'width' then
|
||||
api.nvim_win_set_width(win, v)
|
||||
elseif k == 'height' then
|
||||
api.nvim_win_set_height(win, v)
|
||||
else
|
||||
api.nvim_win_set_option(win, k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue