Skip to content

Commit 16e78ed

Browse files
committed
docs(nvim): documentation about Jobrunner class
1 parent 67c0270 commit 16e78ed

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lua/vectorcode/jobrunner/init.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
local utils = require("vectorcode.utils")
22

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`).
45
--- For the format of the `result`, see https://github.com/Davidyz/VectorCode/blob/main/docs/cli.md#for-developers
56
---@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.
612
---@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).
717
---@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.
820
---@field is_job_running fun(job_handle: integer):boolean
21+
--- Attempts to stop or cancel the job associated with the given handle.
922
---@field stop_job fun(job_handle: integer)
23+
--- Optional initialization function. Some runners (like LSP) might require an initialization step.
1024
---@field init function?
1125

1226
return {

0 commit comments

Comments
 (0)