-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
repl.lua
53 lines (44 loc) · 1.2 KB
/
repl.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local nio = require("nio")
local dap = require("dap")
return function()
local dapui = { elements = {} }
---@class dapui.elements.repl
---@toc_entry REPL
---@text
--- The REPL provided by nvim-dap.
dapui.elements.repl = {}
---@nodoc
local function get_buffer()
-- TODO: All of this is a hack because of an error with indentline when buffer
-- is opened in a window so have to manually find the window that was opened.
local all_wins = nio.api.nvim_list_wins()
local open_wins = {}
for _, win in pairs(all_wins) do
open_wins[win] = true
end
pcall(dap.repl.open, {})
local buf = nio.fn.bufnr("dap-repl")
for _, win in ipairs(nio.api.nvim_list_wins()) do
if not open_wins[win] then
pcall(nio.api.nvim_win_close, win, true)
break
end
end
return buf
end
local buf
---@nodoc
function dapui.elements.repl.render() end
---@nodoc
function dapui.elements.repl.buffer()
if not nio.api.nvim_buf_is_valid(buf or -1) then
buf = get_buffer()
end
return buf
end
---@nodoc
function dapui.elements.repl.float_defaults()
return { width = 80, height = 20, enter = true }
end
return dapui.elements.repl
end