diff --git a/lua/cargdev/core/function/notification_manager.lua b/lua/cargdev/core/function/notification_manager.lua index 9a2c165..fe422f2 100644 --- a/lua/cargdev/core/function/notification_manager.lua +++ b/lua/cargdev/core/function/notification_manager.lua @@ -181,21 +181,97 @@ function M.show_startup_notification(message, level) }) end --- Function to handle startup messages +-- Function to handle startup messages aggressively function M.handle_startup_messages() - -- Clear any existing messages + -- Clear any existing messages immediately vim.cmd("redraw!") + vim.cmd("echo ''") - -- Suppress startup messages + -- Suppress all startup messages vim.opt.shortmess = vim.opt.shortmess + "I" -- No intro message vim.opt.shortmess = vim.opt.shortmess + "c" -- No completion messages vim.opt.shortmess = vim.opt.shortmess + "F" -- No file info message vim.opt.shortmess = vim.opt.shortmess + "W" -- No "written" message vim.opt.shortmess = vim.opt.shortmess + "A" -- No attention message vim.opt.shortmess = vim.opt.shortmess + "o" -- No overwrite messages + vim.opt.shortmess = vim.opt.shortmess + "t" -- No truncation messages + vim.opt.shortmess = vim.opt.shortmess + "T" -- No truncation messages + vim.opt.shortmess = vim.opt.shortmess + "f" -- No file info messages + vim.opt.shortmess = vim.opt.shortmess + "i" -- No intro messages + vim.opt.shortmess = vim.opt.shortmess + "l" -- No line number messages + vim.opt.shortmess = vim.opt.shortmess + "m" -- No modification messages + vim.opt.shortmess = vim.opt.shortmess + "n" -- No line number messages + vim.opt.shortmess = vim.opt.shortmess + "r" -- No read messages + vim.opt.shortmess = vim.opt.shortmess + "s" -- No search messages + vim.opt.shortmess = vim.opt.shortmess + "x" -- No truncation messages + vim.opt.shortmess = vim.opt.shortmess + "O" -- No overwrite messages + + -- Disable command line messages + vim.opt.cmdheight = 0 + vim.opt.showmode = false -- Clear any existing messages vim.cmd("echo ''") + + -- Force clear any pending messages + vim.defer_fn(function() + vim.cmd("redraw!") + vim.cmd("echo ''") + end, 100) +end + +-- Function to eliminate "Press ENTER" prompts completely +function M.eliminate_enter_prompts() + -- Override the message display to prevent "Press ENTER" prompts + local original_echo = vim.cmd.echo + vim.cmd.echo = function(msg) + local msg_str = tostring(msg) + -- Block any messages that might cause "Press ENTER" prompts + if msg_str:match("Press ENTER") or + msg_str:match("lazyredraw") or + msg_str:match("You have enabled") or + msg_str:match("This is only meant") or + msg_str:match("You'll experience issues") then + return -- Don't show these messages + end + -- Allow other messages + original_echo(msg) + end + + -- Create autocmd to handle any remaining prompts + vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + -- Clear any startup messages immediately + vim.cmd("redraw!") + vim.cmd("echo ''") + + -- Force clear any pending messages multiple times + for i = 1, 5 do + vim.defer_fn(function() + vim.cmd("redraw!") + vim.cmd("echo ''") + end, i * 50) + end + end, + once = true, + }) + + -- Create autocmd to handle message events + vim.api.nvim_create_autocmd("MsgShow", { + 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 @@ -216,6 +292,9 @@ function M.setup() end, }) + -- 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) diff --git a/lua/cargdev/core/keymaps/general.lua b/lua/cargdev/core/keymaps/general.lua index df1894f..9614767 100644 --- a/lua/cargdev/core/keymaps/general.lua +++ b/lua/cargdev/core/keymaps/general.lua @@ -29,4 +29,8 @@ keymap.set("n", "pr", "lua require('cargdev.core.function.performan -- Notification management keymaps keymap.set("n", "nc", "lua require('cargdev.core.function.notification_manager').clear_all_notifications()", { desc = "Clear all notifications" }) -keymap.set("n", "nn", "lua require('cargdev.core.function.notification_manager').show_notification('Test notification', vim.log.levels.INFO)", { desc = "Test notification" }) \ No newline at end of file +keymap.set("n", "nn", "lua require('cargdev.core.function.notification_manager').show_notification('Test notification', vim.log.levels.INFO)", { desc = "Test notification" }) + +-- Startup prompt management keymaps +keymap.set("n", "ns", "redraw!echo ''", { desc = "Clear startup prompts" }) +keymap.set("n", "nr", "redraw!", { desc = "Redraw screen" }) \ No newline at end of file diff --git a/lua/cargdev/core/startup_optimization.lua b/lua/cargdev/core/startup_optimization.lua index ebcfc35..25252e6 100644 --- a/lua/cargdev/core/startup_optimization.lua +++ b/lua/cargdev/core/startup_optimization.lua @@ -42,8 +42,8 @@ function M.optimize_startup() vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 - -- Reduce redraw frequency during startup - vim.opt.lazyredraw = true + -- Fix lazyredraw conflict with Noice + vim.opt.lazyredraw = false -- Disable to prevent Noice conflicts -- Optimize completion settings vim.opt.completeopt = "menuone,noselect" @@ -61,15 +61,30 @@ function M.optimize_startup() vim.opt.foldmethod = "manual" vim.opt.foldlevel = 99 - -- Prevent "Press ENTER" prompts + -- Completely eliminate "Press ENTER" prompts vim.opt.shortmess = vim.opt.shortmess + "I" -- No intro message vim.opt.shortmess = vim.opt.shortmess + "c" -- No completion messages vim.opt.shortmess = vim.opt.shortmess + "F" -- No file info message vim.opt.shortmess = vim.opt.shortmess + "W" -- No "written" message vim.opt.shortmess = vim.opt.shortmess + "A" -- No attention message - - -- Disable swap file messages vim.opt.shortmess = vim.opt.shortmess + "o" -- No overwrite messages + vim.opt.shortmess = vim.opt.shortmess + "t" -- No truncation messages + vim.opt.shortmess = vim.opt.shortmess + "T" -- No truncation messages + vim.opt.shortmess = vim.opt.shortmess + "f" -- No file info messages + vim.opt.shortmess = vim.opt.shortmess + "i" -- No intro messages + vim.opt.shortmess = vim.opt.shortmess + "l" -- No line number messages + vim.opt.shortmess = vim.opt.shortmess + "m" -- No modification messages + vim.opt.shortmess = vim.opt.shortmess + "n" -- No line number messages + vim.opt.shortmess = vim.opt.shortmess + "r" -- No read messages + vim.opt.shortmess = vim.opt.shortmess + "s" -- No search messages + vim.opt.shortmess = vim.opt.shortmess + "x" -- No truncation messages + + -- Disable swap file messages completely + vim.opt.shortmess = vim.opt.shortmess + "O" -- No overwrite messages + + -- Disable all startup messages + vim.opt.cmdheight = 0 -- Reduce command line height + vim.opt.showmode = false -- Don't show mode in command line -- Record end time and calculate duration local end_time = vim.loop.hrtime() @@ -132,9 +147,46 @@ function M.check_repo_size() end end +-- Function to completely eliminate startup prompts +function M.eliminate_startup_prompts() + -- Create autocmd to handle any remaining startup messages + vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + -- Clear any startup messages immediately + vim.cmd("redraw!") + vim.cmd("echo ''") + + -- Force clear any pending messages + vim.defer_fn(function() + vim.cmd("redraw!") + vim.cmd("echo ''") + end, 50) + end, + once = true, + }) + + -- Create autocmd to handle any message events + vim.api.nvim_create_autocmd("MsgShow", { + callback = function() + -- Clear messages that might cause prompts + vim.cmd("redraw!") + end, + }) + + -- Override the message display to prevent prompts + local original_echo = vim.cmd.echo + vim.cmd.echo = function(msg) + -- Only echo if it's not a startup message + if not tostring(msg):match("Press ENTER") and not tostring(msg):match("lazyredraw") then + original_echo(msg) + end + end +end + -- Initialize startup optimizations M.optimize_startup() M.defer_heavy_operations() M.check_repo_size() +M.eliminate_startup_prompts() return M