-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Orfo
committed
Oct 30, 2024
1 parent
4a91816
commit e0886e6
Showing
3 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local logger = require 'dbeer.util'.logger | ||
local setup = require 'dbeer'.SETTINGS | ||
local db = setup.db | ||
|
||
if db.connections then | ||
local connection = db.connections[require 'dbeer'.default_db] | ||
if connection.name and connection.dbname and connection.engine and require 'dbeer.engines'.db[connection.engine] and connection.engine == "mongo" then | ||
logger:info(string.format("Database set to [%s]", connection.name)) | ||
vim.api.nvim_set_keymap('v', setup.commands.execute, '<cmd>lua require("dbeer.core").run()<CR>', | ||
{ noremap = true, silent = true }) | ||
vim.api.nvim_set_keymap('n', setup.commands.execute, '<cmd>lua require("dbeer.core").run()<CR>', | ||
{ noremap = true, silent = true }) | ||
vim.api.nvim_set_keymap('n', setup.commands.close, '<cmd>lua require("dbeer.core").close()<CR>', | ||
{ noremap = true, silent = true }) | ||
else | ||
pcall(vim.keymap.del, 'v', setup.commands.execute) | ||
pcall(vim.keymap.del, 'n', setup.commands.execute) | ||
pcall(vim.keymap.del, 'n', setup.commands.close) | ||
end | ||
else | ||
logger:info("No database configured.") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local logger = require 'dbeer.util'.logger | ||
local setup = require 'dbeer'.SETTINGS | ||
local db = setup.db | ||
|
||
if db.connections then | ||
local connection = db.connections[require 'dbeer'.default_db] | ||
if connection.name and connection.dbname and connection.engine and require 'dbeer.engines'.db[connection.engine] and connection.engine ~= "mongo" then | ||
logger:info(string.format("Database set to [%s]", connection.name)) | ||
vim.api.nvim_set_keymap('v', setup.commands.execute, '<cmd>lua require("dbeer.core").run()<CR>', | ||
{ noremap = true, silent = true }) | ||
vim.api.nvim_set_keymap('n', setup.commands.execute, '<cmd>lua require("dbeer.core").run()<CR>', | ||
{ noremap = true, silent = true }) | ||
vim.api.nvim_set_keymap('n', setup.commands.close, '<cmd>lua require("dbeer.core").close()<CR>', | ||
{ noremap = true, silent = true }) | ||
else | ||
pcall(vim.keymap.del, 'v', setup.commands.execute) | ||
pcall(vim.keymap.del, 'n', setup.commands.execute) | ||
pcall(vim.keymap.del, 'n', setup.commands.close) | ||
end | ||
else | ||
logger:info("No database configured.") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters