feat: inline errors, other niceties

This commit is contained in:
Anup Sebastian 2025-11-01 01:14:01 -05:00
parent 30cf2067e9
commit 97cf58c784
4 changed files with 356 additions and 35 deletions

View file

@ -101,13 +101,20 @@ return {
})
-- Filter out didChange error notifications (they're harmless during snippet expansion)
local notify = vim.notify
vim.notify = function(msg, level, opts)
if type(msg) == 'string' and msg:match('textDocument/didChange') then
return -- Suppress this specific error
end
notify(msg, level, opts)
end
-- We'll use an autocmd to do this after noice.nvim is loaded
vim.api.nvim_create_autocmd('User', {
pattern = 'VeryLazy',
once = true,
callback = function()
local notify = vim.notify
vim.notify = function(msg, level, opts)
if type(msg) == 'string' and msg:match('textDocument/didChange') then
return -- Suppress this specific error
end
notify(msg, level, opts)
end
end,
})
end,
-- Color preview for dart variables (Colors.red, Color(0xFF...), etc.)
@ -190,7 +197,7 @@ return {
-- ========================================================================
local dap, dapui = require 'dap', require 'dapui'
-- Configure DAP UI
-- Configure DAP UI to open in tabs for better half-width screen support
dapui.setup {
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
@ -206,7 +213,8 @@ return {
disconnect = '',
},
},
-- Fix layout to prevent resizing issues with Neo-tree
-- Open each element in a new tab instead of side panels
-- This prevents layout issues on small/half-width screens
layouts = {
{
elements = {
@ -215,25 +223,66 @@ return {
{ id = 'stacks', size = 0.25 },
{ id = 'watches', size = 0.25 },
},
size = 40, -- Fixed width instead of percentage
position = 'right', -- Changed to right to avoid conflict with Neo-tree on left
size = 40,
position = 'right',
},
{
elements = {
{ id = 'repl', size = 0.5 },
{ id = 'console', size = 0.5 },
},
size = 10, -- Fixed height
size = 10,
position = 'bottom',
},
},
-- Override element window commands to open in tabs
element_mappings = {},
windows = { indent = 1 },
}
-- Automatically open/close DAP UI
-- Don't close Neo-tree, they can coexist now (DAP on right, Neo-tree on left)
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Custom function to open DAP UI elements in tabs
local function open_dapui_in_tabs()
-- Save current tab to return to it
local current_tab = vim.fn.tabpagenr()
-- Create new tab with a named buffer for debug views
vim.cmd 'tabnew'
local debug_buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(debug_buf, 'Flutter Debug')
vim.api.nvim_set_current_buf(debug_buf)
-- Open DAP UI in this tab
dapui.open()
-- Return to original tab so user continues coding there
vim.cmd('tabnext ' .. current_tab)
end
-- Custom function to close DAP UI tabs
local function close_dapui_tabs()
dapui.close()
-- Find and close the Flutter Debug tab
local current_tab = vim.fn.tabpagenr()
for i = 1, vim.fn.tabpagenr '$' do
vim.cmd('tabnext ' .. i)
local bufname = vim.api.nvim_buf_get_name(0)
if bufname:match('Flutter Debug') then
vim.cmd 'tabclose'
break
end
end
-- Return to original tab
if vim.fn.tabpagenr '$' >= current_tab then
vim.cmd('tabnext ' .. current_tab)
end
end
-- Automatically open/close DAP UI in tabs
dap.listeners.after.event_initialized['dapui_config'] = open_dapui_in_tabs
dap.listeners.before.event_terminated['dapui_config'] = close_dapui_tabs
dap.listeners.before.event_exited['dapui_config'] = close_dapui_tabs
-- Fix for Flutter Tools log buffer - make it non-saveable
-- This prevents Vim from asking to save changes to the log file on exit

View file

@ -176,6 +176,218 @@ return {
end,
},
-- ========================================================================
-- TROUBLE.NVIM - Beautiful diagnostics list (LazyVim-style)
-- ========================================================================
-- Provides a nice list view of diagnostics, quickfix, LSP references, etc.
-- Shows errors inline in a dedicated panel like LazyVim/VS Code.
-- Auto-opens when diagnostics are present to show errors in editor area.
--
-- Keymaps:
-- <leader>xx - Toggle diagnostics list
-- <leader>xX - Buffer diagnostics
-- <leader>cs - Symbols list
-- <leader>cl - LSP references
-- <leader>xL - Location list
-- <leader>xQ - Quickfix list
-- [q / ]q - Previous/next item in trouble list
-- ========================================================================
{
'folke/trouble.nvim',
cmd = 'Trouble', -- Lazy load on command
opts = {
focus = false, -- Don't focus the window when opened (LazyVim behavior)
auto_close = true, -- Auto close when no items
auto_open = false, -- Don't auto open (we'll handle this with autocmd)
warn_no_results = false,
open_no_results = false,
modes = {
-- Configure the diagnostics mode to show in editor area
diagnostics = {
mode = 'diagnostics',
preview = {
type = 'split',
relative = 'win',
position = 'right',
size = 0.3,
},
},
},
},
keys = {
{
'<leader>xx',
'<cmd>Trouble diagnostics toggle<cr>',
desc = 'Diagnostics (Trouble)',
},
{
'<leader>xX',
'<cmd>Trouble diagnostics toggle filter.buf=0<cr>',
desc = 'Buffer Diagnostics (Trouble)',
},
{
'<leader>cs',
'<cmd>Trouble symbols toggle focus=false<cr>',
desc = 'Symbols (Trouble)',
},
{
'<leader>cl',
'<cmd>Trouble lsp toggle focus=false win.position=right<cr>',
desc = 'LSP Definitions / references / ... (Trouble)',
},
{
'<leader>xL',
'<cmd>Trouble loclist toggle<cr>',
desc = 'Location List (Trouble)',
},
{
'<leader>xQ',
'<cmd>Trouble qflist toggle<cr>',
desc = 'Quickfix List (Trouble)',
},
{
'[q',
function()
if require('trouble').is_open() then
require('trouble').prev({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cprev)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = 'Previous Trouble/Quickfix Item',
},
{
']q',
function()
if require('trouble').is_open() then
require('trouble').next({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cnext)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = 'Next Trouble/Quickfix Item',
},
},
},
-- ========================================================================
-- NOICE.NVIM - Better UI for messages, cmdline, and notifications
-- ========================================================================
-- Provides a modern UI for command line, messages, and notifications (LazyVim-style).
-- Makes the editor feel more polished with popup notifications and floating cmdline.
--
-- Features:
-- - Floating command line
-- - Modern notification system
-- - Better message display
-- - Signature help while typing
--
-- Note: This can be disabled if you prefer the classic Vim UI
-- ========================================================================
{
'folke/noice.nvim',
event = 'VeryLazy',
dependencies = {
'MunifTanjim/nui.nvim',
-- Optional: If you want to use `nvim-notify` for notifications
-- 'rcarriga/nvim-notify',
},
opts = {
lsp = {
-- Override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
['vim.lsp.util.stylize_markdown'] = true,
['cmp.entry.get_documentation'] = true,
},
},
-- Presets for easier configuration
presets = {
bottom_search = true, -- Use a classic bottom cmdline for search
command_palette = true, -- Position the cmdline and popupmenu together
long_message_to_split = true, -- Long messages will be sent to a split
inc_rename = false, -- Enables an input dialog for inc-rename.nvim
lsp_doc_border = true, -- Add a border to hover docs and signature help
},
-- Routes configuration (optional customization)
routes = {
{
filter = {
event = 'msg_show',
kind = '',
find = 'written',
},
opts = { skip = true },
},
},
},
keys = {
{
'<leader>sn',
'',
desc = '+noice',
},
{
'<leader>snl',
function()
require('noice').cmd('last')
end,
desc = 'Noice Last Message',
},
{
'<leader>snh',
function()
require('noice').cmd('history')
end,
desc = 'Noice History',
},
{
'<leader>sna',
function()
require('noice').cmd('all')
end,
desc = 'Noice All',
},
{
'<leader>snd',
function()
require('noice').cmd('dismiss')
end,
desc = 'Dismiss All',
},
{
'<c-f>',
function()
if not require('noice.lsp').scroll(4) then
return '<c-f>'
end
end,
silent = true,
expr = true,
desc = 'Scroll Forward',
mode = { 'i', 'n', 's' },
},
{
'<c-b>',
function()
if not require('noice.lsp').scroll(-4) then
return '<c-b>'
end
end,
silent = true,
expr = true,
desc = 'Scroll Backward',
mode = { 'i', 'n', 's' },
},
},
},
-- ========================================================================
-- ADDITIONAL COMMON PLUGINS
-- ========================================================================