Files
mzansi_vim/lua/plugins/flutter.lua

86 lines
2.3 KiB
Lua

return {
{
"nvim-flutter/flutter-tools.nvim",
lazy = false,
dependencies = {
"nvim-lua/plenary.nvim",
"stevearc/dressing.nvim",
},
config = function()
vim.opt.termguicolors = true
vim.env.FLUTTER_FORCE_COLOR = "1"
vim.api.nvim_create_autocmd({ "TextChanged", "BufWinEnter" }, {
pattern = "*__FLUTTER_DEV_LOG__*", -- Default name for flutter-tools logs
callback = function()
local buf = vim.api.nvim_get_current_buf()
-- Check if we are in the log buffer
if vim.bo[buf].filetype == "log" or vim.fn.bufname(buf):match("flutter%-dev%.log") then
local win = vim.api.nvim_get_current_win()
local last_line = vim.api.nvim_buf_line_count(buf)
-- Only scroll if we aren't currently in Insert mode
if vim.api.nvim_get_mode().mode ~= 'i' then
vim.api.nvim_win_set_cursor(win, { last_line, 0 })
end
end
end,
})
require("flutter-tools").setup({
ui = {
border = "rounded",
notification_style = "plugin",
},
decorations = {
statusline = {
app_version = true,
device = true,
}
},
lsp = {
capabilities = require("cmp_nvim_lsp").default_capabilities(),
settings = {
showTodos = true,
completeFunctionCalls = true,
updateImportsOnRename = true,
},
},
widget_guides = {
enabled = true,
},
dev_log = {
enabled = true,
notify_errors = false,
open_cmd = "vertical rightbelow vsplit",
},
})
-- Custom Shorthand Commands
local user_command = vim.api.nvim_create_user_command
-- Simple Aliases
-- user_command("FRun", "FlutterRun", {})
-- user_command("FRun", "FlutterRun --color", {})
user_command("FRun", "FlutterRun --color", {})
user_command("FReload", "FlutterReload", {})
user_command("FRestart", "FlutterRestart", {})
user_command("FQuit", "FlutterQuit", {})
user_command("FDevices", "FlutterDevices", {})
user_command("FEmulators", "FlutterEmulators", {})
user_command("FLogs", "FlutterLogToggle", {})
user_command("FLogsClear", "FlutterLogClear", {})
-- Target-specific Run Command
user_command("FRunT", function(opts)
vim.cmd("FlutterRun --color --target=" .. opts.args)
end, {
nargs = 1,
complete = "file",
desc = "Run Flutter with a specific target file",
})
end,
},
}