Skip to content

Commit 0d537ca

Browse files
committed
feat: allow height to be float
1 parent ac2b062 commit 0d537ca

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

lua/dap-view/actions.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ M.open = function()
5454

5555
local is_term_win_valid = term_winnr and api.nvim_win_is_valid(term_winnr)
5656

57-
local term_position = require("dap-view.util").inverted_directions[setup.config.windows.terminal.position]
57+
local windows_config = setup.config.windows
58+
59+
local term_position = require("dap-view.util").inverted_directions[windows_config.terminal.position]
5860

5961
local winnr = api.nvim_open_win(bufnr, false, {
6062
split = is_term_win_valid and term_position or "below",
6163
win = is_term_win_valid and term_winnr or -1,
62-
height = setup.config.windows.height,
64+
height = windows_config.height < 1 and math.floor(vim.go.lines * windows_config.height)
65+
or windows_config.height,
6366
})
6467

6568
assert(winnr ~= 0, "Failed to create nvim-dap-view window")

lua/dap-view/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local M = {}
1313
---@field start_hidden boolean Don't show the terminal window when starting a new session
1414

1515
---@class dapview.WindowsConfig
16-
---@field height integer
16+
---@field height integer If > 1 number of lines, else percentage the windows should use
1717
---@field terminal dapview.TerminalConfig
1818

1919
---@class dapview.WinbarHeaders

lua/dap-view/term/init.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ end
2828
---IV. There's no term win or it is invalid
2929
---@return integer?
3030
M.open_term_buf_win = function()
31-
local term_config = setup.config.windows.terminal
31+
local windows_config = setup.config.windows
32+
local term_config = windows_config.terminal
3233
local should_term_be_hidden = vim.tbl_contains(term_config.hide, state.last_active_adapter)
3334

3435
if dap.session() and state.term_bufnr and not should_term_be_hidden then
@@ -38,8 +39,9 @@ M.open_term_buf_win = function()
3839
state.term_winnr = api.nvim_open_win(state.term_bufnr, false, {
3940
split = is_win_valid and term_config.position or "below",
4041
win = is_win_valid and state.winnr or -1,
41-
height = setup.config.windows.height,
42-
width = term_config.width < 1 and math.floor(vim.o.columns * term_config.width)
42+
height = windows_config.height < 1 and math.floor(vim.go.lines * windows_config.height)
43+
or windows_config.height,
44+
width = term_config.width < 1 and math.floor(vim.go.columns * term_config.width)
4345
or term_config.width,
4446
})
4547

lua/dap-view/views/util.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ M.jump_to_location = function(pattern, column)
4545
win = api.nvim_open_win(0, true, {
4646
split = "above",
4747
win = -1,
48-
height = vim.o.lines - config.windows.height,
48+
height = config.windows.height < 1 and math.floor(vim.go.lines * (1 - config.windows.height))
49+
or vim.go.lines - config.windows.height,
4950
})
5051
end
5152

0 commit comments

Comments
 (0)