From 65ffd3275bb43298fb2d855597a99a1125977c41 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Date: Tue, 12 Aug 2025 03:04:10 -0400 Subject: [PATCH] adding new theme --- .../core/function/notification_manager.lua | 39 ++++----- lua/cargdev/core/init.lua | 32 ++++++-- lua/cargdev/core/keymaps/general.lua | 7 ++ lua/cargdev/core/startup_optimization.lua | 79 ++++++++++++------- lua/cargdev/plugins/alpha.lua | 4 + lua/cargdev/plugins/colorscheme.lua | 4 +- lua/cargdev/plugins/comments.lua | 28 ++++++- .../plugins/essential_enhancements.lua | 12 --- lua/cargdev/plugins/indent-blankline.lua | 11 ++- lua/cargdev/plugins/nvim-cmp.lua | 1 + 10 files changed, 144 insertions(+), 73 deletions(-) diff --git a/lua/cargdev/core/function/notification_manager.lua b/lua/cargdev/core/function/notification_manager.lua index fe422f2..fbb477a 100644 --- a/lua/cargdev/core/function/notification_manager.lua +++ b/lua/cargdev/core/function/notification_manager.lua @@ -94,8 +94,23 @@ function M.show_notification(message, level, opts) local notification_id = notify(message, level, opts) return notification_id else - -- Fallback to vim.notify - vim.notify(message, level, opts) + -- Fallback to echo instead of vim.notify to avoid circular dependency + local icon = "đŸ’Ŧ" + if level == vim.log.levels.ERROR then + icon = "❌" + elseif level == vim.log.levels.WARN then + icon = "âš ī¸" + elseif level == vim.log.levels.INFO then + icon = "â„šī¸" + end + + -- Use echo for fallback notifications + vim.cmd("echo '" .. icon .. " " .. message .. "'") + + -- Clear message after a delay + vim.defer_fn(function() + vim.cmd("echo ''") + end, opts.timeout or 3000) end end @@ -256,22 +271,13 @@ function M.eliminate_enter_prompts() once = true, }) - -- Create autocmd to handle message events - vim.api.nvim_create_autocmd("MsgShow", { + -- Create autocmd to handle message events - use valid events + vim.api.nvim_create_autocmd("BufReadPost", { callback = function() -- Clear messages that might cause prompts vim.cmd("redraw!") end, }) - - -- Create autocmd to handle any prompt events - vim.api.nvim_create_autocmd("PromptDone", { - callback = function() - -- Clear any remaining prompts - vim.cmd("redraw!") - vim.cmd("echo ''") - end, - }) end -- Function to setup notification system @@ -295,11 +301,8 @@ function M.setup() -- Eliminate "Press ENTER" prompts M.eliminate_enter_prompts() - -- Override vim.notify to use our custom system - local original_notify = vim.notify - vim.notify = function(msg, level, opts) - M.show_notification(msg, level, opts) - end + -- Don't override vim.notify here to avoid circular dependency + -- Let the system handle notifications naturally print("Notification manager initialized") end diff --git a/lua/cargdev/core/init.lua b/lua/cargdev/core/init.lua index c4f59b9..93796cb 100644 --- a/lua/cargdev/core/init.lua +++ b/lua/cargdev/core/init.lua @@ -4,27 +4,44 @@ require("cargdev.core.compatibility").setup() -- Load startup optimizations early require("cargdev.core.startup_optimization") --- Load notification manager for better UX -require("cargdev.core.function.notification_manager") - require("cargdev.core.options") require("cargdev.core.keymaps") --- Load all Lua files inside `cargdev/core/function/` +-- Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded local function load_functions() local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function" local scan = vim.fn.globpath(function_path, "*.lua", false, true) for _, file in ipairs(scan) do local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$") - local success, err = pcall(require, module_name) + -- Skip notification manager as it's loaded separately + if module_name ~= "cargdev.core.function.notification_manager" then + local success, err = pcall(require, module_name) - if not success then - vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR) + if not success then + vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR) + end end end end +-- Defer function loading until after plugins are loaded +vim.api.nvim_create_autocmd("User", { + pattern = "LazyDone", + callback = function() + -- Load notification manager after plugins with error handling + local success, err = pcall(require, "cargdev.core.function.notification_manager") + if not success then + -- Use safe echo instead of vim.notify to avoid circular dependency + local safe_msg = tostring(err):gsub("'", "\\'") + vim.api.nvim_echo({{"Warning: Notification manager failed to load: " .. safe_msg, "WarningMsg"}}, false, {}) + end + + -- Load all other functions + load_functions() + end, + once = true, +}) --[[ vim.api.nvim_create_autocmd("BufReadPost", { once = true, @@ -33,4 +50,3 @@ end end }) ]] -load_functions() diff --git a/lua/cargdev/core/keymaps/general.lua b/lua/cargdev/core/keymaps/general.lua index 9614767..fdea2ab 100644 --- a/lua/cargdev/core/keymaps/general.lua +++ b/lua/cargdev/core/keymaps/general.lua @@ -15,6 +15,13 @@ keymap.set("i", "jk", "", opts) -- Exit insert mode with jk keymap.set("n", "nh", ":nohl", opts) -- Clear search highlights keymap.set("n", "x", '"_x', opts) -- Delete character without copying into register +-- Comment keymaps +keymap.set("n", "gcc", "CommentToggle", { desc = "Toggle comment line" }) +keymap.set("n", "gc", "CommentToggle", { desc = "Toggle comment line" }) +keymap.set("v", "gc", "CommentToggle", { desc = "Toggle comment selection" }) +keymap.set("n", "gbc", "CommentToggle", { desc = "Toggle comment block" }) +keymap.set("v", "gb", "CommentToggle", { desc = "Toggle comment block" }) + -- Save and quit (additional) keymap.set("n", "Q", ":qa!", { desc = "Quit all" }) diff --git a/lua/cargdev/core/startup_optimization.lua b/lua/cargdev/core/startup_optimization.lua index 25252e6..ae57bfe 100644 --- a/lua/cargdev/core/startup_optimization.lua +++ b/lua/cargdev/core/startup_optimization.lua @@ -8,7 +8,6 @@ function M.optimize_startup() -- Disable unused providers vim.g.loaded_python3_provider = 0 - vim.g.loaded_node_provider = 0 vim.g.loaded_ruby_provider = 0 vim.g.loaded_perl_provider = 0 @@ -42,8 +41,14 @@ function M.optimize_startup() vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 - -- Fix lazyredraw conflict with Noice - vim.opt.lazyredraw = false -- Disable to prevent Noice conflicts + -- Fix lazyredraw conflict with Noice - but only after LazyVim loads + vim.api.nvim_create_autocmd("User", { + pattern = "LazyDone", + callback = function() + vim.opt.lazyredraw = false -- Disable to prevent Noice conflicts + end, + once = true, + }) -- Optimize completion settings vim.opt.completeopt = "menuone,noselect" @@ -99,32 +104,50 @@ end -- Function to defer heavy operations function M.defer_heavy_operations() -- Defer treesitter loading - vim.defer_fn(function() - if vim.fn.exists(":TSBufEnable") > 0 then - vim.cmd("TSBufEnable highlight") - end - end, 100) + vim.api.nvim_create_autocmd("User", { + pattern = "LazyDone", + callback = function() + vim.defer_fn(function() + if vim.fn.exists(":TSBufEnable") > 0 then + vim.cmd("TSBufEnable highlight") + end + end, 100) + end, + once = true, + }) -- Defer LSP setup for non-critical buffers - vim.defer_fn(function() - -- Enable LSP for current buffer if it's a supported filetype - local supported_ft = { - "lua", "javascript", "typescript", "python", "java", "cpp", "c", "rust", "go", - "html", "css", "json", "yaml", "markdown" - } - - local current_ft = vim.bo.filetype - if vim.tbl_contains(supported_ft, current_ft) then - vim.cmd("LspStart") - end - end, 200) + vim.api.nvim_create_autocmd("User", { + pattern = "LazyDone", + callback = function() + vim.defer_fn(function() + -- Enable LSP for current buffer if it's a supported filetype + local supported_ft = { + "lua", "javascript", "typescript", "python", "java", "cpp", "c", "rust", "go", + "html", "css", "json", "yaml", "markdown" + } + + local current_ft = vim.bo.filetype + if vim.tbl_contains(supported_ft, current_ft) then + vim.cmd("LspStart") + end + end, 200) + end, + once = true, + }) -- Defer completion setup - vim.defer_fn(function() - if vim.fn.exists(":CmpStatus") > 0 then - vim.cmd("CmpStatus") - end - end, 300) + vim.api.nvim_create_autocmd("User", { + pattern = "LazyDone", + callback = function() + vim.defer_fn(function() + if vim.fn.exists(":CmpStatus") > 0 then + vim.cmd("CmpStatus") + end + end, 300) + end, + once = true, + }) end -- Function to check if we're in a large repository @@ -142,7 +165,7 @@ function M.check_repo_size() vim.opt.cursorline = false -- Disable cursor line vim.opt.relativenumber = false -- Disable relative numbers - print("Large repository detected (" .. file_count .. " files). Applied additional optimizations.") + print("Large repository detected (" .. file_count .. " lines). Applied additional optimizations.") end end end @@ -165,8 +188,8 @@ function M.eliminate_startup_prompts() once = true, }) - -- Create autocmd to handle any message events - vim.api.nvim_create_autocmd("MsgShow", { + -- Create autocmd to handle any message events - use valid events + vim.api.nvim_create_autocmd("BufReadPost", { callback = function() -- Clear messages that might cause prompts vim.cmd("redraw!") diff --git a/lua/cargdev/plugins/alpha.lua b/lua/cargdev/plugins/alpha.lua index e43a816..f038634 100644 --- a/lua/cargdev/plugins/alpha.lua +++ b/lua/cargdev/plugins/alpha.lua @@ -33,10 +33,14 @@ return { dashboard.button("n", "📄 New File", "ene"), dashboard.button("g", "📝 Find Text", "Telescope live_grep"), dashboard.button("r", "📚 Recent Files", "Telescope oldfiles"), + dashboard.button("t", "đŸŒŗ File Tree", "NvimTreeToggle"), dashboard.button("c", "âš™ī¸ Config", "e ~/.config/nvim/init.lua"), dashboard.button("L", "đŸĻĨ Lazy", "Lazy"), dashboard.button("p", "📊 Performance", "lua require('cargdev.core.function.performance_monitor').check_performance()"), dashboard.button("l", "🔧 LSP Health", "lua require('cargdev.core.function.performance_monitor').check_lsp_health()"), + dashboard.button("s", "🧩 Sudoku", "Sudoku"), + dashboard.button("e", "đŸ’ģ LeetCode", "Leet"), + dashboard.button("m", "🔨 Mason", "Mason"), dashboard.button("q", "đŸšĒ Quit", "qa"), } diff --git a/lua/cargdev/plugins/colorscheme.lua b/lua/cargdev/plugins/colorscheme.lua index 695b135..c7e8a71 100644 --- a/lua/cargdev/plugins/colorscheme.lua +++ b/lua/cargdev/plugins/colorscheme.lua @@ -1,9 +1,9 @@ return { "CarGDev/cargdev-cyberpunk", --[[ dir = "/Users/carlos/Documents/SSD_Documents/projects/cargdevschemecolor.nvim", ]] - event = "VimEnter", -- Load only when entering Vim - priority = 1000, config = function() require("cargdev-cyberpunk").setup() end, + priority = 1000, + lazy = false, } diff --git a/lua/cargdev/plugins/comments.lua b/lua/cargdev/plugins/comments.lua index ecc93c4..3771105 100644 --- a/lua/cargdev/plugins/comments.lua +++ b/lua/cargdev/plugins/comments.lua @@ -8,12 +8,32 @@ return { -- import comment plugin safely local comment = require("Comment") - local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim") - - -- enable comment + -- Check if treesitter context commentstring is available + local ok, ts_context_commentstring = pcall(require, "ts_context_commentstring.integrations.comment_nvim") + + -- enable comment with safe configuration comment.setup({ -- for commenting tsx, jsx, svelte, html files - pre_hook = ts_context_commentstring.create_pre_hook(), + pre_hook = ok and ts_context_commentstring.create_pre_hook() or nil, + -- Add explicit commentstring fallbacks + opleader = { + line = "gc", + block = "gb", + }, + toggler = { + line = "gcc", + block = "gbc", + }, + extra = { + above = "gcO", + below = "gco", + eol = "gcA", + }, + mappings = { + basic = true, + extra = true, + extended = false, + }, }) end, } diff --git a/lua/cargdev/plugins/essential_enhancements.lua b/lua/cargdev/plugins/essential_enhancements.lua index 48fdb59..a11df04 100644 --- a/lua/cargdev/plugins/essential_enhancements.lua +++ b/lua/cargdev/plugins/essential_enhancements.lua @@ -288,18 +288,6 @@ return { }, }, - -- Better indentation guides - { - "lukas-reineke/indent-blankline.nvim", - event = "VeryLazy", - opts = { - char = "│", - filetype_exclude = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }, - show_trailing_blankline_indent = false, - show_current_context = false, - }, - }, - -- Better git integration { "lewis6991/gitsigns.nvim", diff --git a/lua/cargdev/plugins/indent-blankline.lua b/lua/cargdev/plugins/indent-blankline.lua index 572e0bd..ff421f5 100644 --- a/lua/cargdev/plugins/indent-blankline.lua +++ b/lua/cargdev/plugins/indent-blankline.lua @@ -3,6 +3,15 @@ return { event = { "BufReadPre", "BufNewFile" }, main = "ibl", opts = { - indent = { char = "┊" }, + indent = { + char = "┊", + exclude_filetypes = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" } + }, + scope = { + enabled = false + }, + exclude = { + filetypes = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" } + } }, } diff --git a/lua/cargdev/plugins/nvim-cmp.lua b/lua/cargdev/plugins/nvim-cmp.lua index c362725..423a9a3 100644 --- a/lua/cargdev/plugins/nvim-cmp.lua +++ b/lua/cargdev/plugins/nvim-cmp.lua @@ -4,6 +4,7 @@ return { dependencies = { "hrsh7th/cmp-buffer", -- source for text in buffer "hrsh7th/cmp-path", -- source for file system paths + "hrsh7th/cmp-nvim-lsp", -- LSP completion source { "L3MON4D3/LuaSnip", -- follow latest release.