|
1 | 1 | local utils = require("vectorcode.utils") |
2 | 2 |
|
3 | | ---- A class for calling vectorcode commands that aims at providing a unified API for both LSP and command-line backend |
| 3 | +--- A class for calling vectorcode commands that aims at providing a unified API for both LSP and command-line backend. |
| 4 | +--- Implementations exist for both direct command-line execution (`cmd.lua`) and LSP (`lsp.lua`). |
4 | 5 | --- For the format of the `result`, see https://github.com/Davidyz/VectorCode/blob/main/docs/cli.md#for-developers |
5 | 6 | ---@class VectorCode.JobRunner |
| 7 | +--- Runs a vectorcode command asynchronously. |
| 8 | +--- Executes the command specified by `args`. Upon completion, if `callback` is provided, |
| 9 | +--- it's invoked with the result table (decoded JSON from stdout) and error table (stderr lines). |
| 10 | +--- The `bufnr` is used for context, potentially to find the project root or attach LSP clients. |
| 11 | +--- Returns a job handle (e.g., PID or LSP request ID) or nil if the job couldn't be started. |
6 | 12 | ---@field run_async fun(args: string[], callback:fun(result: table, error: table)?, bufnr: integer):(job_handle:integer?) |
| 13 | +--- Runs a vectorcode command synchronously, blocking until completion or timeout. |
| 14 | +--- Executes the command specified by `args`. Waits for up to `timeout_ms` milliseconds. |
| 15 | +--- The `bufnr` is used for context, potentially to find the project root or attach LSP clients. |
| 16 | +--- Returns the result table (decoded JSON from stdout) and error table (stderr lines). |
7 | 17 | ---@field run fun(args: string[], timeout_ms: integer?, bufnr: integer):(result:table, error:table) |
| 18 | +--- Checks if a job associated with the given handle is currently running. |
| 19 | +--- Returns true if the job is running, false otherwise. |
8 | 20 | ---@field is_job_running fun(job_handle: integer):boolean |
| 21 | +--- Attempts to stop or cancel the job associated with the given handle. |
9 | 22 | ---@field stop_job fun(job_handle: integer) |
| 23 | +--- Optional initialization function. Some runners (like LSP) might require an initialization step. |
10 | 24 | ---@field init function? |
11 | 25 |
|
12 | 26 | return { |
|
0 commit comments