
Manage your MongoDB collections straight from Neovim.
neomongo.nvim offers a lightweight workflow built around a Telescope-powered dashboard where you can explore databases, preview documents, and update collections without leaving your editor.
<C-f> inside the document picker) to query the current collection without leaving Telescope<C-Space> in the document picker) suggesting field/operator templates based on the sampled documents:w writes back to MongoDB using mongosh)~/.config/nvim/neomongo_connections.lua
Install requires Neovim 0.9+. Always review the code before installing a configuration.
Clone the repository and install the plugins:
git clone git@github.com:tashikomaaa/neomongo.nvim ~/.config/tashikomaaa/neomongo.nvim
Open Neovim with this config:
NVIM_APPNAME=tashikomaaa/neomongo.nvim/lua/neomongo nvim
neomongo.nvim only depends on telescope.nvim and plenary.nvim.
-- lazy.nvim example
{
"tashikomaaa/neomongo.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
}
Once installed, the plugin is ready to use after configuration (see below).
require("neomongo").setup({
uri = "mongodb://localhost:27017",
connection_name = "Local dev",
connections_file = vim.fn.stdpath("config") .. "/neomongo_connections.lua",
prompt_for_connection = true, -- set to false to skip the picker when only one entry exists
})
On first launch, neomongo ensures that the connections file exists (defaults to ~/.config/nvim/neomongo_connections.lua). The file returns a Lua table:
return {
{ name = "Local", uri = "mongodb://localhost:27017" },
{ name = "Replica set", uri = "mongodb://mongo-01:27017" },
-- Add more connections here
}
When prompt_for_connection is true (default), :NeomongoDashboard opens a picker letting you choose which connection you want to use. If only one connection is defined you can skip the prompt by setting prompt_for_connection = false.
:NeomongoDashboard.<CR> on a collection to open a document picker: left-hand list of documents, right-hand JSON preview (Tree-sitter folds are enabled when available). Type a JSON filter in the Telescope prompt and hit <C-f> to re-query the collection (empty prompt reloads the default 100 docs). Need a hand? Hit <C-Space> for autocompletion templates (equals, $in, $regex, $exists, comparisons, $or, …) and then tweak the generated JSON. Press <CR> again to pop a floating window with the selected document; edit it directly and hit :w to update MongoDB and return to the dashboard, or use <C-e> to switch to the full editable collection buffer.neomongo://db/collection), update the JSON array and hit :w; the plugin validates the JSON and issues insert-or-update commands for each document (documents must keep their _id field).ℹ️ Removing a document from the buffer does not delete it remotely. The save routine performs insert or update operations only. Document folding relies on the
nvim-treesitterJSON parser when available. The editor prettifies JSON automatically; if a document contains extremely long lines Neovim may disable syntax highlighting to keep things responsive.
While the document picker is open, you can narrow the result set without leaving Telescope:
{"status":"recruteur"} or {"missionId":{"$in":["123","456"]}}) into the prompt, or press <C-Space> to pick a ready-made template for the currently sampled fields.<C-f> (insert or normal mode) to execute the query. Up to 200 matching documents are shown; an empty prompt reloads the default unfiltered list.This uses the same normalization routines as the save path, so _id values and unique indexes are handled consistently.
Autocompletion assumes the current prompt contains valid JSON; if you get an error, tidy up the syntax before retrying
<C-Space>.
Templates currently offered:
equals value — quickly add { "field": "value" }$in list — scaffold { "field": { "$in": ["a", "b"] } }$regex pattern — add { "field": { "$regex": "" } }$exists flag — add { "field": { "$exists": true } }$gte / $lte — add range boundaries$or, $and, $nor — create compound array filters at the rootAdd this to your shell config if you want to jump into the dashboard from the command line:
alias neomongovim='nvim +"lua require(\"neomongo\").setup({ prompt_for_connection = true })" +"NeomongoDashboard"'
| Command | Description |
|---|---|
:NeomongoConnect |
Display a notification confirming a connection to the configured URI |
:NeomongoListDBs |
List databases using mongosh and echo the JSON response |
:NeomongoListCollections {db} |
List collections for the provided database name |
:NeomongoQuery {expression} |
Run an arbitrary mongosh expression against the configured URI |
:NeomongoDashboard |
Launch the Telescope dashboard described above |
All commands rely on M.config.uri; the dashboard additionally honours the connection selected from your profiles file.
PATHIssues, ideas, and pull requests are welcome! Please open an issue to discuss large changes before submitting a PR.
make lint runs Luacheck against the lua/ directory to catch undefined globals and other common mistakes.make format tidies the Lua sources with StyLua; use make format-check to verify formatting without modifying files.Lua Lint and Lua Formatting) on pushes and pull requests to guarantee consistent style across contributions..luacheckrc and stylua.toml respectively—feel free to tweak them if new rules are needed.MIT License © 2025 tashikomaaa