Skip to content

Commit 97cf58c

Browse files
feat: inline errors, other niceties
1 parent 30cf206 commit 97cf58c

File tree

4 files changed

+356
-35
lines changed

4 files changed

+356
-35
lines changed

init.lua

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,11 @@ require('lazy').setup({
432432
-- Document existing key chains
433433
spec = {
434434
{ '<leader>Q', group = '[Q]uit' }, -- Added Q first so it appears at top
435+
{ '<leader>c', group = '[c]ode' }, -- Code actions, LSP commands
435436
{ '<leader>s', group = '[s]earch' }, -- Search commands
436437
{ '<leader>S', group = '[S]ession' }, -- Session management (capital S)
437438
{ '<leader>t', group = '[T]oggle' },
439+
{ '<leader>x', group = 'diagnostics/quickfi[x]' }, -- Trouble/diagnostics (Telescope has <leader>sd)
438440
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
439441
},
440442
},
@@ -613,6 +615,26 @@ require('lazy').setup({
613615
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
614616
-- and elegantly composed help section, `:help lsp-vs-treesitter`
615617

618+
-- ========================================================================
619+
-- LSP UI Enhancements - Better hover, signature help, and borders
620+
-- ========================================================================
621+
-- Customize LSP handlers for better visual appearance (LazyVim-style)
622+
623+
-- Rounded borders for hover windows
624+
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
625+
border = 'rounded',
626+
max_width = 80,
627+
})
628+
629+
-- Rounded borders for signature help
630+
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, {
631+
border = 'rounded',
632+
max_width = 80,
633+
})
634+
635+
-- NOTE: Diagnostic config is set later in the file (around line 760)
636+
-- with comprehensive settings including virtual_text, signs, etc.
637+
616638
-- This function gets run when an LSP attaches to a particular buffer.
617639
-- That is to say, every time a new file is opened that is associated with
618640
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
@@ -726,33 +748,50 @@ require('lazy').setup({
726748
end,
727749
})
728750

729-
-- Diagnostic Config
751+
-- Diagnostic Config - Enhanced for better visibility (LazyVim-style)
730752
-- See :help vim.diagnostic.Opts
731753
vim.diagnostic.config {
754+
-- Sort diagnostics by severity (errors first)
732755
severity_sort = true,
733-
float = { border = 'rounded', source = 'if_many' },
734-
underline = { severity = vim.diagnostic.severity.ERROR },
735-
signs = vim.g.have_nerd_font and {
756+
757+
-- Underline errors and warnings
758+
underline = {
759+
severity = { min = vim.diagnostic.severity.WARN },
760+
},
761+
762+
-- Show signs in the gutter
763+
signs = {
736764
text = {
737-
[vim.diagnostic.severity.ERROR] = '󰅚 ',
738-
[vim.diagnostic.severity.WARN] = '󰀪 ',
739-
[vim.diagnostic.severity.INFO] = '󰋽 ',
740-
[vim.diagnostic.severity.HINT] = '󰌶 ',
765+
[vim.diagnostic.severity.ERROR] = '󰅚',
766+
[vim.diagnostic.severity.WARN] = '󰀪',
767+
[vim.diagnostic.severity.INFO] = '󰋽',
768+
[vim.diagnostic.severity.HINT] = '󰌶',
741769
},
742-
} or {},
770+
},
771+
772+
-- Virtual text configuration (inline error messages at end of line)
773+
-- This shows the actual diagnostic message text to the right of each line
743774
virtual_text = {
744-
source = 'if_many',
745-
spacing = 2,
775+
spacing = 4,
776+
source = 'if_many', -- Show source if multiple sources
777+
prefix = '', -- Prefix before the message
746778
format = function(diagnostic)
747-
local diagnostic_message = {
748-
[vim.diagnostic.severity.ERROR] = diagnostic.message,
749-
[vim.diagnostic.severity.WARN] = diagnostic.message,
750-
[vim.diagnostic.severity.INFO] = diagnostic.message,
751-
[vim.diagnostic.severity.HINT] = diagnostic.message,
752-
}
753-
return diagnostic_message[diagnostic.severity]
779+
-- Show the full diagnostic message inline
780+
return diagnostic.message
754781
end,
755782
},
783+
784+
-- Floating window configuration (when hovering over error)
785+
float = {
786+
border = 'rounded',
787+
source = 'always', -- Always show source
788+
header = '',
789+
prefix = '',
790+
focusable = true,
791+
},
792+
793+
-- Update diagnostics in insert mode
794+
update_in_insert = false,
756795
}
757796

758797
-- LSP servers and clients are able to communicate to each other what features they support.
@@ -1230,5 +1269,24 @@ vim.api.nvim_create_user_command('PythonRestart', function()
12301269
vim.notify('Pyright stopped. It will restart on next edit.', vim.log.levels.INFO)
12311270
end, { desc = 'Restart Python LSP (pyright)' })
12321271

1272+
-- Ensure virtual text diagnostics are enabled after all plugins load
1273+
-- This needs to be set after plugins that might override diagnostic config
1274+
vim.api.nvim_create_autocmd('User', {
1275+
pattern = 'VeryLazy',
1276+
once = true,
1277+
callback = function()
1278+
vim.diagnostic.config({
1279+
virtual_text = {
1280+
spacing = 4,
1281+
source = 'if_many',
1282+
prefix = '',
1283+
format = function(diagnostic)
1284+
return diagnostic.message
1285+
end,
1286+
},
1287+
})
1288+
end,
1289+
})
1290+
12331291
-- The line beneath this is called `modeline`. See `:help modeline`
12341292
-- vim: ts=2 sts=2 sw=2 et

lazy-lock.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"mini.animate": { "branch": "main", "commit": "8ce6df739aa9d14c876bace722af28c3d09e9971" },
1919
"mini.nvim": { "branch": "main", "commit": "ee4a4a4abed25e3d108d985b0553c5271f2f71aa" },
2020
"neo-tree.nvim": { "branch": "main", "commit": "8cdd6b1940f333c1dd085526a9c45b30fb2dbf50" },
21+
"noice.nvim": { "branch": "main", "commit": "5099348591f7d3ba9e547b1e631c694c65bbe0b9" },
2122
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
2223
"nvim-dap": { "branch": "master", "commit": "6782b097af2417a4c3e33849b0a26ae2188bd7ea" },
2324
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
@@ -30,5 +31,6 @@
3031
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
3132
"todo-comments.nvim": { "branch": "main", "commit": "411503d3bedeff88484de572f2509c248e499b38" },
3233
"tokyonight.nvim": { "branch": "main", "commit": "2642dbb83333e0575d1c3436e1d837926871c5fb" },
34+
"trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" },
3335
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
3436
}

lua/custom/plugins/flutter.lua

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,20 @@ return {
101101
})
102102

103103
-- Filter out didChange error notifications (they're harmless during snippet expansion)
104-
local notify = vim.notify
105-
vim.notify = function(msg, level, opts)
106-
if type(msg) == 'string' and msg:match('textDocument/didChange') then
107-
return -- Suppress this specific error
108-
end
109-
notify(msg, level, opts)
110-
end
104+
-- We'll use an autocmd to do this after noice.nvim is loaded
105+
vim.api.nvim_create_autocmd('User', {
106+
pattern = 'VeryLazy',
107+
once = true,
108+
callback = function()
109+
local notify = vim.notify
110+
vim.notify = function(msg, level, opts)
111+
if type(msg) == 'string' and msg:match('textDocument/didChange') then
112+
return -- Suppress this specific error
113+
end
114+
notify(msg, level, opts)
115+
end
116+
end,
117+
})
111118
end,
112119

113120
-- Color preview for dart variables (Colors.red, Color(0xFF...), etc.)
@@ -190,7 +197,7 @@ return {
190197
-- ========================================================================
191198
local dap, dapui = require 'dap', require 'dapui'
192199

193-
-- Configure DAP UI
200+
-- Configure DAP UI to open in tabs for better half-width screen support
194201
dapui.setup {
195202
icons = { expanded = '', collapsed = '', current_frame = '*' },
196203
controls = {
@@ -206,7 +213,8 @@ return {
206213
disconnect = '',
207214
},
208215
},
209-
-- Fix layout to prevent resizing issues with Neo-tree
216+
-- Open each element in a new tab instead of side panels
217+
-- This prevents layout issues on small/half-width screens
210218
layouts = {
211219
{
212220
elements = {
@@ -215,25 +223,66 @@ return {
215223
{ id = 'stacks', size = 0.25 },
216224
{ id = 'watches', size = 0.25 },
217225
},
218-
size = 40, -- Fixed width instead of percentage
219-
position = 'right', -- Changed to right to avoid conflict with Neo-tree on left
226+
size = 40,
227+
position = 'right',
220228
},
221229
{
222230
elements = {
223231
{ id = 'repl', size = 0.5 },
224232
{ id = 'console', size = 0.5 },
225233
},
226-
size = 10, -- Fixed height
234+
size = 10,
227235
position = 'bottom',
228236
},
229237
},
238+
-- Override element window commands to open in tabs
239+
element_mappings = {},
240+
windows = { indent = 1 },
230241
}
231242

232-
-- Automatically open/close DAP UI
233-
-- Don't close Neo-tree, they can coexist now (DAP on right, Neo-tree on left)
234-
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
235-
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
236-
dap.listeners.before.event_exited['dapui_config'] = dapui.close
243+
-- Custom function to open DAP UI elements in tabs
244+
local function open_dapui_in_tabs()
245+
-- Save current tab to return to it
246+
local current_tab = vim.fn.tabpagenr()
247+
248+
-- Create new tab with a named buffer for debug views
249+
vim.cmd 'tabnew'
250+
local debug_buf = vim.api.nvim_create_buf(false, true)
251+
vim.api.nvim_buf_set_name(debug_buf, 'Flutter Debug')
252+
vim.api.nvim_set_current_buf(debug_buf)
253+
254+
-- Open DAP UI in this tab
255+
dapui.open()
256+
257+
-- Return to original tab so user continues coding there
258+
vim.cmd('tabnext ' .. current_tab)
259+
end
260+
261+
-- Custom function to close DAP UI tabs
262+
local function close_dapui_tabs()
263+
dapui.close()
264+
265+
-- Find and close the Flutter Debug tab
266+
local current_tab = vim.fn.tabpagenr()
267+
for i = 1, vim.fn.tabpagenr '$' do
268+
vim.cmd('tabnext ' .. i)
269+
local bufname = vim.api.nvim_buf_get_name(0)
270+
if bufname:match('Flutter Debug') then
271+
vim.cmd 'tabclose'
272+
break
273+
end
274+
end
275+
276+
-- Return to original tab
277+
if vim.fn.tabpagenr '$' >= current_tab then
278+
vim.cmd('tabnext ' .. current_tab)
279+
end
280+
end
281+
282+
-- Automatically open/close DAP UI in tabs
283+
dap.listeners.after.event_initialized['dapui_config'] = open_dapui_in_tabs
284+
dap.listeners.before.event_terminated['dapui_config'] = close_dapui_tabs
285+
dap.listeners.before.event_exited['dapui_config'] = close_dapui_tabs
237286

238287
-- Fix for Flutter Tools log buffer - make it non-saveable
239288
-- This prevents Vim from asking to save changes to the log file on exit

0 commit comments

Comments
 (0)