feat: refactoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
return {
|
||||
"goolord/alpha-nvim",
|
||||
event = "VimEnter",
|
||||
enable = true,
|
||||
config = function()
|
||||
local alpha = require("alpha")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
return {
|
||||
"rmagatti/auto-session",
|
||||
config = function()
|
||||
local auto_session = require("auto-session")
|
||||
|
||||
require("auto-session").setup({
|
||||
auto_restore = false,
|
||||
suppressed_dirs = { "~/", "~/Dev/", "~/Downloads", "~/Documents", "~/Desktop/" },
|
||||
})
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "<leader>wr", "<cmd>SessionRestore<CR>", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory
|
||||
keymap.set("n", "<leader>ws", "<cmd>SessionSave<CR>", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
log_level = "error",
|
||||
auto_session_suppress_dirs = { "~/", "~/Dev/", "~/Downloads", "~/Documents", "~/Desktop/" },
|
||||
auto_session_enable_last_session = false,
|
||||
auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/",
|
||||
auto_session_enabled = true,
|
||||
auto_save_enabled = true,
|
||||
auto_restore_enabled = false,
|
||||
auto_session_use_git_branch = true,
|
||||
auto_session_create_enabled = true,
|
||||
auto_session_enable_last_session = false,
|
||||
-- Don't auto-restore on startup to allow alpha to show
|
||||
auto_session_restore_on_startup = false,
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("auto-session").setup(opts)
|
||||
|
||||
-- Set recommended sessionoptions
|
||||
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ return {
|
||||
toggle = { enabled = true },
|
||||
words = { enabled = true },
|
||||
})
|
||||
|
||||
-- Set up vim.ui.input and vim.ui.select for snacks
|
||||
vim.ui.input = require("snacks.input").input
|
||||
vim.ui.select = require("snacks.picker").select
|
||||
end,
|
||||
},
|
||||
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||
|
||||
@@ -6,7 +6,6 @@ return {
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
"mfussenegger/nvim-dap-python",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
"nvim-telescope/telescope-dap.nvim",
|
||||
"Weissle/persistent-breakpoints.nvim",
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
@@ -136,12 +135,6 @@ return {
|
||||
end, 200)
|
||||
end, { desc = "🧼 Reset DAP UI Layout" })
|
||||
|
||||
-- 🔭 Telescope Integration
|
||||
require("telescope").load_extension("dap")
|
||||
keymap("n", "<leader>dcf", "<cmd>Telescope dap configurations<cr>", { desc = "🔭 DAP Configs" })
|
||||
keymap("n", "<leader>dcb", "<cmd>Telescope dap list_breakpoints<cr>", { desc = "🧷 List Breakpoints" })
|
||||
keymap("n", "<leader>dco", "<cmd>Telescope dap commands<cr>", { desc = "⚙️ DAP Commands" })
|
||||
|
||||
-- 🧿 Sign Icons
|
||||
for name, icon in pairs({
|
||||
DapBreakpoint = "🔴",
|
||||
|
||||
187
lua/cargdev/plugins/database.lua
Normal file
187
lua/cargdev/plugins/database.lua
Normal file
@@ -0,0 +1,187 @@
|
||||
-- Temporarily disabled to fix database error
|
||||
-- return {
|
||||
-- -- =============================================================================
|
||||
-- -- DATABASE PLUGINS
|
||||
-- -- =============================================================================
|
||||
|
||||
-- -- Database client for Neovim
|
||||
-- {
|
||||
-- "tpope/vim-dadbod",
|
||||
-- dependencies = {
|
||||
-- "kristijanhusak/vim-dadbod-ui",
|
||||
-- "kristijanhusak/vim-dadbod-completion",
|
||||
-- },
|
||||
-- config = function()
|
||||
-- -- Dadbod UI configuration
|
||||
-- vim.g.db_ui_use_nerd_fonts = 1
|
||||
-- vim.g.db_ui_winwidth = 30
|
||||
-- vim.g.db_ui_winposition = "right"
|
||||
-- vim.g.db_ui_show_help = 0
|
||||
-- vim.g.db_ui_auto_execute_table_helpers = 1
|
||||
|
||||
-- -- Disable auto-connection to prevent errors
|
||||
-- vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
-- vim.g.db_ui_show_database_icon = 0
|
||||
-- vim.g.db_ui_winwidth = 30
|
||||
-- vim.g.db_ui_winposition = "right"
|
||||
-- vim.g.db_ui_use_nerd_fonts = 1
|
||||
-- vim.g.db_ui_show_help = 0
|
||||
|
||||
-- -- Disable automatic database loading
|
||||
-- vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
-- vim.g.db_ui_show_database_icon = 0
|
||||
-- vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
-- vim.g.db_ui_show_database_icon = 0
|
||||
|
||||
-- vim.g.db_ui_table_helpers = {
|
||||
-- sqlite = {
|
||||
-- count = "SELECT COUNT(*) FROM {table}",
|
||||
-- explain = "EXPLAIN QUERY PLAN {last_query}",
|
||||
-- indexes = "PRAGMA index_list({table})",
|
||||
-- show = "PRAGMA table_info({table})",
|
||||
-- size = "SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size() WHERE name = '{table}'",
|
||||
-- },
|
||||
-- mysql = {
|
||||
-- count = "SELECT COUNT(*) FROM {table}",
|
||||
-- explain = "EXPLAIN {last_query}",
|
||||
-- indexes = "SHOW INDEX FROM {table}",
|
||||
-- show = "SHOW CREATE TABLE {table}",
|
||||
-- size = "SELECT ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)' FROM information_schema.TABLES WHERE table_schema = '{database}' AND table_name = '{table}'",
|
||||
-- },
|
||||
-- postgresql = {
|
||||
-- count = "SELECT COUNT(*) FROM {table}",
|
||||
-- explain = "EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON) {last_query}",
|
||||
-- indexes = "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = '{table}'",
|
||||
-- show = "\\d {table}",
|
||||
-- size = "SELECT pg_size_pretty(pg_total_relation_size('{table}'))",
|
||||
-- },
|
||||
-- redis = {
|
||||
-- count = "LLEN {table}",
|
||||
-- explain = "SLOWLOG GET 10",
|
||||
-- indexes = "KEYS *",
|
||||
-- show = "TYPE {table}",
|
||||
-- size = "MEMORY USAGE {table}",
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- -- Dadbod completion
|
||||
-- vim.g.vim_dadbod_completion_mark = "📊"
|
||||
|
||||
-- -- Configure database adapters
|
||||
-- vim.g.db_adapter_sqlite = 'sqlite3'
|
||||
-- vim.g.db_adapter_mysql = 'mysql'
|
||||
-- vim.g.db_adapter_postgresql = 'psql'
|
||||
-- vim.g.db_adapter_redis = 'redis-cli'
|
||||
|
||||
-- -- Disable automatic database connections
|
||||
-- vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
-- vim.g.db_ui_show_database_icon = 0
|
||||
-- end,
|
||||
-- },
|
||||
|
||||
-- -- SQL formatting and syntax highlighting
|
||||
-- {
|
||||
-- "b4winckler/vim-objc",
|
||||
-- ft = { "sql", "mysql", "postgresql" },
|
||||
-- },
|
||||
|
||||
-- -- SQL formatting with sqlparse
|
||||
-- {
|
||||
-- "b4winckler/vim-objc",
|
||||
-- ft = { "sql" },
|
||||
-- config = function()
|
||||
-- vim.g.sqlformat_command = "sqlformat"
|
||||
-- vim.g.sqlformat_options = "-r -k upper"
|
||||
-- end,
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- Return empty table to prevent errors
|
||||
return {
|
||||
-- =============================================================================
|
||||
-- DATABASE PLUGINS
|
||||
-- =============================================================================
|
||||
|
||||
-- Database client for Neovim
|
||||
{
|
||||
"tpope/vim-dadbod",
|
||||
dependencies = {
|
||||
"kristijanhusak/vim-dadbod-ui",
|
||||
"kristijanhusak/vim-dadbod-completion",
|
||||
},
|
||||
config = function()
|
||||
-- Disable all automatic database operations
|
||||
vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
vim.g.db_ui_show_database_icon = 0
|
||||
vim.g.db_ui_use_nerd_fonts = 1
|
||||
vim.g.db_ui_winwidth = 30
|
||||
vim.g.db_ui_winposition = "right"
|
||||
vim.g.db_ui_show_help = 0
|
||||
|
||||
-- Disable automatic database loading completely
|
||||
vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
vim.g.db_ui_show_database_icon = 0
|
||||
|
||||
-- Configure table helpers (only used when manually triggered)
|
||||
vim.g.db_ui_table_helpers = {
|
||||
sqlite = {
|
||||
count = "SELECT COUNT(*) FROM {table}",
|
||||
explain = "EXPLAIN QUERY PLAN {last_query}",
|
||||
indexes = "PRAGMA index_list({table})",
|
||||
show = "PRAGMA table_info({table})",
|
||||
size = "SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size() WHERE name = '{table}'",
|
||||
},
|
||||
mysql = {
|
||||
count = "SELECT COUNT(*) FROM {table}",
|
||||
explain = "EXPLAIN {last_query}",
|
||||
indexes = "SHOW INDEX FROM {table}",
|
||||
show = "SHOW CREATE TABLE {table}",
|
||||
size = "SELECT ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)' FROM information_schema.TABLES WHERE table_schema = '{database}' AND table_name = '{table}'",
|
||||
},
|
||||
postgresql = {
|
||||
count = "SELECT COUNT(*) FROM {table}",
|
||||
explain = "EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON) {last_query}",
|
||||
indexes = "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = '{table}'",
|
||||
show = "\\d {table}",
|
||||
size = "SELECT pg_size_pretty(pg_total_relation_size('{table}'))",
|
||||
},
|
||||
redis = {
|
||||
count = "LLEN {table}",
|
||||
explain = "SLOWLOG GET 10",
|
||||
indexes = "KEYS *",
|
||||
show = "TYPE {table}",
|
||||
size = "MEMORY USAGE {table}",
|
||||
},
|
||||
}
|
||||
|
||||
-- Dadbod completion
|
||||
vim.g.vim_dadbod_completion_mark = "📊"
|
||||
|
||||
-- Configure database adapters
|
||||
vim.g.db_adapter_sqlite = 'sqlite3'
|
||||
vim.g.db_adapter_mysql = 'mysql'
|
||||
vim.g.db_adapter_postgresql = 'psql'
|
||||
vim.g.db_adapter_redis = 'redis-cli'
|
||||
|
||||
-- Ensure no automatic connections
|
||||
vim.g.db_ui_auto_execute_table_helpers = 0
|
||||
vim.g.db_ui_show_database_icon = 0
|
||||
end,
|
||||
},
|
||||
|
||||
-- SQL formatting and syntax highlighting
|
||||
{
|
||||
"b4winckler/vim-objc",
|
||||
ft = { "sql", "mysql", "postgresql" },
|
||||
},
|
||||
|
||||
-- SQL formatting with sqlparse
|
||||
{
|
||||
"b4winckler/vim-objc",
|
||||
ft = { "sql" },
|
||||
config = function()
|
||||
vim.g.sqlformat_command = "sqlformat"
|
||||
vim.g.sqlformat_options = "-r -k upper"
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -1,4 +1,23 @@
|
||||
return {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"christoomey/vim-tmux-navigator",
|
||||
}
|
||||
-- Auto-load all plugin files from the plugins directory
|
||||
local function load_all_plugins()
|
||||
local plugins = {}
|
||||
|
||||
-- Add basic plugins
|
||||
table.insert(plugins, "nvim-lua/plenary.nvim")
|
||||
table.insert(plugins, "christoomey/vim-tmux-navigator")
|
||||
|
||||
-- Get all .lua files in the plugins directory (excluding init.lua and lsp directory)
|
||||
local plugin_path = vim.fn.stdpath("config") .. "/lua/cargdev/plugins"
|
||||
local files = vim.fn.globpath(plugin_path, "*.lua", false, true)
|
||||
|
||||
for _, file in ipairs(files) do
|
||||
local filename = vim.fn.fnamemodify(file, ":t:r") -- Get filename without extension
|
||||
if filename ~= "init" then -- Skip init.lua itself
|
||||
table.insert(plugins, { import = "cargdev.plugins." .. filename })
|
||||
end
|
||||
end
|
||||
|
||||
return plugins
|
||||
end
|
||||
|
||||
return load_all_plugins()
|
||||
|
||||
@@ -29,6 +29,9 @@ return {
|
||||
"pyright",
|
||||
"svelte",
|
||||
"tailwindcss",
|
||||
-- Database language servers
|
||||
"sqls", -- SQL language server
|
||||
"mongols", -- MongoDB language server
|
||||
},
|
||||
})
|
||||
|
||||
@@ -71,24 +74,67 @@ return {
|
||||
pyright = {},
|
||||
svelte = {},
|
||||
tailwindcss = {},
|
||||
-- Database servers
|
||||
sqls = {
|
||||
settings = {
|
||||
sqls = {
|
||||
connections = {
|
||||
{
|
||||
name = "PostgreSQL",
|
||||
adapter = "postgresql",
|
||||
host = "localhost",
|
||||
port = 5432,
|
||||
database = "postgres",
|
||||
username = "postgres",
|
||||
password = "",
|
||||
},
|
||||
{
|
||||
name = "MySQL",
|
||||
adapter = "mysql",
|
||||
host = "localhost",
|
||||
port = 3306,
|
||||
database = "mysql",
|
||||
username = "root",
|
||||
password = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
mongols = {
|
||||
settings = {
|
||||
mongols = {
|
||||
connectionString = "mongodb://localhost:27017",
|
||||
maxNumberOfProblems = 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for server, config in pairs(servers) do
|
||||
config.capabilities = capabilities
|
||||
lspconfig[server].setup(config)
|
||||
-- Set up all LSP servers
|
||||
for server_name, server_config in pairs(servers) do
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
settings = server_config.settings or {},
|
||||
})
|
||||
end
|
||||
|
||||
-- ✅ Correct way to setup typescript-tools
|
||||
require("typescript-tools").setup({
|
||||
-- Set up additional LSP servers that might not be in mason-lspconfig
|
||||
lspconfig.css_variables.setup({
|
||||
capabilities = capabilities,
|
||||
-- optional settings:
|
||||
-- settings = {
|
||||
-- tsserver_plugins = {},
|
||||
-- tsserver_max_memory = 4096,
|
||||
-- }
|
||||
})
|
||||
|
||||
-- LSP keymaps are now handled in the main keymaps.lua file
|
||||
-- This ensures consistent keymaps across all file types
|
||||
lspconfig.cssmodules_ls.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- Set up TypeScript Tools
|
||||
require("typescript-tools").setup({
|
||||
settings = {
|
||||
tsserver_plugins = {},
|
||||
tsserver_file_preferences = {},
|
||||
tsserver_format_options = {},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ return {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"folke/todo-comments.nvim",
|
||||
"nvim-telescope/telescope-dap.nvim",
|
||||
"nvim-telescope/telescope-session-lens.nvim",
|
||||
},
|
||||
config = function()
|
||||
local telescope = require("telescope")
|
||||
@@ -51,38 +50,30 @@ return {
|
||||
-- Load extensions
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("dap")
|
||||
telescope.load_extension("session-lens")
|
||||
|
||||
-- set keymaps
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
-- File navigation
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Find string under cursor in cwd" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "Find todos" })
|
||||
|
||||
-- LSP navigation (these work when LSP is attached)
|
||||
keymap.set("n", "<leader>fd", "<cmd>Telescope lsp_definitions<cr>", { desc = "Go to definition" })
|
||||
keymap.set("n", "<leader>fi", "<cmd>Telescope lsp_implementations<cr>", { desc = "Go to implementation" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope lsp_references<cr>", { desc = "Show references" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>Telescope lsp_type_definitions<cr>", { desc = "Go to type definition" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope lsp_document_symbols<cr>", { desc = "Document symbols" })
|
||||
keymap.set("n", "<leader>fw", "<cmd>Telescope lsp_workspace_symbols<cr>", { desc = "Workspace symbols" })
|
||||
keymap.set("n", "<leader>fd", "<cmd>Telescope diagnostics<cr>", { desc = "Show diagnostics" })
|
||||
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Find files" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Live grep" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Grep string" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Recent files" })
|
||||
|
||||
-- Buffer and session management
|
||||
keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>", { desc = "Find buffers" })
|
||||
keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", { desc = "Help tags" })
|
||||
keymap.set("n", "<leader>fm", "<cmd>Telescope marks<cr>", { desc = "Find marks" })
|
||||
keymap.set("n", "<leader>fk", "<cmd>Telescope keymaps<cr>", { desc = "Find keymaps" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope commands<cr>", { desc = "Find commands" })
|
||||
|
||||
keymap.set("n", "<leader>fC", "<cmd>Telescope commands<cr>", { desc = "Find commands" })
|
||||
|
||||
-- Git
|
||||
keymap.set("n", "<leader>fg", "<cmd>Telescope git_commits<cr>", { desc = "Git commits" })
|
||||
keymap.set("n", "<leader>fG", "<cmd>Telescope git_bcommits<cr>", { desc = "Git buffer commits" })
|
||||
keymap.set("n", "<leader>fb", "<cmd>Telescope git_branches<cr>", { desc = "Git branches" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope git_status<cr>", { desc = "Git status" })
|
||||
keymap.set("n", "<leader>gs", "<cmd>Telescope git_status<cr>", { desc = "Git status" })
|
||||
|
||||
-- Todos
|
||||
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "Find todos" })
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user