From fb05a8e3e6df63227b30a86fc95579814a53a4de Mon Sep 17 00:00:00 2001 From: glaulher Date: Tue, 15 Jul 2025 10:39:58 -0300 Subject: [PATCH] feat(diagnostics): emulate VSCode Error Lens with virtual text and lines Added functionality to mimic VSCode's Error Lens behavior: - Displays diagnostics as virtual text with severity icons during insert mode. - Switches to virtual lines with formatted messages in normal mode for better readability. - Replaced `InsertLeave` with `ModeChanged` (`i:*`) to ensure diagnostics update correctly even when exiting insert> This refactor improves code readability, follows single-responsibility principles, and makes it easier to maintain > Improves real-time feedback while coding and enhances the visual presentation of diagnostics. --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 06b23a2b..a6aa858e 100644 --- a/init.lua +++ b/init.lua @@ -672,7 +672,8 @@ require('lazy').setup({ end, }) - vim.api.nvim_create_autocmd('InsertLeave', { + vim.api.nvim_create_autocmd('ModeChanged', { + pattern = 'i:*', callback = function() set_virtual_text(false) end,