1- *VectorCode.txt* For Last change: 2025 March 31
1+ *VectorCode.txt*A code repository indexing tool to supercharge your LLM experience.
22
33==============================================================================
44Table of Contents *VectorCode-table-of-contents*
@@ -9,6 +9,7 @@ Table of Contents *VectorCode-table-of-contents*
99 - User Command | VectorCode-neovim-plugin-user-command |
1010 - Configuration | VectorCode-neovim-plugin-configuration |
1111 - API Usage | VectorCode-neovim-plugin-api-usage |
12+ - Debugging and Logging | VectorCode-neovim-plugin-debugging-and-logging |
1213
1314==============================================================================
14151. NeoVim Plugin *VectorCode-neovim-plugin*
@@ -41,6 +42,7 @@ Table of Contents *VectorCode-table-of-contents*
4142 - | VectorCode-`cacher_backend.buf_job_count(bufnr?)` |
4243 - | VectorCode-`cacher_backend.make_prompt_component(bufnr?,-component_cb?)` |
4344 - | VectorCode-built-in-query-callbacks |
45+ - | VectorCode-debugging-and-logging |
4446
4547
4648INSTALLATION *VectorCode-neovim-plugin-installation*
@@ -176,27 +178,33 @@ This function initialises the VectorCode client and sets up some default
176178 update = false, -- set to true to enable update when `setup` is called.
177179 lsp = false,
178180 }
181+ sync_log_env_var = false,
179182 })
180183<
181184
182185The following are the available options for the parameter of this function: -
183- `n_query` : number of retrieved documents. A large number gives a higher chance
184- of including the right file, but with the risk of saturating the context window
185- and getting truncated. Default: `1 ` ; - `notify` : whether to show notifications
186- when a query is completed. Default: `true` ; - `timeout_ms` : timeout in
186+ `n_query` number of retrieved documents. A large number gives a higher chance of
187+ including the right file, but with the risk of saturating the context window
188+ and getting truncated. Default: `1 ` ; - `notify` whether to show notifications
189+ when a query is completed. Default: `true` ; - `timeout_ms` timeout in
187190milliseconds for the query operation. Applies to synchronous API only. Default:
188- `5000 ` (5 seconds); - `exclude_this` : whether to exclude the file you’re
191+ `5000 ` (5 seconds); - `exclude_this` whether to exclude the file you’re
189192editing. Setting this to `false` may lead to an outdated version of the current
190193file being sent to the LLM as the prompt, and can lead to generations with
191- outdated information; - `async_opts` : default options used when registering
194+ outdated information; - `async_opts` default options used when registering
192195buffers. See | VectorCode-`register_buffer(bufnr?,-opts?)` | for details; -
193- `async_backend` : the async backend to use, currently either `" default" ` or
194- `" lsp" ` . Default: `" default" ` ; - `on_setup` : some actions that can be
195- registered to run when `setup` is called. Supported keys: - `update ` : if
196- `true` , the plugin will run `vectorcode update` on startup to update the
197- embeddings; - `lsp ` : if `true` , the plugin will try to start the LSP server on
198- startup so that you won’t need to wait for the server loading when making
199- your first request.
196+ `async_backend` the async backend to use, currently either `" default" ` or
197+ `" lsp" ` . Default: `" default" ` ; - `on_setup` some actions that can be registered
198+ to run when `setup` is called. Supported keys: - `update ` if `true` , the plugin
199+ will run `vectorcode update` on startup to update the embeddings; - `lsp ` if
200+ `true` , the plugin will try to start the LSP server on startup so that you
201+ won’t need to wait for the server loading when making your first request. -
202+ `sync_log_env_var``boolean ` . If true, this plugin will automatically set the
203+ `VECTORCODE_LOG_LEVEL` environment variable for LSP or cmd processes started
204+ within your neovim session when logging is turned on for this plugin. Use at
205+ caution because the CLI write all logs to stderr, which _may_ make this plugin
206+ VERY verbose. See | VectorCode-debugging-and-logging | for details on how to turn
207+ on logging.
200208
201209You may notice that a lot of options in `async_opts` are the same as the other
202210options in the top-level of the main option table. This is because the
@@ -232,8 +240,8 @@ This function queries VectorCode and returns an array of results.
232240 })
233241<
234242
235- - `query_message` : string or a list of strings, the query messages;
236- - `opts` : The following are the available options for this function (see | VectorCode-`setup(opts?)` | for details):
243+ - `query_message` string or a list of strings, the query messages;
244+ - `opts` The following are the available options for this function (see | VectorCode-`setup(opts?)` | for details):
237245
238246>lua
239247 {
@@ -244,7 +252,7 @@ This function queries VectorCode and returns an array of results.
244252 }
245253<
246254
247- - `callback` : a callback function that takes the result of the retrieval as the
255+ - `callback` a callback function that takes the result of the retrieval as the
248256 only parameter. If this is set, the `query` function will be non-blocking and
249257 runs in an async manner. In this case, it doesn’t return any value and
250258 retrieval results can only be accessed by this callback function.
@@ -288,7 +296,7 @@ project. See the CLI manual for details <./cli.md>.
288296 require("vectorcode").check()
289297<
290298
291- The following are the available options for this function: - `check_item` : Only
299+ The following are the available options for this function: - `check_item` Only
292300supports `" config" ` at the moment. Checks if a project-local config is present.
293301Return value: `true` if passed, `false` if failed.
294302
@@ -372,27 +380,27 @@ This function registers a buffer to be cached by VectorCode.
372380 })
373381<
374382
375- The following are the available options for this function: - `bufnr ` : buffer
376- number. Default: current buffer; - `opts` : accepts a lua table with the
377- following keys: - `project_root` : a string of the path that overrides the
378- detected project root. Default: `nil` . This is mostly intended to use with the
383+ The following are the available options for this function: - `bufnr ` buffer
384+ number. Default: current buffer; - `opts` accepts a lua table with the following
385+ keys: - `project_root` a string of the path that overrides the detected project
386+ root. Default: `nil` . This is mostly intended to use with the
379387| VectorCode-user-command | , and you probably should not use this directly in
380388your config. **If you’re using the LSP backend and did not specify this
381389value, it will be automatically detected based on .vectorcode or .git. If this
382- fails, LSP backend will not work**; - `exclude_this` : whether to exclude the
383- file you’re editing. Default: `true` ; - `n_query` : number of retrieved
384- documents. Default: `1 ` ; - `debounce` : debounce time in milliseconds. Default:
385- `10 ` ; - ` notify`: whether to show notifications when a query is completed.
386- Default: `false` ; - `query_cb` : `fun(bufnr: integer):string|string[]`, a
387- callback function that accepts the buffer ID and returns the query message(s).
388- Default: `require (" vectorcode.utils" ).make_surrounding_lines_cb (-1 )` . See
389- | VectorCode-this-section | for a list of built-in query callbacks; - `events` :
390- list of autocommand events that triggers the query. Default: `{"BufWritePost",
391- " InsertEnter", "BufReadPost"}`; - `run_on_register` : whether to run the query
392- when the buffer is registered. Default: `false` ; - `single_job` : boolean. If
393- this is set to `true` , there will only be one running job for each buffer, and
394- when a new job is triggered, the last-running job will be cancelled. Default:
395- `false` .
390+ fails, LSP backend will not work**; - `exclude_this` whether to exclude the file
391+ you’re editing. Default: `true` ; - `n_query` number of retrieved documents.
392+ Default: `1 ` ; - `debounce` debounce time in milliseconds. Default: ` 10 ` ; -
393+ `notify` whether to show notifications when a query is completed. Default:
394+ `false` ; - `query_cb` `fun(bufnr: integer):string|string[]`, a callback function
395+ that accepts the buffer ID and returns the query message(s). Default:
396+ `require (" vectorcode.utils" ).make_surrounding_lines_cb (-1 )` . See
397+ | VectorCode-this-section | for a list of built-in query callbacks; -
398+ `events` list of autocommand events that triggers the query. Default:
399+ `{"BufWritePost", " InsertEnter", "BufReadPost"}`; - `run_on_register` whether to
400+ run the query when the buffer is registered. Default: `false` ; -
401+ `single_job` boolean. If this is set to `true` , there will only be one running
402+ job for each buffer, and when a new job is triggered, the last-running job will
403+ be cancelled. Default: `false` .
396404
397405
398406CACHER_BACKEND.QUERY_FROM_CACHE(BUFNR?)
@@ -403,10 +411,10 @@ This function queries VectorCode from cache.
403411 local query_results = cacher_backend.query_from_cache(0, {notify=false} )
404412<
405413
406- The following are the available options for this function: - `bufnr ` : buffer
407- number. Default: current buffer; - `opts` : accepts a lua table with the
408- following keys: - `notify` : boolean, whether to show notifications when a query
409- is completed. Default: `false` ;
414+ The following are the available options for this function: - `bufnr ` buffer
415+ number. Default: current buffer; - `opts` accepts a lua table with the following
416+ keys: - `notify` boolean, whether to show notifications when a query is
417+ completed. Default: `false` ;
410418
411419Return value: an array of results. Each item of the array is in the format of
412420`{path="path/to/your/code.lua", document="document content"}`.
@@ -425,18 +433,17 @@ project.
425433 )
426434<
427435
428- The following are the available options for this function: - `check_item` : any
436+ The following are the available options for this function: - `check_item` any
429437check that works with `vectorcode check` command. If not set, it defaults to
430- `" config" ` ; - `on_success` : a callback function that is called when the check
431- passes; - `on_failure` : a callback function that is called when the check
432- fails.
438+ `" config" ` ; - `on_success` a callback function that is called when the check
439+ passes; - `on_failure` a callback function that is called when the check fails.
433440
434441
435442CACHER_BACKEND.BUF_IS_REGISTERED(BUFNR?)
436443
437444This function checks if a buffer has been registered with VectorCode.
438445
439- The following are the available options for this function: - `bufnr ` : buffer
446+ The following are the available options for this function: - `bufnr ` buffer
440447number. Default: current buffer. Return value: `true` if registered, `false`
441448otherwise.
442449
@@ -448,7 +455,7 @@ slightly different from `buf_is_registered`, because it does not guarantee
448455VectorCode is actively caching the content of the buffer. It is the same as
449456`buf_is_registered && not is_paused`.
450457
451- The following are the available options for this function: - `bufnr ` : buffer
458+ The following are the available options for this function: - `bufnr ` buffer
452459number. Default: current buffer. Return value: `true` if enabled, `false`
453460otherwise.
454461
@@ -460,8 +467,8 @@ Returns the number of running jobs in the background.
460467
461468CACHER_BACKEND.MAKE_PROMPT_COMPONENT(BUFNR?, COMPONENT_CB?)
462469
463- Compile the retrieval results into a string. Parameters: - `bufnr ` : buffer
464- number. Default: current buffer; - `component_cb` : a callback function that
470+ Compile the retrieval results into a string. Parameters: - `bufnr ` buffer
471+ number. Default: current buffer; - `component_cb` a callback function that
465472formats each retrieval result, so that you can customise the control token,
466473etc. for the component. The default is the following:
467474
@@ -471,8 +478,8 @@ etc. for the component. The default is the following:
471478 end
472479<
473480
474- `make_prompt_component` returns a table with 2 keys: - `count ` : number of
475- retrieved documents; - `content` : The retrieval results concatenated together
481+ `make_prompt_component` returns a table with 2 keys: - `count ` number of
482+ retrieved documents; - `content` The retrieval results concatenated together
476483into a string. Each result is formatted by `component_cb` .
477484
478485
@@ -483,19 +490,28 @@ takes the buffer ID as the only parameter, and return a string or a list of
483490strings. The `vectorcode.utils` module provides the following callback
484491constructor for you to play around with it, but you can easily build your own!
485492
486- - `require (" vectorcode.utils" ).make_surrounding_lines_cb (line_count)` : returns a
493+ - `require (" vectorcode.utils" ).make_surrounding_lines_cb (line_count)` returns a
487494 callback that uses `line_count` lines around the cursor as the query. When
488495 `line_count` is negative, it uses the full buffer;
489- - `require (" vectorcode.utils" ).make_lsp_document_symbol_cb ()` : returns a
496+ - `require (" vectorcode.utils" ).make_lsp_document_symbol_cb ()` returns a
490497 callback which uses the `textDocument/documentSymbol` method to retrieve a
491498 list of symbols in the current document. This will fallback to
492499 `make_surrounding_lines_cb (-1 )` when there’s no LSP that supports the
493500 `documentSymbol` method;
494- - `require (" vectorcode.utils" ).make_changes_cb (max_num)` : returns a callback
501+ - `require (" vectorcode.utils" ).make_changes_cb (max_num)` returns a callback
495502 that fetches `max_num` unique items from the `:changes ` list. This will also
496503 fallback to `make_surrounding_lines_cb (-1 )` . The default value for `max_num`
497504 is 50.
498505
506+
507+ DEBUGGING AND LOGGING *VectorCode-neovim-plugin-debugging-and-logging*
508+
509+ You can enable logging by setting `VECTORCODE_NVIM_LOG_LEVEL` environment
510+ variable to a supported log level
511+ <https://github.com/nvim-lua/plenary.nvim/blob/857c5ac632080dba10aae49dba902ce3abf91b35/lua/plenary/log.lua#L44 >.
512+ The log file will be written to `stdpath (" log" )` or `stdpath (" cache" )` . On
513+ Linux, this is usually `~/.local/state/nvim/ ` .
514+
499515Generated by panvimdoc <https://github.com/kdheepak/panvimdoc >
500516
501517vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments