Skip to content
Merged
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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [Usage](#usage)
- [Recommended Setup](#recommended-setup)
- [Hide Terminal](#hide-terminal)
- [Terminal Position and Integration](#terminal-position-and-integration)
- [Highlight Groups](#highlight-groups)
- [Filetypes and autocommands](#filetypes-and-autocommands)
- [Roadmap](#roadmap)
Expand Down Expand Up @@ -119,6 +120,8 @@ return {
windows = {
height = 12,
terminal = {
-- 'left'|'right': Terminal position in layout
position = "left",
-- List of adapters for which the terminal should be hidden
hide = {},
},
Expand Down Expand Up @@ -196,6 +199,21 @@ return {
}
```

#### Terminal Position and Integration

When setting `windows.terminal.position` to `right` the views window may be used
to display the current breakpoint because `nvim-dap` defaults to the global
`switchbuf` setting. A common solution is to set `switchbuf` to "useopen":

```lua
require("dap").defaults.fallback.switchbuf = "useopen"
```

If you are using an adapter that does not natively support the `nvim-dap` integrated
terminal, you can get the `winnr` and `bufnr` of the `nvim-dap-view` terminal via
`dap-view.state` and use `vim.fn.jobstart` to start your debugger in the `nvim-dap-view`
terminal! An example can be found [here](https://github.com/catgoose/nvim/blob/a783e0fe931a5e417c4e3cc7e964793d895862e6/lua/config/dap/go.lua)

### Highlight Groups

`nvim-dap-view` defines 8 highlight groups:
Expand Down
4 changes: 3 additions & 1 deletion lua/dap-view/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ M.open = function()

local is_term_win_valid = term_winnr ~= nil and api.nvim_win_is_valid(term_winnr)

local term_position = config.windows.terminal.position == "left" and "right" or "left"

local winnr = api.nvim_open_win(bufnr, false, {
split = is_term_win_valid and "right" or "below",
split = is_term_win_valid and term_position or "below",
win = is_term_win_valid and term_winnr or -1,
height = config.windows.height,
})
Expand Down
2 changes: 2 additions & 0 deletions lua/dap-view/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local M = {}

---@class TerminalConfig
---@field hide string[] Hide the terminal for listed adapters.
---@field position 'right' | 'left'

---@class WindowsConfig
---@field height integer
Expand All @@ -27,6 +28,7 @@ M.config = {
windows = {
height = 12,
terminal = {
position = "left",
hide = {},
},
},
Expand Down
1 change: 1 addition & 0 deletions lua/dap-view/setup/validate/windows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function M.validate(config)
}, config)

validate("windows.terminal", {
position = { config.terminal.position, "string" },
hide = { config.terminal.hide, "table" },
}, config.terminal)
end
Expand Down