@@ -107,8 +107,14 @@ local function async_runner(query_message, buf_nr)
107107end
108108
109109M .register_buffer = vc_config .check_cli_wrap (
110- --- @param bufnr integer ?
111- --- @param opts VectorCode.RegisterOpts ?
110+ --- This function registers a buffer to be cached by VectorCode. The
111+ --- registered buffer can be aquired by the `query_from_cache` API.
112+ --- The retrieval of the files occurs in the background, so this
113+ --- function will not block the main thread.
114+ ---
115+ --- NOTE: this function uses an autocommand to track the changes to the buffer and trigger retrieval.
116+ --- @param bufnr integer ? Default to the current buffer.
117+ --- @param opts VectorCode.RegisterOpts ? Async options.
112118 function (bufnr , opts )
113119 if bufnr == 0 or bufnr == nil then
114120 bufnr = vim .api .nvim_get_current_buf ()
@@ -166,6 +172,10 @@ M.register_buffer = vc_config.check_cli_wrap(
166172)
167173
168174M .deregister_buffer = vc_config .check_cli_wrap (
175+ --- This function deregisters a buffer from VectorCode. This will kill all
176+ --- running jobs, delete cached results, and deregister the autocommands
177+ --- associated with the buffer. If the caching has not been registered, an
178+ --- error notification will bef ired.
169179 --- @param bufnr integer ?
170180 --- @param opts { notify : boolean }
171181 function (bufnr , opts )
@@ -204,6 +214,8 @@ M.buf_is_registered = function(bufnr)
204214end
205215
206216M .query_from_cache = vc_config .check_cli_wrap (
217+ --- This function queries VectorCode from cache. Returns an array of results. Each item
218+ --- of the array is in the format of `{path="path/to/your/code.lua", document="document content"}`.
207219 --- @param bufnr integer ?
208220 --- @param opts { notify : boolean }?
209221 --- @return VectorCode.Result[]
@@ -233,8 +245,11 @@ M.query_from_cache = vc_config.check_cli_wrap(
233245 end
234246)
235247
248+ --- @alias ComponentCallback fun ( result : VectorCode.Result ): string
249+
250+ --- Compile the retrieval results into a string.
236251--- @param bufnr integer
237- --- @param component_cb ( fun ( result : VectorCode.Result ): string )?
252+ --- @param component_cb ComponentCallback ? The component callback that formats a retrieval result.
238253--- @return { content : string , count : integer }
239254function M .make_prompt_component (bufnr , component_cb )
240255 if bufnr == 0 or bufnr == nil then
@@ -257,6 +272,8 @@ function M.make_prompt_component(bufnr, component_cb)
257272 return { content = final_component , count = # retrieval }
258273end
259274
275+ --- Checks if VectorCode has been configured properly for your project.
276+ --- See the CLI manual for details.
260277--- @param check_item string ?
261278--- @param on_success fun ( out : vim.SystemCompleted )?
262279--- @param on_failure fun ( out : vim.SystemCompleted ?)?
0 commit comments