From 6f718e517c69a1257a9ff4b30ae91d9d41594a75 Mon Sep 17 00:00:00 2001 From: Asep Komarudin <68836805+pojokcodeid@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:57:12 +0700 Subject: [PATCH] Updated 7. Example Custom Plugins (markdown) --- 7.-Example-Custom-Plugins.md | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/7.-Example-Custom-Plugins.md b/7.-Example-Custom-Plugins.md index 2f89e56..b8fb090 100644 --- a/7.-Example-Custom-Plugins.md +++ b/7.-Example-Custom-Plugins.md @@ -2818,4 +2818,61 @@ return { opts = {}, }, } +``` +# Database Management +```lua +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", + }, + keys = { + { + + "D", + "NvimTreeClosetabnewDBUI", + }, + }, +} ``` \ No newline at end of file