### LazyVim Installation Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Installation instructions for databox.nvim using LazyVim, including setup with private and public keys. ```lua { "chrisgve/databox.nvim", config = function() local success, err = require("databox").setup({ private_key = "~/.config/age/keys.txt", public_key = "age1example...", -- Your public key string -- Optional: Use rage for better performance -- encryption_cmd = "rage -e -r %s", -- decryption_cmd = "rage -d -i %s", }) if not success then vim.notify("Databox setup failed: " .. err, vim.log.levels.ERROR) end end, } ``` -------------------------------- ### Rage Setup Configuration Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Configuration example for databox.nvim using rage for potentially better performance. ```lua require("databox").setup({ private_key = "~/.config/age/keys.txt", public_key = "age1abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567890ab", encryption_cmd = "rage -e -a -r %s", -- Note: -a flag for ASCII armor decryption_cmd = "rage -d -i %s", }) ``` -------------------------------- ### Manual Installation (packer.nvim) Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Manual installation instructions for databox.nvim using packer.nvim, including setup with private and public keys. ```lua -- Example with packer.nvim use { 'chrisgve/databox.nvim', config = function() local success, err = require("databox").setup({ private_key = "~/.config/age/keys.txt", public_key = "age1example...", }) if not success then print("Databox setup failed: " .. err) end end } ``` -------------------------------- ### Debug Mode and Error Handling Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Demonstrates how to enable debug mode in databox.nvim by calling the setup function and checking individual operations for errors. It provides examples of how to handle setup failures and operation errors using vim.notify. ```lua -- Check setup status local success, err = require("databox").setup({ ... }) if not success then vim.notify("Setup failed: " .. err, vim.log.levels.ERROR) end -- Check individual operations local ok, err = db.set("test", "value") if not ok then vim.notify("Set failed: " .. err, vim.log.levels.ERROR) end ``` -------------------------------- ### Standard Age Setup Configuration Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Configuration example for databox.nvim using the standard age encryption utility. ```lua require("databox").setup({ private_key = "~/.config/age/keys.txt", public_key = "age1abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567890ab", }) ``` -------------------------------- ### Error Handling Examples Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Provides examples of how the databox plugin handles errors, such as attempting to set an existing key, update a non-existent key, or serialize unsupported data types like functions. ```lua local ok, err = db.set("existing_key", "value") if not ok then print("Error: " .. err) -- "Key already exists: existing_key" end local ok, err = db.update("nonexistent_key", "value") if not ok then print("Error: " .. err) -- "Key does not exist: nonexistent_key" end local ok, err = db.set("test", function() end) if not ok then print("Error: " .. err) -- "Cannot serialize function values" end ``` -------------------------------- ### Advanced Custom Encryption Tool Configuration Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Configuration example for databox.nvim using a custom encryption tool with specified commands. ```lua require("databox").setup({ private_key = "~/.config/mycrypt/key.pem", public_key = "~/.config/mycrypt/pub.pem", encryption_cmd = "mycrypt encrypt --key %s", decryption_cmd = "mycrypt decrypt --key %s", }) ``` -------------------------------- ### Custom Storage Location Configuration Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Configuration example for databox.nvim to specify a custom storage path for encrypted data. ```lua require("databox").setup({ private_key = "~/.config/age/keys.txt", public_key = "age1abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567890ab", store_path = "~/my-project/.secrets.txt", }) ``` -------------------------------- ### Core Databox Operations Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Demonstrates fundamental operations for setting, updating, getting, checking existence, and removing data within the databox. Includes examples of encrypting various data types like strings, numbers, booleans, nil values, and tables. ```lua local db = require("databox") -- Check if plugin is working local success, err = db.setup({ ... }) -- Set a new key (fails if key exists) local ok, err = db.set("project1", { token = "secret123", -- String: encrypted max_requests = 1000, -- Number: encrypted (protects limits/quotas) debug_enabled = true, -- Boolean: encrypted (protects config flags) config = { lang = "lua", timeout = 30, -- Nested number: encrypted features = {}, -- Empty table: encrypted and preserved disabled_feature = nil -- nil value: encrypted and preserved } }) -- Update existing key (fails if key doesn't exist) local ok, err = db.update("project1", { token = "newsecret456" }) -- Get value (returns value, error) local value, err = db.get("project1") -- Check existence local exists = db.exists("project1") -- true/false -- Remove key local ok, err = db.remove("project1") ``` -------------------------------- ### Batch Databox Operations Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Illustrates batch operations for retrieving all keys, clearing all data, and performing manual save/load operations for the databox. ```lua -- Get all keys local all_keys = db.keys() -- returns string[] -- Clear all data local ok, err = db.clear() -- Manual save/load local ok, err = db.save() local ok, err = db.load() ``` -------------------------------- ### Databox API Reference Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Overview of the databox.nvim API, noting that all functions return a success status and an optional error message. ```APIDOC All functions return `(success: boolean, error?: string)` for operations that can fail. ``` -------------------------------- ### Encryption Performance Testing Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Provides bash commands to test the performance of encryption utilities 'age' and 'rage' using ASCII armor. This helps in choosing the most suitable tool for performance-critical operations. ```bash # Test age performance with ASCII armor time echo "test data" | age -e -a -r | age -d -i # Test rage performance with ASCII armor time echo "test data" | rage -e -a -r | rage -d -i ``` -------------------------------- ### Save Control for Batch Operations Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Shows how to control automatic saving by batching multiple operations and then saving them all at once using `save = false`. ```lua -- Batch operations without saving each time db.set("key1", "value1", false) db.set("key2", "value2", false) db.set("key3", "value3", false) -- Save all at once local ok, err = db.save() ``` -------------------------------- ### Age Key Generation Source: https://github.com/chrisgve/databox.nvim/blob/main/README.md Command to generate an age key pair for use with databox.nvim. ```bash # Create age directory mkdir -p ~/.config/age # Generate key pair (works with both age and rage) age-keygen -o ~/.config/age/keys.txt # Your public key will be displayed in the terminal # Example: age1abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567890ab ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.