fix: multiple fixes

This commit is contained in:
Anup Sebastian 2025-10-30 20:20:29 -05:00
parent ebc91cd36c
commit 6f1e570a92
4 changed files with 116 additions and 43 deletions

View file

@ -69,9 +69,22 @@ return {
local capabilities = require('blink.cmp').get_lsp_capabilities()
require('flutter-tools').setup {
-- UI configuration
ui = {
border = 'rounded', -- border type for floating windows
notification_style = 'native', -- 'native' or 'plugin' (native uses vim.notify)
},
-- Flutter SDK path (usually auto-detected, but you can specify if needed)
-- flutter_path = '/path/to/flutter/bin/flutter',
-- flutter_lookup_cmd = nil, -- example: "dirname $(which flutter)" or "asdf where flutter"
-- FVM support - takes priority over path, uses <workspace>/.fvm/flutter_sdk if enabled
fvm = false,
-- Root patterns to find the root of your flutter project
root_patterns = { '.git', 'pubspec.yaml' },
-- Uncomment to set a default device (get ID from `flutter devices`)
-- device = {
-- id = 'chrome', -- or 'macos', 'emulator-5554', etc.
@ -79,6 +92,16 @@ return {
lsp = {
capabilities = capabilities,
-- Color preview for dart variables (Colors.red, Color(0xFF...), etc.)
-- This shows the actual Material Design colors inline!
color = {
enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = true, -- highlight the background
background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
foreground = false, -- highlight the foreground
virtual_text = true, -- show the highlight using virtual text
virtual_text_str = '', -- the virtual text character to highlight
},
-- Settings passed to the Dart LSP
settings = {
-- Show TODOs in the problems pane
@ -87,8 +110,9 @@ return {
completeFunctionCalls = true,
-- Enable/disable specific lints
-- analysisExcludedFolders = {},
renameFilesWithClasses = 'prompt',
renameFilesWithClasses = 'prompt', -- "always" or "prompt"
enableSnippets = true,
updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed
},
},
@ -118,9 +142,26 @@ return {
focus_on_open = false, -- Don't auto-focus the log window
},
dev_tools = {
autostart = false, -- autostart devtools server if not detected
auto_open_browser = false, -- Automatically opens devtools in the browser
},
outline = {
open_cmd = '30vnew', -- command to use to open the outline buffer
auto_open = false, -- if true this will open the outline automatically when it is first populated
},
debugger = {
enabled = true, -- Enable Flutter debugger integration
run_via_dap = true, -- Use DAP for debugging
-- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
-- see |:help dap.set_exception_breakpoints()| for more info
exception_breakpoints = {},
-- Whether to call toString() on objects in debug views like hovers and the variables list.
-- Invoking toString() has a performance cost and may introduce side-effects,
-- although users may expected this functionality. null is treated like false.
evaluate_to_string_in_debug_views = true,
-- Flutter tools will automatically register DAP configurations
-- No need to manually configure launch.json
},
@ -176,28 +217,31 @@ return {
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Fix for Flutter Tools log buffer becoming non-modifiable
-- This catches all buffer types that might be used for Flutter logs
-- Fix for Flutter Tools log buffer - make it non-saveable
-- This prevents Vim from asking to save changes to the log file on exit
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, {
pattern = '*',
callback = function(args)
local bufname = vim.api.nvim_buf_get_name(args.buf)
-- Check if this is a Flutter log buffer
if bufname:match('__FLUTTER_DEV_LOG__') or vim.bo[args.buf].filetype == 'log' then
vim.bo[args.buf].modifiable = true
vim.bo[args.buf].readonly = false
vim.bo[args.buf].buftype = '' -- Make it a normal buffer
vim.bo[args.buf].modifiable = true -- Allow Flutter to write to it
vim.bo[args.buf].modified = false -- Mark as unmodified
vim.bo[args.buf].buftype = 'nofile' -- Don't associate with a file (prevents save prompt)
vim.bo[args.buf].swapfile = false -- Don't create swap file
end
end,
})
-- Also fix it whenever Flutter tries to write to the log
-- Keep log buffer marked as unmodified whenever it changes
-- This prevents the "save changes?" prompt on exit
vim.api.nvim_create_autocmd('BufModifiedSet', {
pattern = '*',
callback = function(args)
local bufname = vim.api.nvim_buf_get_name(args.buf)
if bufname:match('__FLUTTER_DEV_LOG__') then
vim.bo[args.buf].modifiable = true
vim.bo[args.buf].modified = false -- Keep it marked as unmodified
end
end,
})

View file

@ -7,21 +7,35 @@
-- the same directory.
--
-- Features:
-- - Auto-saves session on exit
-- - Auto-restores session when opening Neovim in a directory
-- - Auto-saves session on exit (automatically!)
-- - ✅ Auto-restores session when you `cd` into a directory and run `nvim`
-- - Saves per-directory (each project has its own session)
-- - Saves open buffers, window splits, cursor positions, and more
--
-- Keymaps:
-- <leader>ss - Save session manually
-- <leader>sr - Restore session manually
-- <leader>sd - Delete session for current directory
-- <leader>sf - Find/search all sessions (Telescope)
-- IMPORTANT: Auto-restore works when you:
-- 1. cd /path/to/your/project
-- 2. nvim (without specifying files)
--
-- If you open a specific file (e.g., `nvim main.dart`), auto-restore is skipped.
-- Use manual restore (<leader>Sr) if needed.
--
-- Quit keymaps (in init.lua):
-- <leader>Qa - Quit all windows
-- <leader>Qq - Force quit all without saving
-- <leader>Qw - Save all and quit
-- Keymaps:
-- <leader>Ss - Save session manually
-- <leader>Sr - Restore session manually (if auto-restore didn't trigger)
-- <leader>Sd - Delete session for current directory
-- <leader>Sf - Find/search all sessions (Telescope)
--
-- Quit keymaps (in init.lua, integrated with auto-session):
-- <leader>Qa - Quit all and save session (most common)
-- <leader>Qq - Force quit all without saving (no session save)
-- <leader>Qw - Save all files, save session, then quit
--
-- WORKFLOW:
-- 1. cd into your project directory
-- 2. nvim (session auto-restores if it exists!)
-- 3. Work on your project
-- 4. Quit with <leader>Qa or just :qa (auto-saves!)
-- 5. Next time: repeat from step 1 - your workspace is restored!
--
-- Sessions are saved in: ~/.local/share/nvim/sessions/
-- ========================================================================
@ -31,14 +45,15 @@ return {
lazy = false, -- Load on startup to restore session
opts = {
-- Session save/restore options
auto_session_enabled = true, -- Automatically save sessions
auto_restore_enabled = true, -- Automatically restore sessions
auto_save_enabled = true, -- Auto-save on exit
auto_session_enabled = true, -- Automatically save sessions on exit
auto_restore_enabled = true, -- Automatically restore sessions on startup
auto_save_enabled = true, -- Auto-save session on exit
auto_session_suppress_dirs = { '~/', '~/Downloads', '/' }, -- Don't save sessions in these dirs
auto_session_use_git_branch = false, -- One session per directory (not per git branch)
-- What to save in the session
auto_session_enable_last_session = false, -- Don't restore last session if not in a project
auto_session_create_enabled = true, -- Auto-create session on first save
-- Hooks to run before/after session save/restore
pre_save_cmds = {
@ -56,25 +71,25 @@ return {
},
},
keys = {
-- Manual session control
-- Manual session control (Capital S to avoid conflict with search)
{
'<leader>ss',
'<cmd>SessionSave<cr>',
'<leader>Ss',
'<cmd>AutoSession save<cr>',
desc = '[S]ession: [S]ave',
},
{
'<leader>sr',
'<cmd>SessionRestore<cr>',
'<leader>Sr',
'<cmd>AutoSession restore<cr>',
desc = '[S]ession: [R]estore',
},
{
'<leader>sd',
'<cmd>SessionDelete<cr>',
'<leader>Sd',
'<cmd>AutoSession delete<cr>',
desc = '[S]ession: [D]elete',
},
{
'<leader>sf',
'<cmd>SessionSearch<cr>',
'<leader>Sf',
'<cmd>AutoSession search<cr>',
desc = '[S]ession: [F]ind/search',
},
},