Commit graph

638 commits

Author SHA1 Message Date
Mathias Fussenegger
0a02ed103e Use ps ah -u $USER for dap.utils.pick_process
To show more processes. Otherwise it's restricted to terminal processes.
2023-07-26 16:34:43 +02:00
Mathias Fussenegger
d17d1bba23 Don't switch away from REPL on stopped event; Fix close/wipe handling in widgets
Follow up to https://github.com/mfussenegger/nvim-dap/pull/982
2023-07-17 16:24:05 +02:00
Mathias Fussenegger
3bde6f7860 Focus window with breakpoint on stopped event
So far it set the cursor, but didn't change the active window.

See https://github.com/mfussenegger/nvim-dap/issues/980#issuecomment-1625103893
2023-07-09 14:45:48 +02:00
Mathias Fussenegger
bb1ddce6cd Fix overwrite spelling
Closes https://github.com/mfussenegger/nvim-dap/issues/975
2023-06-30 08:48:34 +02:00
Karl Yngve Lervåg
a6d48d2340
Allow setting title for widgets via winopts (#974) 2023-06-14 21:01:48 +02:00
Mathias Fussenegger
7c1d47cf71 Send sigterm to server adapter executable after connection closes
Should fix https://github.com/mfussenegger/nvim-dap/issues/948
2023-06-01 16:39:43 +02:00
Mathias Fussenegger
d234b0a77f Replace calls to nvim[_buf|_win]_[gs]et_option
They are getting deprecated: https://github.com/neovim/neovim/pull/23670
2023-06-01 13:10:54 +02:00
Armand Touminet
56118cee6a
Don't clear history on new session (#942)
It's sometimes useful to re-use the same commands across sessions.
2023-05-17 20:55:20 +02:00
Jongwook Choi
d451c30dda
repl: Move cursor to end of line on history selection (up/down) (#951)
Makes the behavior more consistent with other REPLs (ipython, bash, zsh, ...)
2023-05-17 20:51:20 +02:00
Mathias Fussenegger
6cedcb527e Bump supported versions 2023-04-21 13:47:22 +02:00
Mathias Fussenegger
55e3a7fdc6 Show warning if adapter process exits with code ~= 0 2023-04-21 13:35:32 +02:00
Mathias Fussenegger
debd7c2f80 Add filter option to pick_process 2023-04-07 13:22:24 +02:00
Mathias Fussenegger
1dd02e82c7 Document continue opts 2023-03-31 08:49:52 +02:00
Mathias Fussenegger
da439b2d9c Change startDebugging to connect to parent adapter if type=server with executable
With this change `startDebugging` should work out of the box for debug
adapters configured with type=server and an executable.

For example, for vscode-js-debug, instead of a custom adapter factory
like:

```lua
require("dap").adapters["pwa-node"] = function(on_config, config, parent)
  local target = config["__pendingTargetId"]
  if target and parent then
    local adapter = parent.adapter --[[@as ServerAdapter]]
    on_config({
      type = "server",
      host = "localhost",
      port = adapter.port
    })
  else
    on_config({
      type = "server",
      host = "localhost",
      port = "${port}",
      executable = {
        command = "node",
        args = {"/path/to/js-debug/src/dapDebugServer.js", "${port}"},
      }
    })
  end
end
```

It will be possible to use the simpler definition:

```lua
require("dap").adapters["pwa-node"] = {
  type = "server",
  host = "localhost",
  port = "${port}",
  executable = {
    command = "node",
    args = {"/path/to/js-debug/src/dapDebugServer.js", "${port}"},
  }
}
```
2023-03-31 08:04:46 +02:00
Mathias Fussenegger
7389e85233 Pass parent session to adapter factory
For the `startDebugging` implementation of `vscode-js-debug` the client
needs to connect to the parent adapter instance.

This change enables an adapter configuration like this:

```lua
require("dap").adapters["pwa-node"] = function(on_config, config, parent)
  local target = config["__pendingTargetId"]
  if target and parent then
    local adapter = parent.adapter --[[@as ServerAdapter]]
    on_config({
      type = "server",
      host = "localhost",
      port = adapter.port
    })
  else
    on_config({
      type = "server",
      host = "localhost",
      port = "${port}",
      executable = {
        command = "node",
        args = {"/path/to/js-debug/src/dapDebugServer.js", "${port}"},
      }
    })
  end
end
```
2023-03-24 18:44:26 +01:00
Mathias Fussenegger
7e81998e31 Fix losing session ref when stepping without being stopped
Closes https://github.com/mfussenegger/nvim-dap/issues/904
2023-03-18 07:31:08 +01:00
Mathias Fussenegger
5e1e259798 Jump on stopped event if same threadId is already marked as stopped
Some debug adapters allow to resume execution using custom evaluate
commands. This unfortunately by-passes some logic that puts the client
into "running" state again.

If the client then receives a stopped event it assumed it
was already stopped and sent a continue request (unless
`auto_continue_if_many_stopped` was disabled)

This changes the condition to also jump if `stopped_thread_id ==
stopped.threadId`

Closes https://github.com/mfussenegger/nvim-dap/issues/898

Co-authored-by: xac <jiangfengxi.c@gmail.com>
2023-03-15 20:11:26 +01:00
Artyom Andreev
a5b059ed83
Make restart opts optional (#900) 2023-03-15 18:26:32 +01:00
Mathias Fussenegger
7319607562 Use local session variable in run_to_cursor
The global variable may change between the initial call and a callback.
A local variable ensures the whole operation uses the same session.
2023-03-08 17:42:45 +01:00
Kei Takahashi
75a94b8b57
Fix lines in scope widget appearing under wrong group (#889)
When dap.ui.Layer.render is called with start == nil and end_ == nil, assign
start = 0 only when the buffer contains a single, empty line. For all other
cases, assign start == line-count instead of start == line-count - 1, which
appears to be causing the line swapping issue.

Add a simple test case where the buffer already contains non-empty lines, and a
new line is added with start == nil and end_ == nil, which should now be
appended to the end.
2023-03-06 18:29:09 +01:00
Mathias Fussenegger
c1bfcd89ef Use first frame with source as top-frame
It doesn't need to have a path. Frames with source reference can be
fetched
2023-03-04 07:45:21 +01:00
Mathias Fussenegger
1cedf68953 Clear children from parent if child session closes
Otherwise the session remains in memory longer than necessary and the
sessions widget continues showing the child session until the parent
session ends.
2023-03-02 08:28:24 +01:00
Mathias Fussenegger
5b986edc95 Reset new flag for run_last
Otherwise repeated run_last will stop terminating the running session

Closes https://github.com/mfussenegger/nvim-dap/issues/878
2023-02-26 08:28:18 +01:00
Mathias Fussenegger
72684a4d70 Set session parent for executable adapter in startDebugging 2023-02-25 14:11:17 +01:00
Mathias Fussenegger
fd291e970a Add some more type annotations 2023-02-22 21:20:09 +01:00
Mathias Fussenegger
9915c3a94e Add tag for dap.status in docs 2023-02-22 20:09:11 +01:00
Mathias Fussenegger
e8dd631ee4 Support label/value objects in ${input} pickString options
Co-authored-by: Giancarlo Misasi <giancarlo-misasi@users.noreply.github.com>
2023-02-22 15:01:56 +01:00
Mathias Fussenegger
0199d026da Set default for ${input} to empty string
Co-authored-by: Giancarlo Misasi <giancarlo-misasi@users.noreply.github.com>
2023-02-22 15:01:56 +01:00
Andreas Schneider
04a0381363 Fix listing breakpoints if properties are nil instead of empty
E5108: Error executing lua:
     ~/.local/share/nvim/lazy/nvim-dap/lua/dap/breakpoints.lua:187: invalid
     value (boolean) at index 2 in table for 'concat'
    stack traceback:
       [C]: in function 'concat'
       ~/.local/share/nvim/lazy/nvim-dap/lua/dap/breakpoints.lua:187: in function 'to_qf_list'
       ~/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:723: in function 'list_breakpoints'
       ...azy/telescope-dap.nvim/lua/telescope/_extensions/dap.lua:115: in function 'list_breakpoints'
       ~/.config/nvim/lua/plugins/dap/init.lua:76: in function <~/.config/nvim/lua/plugins/dap/init.lua:75>
2023-02-22 14:09:14 +01:00
Mathias Fussenegger
76286fd4ba Fix defunct processes using server adapter executable
The uv process handle was closed too early, running into https://github.com/libuv/libuv/issues/1911

Closes https://github.com/mfussenegger/nvim-dap/issues/868
2023-02-21 18:05:58 +01:00
Mathias Fussenegger
d7d67c575c Fix some lua-ls warnings 2023-02-21 17:55:22 +01:00
Marc Jakobi
049eebe3a1 Add support for LuaRocks + release workflow
nvim-dap is a common dependency across Neovim plugins.
Using luarocks may alleviate the need for users to specify their
plugins' dependencies in their plugin manager
(e.g., vim-plug or packer). See also
[this blog post](https://teto.github.io/posts/2021-09-17-neovim-plugin-luarocks.html)
for details.

This PR adds a release workflow that publishes this plugin to
[LuaRocks](https://luarocks.org/) whenever a tag is pushed,
as well as a rockspec that can be used to release to the `dev` channel.

For the release workflow to work, someone with a LuaRocks account
will have to add their API key to this repo's secrets.

Note that I have added a shield to the readme that assumes the
existence of an `mfussenegger/nvim-dap` LuaRocks module.
2023-02-17 12:32:54 +01:00
Mathias Fussenegger
ebd87bd023 Don't add extra newlines to REPL on output events
Closes https://github.com/mfussenegger/nvim-dap/issues/845 and https://github.com/mfussenegger/nvim-dap/issues/854
2023-02-17 08:41:06 +01:00
Mathias Fussenegger
0878669eb3 Don't flip to end/start when moving frames up/down
Closes https://github.com/mfussenegger/nvim-dap/issues/735
2023-02-17 07:54:11 +01:00
Mathias Fussenegger
39bc5aeddf Add startDebugging support 2023-02-17 07:34:07 +01:00
Mathias Fussenegger
82e98f340c Remove BWC from attach
It's been long enough
2023-02-15 14:57:24 +01:00
Mathias Fussenegger
401f5f22b2 Change active session on stopped event; propagate breakpoint changes
Should make working with multiple sessions a bit less clunky
2023-02-10 18:56:22 +01:00
Mathias Fussenegger
0d77088e0a Add support for running concurrent debug sessions
New API:

- `dap.sessions()` to return active debug sessions
- `dap.ui.widgets.sessions` to show active debug sessions

Step functions will change the focus automatically if the currently
focused session is not stopped.
This should make common scenarios like debugging client + server where
you step from making requests on the client to receiving request on the
server convenient.

Note that this is unrelated to `startDebugging` support. The PR here is
about concurrent top-level sessions. `startDebugging` support will
introduce hierarchical sessions. (Probably including something like
`children` in the `Session` object)
2023-02-08 13:45:53 +01:00
Mathias Fussenegger
0e376f00e7 Add pooling for terminal buffers
Will be required for multi-session support. There might be multiple
terminal buffers in use at the same time.
2023-01-29 07:57:19 +01:00
Mathias Fussenegger
d213b7d5bf Replace nested callbacks with coroutines in threads widget 2023-01-28 12:31:03 +01:00
Mathias Fussenegger
e11545b33a Add example mappings for widgets to help 2023-01-28 09:33:14 +01:00
Chris Patti
5b52d25a83
Use Lua for example mappings in help (#834)
Everything else is in Lua too
2023-01-28 07:50:31 +01:00
Mathias Fussenegger
43695d2cb7 Set dap-repl filetype after all options are set
Allows users to override options in a FileType autocmd
2023-01-27 16:14:36 +01:00
Rónán Carrigan
6aab7ce9fa
Set buflisted=false for REPL buffer (#839) 2023-01-27 16:08:58 +01:00
Mathias Fussenegger
6236a9eed5 Allow underscore in id of ${input:<id>}
Fixes https://github.com/mfussenegger/nvim-dap/issues/837
2023-01-27 07:40:37 +01:00
Mathias Fussenegger
c64a6627bb Fix jumping to frame where source must be fetched
Closes https://github.com/mfussenegger/nvim-dap/issues/829
2023-01-18 07:54:37 +01:00
Mathias Fussenegger
5a1479c5d6 Add supportsProgressReporting capability
Not sure which debug adapters make use of this.
Basic implementation that shows title and message in the `status()`
function.

This will also allow extensions to subscribe to the events and display
the information in more sophisticated ways.
2023-01-14 15:57:16 +01:00
Mathias Fussenegger
0efe0eb17e Shuffle documented functions a bit
Moves lower level functions that users typically do not want to use
further down. E.g there is almost no reason to use `disconnect` or
`close`, but users should use `terminate()` instead.

Same for `launch` and `attach` which are low level APIs that users
should not call. There is `run` and `continue` instead.
2023-01-14 14:15:29 +01:00
Mathias Fussenegger
4a8b1bd83f Document restart and implement !supportsRestartRequest fallback 2023-01-14 14:15:29 +01:00
Mathias Fussenegger
8a2ada1128 Support restart property in terminated event 2023-01-14 14:15:29 +01:00