Skip to content

Commit

Permalink
autocmd trick
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Orfo committed Oct 30, 2024
1 parent 4402d72 commit 7719c47
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*Minimal Multi database client for Neovim*

## Caveats
- These dependencies are required to be installed: `Go v1.23.2`, `unixodbc`.
- These dependencies are required to be installed: `Go` (1.23), `unixodbc`.
- For the sake of simplicity, **this plugin is STATELESS**. It does not use database sessions or keep states after Neovim is closed.
- This plugin has been developed on and for `Linux` following open source philosophy.

Expand Down Expand Up @@ -38,6 +38,7 @@
- [Supported Operations](#supported-operations)
- [Usage](#usage)
- [Commands](#commands)
- [Tricks](#tricks)
- [Logs](#logs)

---
Expand Down Expand Up @@ -295,6 +296,20 @@ mycollection.find({ "field1": "value1" }).sort({"info": -1})

---

## Tricks
As **nvim-dbeer** resets the default database connection everytime Neovim is close. There is a chance to set N scripts to X database everytime threy are opened. Using **Neovim autocmd**:
```lua
-- Everytime test.sql, other.sql, update.sql the default database is set to '2'
vim.api.nvim_create_autocmd("BufReadPost", {
pattern = { "test.sql", "other.sql", "update.sql" },
callback = function()
require 'dbeer'.default_db = 2
end,
})
```

---

## Logs
Logs are saved generally in this path: **/home/your_user/.local/state/nvim/dbeer.log**

Expand Down

0 comments on commit 7719c47

Please sign in to comment.