From 80770c67aa2d9e1eccf6bb52fac78115831acd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20=C5=A0idlauskas?= Date: Wed, 13 Nov 2024 08:22:13 +0200 Subject: [PATCH] feat(config): add ability to set web-browser-flag (#406) --- README.md | 3 ++- doc/flutter-tools.txt | 3 ++- lua/flutter-tools/commands.lua | 2 ++ lua/flutter-tools/config.lua | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a6935bc..e4eb2dd 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,8 @@ require('flutter-tools').setup_project({ name = 'Web', device = 'chrome', flavor = 'WebApp', - web_port = 4000 + web_port = "4000", + web_browser_flag = "--disable-web-security", }, { name = 'Profile', diff --git a/doc/flutter-tools.txt b/doc/flutter-tools.txt index 33f1edb..ec52b00 100644 --- a/doc/flutter-tools.txt +++ b/doc/flutter-tools.txt @@ -375,7 +375,8 @@ _conceptually_ to vscode’s `launch.json` file. name = 'Web', device = 'chrome', flavor = 'WebApp', - web_port = 4000 + web_port = "4000", + web_browser_flag = "--disable-web-security", }, { name = 'Profile', diff --git a/lua/flutter-tools/commands.lua b/lua/flutter-tools/commands.lua index 30caf02..65d312c 100644 --- a/lua/flutter-tools/commands.lua +++ b/lua/flutter-tools/commands.lua @@ -135,6 +135,7 @@ local function get_run_args(opts, conf) local flutter_mode = conf and conf.flutter_mode local web_port = conf and conf.web_port local dev_url = dev_tools.get_url() + local web_browser_flag = conf and conf.web_browser_flag if not use_debugger_runner() then vim.list_extend(args, { "run" }) end if not cmd_args and device then vim.list_extend(args, { "-d", device }) end @@ -158,6 +159,7 @@ local function get_run_args(opts, conf) end -- else default to debug end if dev_url then vim.list_extend(args, { "--devtools-server-address", dev_url }) end + if web_browser_flag then vim.list_extend(args, { "--web-browser-flag", web_browser_flag }) end return args end diff --git a/lua/flutter-tools/config.lua b/lua/flutter-tools/config.lua index 911c740..47b4fd1 100644 --- a/lua/flutter-tools/config.lua +++ b/lua/flutter-tools/config.lua @@ -12,8 +12,9 @@ local utils = lazy.require("flutter-tools.utils") ---@module "flutter-tools.util ---@field dart_define? {[string]: string} ---@field dart_define_from_file? string ---@field flutter_mode? string ----@field web_port? number +---@field web_port? string ---@field cwd? string full path of current working directory, defaults to LSP root +---@field web_browser_flag? string e.g. --web-browser-flag "--disable-web-security" local M = {}