neomongo.nvim/lua/neomongo
October 16, 2025 Β· View on GitHub

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.
π Features
- π Telescope dashboard listing databases on the left and collections on the right
- π Collection picker that expands into a document list with live previews
- π Inline JSON filter (press
<C-f>inside the document picker) to query the current collection without leaving Telescope - π€ Filter autocompletion (
<C-Space>in the document picker) suggesting field/operator templates based on the sampled documents - π§Ύ ASCII banner highlighting the active connection, database, and document metadata
- βοΈ Editable collection buffers (
:wwrites back to MongoDB usingmongosh) - ποΈ Connection profiles stored in
~/.config/nvim/neomongo_connections.lua - βοΈ Simple commands for connecting, listing databases, listing collections, and running ad hoc queries
π¦ Installation
neomongo.nvim/lua/neomongo
Install Instructions
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).
βοΈ Setup
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
})
Connection profiles
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.
π§ Dashboard Workflow
- Run
:NeomongoDashboard. - Pick a connection (if several are defined). The picker lists databases and collections, each prefixed with an icon.
- Hover a collection to preview up to 100 documents on the right. Each entry shows a folded one-line JSON summary.
- Press
<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:wto update MongoDB and return to the dashboard, or use<C-e>to switch to the full editable collection buffer. - In the editable 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_idfield).
βΉοΈ 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.
Quick filters from the picker
While the document picker is open, you can narrow the result set without leaving Telescope:
- Type any valid MongoDB JSON filter (e.g.
{"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. - Press
<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. - Continue navigating, editing, or saving as usual.
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 root
Quick-start alias
Add 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"'
π Commands
| 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.
π§ Requirements
- Neovim 0.9+
- mongosh available on your
PATH - nvim-lua/plenary.nvim
- nvim-telescope/telescope.nvim
π€ Contributing
Issues, ideas, and pull requests are welcome! Please open an issue to discuss large changes before submitting a PR.
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a pull request π
π§Ή Development Workflow
make lintruns Luacheck against thelua/directory to catch undefined globals and other common mistakes.make formattidies the Lua sources with StyLua; usemake format-checkto verify formatting without modifying files.- Continuous integration runs two separate GitHub Actions (
Lua LintandLua Formatting) on pushes and pull requests to guarantee consistent style across contributions. - The linter and formatter configurations live in
.luacheckrcandstylua.tomlrespectivelyβfeel free to tweak them if new rules are needed.
π License
MIT License Β© 2025 tashikomaaa