fixing the issues on the tags
This commit is contained in:
52
lua/cargdev/core/keymaps/database.lua
Normal file
52
lua/cargdev/core/keymaps/database.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
-- Database keymaps
|
||||
local keymap = vim.keymap
|
||||
|
||||
-- =============================================================================
|
||||
-- DATABASE KEYMAPS (vim-dadbod)
|
||||
-- =============================================================================
|
||||
|
||||
-- Toggle database UI
|
||||
keymap.set("n", "<leader>du", "<cmd>DBUIToggle<CR>", { desc = "Toggle Database UI" })
|
||||
|
||||
-- Add a new database connection
|
||||
keymap.set("n", "<leader>da", "<cmd>DBUIAddConnection<CR>", { desc = "Add DB Connection" })
|
||||
|
||||
-- Find buffer (useful when you have multiple query buffers)
|
||||
keymap.set("n", "<leader>df", "<cmd>DBUIFindBuffer<CR>", { desc = "Find DB Buffer" })
|
||||
|
||||
-- Execute query (works in sql buffers)
|
||||
keymap.set("n", "<leader>de", "<Plug>(DBUI_ExecuteQuery)", { desc = "Execute Query" })
|
||||
keymap.set("v", "<leader>de", "<Plug>(DBUI_ExecuteQuery)", { desc = "Execute Selected Query" })
|
||||
|
||||
-- Save query
|
||||
keymap.set("n", "<leader>dw", "<Plug>(DBUI_SaveQuery)", { desc = "Save Query" })
|
||||
|
||||
-- Rename buffer
|
||||
keymap.set("n", "<leader>dr", "<Plug>(DBUI_RenameBuf)", { desc = "Rename DB Buffer" })
|
||||
|
||||
-- =============================================================================
|
||||
-- QUICK CONNECTIONS
|
||||
-- =============================================================================
|
||||
|
||||
-- PostgreSQL Docker (default: 5432 postgres postgres postgres)
|
||||
keymap.set("n", "<leader>dp", "<cmd>DBPostgresDocker<CR>", { desc = "Connect PostgreSQL Docker" })
|
||||
|
||||
-- =============================================================================
|
||||
-- MONGODB
|
||||
-- =============================================================================
|
||||
|
||||
-- Open MongoDB shell (local)
|
||||
keymap.set("n", "<leader>dm", "<cmd>MongoDB<CR>", { desc = "Open MongoDB Shell" })
|
||||
|
||||
-- Open MongoDB in Docker container
|
||||
keymap.set("n", "<leader>dM", "<cmd>MongoDBDocker<CR>", { desc = "MongoDB Docker Shell" })
|
||||
|
||||
-- =============================================================================
|
||||
-- REDIS
|
||||
-- =============================================================================
|
||||
|
||||
-- Open Redis CLI (local)
|
||||
keymap.set("n", "<leader>di", "<cmd>Redis<CR>", { desc = "Open Redis CLI" })
|
||||
|
||||
-- Open Redis in Docker container
|
||||
keymap.set("n", "<leader>dI", "<cmd>RedisDocker<CR>", { desc = "Redis Docker CLI" })
|
||||
@@ -50,7 +50,7 @@ return {
|
||||
require("codetyper").setup({
|
||||
llm = {
|
||||
-- Available providers: "ollama", "claude", "openai", "gemini", "copilot"
|
||||
provider = "ollama",
|
||||
provider = "copilot", -- Using GitHub Copilot
|
||||
|
||||
-- Ollama (local LLM)
|
||||
ollama = {
|
||||
@@ -84,10 +84,10 @@ return {
|
||||
-- -- model = "gemini-2.0-flash-exp",
|
||||
-- },
|
||||
|
||||
-- GitHub Copilot (requires copilot.vim or copilot.lua plugin)
|
||||
-- copilot = {
|
||||
-- enabled = true,
|
||||
-- },
|
||||
-- GitHub Copilot (uses OAuth from copilot.vim/copilot.lua)
|
||||
copilot = {
|
||||
model = "gpt-4o", -- or "gpt-4", "gpt-3.5-turbo"
|
||||
},
|
||||
},
|
||||
window = {
|
||||
width = 0.25, -- 1/4 of window
|
||||
@@ -104,7 +104,7 @@ return {
|
||||
agent_mode = false,
|
||||
scheduler = {
|
||||
enabled = true,
|
||||
ollama_scout = true, -- Use ollama first, escalate if low confidence
|
||||
ollama_scout = false, -- Disabled since using Copilot directly
|
||||
escalation_threshold = 0.7,
|
||||
max_concurrent = 2,
|
||||
completion_delay_ms = 100, -- Delay before checking completion visibility
|
||||
|
||||
154
lua/cargdev/plugins/dadbod.lua
Normal file
154
lua/cargdev/plugins/dadbod.lua
Normal file
@@ -0,0 +1,154 @@
|
||||
return {
|
||||
"kristijanhusak/vim-dadbod-ui",
|
||||
dependencies = {
|
||||
{ "tpope/vim-dadbod", lazy = true },
|
||||
{ "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true },
|
||||
},
|
||||
cmd = {
|
||||
"DBUI",
|
||||
"DBUIToggle",
|
||||
"DBUIAddConnection",
|
||||
"DBUIFindBuffer",
|
||||
},
|
||||
init = function()
|
||||
-- Database UI configuration
|
||||
vim.g.db_ui_use_nerd_fonts = 1
|
||||
vim.g.db_ui_show_database_icon = 1
|
||||
vim.g.db_ui_force_echo_notifications = 1
|
||||
|
||||
-- Save query results to a file
|
||||
vim.g.db_ui_save_location = vim.fn.stdpath("data") .. "/db_ui"
|
||||
|
||||
-- Use better split
|
||||
vim.g.db_ui_win_position = "left"
|
||||
vim.g.db_ui_winwidth = 40
|
||||
|
||||
-- Table helpers
|
||||
vim.g.db_ui_table_helpers = {
|
||||
postgresql = {
|
||||
Count = "SELECT COUNT(*) FROM {table}",
|
||||
List = "SELECT * FROM {table} LIMIT 100",
|
||||
Schema = "\\d+ {table}",
|
||||
Indexes = "SELECT * FROM pg_indexes WHERE tablename = '{table}'",
|
||||
Size = "SELECT pg_size_pretty(pg_total_relation_size('{table}'))",
|
||||
},
|
||||
mysql = {
|
||||
Count = "SELECT COUNT(*) FROM {table}",
|
||||
List = "SELECT * FROM {table} LIMIT 100",
|
||||
Schema = "DESCRIBE {table}",
|
||||
Indexes = "SHOW INDEX FROM {table}",
|
||||
},
|
||||
sqlite = {
|
||||
Count = "SELECT COUNT(*) FROM {table}",
|
||||
List = "SELECT * FROM {table} LIMIT 100",
|
||||
Schema = ".schema {table}",
|
||||
},
|
||||
}
|
||||
|
||||
-- Icons
|
||||
vim.g.db_ui_icons = {
|
||||
expanded = "▾",
|
||||
collapsed = "▸",
|
||||
saved_query = "*",
|
||||
new_query = "+",
|
||||
tables = "~",
|
||||
buffers = "»",
|
||||
connection_ok = "✓",
|
||||
connection_error = "✕",
|
||||
}
|
||||
|
||||
-- Quick connect to Docker PostgreSQL
|
||||
-- Use 127.0.0.1 instead of localhost (localhost may resolve to IPv6)
|
||||
vim.api.nvim_create_user_command("DBPostgresDocker", function(opts)
|
||||
local args = opts.args
|
||||
local port = "5432"
|
||||
local user = "postgres"
|
||||
local password = "postgres"
|
||||
local database = "postgres"
|
||||
|
||||
-- Parse arguments: port user password database
|
||||
local parts = vim.split(args, " ")
|
||||
if parts[1] and parts[1] ~= "" then port = parts[1] end
|
||||
if parts[2] and parts[2] ~= "" then user = parts[2] end
|
||||
if parts[3] and parts[3] ~= "" then password = parts[3] end
|
||||
if parts[4] and parts[4] ~= "" then database = parts[4] end
|
||||
|
||||
local url = string.format("postgresql://%s:%s@127.0.0.1:%s/%s", user, password, port, database)
|
||||
-- Set the connection and open DBUI
|
||||
local dbs = vim.g.dbs or {}
|
||||
dbs[database] = url
|
||||
vim.g.dbs = dbs
|
||||
vim.cmd("DBUIToggle")
|
||||
vim.notify("Added PostgreSQL connection: " .. database, vim.log.levels.INFO)
|
||||
end, {
|
||||
nargs = "*",
|
||||
desc = "Connect to Docker PostgreSQL (args: port user password database)",
|
||||
})
|
||||
|
||||
-- MongoDB terminal command
|
||||
vim.api.nvim_create_user_command("MongoDB", function(opts)
|
||||
local args = opts.args
|
||||
local cmd = "mongosh"
|
||||
if args and args ~= "" then
|
||||
cmd = cmd .. " " .. args
|
||||
else
|
||||
cmd = cmd .. " mongodb://127.0.0.1:27017"
|
||||
end
|
||||
vim.cmd("terminal " .. cmd)
|
||||
vim.cmd("startinsert")
|
||||
end, {
|
||||
nargs = "*",
|
||||
desc = "Open MongoDB shell (args: connection string or options)",
|
||||
})
|
||||
|
||||
-- Redis terminal command
|
||||
vim.api.nvim_create_user_command("Redis", function(opts)
|
||||
local args = opts.args
|
||||
local cmd = "redis-cli"
|
||||
if args and args ~= "" then
|
||||
cmd = cmd .. " " .. args
|
||||
else
|
||||
cmd = cmd .. " -h 127.0.0.1 -p 6379"
|
||||
end
|
||||
vim.cmd("terminal " .. cmd)
|
||||
vim.cmd("startinsert")
|
||||
end, {
|
||||
nargs = "*",
|
||||
desc = "Open Redis CLI (args: host/port options)",
|
||||
})
|
||||
|
||||
-- MongoDB with Docker
|
||||
vim.api.nvim_create_user_command("MongoDBDocker", function(opts)
|
||||
local container = opts.args ~= "" and opts.args or "mongodb"
|
||||
vim.cmd("terminal docker exec -it " .. container .. " mongosh")
|
||||
vim.cmd("startinsert")
|
||||
end, {
|
||||
nargs = "?",
|
||||
desc = "Open MongoDB shell in Docker container (arg: container name)",
|
||||
})
|
||||
|
||||
-- Redis with Docker
|
||||
vim.api.nvim_create_user_command("RedisDocker", function(opts)
|
||||
local container = opts.args ~= "" and opts.args or "redis"
|
||||
vim.cmd("terminal docker exec -it " .. container .. " redis-cli")
|
||||
vim.cmd("startinsert")
|
||||
end, {
|
||||
nargs = "?",
|
||||
desc = "Open Redis CLI in Docker container (arg: container name)",
|
||||
})
|
||||
end,
|
||||
config = function()
|
||||
-- Setup completion for sql files
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "sql", "mysql", "plsql" },
|
||||
callback = function()
|
||||
require("cmp").setup.buffer({
|
||||
sources = {
|
||||
{ name = "vim-dadbod-completion" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -24,7 +24,7 @@ return {
|
||||
{ section = "startup" },
|
||||
},
|
||||
},
|
||||
explorer = { enabled = true },
|
||||
explorer = { enabled = false },
|
||||
image = {
|
||||
enabled = true,
|
||||
terminal = nil,
|
||||
@@ -51,5 +51,6 @@ return {
|
||||
vim.ui.input = require("snacks.input").input
|
||||
vim.ui.select = require("snacks.picker").select
|
||||
end)
|
||||
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user