Skip to content

Commit

Permalink
feat: use external nio (#311)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires https://github.com/nvim-neotest/nvim-nio to be
installed
  • Loading branch information
rcarriga authored Mar 18, 2024
1 parent d548de8 commit f7d75cc
Show file tree
Hide file tree
Showing 34 changed files with 124 additions and 5,290 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ good out of the box configuration.

## Installation

Install with your favourite package manager alongside nvim-dap
Install with your favourite package manager alongside nvim-dap and nvim-nio

[**dein**](https://github.com/Shougo/dein.vim):

```vim
call dein#add("mfussenegger/nvim-dap")
call dein#add("nvim-neotest/nvim-nio")
call dein#add("rcarriga/nvim-dap-ui")
```

[**vim-plug**](https://github.com/junegunn/vim-plug)

```vim
Plug 'mfussenegger/nvim-dap'
Plug 'nvim-neotest/nvim-nio'
Plug 'rcarriga/nvim-dap-ui'
```

[**packer.nvim**](https://github.com/wbthomason/packer.nvim)

```lua
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"} }
```

It is highly recommended to use [neodev.nvim](https://github.com/folke/neodev.nvim) to enable type checking for nvim-dap-ui to get
Expand Down
326 changes: 0 additions & 326 deletions doc/nvim-dap-ui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ nvim-dap-ui *nvim-dap-ui*
Watch Expressions...................................|dapui.elements.watches|
Breakpoints.....................................|dapui.elements.breakpoints|
Console.............................................|dapui.elements.console|
Async Library..................................................|dapui.async|

A UI for nvim-dap which provides a good out of the box configuration.
nvim-dap-ui is built on the idea of "elements". These elements are windows
Expand Down Expand Up @@ -431,329 +430,4 @@ dapui.elements.console *dapui.elements.console*
The console window used by nvim-dap for the integrated terminal.


==============================================================================
dapui.async *dapui.async*


The API is heavily inspired by Python's asyncio module and is currently
experimental meaning that interfaces may change without warning.
Users of nvim-dap-ui should not need to use this module directly.

*dapui.async.run()*
`run`({func}, {cb})

Run a function in an async context. This is the entrypoint to all async
functionality.
>lua
local async = require("dapui").async
async.run(function()
async.sleep(10)
print("Hello world")
end)
<
Parameters~
{func} `(function)`
Return~
`(dapui.async.tasks.Task)`

*dapui.async.wrap()*
`wrap`({func}, {argc})

Creates an async function with a callback style function.
>lua
local async = require("dapui").async
local sleep = async.wrap(function(ms, cb)
vim.defer_fn(cb, ms)
end, 2)

async.run(function()
sleep(10)
print("Slept for 10ms")
end)
<
Parameters~
{func} `(function)` A callback style function to be converted. The last argument must be the callback.
{argc} `(integer)` The number of arguments of func. Must be included.
Return~
`(function)` Returns an async function

*dapui.async.gather()*
`gather`({functions})

Run a collection of async functions concurrently and return when
all have finished.
If any of the functions fail, all pending tasks will be cancelled and the
error will be re-raised

Parameters~
{functions} `(function[])`
Return~
`(any[][])` Packed results of all functions

*dapui.async.first()*
`first`({functions})

Run a collection of async functions concurrently and return the result of
the first to finish.

Parameters~
{functions} `(function[])`
Return~
`(any)`

*dapui.async.sleep()*
`sleep`({ms})

Suspend the current task for given time.
Parameters~
{ms} `(number)` Time in milliseconds

*dapui.async.scheduler()*
`scheduler`()

Yields to the Neovim scheduler to be able to call the API.


dapui.async.api *dapui.async.api*

Safely proxies calls to the vim.api module while in an async context.

dapui.async.fn *dapui.async.fn*

Safely proxies calls to the vim.fn module while in an async context.

Async versions of vim.ui functions


==============================================================================
dapui.async.control *dapui.async.control*


Provides primitives for flow control to be used in async functions


An event can signal to multiple listeners to resume execution
The event can be set from a non-async context.
*dapui.async.control.Event*
Fields~
{set} `(fun(max_woken?: integer): nil)` Set the event and signal to all (or limited number of) listeners that the event has occurred. If max_woken is provided and there are more listeners then the event is cleared immediately
{wait} `(async fun(): nil)` Wait for the event to occur, returning immediately if
already set
{clear} `(fun(): nil)` Clear the event
{is_set} `(fun(): boolean)` Returns true if the event is set

*dapui.async.control.event()*
`event`()

Create a new event
Return~
`(dapui.async.control.Event)`


An future represents a value that will be available in the future.
The future result can be set from a non-async context.
*dapui.async.control.Future*
Fields~
{set} `(fun(value): nil)` Set the future value and wake all waiters.
{set_error} `(fun(message): nil)` Set the error for this future to raise to
waiters
{wait} `(async fun(): any)` Wait for the value to be set, returning immediately if already set

*dapui.async.control.future()*
`future`()

Create a new future
Return~
`(dapui.async.control.Future)`


A FIFO queue with async support.
*dapui.async.control.Queue*
Fields~
{size} `(fun(): number)` Returns the number of items in the queue
{max_size} `(fun(): number|nil)` Returns the maximum number of items in the queue
{get} `(async fun(): any)` Get a value from the queue, blocking if the queue is empty
{get_nowait} `(fun(): any)` Get a value from the queue, erroring if queue is empty.
{put} `(async fun(value: any): nil)` Put a value into the queue
{put_nowait} `(fun(value: any): nil)` Put a value into the queue, erroring if queue is full.

*dapui.async.control.queue()*
`queue`({max_size})

Create a new queue
Parameters~
{max_size?} `(integer)` The maximum number of items in the queue, defaults to no limit
Return~
`(dapui.async.control.Queue)`


An async semaphore that allows up to a given number of acquisitions.
*dapui.async.control.Semaphore*
Fields~
{with} `(async fun(callback: fun(): nil): nil)` Run the callback with the semaphore acquired

*dapui.async.control.semaphore()*
`semaphore`({value})

Create a new semaphore
Parameters~
{value} `(integer)` The number of allowed concurrent acquisitions


==============================================================================
dapui.async.uv *dapui.async.uv*


Provides asynchronous versions of vim.loop functions.
See corresponding function documentation for parameter and return
information.

Fields~
{close} `(async fun(handle: dapui.async.uv.Handle))`
{fs_open} `(async fun(path: any, flags: any, mode: any): (string|nil,integer|nil))`
{fs_read} `(async fun(fd: integer, size: integer, offset?: integer): (string|nil,string|nil))`
{fs_close} `(async fun(fd: integer): (string|nil,boolean|nil))`
{fs_unlink} `(async fun(path: string): (string|nil,boolean|nil))`
{fs_write} `(async fun(fd: any, data: any, offset?: any): (string|nil,integer|nil))`
{fs_mkdir} `(async fun(path: string, mode: integer): (string|nil,boolean|nil))`
{fs_mkdtemp} `(async fun(template: string): (string|nil,string|nil))`
{fs_rmdir} `(async fun(path: string): (string|nil,boolean|nil))`
{fs_stat} `(async fun(path: string): (string|nil,dapui.async.uv.Stat|nil))`
{fs_fstat} `(async fun(fd: integer): (string|nil,dapui.async.uv.Stat|nil))`
{fs_lstat} `(async fun(path: string): (string|nil,dapui.async.uv.Stat|nil))`
{fs_statfs} `(async fun(path: string): (string|nil,dapui.async.uv.StatFs|nil))`
{fs_rename} `(async fun(old_path: string, new_path: string): (string|nil,boolean|nil))`
{fs_fsync} `(async fun(fd: integer): (string|nil,boolean|nil))`
{fs_fdatasync} `(async fun(fd: integer): (string|nil,boolean|nil))`
{fs_ftruncate} `(async fun(fd: integer, offset: integer): (string|nil,boolean|nil))`
{fs_sendfile} `(async fun(out_fd: integer, in_fd: integer, in_offset: integer, length: integer): (string|nil,integer|nil))`
{fs_access} `(async fun(path: string, mode: integer): (string|nil,boolean|nil))`
{fs_chmod} `(async fun(path: string, mode: integer): (string|nil,boolean|nil))`
{fs_fchmod} `(async fun(fd: integer, mode: integer): (string|nil,boolean|nil))`
{fs_utime} `(async fun(path: string, atime: number, mtime: number): (string|nil,boolean|nil))`
{fs_futime} `(async fun(fd: integer, atime: number, mtime: number): (string|nil,boolean|nil))`
{fs_link} `(async fun(path: string, new_path: string): (string|nil,boolean|nil))`
{fs_symlink} `(async fun(path: string, new_path: string, flags?: integer): (string|nil,boolean|nil))`
{fs_readlink} `(async fun(path: string): (string|nil,string|nil))`
{fs_realpath} `(async fun(path: string): (string|nil,string|nil))`
{fs_chown} `(async fun(path: string, uid: integer, gid: integer): (string|nil,boolean|nil))`
{fs_fchown} `(async fun(fd: integer, uid: integer, gid: integer): (string|nil,boolean|nil))`
{fs_lchown} `(async fun(path: string, uid: integer, gid: integer): (string|nil,boolean|nil))`
{fs_copyfile} `(async fun(path: any, new_path: any, flags?: any): (string|nil,boolean|nil))`
{fs_opendir} `(async fun(path: string, entries?: integer): (string|nil,dapui.async.uv.Dir|nil))`
{fs_readdir} `(async fun(dir: dapui.async.uv.Dir): (string|nil,dapui.async.uv.DirEntry[]|nil))`
{fs_closedir} `(async fun(dir: dapui.async.uv.Dir): (string|nil,boolean|nil))`
{fs_scandir} `(async fun(path: string): (string|nil,dapui.async.uv.DirEntry[]|nil))`
{shutdown} `(async fun(stream: dapui.async.uv.Stream): string|nil)`
{listen} `(async fun(stream: dapui.async.uv.Stream, backlog: integer): string|nil)`
{write} `(async fun(stream: dapui.async.uv.Stream, data: string|string[]): string|nil)`
{write2} `(async fun(stream: dapui.async.uv.Stream, data: string|string[], send_handle: dapui.async.uv.Stream): string|nil)`

*dapui.async.uv.Handle*

*dapui.async.uv.Stream*
Inherits: `dapui.async.uv.Handle`


*dapui.async.uv.Stat*
Fields~
{dev} `(integer)`
{mode} `(integer)`
{nlink} `(integer)`
{uid} `(integer)`
{gid} `(integer)`
{rdev} `(integer)`
{ino} `(integer)`
{size} `(integer)`
{blksize} `(integer)`
{blocks} `(integer)`
{flags} `(integer)`
{gen} `(integer)`
{atime} `(dapui.async.uv.StatTime)`
{mtime} `(dapui.async.uv.StatTime)`
{ctime} `(dapui.async.uv.StatTime)`
{birthtime} `(dapui.async.uv.StatTime)`
{type} `(string)`

*dapui.async.uv.StatTime*
Fields~
{sec} `(integer)`
{nsec} `(integer)`

*dapui.async.uv.StatFs*
Fields~
{type} `(integer)`
{bsize} `(integer)`
{blocks} `(integer)`
{bfree} `(integer)`
{bavail} `(integer)`
{files} `(integer)`
{ffree} `(integer)`

*dapui.async.uv.Dir*

*dapui.async.uv.DirEntry*


==============================================================================
dapui.async.ui *dapui.async.ui*


Async versions of vim.ui functions.

*dapui.async.ui.input()*
`input`({args})


Parameters~
{args} `(dapui.async.ui.InputArgs)`

*dapui.async.ui.InputArgs*
Fields~
{prompt} `(string|nil)` Text of the prompt
{default} `(string|nil)` Default reply to the input
{completion} `(string|nil)` Specifies type of completion supported for input. Supported types are the same that can be supplied to a user-defined command using the "-complete=" argument. See |:command-completion|
{highlight} `(function)` Function that will be used for highlighting user inputs.

*dapui.async.ui.select()*
`select`({items}, {args})


Parameters~
{items} `(any[])`
{args} `(dapui.async.ui.SelectArgs)`

*dapui.async.ui.SelectArgs*
Fields~
{prompt} `(string|nil)` Text of the prompt. Defaults to `Select one of:`
{format_item} `(function|nil)` Function to format an individual item from `items`. Defaults to `tostring`.
{kind} `(string|nil)` Arbitrary hint string indicating the item shape. Plugins reimplementing `vim.ui.select` may wish to use this to infer the structure or semantics of `items`, or the context in which select() was called.


==============================================================================
dapui.async.tests *dapui.async.tests*


Async versions of plenary's test functions.

*dapui.async.tests.it()*
`it`({name}, {async_func})

Parameters~
{name} `(string)`
{async_func} `(function)`

*dapui.async.tests.before_each()*
`before_each`({async_func})

Parameters~
{async_func} `(function)`

*dapui.async.tests.after_each()*
`after_each`({async_func})

Parameters~
{async_func} `(function)`


vim:tw=78:ts=8:noet:ft=help:norl:
Loading

0 comments on commit f7d75cc

Please sign in to comment.