fix: Completely eliminate 'Press ENTER' prompts and resolve lazyredraw conflicts
- Fix lazyredraw conflict with Noice plugin that was causing warnings - Completely eliminate 'Press ENTER or type command to continue' prompts - Implement aggressive startup message suppression - Add comprehensive message filtering for all startup prompts - Create multiple layers of prompt elimination (autocmds, overrides, deferred clearing) - Add manual keymaps for clearing any remaining prompts - Enhance notification manager with aggressive startup message handling - Implement message blocking for problematic startup messages - Add multiple redraw and echo clearing operations during startup - Create comprehensive startup prompt elimination system New keymaps: - <leader>ns - Clear startup prompts manually - <leader>nr - Redraw screen to clear any visual artifacts Technical improvements: - Disable lazyredraw to prevent Noice conflicts - Override echo function to block problematic messages - Multiple autocmd layers for prompt elimination - Deferred message clearing for persistent prompts - Comprehensive shortmess configuration - Command line height optimization Expected results: - No more 'Press ENTER' prompts at startup - No more lazyredraw warnings - Clean, smooth startup experience - Immediate access to dashboard without prompts - Professional startup appearance
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -29,4 +29,8 @@ keymap.set("n", "<leader>pr", "<cmd>lua require('cargdev.core.function.performan
|
||||
|
||||
-- Notification management keymaps
|
||||
keymap.set("n", "<leader>nc", "<cmd>lua require('cargdev.core.function.notification_manager').clear_all_notifications()<CR>", { desc = "Clear all notifications" })
|
||||
keymap.set("n", "<leader>nn", "<cmd>lua require('cargdev.core.function.notification_manager').show_notification('Test notification', vim.log.levels.INFO)<CR>", { desc = "Test notification" })
|
||||
keymap.set("n", "<leader>nn", "<cmd>lua require('cargdev.core.function.notification_manager').show_notification('Test notification', vim.log.levels.INFO)<CR>", { desc = "Test notification" })
|
||||
|
||||
-- Startup prompt management keymaps
|
||||
keymap.set("n", "<leader>ns", "<cmd>redraw!<CR><cmd>echo ''<CR>", { desc = "Clear startup prompts" })
|
||||
keymap.set("n", "<leader>nr", "<cmd>redraw!<CR>", { desc = "Redraw screen" })
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user