add: config for database management

This commit is contained in:
asep.komarudin 2024-06-12 18:38:25 +07:00
parent 17f2ffe48b
commit 9dbcd4b755
9 changed files with 218 additions and 82 deletions

View file

@ -15,6 +15,7 @@
"dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" },
"friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" },
"gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" }, "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" },
"inc-rename.nvim": { "branch": "main", "commit": "535b508c0cb14d00c1836ad901b3c531cb1152bb" },
"indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" },
"lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" },
"lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" }, "lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" },
@ -24,7 +25,7 @@
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" }, "mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" },
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
"noice.nvim": { "branch": "main", "commit": "29c7f030b0920e2f17263a9ab8742cde144b9140" }, "noice.nvim": { "branch": "main", "commit": "b828b575805f1b303c2f4b768744609835140739" },
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" }, "none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
"none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" }, "none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" },
"nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" },
@ -37,18 +38,23 @@
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" }, "nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" },
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
"nvim-treesitter": { "branch": "master", "commit": "9a7ad2ff7a7ea81016aca2fc89c9b2c1a5365421" }, "nvim-treesitter": { "branch": "master", "commit": "26171d8f105d97746371d1b6c07c8d88bf13fec2" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-ts-autotag": { "branch": "main", "commit": "2692808eca8a4ac3311516a1c4a14bb97ecc6482" }, "nvim-ts-autotag": { "branch": "main", "commit": "06fe07d7523ba8c755fac7c913fceba43b1720ee" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
"nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" },
"playground": { "branch": "master", "commit": "bcfab84f98a33f2ad34dda6c842046dca70aabf6" }, "playground": { "branch": "master", "commit": "bcfab84f98a33f2ad34dda6c842046dca70aabf6" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" },
"refactoring.nvim": { "branch": "master", "commit": "d2786877c91aa409c824f27b4ce8a9f560dda60a" },
"smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" }, "smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "a7ab9a957b17199183388c6f357d614fcaa508e5" },
"telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" }, "telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" },
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "f3f136fd82eded0bd1e1870cf7dfab7e8c36801e" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "f3f136fd82eded0bd1e1870cf7dfab7e8c36801e" },
"toggleterm.nvim": { "branch": "main", "commit": "fee58a0473fd92b28c34f8f724e4918b15ba30a3" }, "toggleterm.nvim": { "branch": "main", "commit": "fee58a0473fd92b28c34f8f724e4918b15ba30a3" },
"vim-dadbod": { "branch": "master", "commit": "6f8b99868fd5560d6eb47f82ca76ec62e3d5ae78" },
"vim-dadbod-completion": { "branch": "master", "commit": "5d5ad196fcde223509d7dabbade0148f7884c5e3" },
"vim-dadbod-ui": { "branch": "master", "commit": "0dc68d9225a70d42f8645049482e090c1a8dce25" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" }, "vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" },
"vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" }, "vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" },

View file

@ -133,3 +133,5 @@ vim.g.pcode_columnline = true
---| "center" # retain the default telescope theme ---| "center" # retain the default telescope theme
vim.g.pcode_telescope_theme_find_file = "center" vim.g.pcode_telescope_theme_find_file = "center"
vim.g.pcode_telescope_theme_live_grep = "dropdown" vim.g.pcode_telescope_theme_live_grep = "dropdown"
-- https://github.com/kristijanhusak/vim-dadbod-ui
vim.g.pcode_database = true

View file

@ -1,47 +0,0 @@
return {
-- "kristijanhusak/vim-dadbod-ui",
-- dependencies = {
-- { "tpope/vim-dadbod", lazy = true },
-- { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true },
-- },
-- init = function()
-- -- Your DBUI configuration
-- vim.g.db_ui_show_database_icon = 1
-- vim.g.db_ui_use_nerd_fonts = 1
-- vim.g.db_ui_show_help = 0
-- end,
-- config = function()
-- local function db_completion()
-- require("cmp").setup.buffer {
-- sources = { { name = "vim-dadbod-completion" } },
-- }
-- end
-- vim.g.db_ui_save_location = vim.fn.stdpath "config" .. require("plenary.path").path.sep .. "db_ui"
--
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = {
-- "sql",
-- },
-- command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
-- })
--
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = {
-- "sql",
-- "mysql",
-- "plsql",
-- },
-- callback = function()
-- vim.schedule(db_completion)
-- end,
-- })
-- end,
-- cmd = {
-- "DBUIToggle",
-- "DBUI",
-- "DBUIAddConnection",
-- "DBUIFindBuffer",
-- "DBUIRenameBuffer",
-- "DBUILastQueryInfo",
-- },
}

View file

@ -0,0 +1,60 @@
return {
-- "nvim-telescope/telescope-file-browser.nvim",
-- dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
-- keys = {
-- {
-- "sf",
-- function()
-- local telescope = require "telescope"
--
-- local function telescope_buffer_dir()
-- return vim.fn.expand "%:p:h"
-- end
--
-- telescope.extensions.file_browser.file_browser {
-- path = "%:p:h",
-- cwd = telescope_buffer_dir(),
-- respect_gitignore = false,
-- hidden = true,
-- grouped = true,
-- previewer = false,
-- initial_mode = "insert",
-- layout_config = { height = 40 },
-- }
-- end,
-- desc = "Open File Browser with the path of the current buffer",
-- },
-- },
-- config = function(_, opts)
-- local telescope = require "telescope"
-- local actions = require "telescope.actions"
-- local fb_actions = require("telescope").extensions.file_browser.actions
-- opts.extensions = {
-- file_browser = {
-- theme = "dropdown",
-- -- disables netrw and use telescope-file-browser in its place
-- hijack_netrw = true,
-- mappings = {
-- -- your custom insert mode mappings
-- ["n"] = {
-- -- your custom normal mode mappings
-- ["N"] = fb_actions.create,
-- ["h"] = fb_actions.goto_parent_dir,
-- ["<C-u>"] = function(prompt_bufnr)
-- for i = 1, 10 do
-- actions.move_selection_previous(prompt_bufnr)
-- end
-- end,
-- ["<C-d>"] = function(prompt_bufnr)
-- for i = 1, 10 do
-- actions.move_selection_next(prompt_bufnr)
-- end
-- end,
-- },
-- },
-- },
-- }
-- telescope.setup(opts)
-- require("telescope").load_extension "file_browser"
-- end,
}

View file

@ -0,0 +1,40 @@
return {
-- Incremental rename
-- {
-- "smjonas/inc-rename.nvim",
-- cmd = "IncRename",
-- keys = {
-- {
-- "<leader>un",
-- function()
-- return ":IncRename " .. vim.fn.expand "<cword>"
-- end,
-- desc = "Incremental rename",
-- mode = "n",
-- noremap = true,
-- expr = true,
-- },
-- },
-- config = true,
-- },
--
-- -- Refactoring tool
-- {
-- "ThePrimeagen/refactoring.nvim",
-- keys = {
-- {
-- "<leader>r",
-- function()
-- require("refactoring").select_refactor {
-- show_success_message = true,
-- }
-- end,
-- mode = "v",
-- noremap = true,
-- silent = true,
-- expr = false,
-- },
-- },
-- opts = {},
-- },
}

52
lua/plugins/database.lua Normal file
View file

@ -0,0 +1,52 @@
local M = {}
if vim.g.pcode_database then
return {
"kristijanhusak/vim-dadbod-ui",
dependencies = {
{ "tpope/vim-dadbod", lazy = true },
{ "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true },
},
init = function()
-- Your DBUI configuration
vim.g.db_ui_show_database_icon = 1
vim.g.db_ui_use_nerd_fonts = 1
vim.g.db_ui_show_help = 0
end,
config = function()
local function db_completion()
require("cmp").setup.buffer {
sources = { { name = "vim-dadbod-completion" } },
}
end
vim.g.db_ui_save_location = vim.fn.stdpath "config" .. require("plenary.path").path.sep .. "db_ui"
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
},
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
"mysql",
"plsql",
},
callback = function()
vim.schedule(db_completion)
end,
})
end,
cmd = {
"DBUIToggle",
"DBUI",
"DBUIAddConnection",
"DBUIFindBuffer",
"DBUIRenameBuffer",
"DBUILastQueryInfo",
},
}
end
return M

View file

@ -1,31 +1,31 @@
return { return {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
lazy = true, lazy = true,
event = "VeryLazy", event = "VeryLazy",
keys = { keys = {
{ {
"<leader>un", "<leader>un",
function() function()
require("notify").dismiss({ silent = true, pending = true }) require("notify").dismiss { silent = true, pending = true }
end, end,
desc = "Delete all Notifications", desc = "Delete all Notifications",
}, },
}, },
opts = { opts = {
timeout = 3000, timeout = 3000,
max_height = function() max_height = function()
return math.floor(vim.o.lines * 0.75) return math.floor(vim.o.lines * 0.75)
end, end,
max_width = function() max_width = function()
return math.floor(vim.o.columns * 0.75) return math.floor(vim.o.columns * 0.75)
end, end,
}, },
-- event = "BufWinEnter", -- event = "BufWinEnter",
config = function() config = function()
local notify = require("notify") local notify = require "notify"
-- this for transparency -- this for transparency
notify.setup({ background_colour = "#000000" }) notify.setup { background_colour = "#000000", render = "compact" }
-- this overwrites the vim notify function -- this overwrites the vim notify function
vim.notify = notify.notify vim.notify = notify.notify
end, end,
} }

View file

@ -6,7 +6,7 @@ elseif substring(tostring(colorscheme), "material") then
colorscheme = "material" colorscheme = "material"
end end
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) local ok, _ = pcall(vim.cmd.colorscheme, colorscheme)
if not status_ok then if not ok then
return require "notify"("Colorscheme '" .. colorscheme .. "' not found!", "error")
end end

View file

@ -282,6 +282,29 @@ if vim.g.pcode_codeium then
table.insert(M.mappings, { ["c"] = { ":call codeium#Chat()<cr>", "󰭹 Codeium Chat" } }) table.insert(M.mappings, { ["c"] = { ":call codeium#Chat()<cr>", "󰭹 Codeium Chat" } })
end end
if vim.g.pcode_database then
table.insert(M.mappings, {
["D"] = {
name = " 󰆼 DBUI",
d = { "<cmd>NvimTreeClose<cr><cmd>tabnew<cr><bar><bar><cmd>DBUI<cr>", "󰆼 DBUI Toggle" },
q = {
"<cmd>DBUIClose<cr><cmd>BufferLineCloseOthers<cr><cmd>bd!<cr><cmd>lua require('user.utils.bufferline').bufremove()<cr><cmd>Alpha<cr>",
"󰅙 DBUI Close",
},
},
})
-- table.insert(
-- M.mappings,
-- { ["D"] = { "<cmd>NvimTreeClose<cr><cmd>tabnew<cr><bar><bar><cmd>DBUI<cr>", "󰆼 DBUI Toggle" } }
-- )
-- table.insert(M.mappings, {
-- ["x"] = {
-- "<cmd>DBUIClose<cr><cmd>lua require('user.utils.bufferline').bufremove()<cr><cmd>Alpha<cr>",
-- "󰆼 DBUI Toggle",
-- },
-- })
end
M.mappings2 = { M.mappings2 = {
["/"] = { "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", " 󰆈 Commet Block" }, ["/"] = { "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", " 󰆈 Commet Block" },
} }