Skip to content

LeuciRemi/arangodb.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arangodb.nvim

Browse and edit ArangoDB documents from Neovim.

This plugin extracts the ArangoDB browser workflow from my personal config into a reusable Neovim plugin with a small public API, user commands, and a healthcheck.

Features

  • Pick a database and manage collections from inside Neovim
  • Search documents live with snacks.nvim
  • Open documents in JSON buffers and save them back to ArangoDB
  • Create draft documents with prefilled _key, _id, and _rev, then insert them on first save
  • Jump to related documents from direct foreign keys, nested relation objects, and reverse links discovered in other collections
  • Create, duplicate, rename, and truncate collections from the collections picker
  • Duplicate draftable documents, delete documents, rename collections, and truncate collections
  • Discover databases from environment variables or explicit connection config

Requirements

  • Neovim >= 0.9
  • folke/snacks.nvim
  • curl for https:// connections

The plugin now talks to ArangoDB through a built-in Lua HTTP client. Plain http:// URLs use the built-in Lua transport. https:// URLs are supported through curl.

Installation

lazy.nvim

{
  "LeuciRemi/arangodb.nvim",
  dependencies = {
    "folke/snacks.nvim",
  },
  config = function()
    require("arangodb").setup({
      default_database = "_system",
      connections = {
        _system = "http://root:root@127.0.0.1:8529/_system",
      },
      keymaps = {
        browse = "<leader>ea",
        resume = "<leader>eA",
        back = "<leader>eb",
      },
      picker_keymaps = {
        execute = "<C-x>",
        create = "<C-a>",
        next_page = "<C-n>",
        prev_page = "<C-p>",
        back = "<C-b>",
        change_field = "<C-f>",
        reset = "<C-u>",
        related = "<C-o>",
        delete = "<C-d>",
        duplicate = "<C-y>",
        truncate = "<C-t>",
        rename = "<C-r>",
      },
      layout = {
        preset = "auto",
        preview = true,
      },
      document_keymaps = {
        save = "<leader>w",
        delete = "<leader>d",
        duplicate = "<leader>y",
        related = "gr",
      },
    })
  end,
}

Setup

require("arangodb").setup({
  connections = {
    _system = "http://root:root@127.0.0.1:8529/_system",
    kore = "https://root:root@db.example.com:8529/kore",
  },
  default_database = "kore",
  keymaps = {
    browse = "<leader>ea",
    resume = "<leader>eA",
    back = "<leader>eb",
  },
  picker_keymaps = {
    execute = "<C-x>",
    create = "<C-a>",
    next_page = "<C-n>",
    prev_page = "<C-p>",
    back = "<C-b>",
    change_field = "<C-f>",
    reset = "<C-u>",
    related = "<C-o>",
    delete = "<C-d>",
    duplicate = "<C-y>",
    truncate = "<C-t>",
    rename = "<C-r>",
  },
  layout = {
    preset = "auto",
    preview = true,
  },
  field_sample_size = 200,
  page_size = 50,
  json_indent = 2,
  truncate_length = 120,
  max_field_depth = 4,
  aql_batch_size = 1000,
  default_sort = "doc._key ASC",
  show_system_collections = false,
  http_timeout = 30000,
  tls_verify = true,
  tls_ca_file = nil,
})

Options

  • connections: table of named connection URLs, either { name = url } or { { name = "db", url = "..." } }; accepts http:// and https://
  • default_database: preferred database name or { name, url }
  • keymaps.browse: global normal-mode keymap for require("arangodb").browse()
  • keymaps.resume: global normal-mode keymap for require("arangodb").resume()
  • keymaps.back: global normal-mode keymap for require("arangodb").back()
  • picker_keymaps: picker-local key bindings for actions such as create, pagination, related lookup, delete, duplicate, truncate, and rename
  • layout.preset: snacks picker layout preset; "auto" by default chooses a side-by-side layout on wide screens and a stacked layout on narrower screens
  • layout.preview: enable picker preview window (default: true)
  • document_keymaps.save: buffer-local keymap for saving the current document
  • document_keymaps.delete: buffer-local keymap for deleting the current document
  • document_keymaps.duplicate: buffer-local keymap for duplicating the current document into a new draft
  • document_keymaps.related: buffer-local keymap for opening related documents
  • field_sample_size: number of documents sampled when listing candidate filter fields
  • page_size: number of documents fetched per picker page
  • json_indent: indentation width used for JSON previews and document formatting (default: 2)
  • truncate_length: max preview text length before truncation (default: 120)
  • max_field_depth: recursion depth when discovering nested field paths (default: 4)
  • aql_batch_size: cursor batch size used for AQL pagination (default: 1000)
  • default_sort: AQL sort clause used in document listings and related searches (default: "doc._key ASC")
  • show_system_collections: include ArangoDB system collections in collection listings (default: false)
  • http_timeout: timeout in milliseconds for ArangoDB HTTP requests
  • tls_verify: verify HTTPS certificates when using https:// URLs (default: true)
  • tls_ca_file: custom CA bundle path passed to curl --cacert for https:// URLs

Environment variables

You can use environment variables instead of explicit connections:

  • NVIM_ARANGO_HOST
  • NVIM_ARANGO_PORT
  • NVIM_ARANGO_SCHEME
  • NVIM_ARANGO_USER
  • NVIM_ARANGO_PASSWORD
  • NVIM_ARANGO_SYSTEM_URL
  • NVIM_ARANGO_<DATABASE>_URL

Example:

export NVIM_ARANGO_USER=root
export NVIM_ARANGO_PASSWORD=root
export NVIM_ARANGO_SCHEME=https
export NVIM_ARANGO_HOST=db.example.com
export NVIM_ARANGO_PORT=8529
export NVIM_ARANGO_KORE_URL='https://root:root@db.example.com:8529/kore'

Commands

  • :ArangoBrowse - pick a database, then open the collections picker
  • :ArangoBrowse {database} - open the collections picker for a specific database
  • :ArangoResume - reopen the current browser picker
  • :ArangoBack - return to the previous ArangoDB picker or document view
  • :ArangoDocumentSave - buffer-local command that saves the current document buffer, or creates a draft document on first save
  • :ArangoDocumentDuplicate - buffer-local command that duplicates the current document buffer into a new draft with a fresh id
  • :ArangoDocumentDelete - buffer-local command that deletes the current document buffer, or discards a draft document
  • :ArangoDocumentRelated - buffer-local command that opens a related document from direct keys, nested relations, or reverse links in the current buffer

Picker actions

  • Collections picker defaults: Enter open collection, Ctrl-a create a draft document, Ctrl-n create a collection, Ctrl-d duplicate a collection, Ctrl-r rename a collection, Ctrl-t truncate a collection, Ctrl-x open the actions menu, Ctrl-b go back to the database picker when available
  • Documents picker defaults: Ctrl-a create a draft document in the current collection, Ctrl-y duplicate the selected document into a new draft with a fresh id, Ctrl-d delete the selected document, Ctrl-t truncate the current collection after confirmation, Ctrl-x open the actions menu for the current document listing, Ctrl-f change filter field, Ctrl-u reset search, Ctrl-o open related, Ctrl-p previous page, Ctrl-n next page, Ctrl-b go back

Lua API

require("arangodb").setup(opts)
require("arangodb").browse({ database = "kore" })
require("arangodb").resume()
require("arangodb").back()

Healthcheck

Run:

:checkhealth arangodb

It checks the HTTP transport setup, optional HTTPS support through curl, snacks.nvim, and detected database candidates.

Notes

  • This plugin currently relies on folke/snacks.nvim for the live picker UI.
  • Use http:// for plain connections or https:// for TLS-enabled instances.
  • Install curl to use https:// connections.
  • Connection strings may contain credentials, so prefer environment variables if you do not want them stored in your config.
  • Add a license before making the repository fully public for reuse.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages