From 4f2d78fcaf3550c1f5d98f2f8af78a2011e5354e Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 15 Jan 2025 00:10:12 +0100 Subject: [PATCH 1/2] plugins/flutter-tools: update settingsExample --- plugins/by-name/flutter-tools/default.nix | 33 +++++++++---------- .../plugins/by-name/flutter-tools/default.nix | 33 +++++++++---------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/plugins/by-name/flutter-tools/default.nix b/plugins/by-name/flutter-tools/default.nix index 8e4a34df33..def7d48aa8 100644 --- a/plugins/by-name/flutter-tools/default.nix +++ b/plugins/by-name/flutter-tools/default.nix @@ -35,24 +35,23 @@ lib.nixvim.plugins.mkNeovimPlugin { settingsOptions = import ./settings-options.nix lib; settingsExample = { - debugger = { - enabled = true; - run_via_dap = true; - }; - widget_guides.enabled = false; - closing_tags.highlight = "Comment"; - lsp = { - on_attach = null; - capabilities.__raw = '' - function(config) - config.documentFormattingProvider = false - return config - end - ''; - settings = { - enableSnippets = false; - updateImportsOnRename = true; + decorations = { + statusline = { + app_version = true; + device = true; }; }; + dev_tools = { + autostart = true; + auto_open_browser = true; + }; + lsp.color.enabled = true; + widget_guides.enabled = true; + closing_tags = { + highlight = "ErrorMsg"; + prefix = ">"; + priority = 10; + enabled = false; + }; }; } diff --git a/tests/test-sources/plugins/by-name/flutter-tools/default.nix b/tests/test-sources/plugins/by-name/flutter-tools/default.nix index 5c3c0be8d0..4713b35761 100644 --- a/tests/test-sources/plugins/by-name/flutter-tools/default.nix +++ b/tests/test-sources/plugins/by-name/flutter-tools/default.nix @@ -85,25 +85,24 @@ enable = true; settings = { - debugger = { - enabled = true; - run_via_dap = true; - }; - widget_guides.enabled = false; - closing_tags.highlight = "Comment"; - lsp = { - on_attach = null; - capabilities.__raw = '' - function(config) - config.documentFormattingProvider = false - return config - end - ''; - settings = { - enableSnippets = false; - updateImportsOnRename = true; + decorations = { + statusline = { + app_version = true; + device = true; }; }; + dev_tools = { + autostart = true; + auto_open_browser = true; + }; + lsp.color.enabled = true; + widget_guides.enabled = true; + closing_tags = { + highlight = "ErrorMsg"; + prefix = ">"; + priority = 10; + enabled = false; + }; }; }; }; From cbf960e5659054b2ccf27b67218782e69016bef5 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 15 Jan 2025 00:12:04 +0100 Subject: [PATCH 2/2] plugins/flutter-tools: update options --- .../flutter-tools/settings-options.nix | 166 +++++++++++------- .../plugins/by-name/flutter-tools/default.nix | 32 ++-- 2 files changed, 120 insertions(+), 78 deletions(-) diff --git a/plugins/by-name/flutter-tools/settings-options.nix b/plugins/by-name/flutter-tools/settings-options.nix index b34ca13efa..0fb782e5c4 100644 --- a/plugins/by-name/flutter-tools/settings-options.nix +++ b/plugins/by-name/flutter-tools/settings-options.nix @@ -3,81 +3,102 @@ let inherit (lib) types; inherit (lib.nixvim) defaultNullOpts - literalLua mkNullOrOption' mkNullOrOption + literalLua ; in { ui = { - border = defaultNullOpts.mkNullable (with types; either str (listOf (maybeRaw str))) "rounded" '' - The border type to use for all floating windows, the same options/formats used for - `:h nvim_open_win` e.g. `"single"` | `"shadow"` | `[]`. - ''; + border = defaultNullOpts.mkBorder' { + pluginDefault = "single"; + example = "rounded"; + name = "all floating windows"; + }; }; + decorations = { statusline = { app_version = defaultNullOpts.mkBool false '' Set to true to be able use the `flutter_tools_decorations.app_version` in your statusline. + This will show the current version of the flutter app from the `pubspec.yaml` file. ''; device = defaultNullOpts.mkBool false '' Set to true to be able use the `flutter_tools_decorations.device` in your statusline. + This will show the currently running device if an application was started with a specific device. ''; project_config = defaultNullOpts.mkBool false '' Set to true to be able use the `flutter_tools_decorations.project_config` in your - statusline this will show the currently selected project configuration. + statusline. + + This will show the currently selected project configuration. ''; }; }; debugger = { enabled = defaultNullOpts.mkBool false '' - Integrate with nvim `dap` + install dart code debugger. + Enable `nvim-dap` integration. ''; - exception_breakpoints = defaultNullOpts.mkListOf types.anything [ ] '' - 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 = defaultNullOpts.mkListOf types.anything null '' + If empty, dap will not stop on any exceptions. + Otherwise it will stop on those specified. + + See `|:help dap.set_exception_breakpoints()|` for more information. ''; evaluate_to_string_in_debug_views = defaultNullOpts.mkBool true '' 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. + may expect this functionality. ''; - register_configurations = - defaultNullOpts.mkRaw - '' - function(paths) - require("dap").configurations.dart = { - --put here config that you would find in .vscode/launch.json - } - -- If you want to load .vscode launch.json automatically run the following: + register_configurations = defaultNullOpts.mkRaw' { + pluginDefault = null; + example = '' + function(paths) + require("dap").configurations.dart = { + --put here config that you would find in .vscode/launch.json + } + -- If you want to load .vscode launch.json automatically run the following: -- require("dap.ext.vscode").load_launchjs() - end - '' - '' - Function to register `dap` configurations. - ''; + end + ''; + description = '' + Function to register configurations. + ''; + }; }; - flutter_path = defaultNullOpts.mkStr null '' - Path to the `flutter` executable. - This takes priority over the lookup - ''; + flutter_path = defaultNullOpts.mkStr' { + pluginDefault = null; + example = ""; + description = '' + Absolute path to the `flutter` binary. - flutter_lookup_cmd = mkNullOrOption' { + This takes priority over the `flutter_lookup_cmd`. + ''; + }; + + flutter_lookup_cmd = defaultNullOpts.mkStr' { + pluginDefault = literalLua '' + function get_default_lookup() + local exepath = fn.exepath("flutter") + local is_snap_installation = exepath and exepath:match("snap") or false + return (path.is_linux and is_snap_installation) and "flutter sdk-path" or nil + end + ''; example = "dirname $(which flutter)"; description = '' - The command used to locate the flutter path. + The command used to find the directory where flutter is installed. ''; - type = types.str; }; root_patterns = defaultNullOpts.mkListOf types.str [ ".git" "pubspec.yaml" ] '' @@ -95,22 +116,33 @@ in }; closing_tags = { - highlight = defaultNullOpts.mkStr "ErrorMsg" '' - Highlight group for the closing tag. - ''; + highlight = defaultNullOpts.mkStr' { + example = "ErrorMsg"; + pluginDefault = "Comment"; + description = '' + Highlight group for the closing tag. + ''; + }; - prefix = defaultNullOpts.mkStr ">" '' - Haracter to use for close tag e.g. > Widget. - ''; + prefix = defaultNullOpts.mkStr' { + pluginDefault = "// "; + example = ">"; + description = '' + Character to use for close tag. + ''; + }; priority = defaultNullOpts.mkUnsignedInt 10 '' Priority of virtual text in current line. - ''; - enabled = defaultNullOpts.mkBool true '' Consider to configure this when there is a possibility of multiple virtual text items in one line. - See `priority` option in `|:help nvim_buf_set_extmark|` for more info. + + See `priority` option in `|:help nvim_buf_set_extmark|` for more information. + ''; + + enabled = defaultNullOpts.mkBool true '' + Set to `false` to disable closing tags. ''; }; @@ -121,37 +153,47 @@ in filter = defaultNullOpts.mkRaw null '' Optional callback to filter the log. + Takes a `log_line` as string argument; returns a boolean or `nil`. + The `log_line` is only added to the output if the function returns `true`. ''; notify_errors = defaultNullOpts.mkBool false '' - If there is an error whilst running then notify the user. + Whether notify the user when there is an error whilst running. ''; - open_cmd = defaultNullOpts.mkStr "15split" '' - Command to use to open the log buffer. - ''; + open_cmd = defaultNullOpts.mkStr' { + example = "15split"; + pluginDefault = literalLua "('botright %dvnew'):format(math.max(vim.o.columns * 0.4, 50))"; + description = '' + Command to use to open the log buffer. + ''; + }; focus_on_open = defaultNullOpts.mkBool true '' - Focus on the newly opened log window. + Whether to focus on the newly opened log window. ''; }; dev_tools = { autostart = defaultNullOpts.mkBool false '' - Autostart devtools server if not detected. + Whether to autostart `devtools` server if not detected. ''; auto_open_browser = defaultNullOpts.mkBool false '' - Automatically opens devtools in the browser. + Automatically opens `devtools` in the browser. ''; }; outline = { - open_cmd = defaultNullOpts.mkStr "30vnew" '' - Command to use to open the outline buffer. - ''; + open_cmd = defaultNullOpts.mkStr' { + pluginDefault = literalLua "('botright %dvnew'):format(math.max(vim.o.columns * 0.3, 40))"; + example = "30vnew"; + description = '' + Command to use to open the outline buffer. + ''; + }; auto_open = defaultNullOpts.mkBool false '' If `true` this will open the outline automatically when it is first populated. @@ -161,15 +203,17 @@ in lsp = { color = { enabled = defaultNullOpts.mkBool false '' - Whether or not to highlight color variables at all, only supported on flutter >= 2.10. + Show the derived colors for dart variables. + Set this to `true` to enable color variables highlighting (only supported on + flutter >= 2.10). ''; background = defaultNullOpts.mkBool false '' Whether to highlight the background. ''; - background_color = defaultNullOpts.mkAttrsOf' { - type = types.ints.unsigned; + background_color = defaultNullOpts.mkNullable' { + type = with types; either str (attrsOf ints.unsigned); pluginDefault = null; example = { r = 19; @@ -177,7 +221,8 @@ in b = 24; }; description = '' - Required when the background is transparent. + Background color. + Required, when background is transparent. ''; }; @@ -195,11 +240,11 @@ in }; on_attach = mkNullOrOption types.rawLua '' - The function to call when attaching the language server. + Provide a custom `on_attach` function. ''; capabilities = mkNullOrOption' { - type = with types; attrsOf anything; + type = types.rawLua; example = literalLua '' function(config) config.specificThingIDontWant = false @@ -207,9 +252,8 @@ in end ''; description = '' - LSP capabilities. - You can use the ones of `lsp_status` or you can specify a function to deactivate or change - or control how the config is created. + Provide a custom value for `capabilities`. + Example: `lsp_status` capabilities. ''; }; @@ -224,9 +268,9 @@ in updateImportsOnRename = true; }; description = '' - LSP settings. + Settings for the dart language server. See [here](https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration) - the link below for details on each option. + for details on each option. ''; }; }; diff --git a/tests/test-sources/plugins/by-name/flutter-tools/default.nix b/tests/test-sources/plugins/by-name/flutter-tools/default.nix index 4713b35761..888c3ce51e 100644 --- a/tests/test-sources/plugins/by-name/flutter-tools/default.nix +++ b/tests/test-sources/plugins/by-name/flutter-tools/default.nix @@ -9,7 +9,7 @@ settings = { ui = { - border = "rounded"; + border = "single"; }; decorations = { statusline = { @@ -20,20 +20,18 @@ }; debugger = { enabled = false; - exception_breakpoints = [ ]; + exception_breakpoints = null; evaluate_to_string_in_debug_views = true; - register_configurations.__raw = '' - function(paths) - require("dap").configurations.dart = { - --put here config that you would find in .vscode/launch.json - } - -- If you want to load .vscode launch.json automatically run the following: - -- require("dap.ext.vscode").load_launchjs() - end - ''; + register_configurations = null; }; flutter_path = null; - flutter_lookup_cmd = null; + flutter_lookup_cmd.__raw = '' + (function() + local exepath = vim.fn.exepath("flutter") + local is_snap_installation = exepath and exepath:match("snap") or false + return (require'flutter-tools.utils.path'.is_linux and is_snap_installation) and "flutter sdk-path" or nil + end)() + ''; root_patterns = [ ".git" "pubspec.yaml" @@ -43,8 +41,8 @@ enabled = false; }; closing_tags = { - highlight = "ErrorMsg"; - prefix = ">"; + highlight = "Comment"; + prefix = "// "; priority = 10; enabled = true; }; @@ -52,7 +50,7 @@ enabled = true; filter = null; notify_errors = false; - open_cmd = "15split"; + open_cmd.__raw = "('botright %dvnew'):format(math.max(vim.o.columns * 0.4, 50))"; focus_on_open = true; }; dev_tools = { @@ -60,7 +58,7 @@ auto_open_browser = false; }; outline = { - open_cmd = "30vnew"; + open_cmd.__raw = "('botright %dvnew'):format(math.max(vim.o.columns * 0.3, 40))"; auto_open = false; }; lsp = { @@ -74,7 +72,7 @@ }; on_attach = null; capabilities = null; - settings = { }; + settings = null; }; }; };