### Example LSP ExecuteCommand Request (vectorcode query) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Provides an example of a 'workspace/executeCommand' request JSON object to execute the 'vectorcode query -n 10 reranker' command via the 'vectorcode-server' LSP. ```JSON { command: "vectorcode", arguments: ["query", "-n", "10", "reranker"] } ``` -------------------------------- ### Install VectorCode CLI from Git URL via pipx Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx directly from the official GitHub repository URL. ```bash pipx install git+https://github.com/Davidyz/VectorCode ``` -------------------------------- ### Install VectorCode CLI from Local Source via pipx Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx directly from a local clone of the source repository. ```bash pipx install ``` -------------------------------- ### Install VectorCode CLI via pipx (Basic) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx, which creates an isolated virtual environment for the package. ```bash pipx install vectorcode ``` -------------------------------- ### Install VectorCode CLI via pipx (CPU-only) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx, forcing a CPU-only installation of PyTorch dependencies by specifying alternative index URLs. ```bash PIP_INDEX_URL="https://download.pytorch.org/whl/cpu" PIP_EXTRA_INDEX_URL="https://pypi.org/simple" pipx install vectorcode ``` -------------------------------- ### Install VectorCode LSP Dependency (pipx) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Command to inject the 'lsp' dependency group into an existing 'vectorcode' installation using 'pipx', forcing the update. ```Shell pipx inject vectorcode vectorcode[lsp] --force ``` -------------------------------- ### Install VectorCode CLI via pipx (with Extras) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx, including additional dependency groups like 'lsp' and 'mcp' for extended functionality. ```bash pipx install vectorcode[lsp,mcp] ``` -------------------------------- ### Initializing VectorCode Project (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Initializes the VectorCode project in the current directory, creating a .vectorcode subdirectory for configuration. This command sets up the project root for VectorCode operations. ```bash vectorcode init ``` -------------------------------- ### Install VectorCode CLI via pipx (Specific Python) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Installs the VectorCode command-line interface using pipx, specifying a particular Python version for the virtual environment. ```bash pipx install vectorcode --python python3.11 ``` -------------------------------- ### Configure VectorCode for OpenVINO Backend (JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Sets the embedding backend to 'openvino' in the VectorCode configuration file to utilize Intel OpenVINO for hardware acceleration. This requires installing VectorCode with the '[intel]' dependency group. ```json { "embedding_params": { "backend": "openvino" } } ``` -------------------------------- ### Check VectorCode Environment Packages via pipx Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Runs the 'pip freeze' command within the VectorCode virtual environment managed by pipx to list installed packages and their versions, useful for debugging legacy environments. ```bash pipx runpip vectorcode freeze ``` -------------------------------- ### Dropping VectorCode Project Embeddings (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Wipes the entire embedding database for the current VectorCode project. This is useful for starting fresh, changing embedding functions, or after upgrades with breaking changes. ```bash vectorcode drop ``` -------------------------------- ### Install VectorCode with LSP Dependency (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Command to install VectorCode using pipx, including the 'lsp' dependency group. This is required to use the experimental language server mode, which keeps the embedding model loaded for faster queries. ```bash pipx install vectorcode[lsp] ``` -------------------------------- ### Querying Documents with VectorCode (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Demonstrates the basic command to query documents using VectorCode CLI. Explains the use of quotation marks for full sentences and mentions optional parameters like -n/--number and --multiplier. ```bash vectorcode query "your query message" ``` -------------------------------- ### Limiting Query Output with VectorCode (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Shows how to use the --include flag to limit the output of a query to specific fields, such as the document path. Useful for integrating with other tools or scripts. ```bash vectorcode query foo bar --include path ``` -------------------------------- ### LSP workspace/executeCommand Request Structure Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Defines the expected JSON structure for the 'workspace/executeCommand' request used by the 'vectorcode-server' LSP implementation. It requires a 'command' string and an 'arguments' list. ```JSON { command: str arguments: list[Any] } ``` -------------------------------- ### Configure VectorCode Client in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md This snippet shows the default configuration options for initializing the VectorCode client using the `setup` function. It includes settings for asynchronous operations, backend selection, query behavior, notifications, timeouts, and actions to run on setup. ```lua -- Default configuration require("vectorcode").setup({ async_opts = { debounce = 10, events = { "BufWritePost", "InsertEnter", "BufReadPost" }, exclude_this = true, n_query = 1, notify = false, query_cb = require("vectorcode.utils").make_surrounding_lines_cb(-1), run_on_register = false, }, async_backend = "default", -- or "lsp" exclude_this = true, n_query = 1, notify = true, timeout_ms = 5000, on_setup = { update = false, -- set to true to enable update when `setup` is called. lsp = false, }, sync_log_env_var = false }) ``` -------------------------------- ### Enabling Logging for VectorCode (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Illustrates how to set the VECTORCODE_LOG_LEVEL environment variable before running a VectorCode command to enable detailed logging for debugging purposes. ```bash VECTORCODE_LOG_LEVEL=INFO vectorcode vectorise file1.py file2.lua ``` -------------------------------- ### Configure VectorCode for CUDA Backend (JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Sets the embedding backend to 'torch' and device to 'cuda' in the VectorCode configuration file for Nvidia GPUs. This configuration enables hardware acceleration using CUDA. ```json { "embedding_params": { "backend": "torch", "device": "cuda" } } ``` -------------------------------- ### Generating Shell Completion Script (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Shows the command to print the shell completion script for VectorCode CLI, supporting bash, zsh, and tcsh. Useful for integrating VectorCode commands with shell completion features. ```bash vectorcode -s {bash,zsh,tcsh} ``` -------------------------------- ### VectorCode Query Output Format (Pipe Mode, Basic JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Describes the basic JSON output format when running 'vectorcode query' with the '--pipe' flag. It returns an array of objects, each containing the 'path' to the document and the 'document' content itself. ```json [ { "path": "path_to_your_code.py", "document":"import something" }, { "path": "path_to_another_file.py", "document": "print('hello world')" } ] ``` -------------------------------- ### Install VectorCode NeoVim Plugin (Basic) Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Basic lazy.nvim configuration for installing the VectorCode NeoVim plugin, including the required dependency 'nvim-lua/plenary.nvim' and lazy-loading via the 'VectorCode' command. ```Lua { "Davidyz/VectorCode", version = "*", -- optional, depending on whether you're on nightly or release dependencies = { "nvim-lua/plenary.nvim" }, cmd = "VectorCode", -- if you're lazy-loading VectorCode } ``` -------------------------------- ### Querying VectorCode with a Sentence (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Queries the VectorCode embedding database using a full sentence as the query. The sentence should be wrapped in double quotes. The command finds and outputs the most relevant documents based on the sentence embedding. ```bash vectorcode query "How to configure reranker model" ``` -------------------------------- ### Configuring CrossEncoder Reranker Model (JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This JSON snippet demonstrates how to set the `reranker_params` for the `CrossEncoderReranker`. It shows how to specify a custom model path or name for the cross-encoder model used for reranking search results. ```JSON { "reranker_params": { "model_name_or_path": "your_model_here" } } ``` -------------------------------- ### Install VectorCode NeoVim Plugin (with Build Hook) Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md lazy.nvim configuration for installing the VectorCode NeoVim plugin, including a 'build' hook to automatically upgrade the VectorCode CLI using pipx when the plugin updates. Requires 'nvim-lua/plenary.nvim'. ```Lua { "Davidyz/VectorCode", version = "*", -- optional, depending on whether you're on nightly or release build = "pipx upgrade vectorcode", -- optional but recommended if you set `version = "*"` dependencies = { "nvim-lua/plenary.nvim" }, } ``` -------------------------------- ### VectorCode List Collections Output Format (JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Shows the JSON format for the output of the 'vectorcode ls' command. It provides an array of collection information objects, detailing the project root, user, hostname, collection name, size, number of files, and embedding function. ```json { "project_root": str, "user": str, "hostname": str, "collection_name": str, "size": int, "num_files": int, "embedding_function": str } ``` -------------------------------- ### Configuring Ollama Embedding Function Parameters (JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This JSON snippet shows how to configure the `embedding_params` for the `OllamaEmbeddingFunction` in VectorCode's configuration file. It specifies the URL of the Ollama server and the model name to use for generating embeddings. ```JSON { "url": "http://127.0.0.1:11434/api/embeddings", "model_name": "nomic-embed-text" } ``` -------------------------------- ### Asynchronously Checking VectorCode Configuration in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Illustrates how to use `cacher_backend.async_check` to verify the VectorCode configuration asynchronously. The example shows checking the 'config' item and providing placeholder functions for success and failure callbacks. This function is used to check project setup. ```lua cacher_backend.async_check( "config", do_something(), -- on success do_something_else() -- on failure ) ``` -------------------------------- ### Querying VectorCode with Multiple Terms (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Queries the VectorCode embedding database to find the top N (here, 3) most relevant documents related to multiple query terms (here, embedding reranking). The command outputs the paths and content of the relevant documents. ```bash vectorcode query embedding reranking -n 3 ``` -------------------------------- ### VectorCode Query Output Format (Pipe Mode, Detailed JSON) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Describes the JSON output format for 'vectorcode query' when using '--pipe' and including 'chunk path' parameters. The output array includes 'path', 'chunk', 'start_line', and 'end_line' for each result, with line numbers being inclusive. ```json [ { "path": "path_to_your_code.py", "chunk": "foo", "start_line": 1, "end_line": 1 }, { "path": "path_to_another_file.py", "chunk": "bar", "start_line": 1, "end_line": 1 } ] ``` -------------------------------- ### Querying VectorCode with Single Term (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Queries the VectorCode embedding database to find the top N (here, 3) most relevant documents related to a single query term (here, reranker). The command outputs the paths and content of the relevant documents. ```bash vectorcode query reranker -n 3 ``` -------------------------------- ### Vectorizing Files with VectorCode (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md Vectorizes specified files (e.g., Python files in src/) for the current VectorCode project. This command processes the code content and stores embeddings in the database. Note that files need to be re-vectorized after editing. ```bash vectorcode vectorise src/**/*.py ``` -------------------------------- ### Configuring HNSW Parameters in VectorCode JSON Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This snippet shows how to configure Hierarchical Navigable Small World (HNSW) parameters within the VectorCode configuration JSON file. It sets the `M` and `construction_ef` values for the HNSW index, which affect search performance and index build time. These options are typically set during collection creation. ```json "hnsw": { "hnsw:M": 64, "hnsw:construction_ef": 100 } ``` -------------------------------- ### Vectorising Staged Files Before Commit (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This bash script is intended for use as a pre-commit git hook. It identifies files staged for commit using `git diff --cached --name-only`. If the list of staged files is not empty, it executes the `vectorcode vectorise` command on these files, ensuring their vector representations are updated before the commit proceeds. ```bash # pre-commit hook that vectorise changed files before you commit. diff_files=$(git diff --cached --name-only) [ -z "$diff_files" ] || vectorcode vectorise $diff_files ``` -------------------------------- ### Getting VectorCode Cacher Backend (Lua) Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Retrieves the configured asynchronous cache backend object. This object provides the API for interacting with the cache, allowing users to call functions like `query_from_cache` or `register_buffer` on the selected backend ('default' or 'lsp'). ```lua local cacher_backend = require("vectorcode.config").get_cacher_backend() ``` -------------------------------- ### Configuring Chunk Filters in VectorCode JSON5 Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This snippet demonstrates how to define `chunk_filters` in the VectorCode configuration using JSON5 format. It specifies Python regex patterns to exclude certain code chunks from vectorization based on language. Filters can be defined per language or using a wildcard `*` for languages without specific filters. ```json5 "chunk_filters": { "python": ["^[^a-zA-Z0-9]+$"], // multiple patterns will be merged (unioned) // or you can use wildcard to match any languages that has no dedicated filters: "*": ["^[^a-zA-Z0-9]+$"], } ``` -------------------------------- ### Vectorising Changed Files After Checkout (Bash) Source: https://github.com/davidyz/vectorcode/blob/main/docs/cli.md This bash script is designed to be a post-checkout git hook. It determines which files have changed between the previous and new commits/branches using `git diff --name-only "$1" "$2"`, where `$1` and `$2` are the previous and new commit hashes. If any files have changed, it runs the `vectorcode vectorise` command on them to update their vector representations after a checkout. ```bash # post-checkout hook that vectorise changed files when you checkout to a # different branch/tag/commit files=$(git diff --name-only "$1" "$2") [ -z "$files" ] || vectorcode vectorise $files ``` -------------------------------- ### Querying VectorCode Cache in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Demonstrates how to query cached VectorCode results using `cacher_backend.query_from_cache`. The example shows querying buffer 0 with notifications disabled. The function accepts an optional buffer number and an options table to control behavior like notifications, returning an array of result objects. ```lua local query_results = cacher_backend.query_from_cache(0, {notify=false}) ``` -------------------------------- ### Default Prompt Component Callback for VectorCode in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Provides the default implementation for the `component_cb` parameter used in `cacher_backend.make_prompt_component`. This callback formats each retrieved document result by prepending a file separator token, followed by the file path, a newline, and the document content. ```lua function(result) return "<|file_sep|>" .. result.path .. "\n" .. result.document end ``` -------------------------------- ### Checking VectorCode Configuration in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md This function checks if VectorCode is properly configured for the current project. It can optionally check specific items like the project-local config ("config"). It returns true on success and false on failure. This is useful as a pre-condition before calling more expensive APIs like query. ```lua require("vectorcode").check() ``` -------------------------------- ### Registering Buffer with VectorCode Cacher (Lua) Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Registers a specific buffer (buffer 0, typically the current buffer) with the VectorCode asynchronous cache backend. This enables caching and querying for the buffer based on configured events and options, such as the number of documents to retrieve (`n_query`). ```lua cacher_backend.register_buffer(0, { n_query = 1, }) ``` -------------------------------- ### Querying VectorCode in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md This function queries VectorCode with a message and returns relevant code snippets. It supports options like limiting results (n_query) and can run asynchronously via a callback. The return value is an array of tables with path and document fields. The opts table can include exclude_this, n_query, notify, and timeout_ms. ```lua require("vectorcode").query("some query message", { n_query = 5, }) ``` ```lua prompt = function(prefix, suffix) local retrieval_results = require("vectorcode").query("some query message", { n_query = 5, }) for _, source in pairs(retrieval_results) do -- This works for qwen2.5-coder. file_context = file_context .. "<|file_sep|>" .. source.path .. "\n" .. source.document .. "\n" end return file_context .. "<|fim_prefix|>" .. prefix .. "<|fim_suffix|>" .. suffix .. "<|fim_middle|>" end ``` -------------------------------- ### Updating VectorCode Index in Lua Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md This function triggers an update of the VectorCode index for the current project. It runs asynchronously and does not block the UI. An optional project_root parameter can be provided to specify the project directory. ```lua require("vectorcode").update() ``` -------------------------------- ### Register Buffer for VectorCode Caching via Autocmd Source: https://github.com/davidyz/vectorcode/blob/main/docs/neovim.md Lua autocmd definition using nvim_create_autocmd to automatically register the current buffer for VectorCode async caching upon 'LspAttach'. It first checks the 'config' status asynchronously before registering the buffer with specific options. ```Lua vim.api.nvim_create_autocmd("LspAttach", { callback = function() local bufnr = vim.api.nvim_get_current_buf() cacher.async_check("config", function() cacher.register_buffer( bufnr, { n_query = 10, } ) end, nil) end, desc = "Register buffer for VectorCode", }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.