{"id":19989536,"url":"https://github.com/willothy/durable.nvim","last_synced_at":"2025-09-19T22:31:23.774Z","repository":{"id":261046755,"uuid":"883080212","full_name":"willothy/durable.nvim","owner":"willothy","description":"SQLite-backed key-value store and persistent objects for Neovim","archived":false,"fork":false,"pushed_at":"2024-12-18T01:27:35.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T02:31:21.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willothy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-04T10:44:14.000Z","updated_at":"2024-12-18T01:27:39.000Z","dependencies_parsed_at":"2024-11-04T12:31:46.322Z","dependency_job_id":"7b633fbc-c7c8-4269-933a-417ff639003d","html_url":"https://github.com/willothy/durable.nvim","commit_stats":null,"previous_names":["willothy/durable.nvim"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fdurable.nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fdurable.nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fdurable.nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fdurable.nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willothy","download_url":"https://codeload.github.com/willothy/durable.nvim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233600882,"owners_count":18700747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:48:15.489Z","updated_at":"2025-09-19T22:31:18.520Z","avatar_url":"https://github.com/willothy.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# 📦 durable.nvim\n\n*SQLite-backed key-value store and persistent objects for Neovim*\n\nInspired by my friends at [freestyle](https://github.com/freestyle-sh), and by Cloudflare Durable Objects.\n\n[![License](https://img.shields.io/github/license/willothy/durable.nvim.svg)](https://github.com/willothy/durable.nvim/blob/main/LICENSE)\n[![Neovim Minimum Version](https://img.shields.io/badge/Neovim-0.10+-green.svg)](https://neovim.io)\n\n---\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [🚀 Features](#-features)\n- [🛠️ Installation](#️-installation)\n  - [Requirements](#requirements)\n  - [Plugin Managers](#plugin-managers)\n- [📖 Usage](#-usage)\n  - [Key-Value Store](#key-value-store)\n  - [Persistent Objects](#persistent-objects-development-in-progress)\n- [🔧 Configuration](#-configuration)\n- [💡 Examples](#-examples)\n  - [Caching API Responses](#caching-api-responses)\n  - [Saving Plugin State](#saving-plugin-state)\n- [🛣️ Roadmap](#️-roadmap)\n- [🤝 Contributing](#-contributing)\n- [📝 License](#-license)\n- [🙏 Acknowledgments](#-acknowledgments)\n- [🐞 Issues and Support](#-issues-and-support)\n\n---\n\n## Introduction\n\n`durable.nvim` brings the power of persistent storage to your Neovim environment. By leveraging SQLite, it allows you to store and retrieve data across Neovim sessions effortlessly. Ideal for plugin developers and users who need a simple yet robust way to maintain state, cache data, or manage complex objects over time.\n\n---\n\n## 🚀 Features\n\n- ⚡ **SQLite-backed key-value store**: Fast and reliable data storage using SQLite.\n- 💾 **Persistent objects**: Store Lua tables and objects persistently.\n- 🛠️ **Easy API**: Simple functions to get you started quickly.\n- 🪶 **Lightweight**: Minimal dependencies and overhead.\n- 🔧 **Customizable**: Configure storage paths and settings.\n\n---\n\n## 🛠️ Installation\n\n### Requirements\n\n- [Neovim](https://neovim.io/) 0.10 or higher\n- [sqlite.lua](https://github.com/kkharji/sqlite.lua)\n\n### Plugin Managers\n\nUsing [lazy.nvim](https://github.com/folke/lazy.nvim):\n\n```vim\n{\n  \"willothy/durable.nvim\",\n  config = true,\n}\n```\n\n---\n\n## 📖 Usage\n\n### Key-Value Store\n\n`durable.nvim` provides a simple API for key-value storage.\n\nKeys should always be strings, but multiple value types are supported. `durable.nvim` tracks\nvalue types to provide type-safety between Lua and SQLite.\n\nSupported types are `string`, `number`, `boolean`, `table` (json), and `nil`.\n\n**Setting a value**\n\n```lua\nlocal durable = require('durable')\nlocal kv = durable.kv\n\n-- Set a value\nkv.set('theme', 'gruvbox')\n```\n\n**Getting a value**\n\n```lua\n-- Get a value\nlocal theme = kv.get('theme')  -- returns 'gruvbox'\n```\n\n**Deleting a key**\n\n```lua\n-- Delete a key\nkv.delete('theme')\n```\n\n#### Namespaces\n\nBy default all operations happen in a global namespace, but all functions accept\na namespace parameter which provides scoping/isolaiton for plugins and other use\ncases.\n\n```lua\nkv.set('enable_my_plugin', true, \"my_plugin\")\n```\n\n### Persistent Objects (development in-progress)\n\nStore complex Lua tables, including nested tables and complex state.\n\n**Storing an object**\n\n```lua\n---@class PersistentCounter\n---@field count number\nlocal PersistentCounter = {}\n\nfunction PersistentCounter.new()\n  return {\n    count = 0\n  }\nend\n\nfunction PersistentCounter:increment()\n  self.count = self.count + 1\nend\n\nfunction PersistentCounter:decrement()\n  self.count = self.count - 1\nend\n\n-- state is automatically persistent across sessions using the given id,\n-- in this case \"counter\"\nlocal counter = durable.persist(\"counter\", PersistentCounter)\n\ncounter:increment()\n```\n\n---\n\n## 🔧 Configuration\n\nCustomize the plugin by setting variables in your `init.lua` or `init.vim`.\n\n```lua\nrequire('durable').setup({\n  db_path = vim.fn.stdpath('data') .. '/databases/durable.db',\n})\n```\n\n---\n\n## 💡 Examples\n\n### Caching API Responses\n\n```lua\nlocal http = require('socket.http')\n\nlocal function get_data()\n  local cached = kv.get('api_response', \"my_api_cache\")\n  if cached then\n    return cached\n  else\n    local response = http.request('http://api.example.com/data')\n    kv.set('api_response', response, \"my_api_cache\")\n    return response\n  end\nend\n\nvim.print(get_data())\n```\n\n### Saving Plugin State\n\n```lua\n-- Save window layout or other state information\nkv.set('window_state', vim.fn.getwininfo())\n\n-- Later, restore the state\nlocal window_state = kv.get('window_state')\n-- Use vim.fn.winrestview(window_state) or similar functions\n```\n\n---\n\n## 🛣️ Roadmap\n\n- [ ] Persistent objects (in progress)\n- [ ] Add support for transactions\n- [ ] Implement TTL (Time to Live) for keys\n- [ ] Support for custom serialization methods\n- [ ] Performance optimizations\n\nSee the [open issues](https://github.com/willothy/durable.nvim/issues) for a full list of proposed features (and known issues).\n\n---\n\n## 🤝 Contributing\n\nContributions are what make the open-source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the project.\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`).\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\n4. Push to the branch (`git push origin feature/AmazingFeature`).\n5. Open a pull request.\n\nPlease make sure to update tests as appropriate.\n\n---\n\n## 📝 License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/willothy/durable.nvim/blob/main/LICENSE) for more information.\n\n---\n\n## 🙏 Acknowledgments\n\n- [Neovim Lua API](https://neovim.io/doc/user/lua.html)\n- [sqlite.lua](https://github.com/kkharji/sqlite.lua) - SQLite/LuaJIT binding for Lua and Neovim\n\n---\n\n## 🐞 Issues and Support\n\nIf you encounter any issues or have questions, feel free to open an [issue](https://github.com/willothy/durable.nvim/issues) on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fdurable.nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillothy%2Fdurable.nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fdurable.nvim/lists"}