diff --git a/plugins/by-name/dap/dap-go.nix b/plugins/by-name/dap/dap-go.nix index 91db8d7d..89f22aeb 100644 --- a/plugins/by-name/dap/dap-go.nix +++ b/plugins/by-name/dap/dap-go.nix @@ -1,15 +1,15 @@ { lib, - helpers, config, pkgs, ... }: let inherit (lib) types; + inherit (lib.nixvim) defaultNullOpts; cfg = config.plugins.dap.extensions.dap-go; - dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; + dapHelpers = import ./dapHelpers.nix { inherit lib; }; in { options.plugins.dap.extensions.dap-go = { @@ -22,25 +22,25 @@ in ]; }; - dapConfigurations = helpers.mkNullOrOption (types.listOf dapHelpers.configurationOption) '' + dapConfigurations = lib.nixvim.mkNullOrOption (types.listOf dapHelpers.configurationOption) '' Additional dap configurations. See `:h dap-configuration` for more detail. ''; delve = { - path = helpers.defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging."; + path = defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging."; - initializeTimeoutSec = helpers.defaultNullOpts.mkInt 20 "Time to wait for delve to initialize the debug session."; + initializeTimeoutSec = defaultNullOpts.mkInt 20 "Time to wait for delve to initialize the debug session."; - port = helpers.defaultNullOpts.mkStr "$\{port}" '' + port = defaultNullOpts.mkStr "$\{port}" '' A string that defines the port to start delve debugger. Defaults to string "$\{port}" which instructs dap to start the process in a random available port. ''; - args = helpers.mkNullOrOption (types.listOf types.str) "Additional args to pass to dlv."; + args = lib.nixvim.mkNullOrOption (types.listOf types.str) "Additional args to pass to dlv."; - buildFlags = helpers.defaultNullOpts.mkStr "" "Build flags to pass to dlv."; + buildFlags = defaultNullOpts.mkStr "" "Build flags to pass to dlv."; }; }; diff --git a/plugins/by-name/dap/dap-python.nix b/plugins/by-name/dap/dap-python.nix index 9fdaef97..f3a7ddb1 100644 --- a/plugins/by-name/dap/dap-python.nix +++ b/plugins/by-name/dap/dap-python.nix @@ -1,15 +1,22 @@ { lib, - helpers, config, pkgs, ... }: let - inherit (lib) types; + inherit (lib) + optionalString + types + ; + inherit (lib.nixvim) + defaultNullOpts + mkNullOrOption + toLuaObject + ; cfg = config.plugins.dap.extensions.dap-python; - dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; + dapHelpers = import ./dapHelpers.nix { inherit lib; }; in { options.plugins.dap.extensions.dap-python = { @@ -31,28 +38,28 @@ in type = types.str; }; - console = helpers.defaultNullOpts.mkEnumFirstDefault [ + console = defaultNullOpts.mkEnumFirstDefault [ "integratedTerminal" "internalConsole" "externalTerminal" ] "Debugpy console."; - customConfigurations = helpers.mkNullOrOption (types.listOf dapHelpers.configurationOption) "Custom python configurations for dap."; + customConfigurations = mkNullOrOption (types.listOf dapHelpers.configurationOption) "Custom python configurations for dap."; - includeConfigs = helpers.defaultNullOpts.mkBool true "Add default configurations."; + includeConfigs = defaultNullOpts.mkBool true "Add default configurations."; - resolvePython = helpers.defaultNullOpts.mkLuaFn null '' + resolvePython = defaultNullOpts.mkLuaFn null '' Function to resolve path to python to use for program or test execution. By default the `VIRTUAL_ENV` and `CONDA_PREFIX` environment variables are used if present. ''; - testRunner = helpers.mkNullOrOption (types.either types.str types.rawLua) '' + testRunner = mkNullOrOption (types.either types.str types.rawLua) '' The name of test runner to use by default. The default value is dynamic and depends on `pytest.ini` or `manage.py` markers. If neither is found "unittest" is used. ''; - testRunners = helpers.mkNullOrOption (with lib.types; attrsOf strLuaFn) '' + testRunners = mkNullOrOption (with lib.types; attrsOf strLuaFn) '' Set to register test runners. Built-in are test runners for unittest, pytest and django. The key is the test runner name, the value a function to generate the @@ -75,13 +82,12 @@ in enable = true; extensionConfigLua = - with helpers; '' require("dap-python").setup("${cfg.adapterPythonPath}", ${toLuaObject options}) '' + (optionalString (cfg.testRunners != null) '' table.insert(require("dap-python").test_runners, - ${toLuaObject (builtins.mapAttrs (_: mkRaw) cfg.testRunners)}) + ${toLuaObject (builtins.mapAttrs (_: lib.nixvim.mkRaw) cfg.testRunners)}) '') + (optionalString (cfg.customConfigurations != null) '' table.insert(require("dap").configurations.python, ${toLuaObject cfg.customConfigurations}) diff --git a/plugins/by-name/dap/dap-ui.nix b/plugins/by-name/dap/dap-ui.nix index f0151772..659b9550 100644 --- a/plugins/by-name/dap/dap-ui.nix +++ b/plugins/by-name/dap/dap-ui.nix @@ -1,29 +1,27 @@ { lib, - helpers, config, pkgs, ... }: let inherit (lib) mkOption types; + inherit (lib.nixvim) defaultNullOpts; cfg = config.plugins.dap.extensions.dap-ui; - mkSizeOption = helpers.mkNullOrOption (with types; either int (numbers.between 0.0 1.0)); + mkSizeOption = lib.nixvim.mkNullOrOption (with types; either int (numbers.between 0.0 1.0)); mkKeymapOptions = name: lib.mapAttrs ( key: default: - helpers.defaultNullOpts.mkNullable ( - with types; either str (listOf str) - ) default "Map `${key}` for ${name}" + defaultNullOpts.mkNullable (with types; either str (listOf str)) default "Map `${key}` for ${name}" ); elementOption = types.submodule { options = { - id = helpers.mkNullOrOption types.str "Element ID."; + id = lib.nixvim.mkNullOrOption types.str "Element ID."; size = mkSizeOption "Size of the element in lines/columns or as proportion of total editor size (0-1)."; }; @@ -68,9 +66,9 @@ in }; controls = { - enabled = helpers.defaultNullOpts.mkBool true "Enable controls"; + enabled = defaultNullOpts.mkBool true "Enable controls"; - element = helpers.defaultNullOpts.mkEnumFirstDefault [ + element = defaultNullOpts.mkEnumFirstDefault [ "repl" "scopes" "stacks" @@ -80,19 +78,19 @@ in ] "Element to show the controls on."; icons = { - disconnect = helpers.defaultNullOpts.mkStr "" ""; - pause = helpers.defaultNullOpts.mkStr "" ""; - play = helpers.defaultNullOpts.mkStr "" ""; - run_last = helpers.defaultNullOpts.mkStr "" ""; - step_into = helpers.defaultNullOpts.mkStr "" ""; - step_over = helpers.defaultNullOpts.mkStr "" ""; - step_out = helpers.defaultNullOpts.mkStr "" ""; - step_back = helpers.defaultNullOpts.mkStr "" ""; - terminate = helpers.defaultNullOpts.mkStr "" ""; + disconnect = defaultNullOpts.mkStr "" ""; + pause = defaultNullOpts.mkStr "" ""; + play = defaultNullOpts.mkStr "" ""; + run_last = defaultNullOpts.mkStr "" ""; + step_into = defaultNullOpts.mkStr "" ""; + step_over = defaultNullOpts.mkStr "" ""; + step_out = defaultNullOpts.mkStr "" ""; + step_back = defaultNullOpts.mkStr "" ""; + terminate = defaultNullOpts.mkStr "" ""; }; }; - elementMappings = helpers.mkNullOrOption (types.attrsOf ( + elementMappings = lib.nixvim.mkNullOrOption (types.attrsOf ( types.submodule { options = mkKeymapOptions "element mapping overrides" { edit = "e"; @@ -108,16 +106,16 @@ in } )) "Per-element overrides of global mappings."; - expandLines = helpers.defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size."; + expandLines = defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size."; floating = { maxHeight = mkSizeOption "Maximum height of the floating window."; maxWidth = mkSizeOption "Maximum width of the floating window."; - border = helpers.defaultNullOpts.mkBorder "single" "dap-ui floating window" ""; + border = defaultNullOpts.mkBorder "single" "dap-ui floating window" ""; - mappings = helpers.mkNullOrOption (types.submodule { + mappings = lib.nixvim.mkNullOrOption (types.submodule { options = mkKeymapOptions "dap-ui floating" { close = [ "" @@ -127,15 +125,15 @@ in }) "Keys to trigger actions in elements."; }; - forceBuffers = helpers.defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows."; + forceBuffers = defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows."; icons = { - collapsed = helpers.defaultNullOpts.mkStr "" ""; - current_frame = helpers.defaultNullOpts.mkStr "" ""; - expanded = helpers.defaultNullOpts.mkStr "" ""; + collapsed = defaultNullOpts.mkStr "" ""; + current_frame = defaultNullOpts.mkStr "" ""; + expanded = defaultNullOpts.mkStr "" ""; }; - layouts = helpers.defaultNullOpts.mkListOf layoutOption [ + layouts = defaultNullOpts.mkListOf layoutOption [ { elements = [ { @@ -174,7 +172,7 @@ in } ] "List of layouts for dap-ui."; - mappings = helpers.mkNullOrOption (types.submodule { + mappings = lib.nixvim.mkNullOrOption (types.submodule { options = mkKeymapOptions "dap-ui" { edit = "e"; expand = [ @@ -189,14 +187,14 @@ in }) "Keys to trigger actions in elements."; render = { - indent = helpers.defaultNullOpts.mkInt 1 "Default indentation size."; + indent = defaultNullOpts.mkInt 1 "Default indentation size."; - maxTypeLength = helpers.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming."; + maxTypeLength = lib.nixvim.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming."; - maxValueLines = helpers.defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming."; + maxValueLines = defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming."; }; - selectWindow = helpers.defaultNullOpts.mkLuaFn null '' + selectWindow = defaultNullOpts.mkLuaFn null '' A function which returns a window to be used for opening buffers such as a stack frame location. ''; }; diff --git a/plugins/by-name/dap/dap-virtual-text.nix b/plugins/by-name/dap/dap-virtual-text.nix index 5c89005e..a84f9c19 100644 --- a/plugins/by-name/dap/dap-virtual-text.nix +++ b/plugins/by-name/dap/dap-virtual-text.nix @@ -1,11 +1,12 @@ { lib, - helpers, config, pkgs, ... }: let + inherit (lib.nixvim) defaultNullOpts; + cfg = config.plugins.dap.extensions.dap-virtual-text; in { @@ -19,30 +20,30 @@ in ]; }; - enabledCommands = helpers.defaultNullOpts.mkBool true '' + enabledCommands = defaultNullOpts.mkBool true '' Create commands `DapVirtualTextEnable`, `DapVirtualTextDisable`, `DapVirtualTextToggle`. (`DapVirtualTextForceRefresh` for refreshing when debug adapter did not notify its termination). ''; - highlightChangedVariables = helpers.defaultNullOpts.mkBool true '' + highlightChangedVariables = defaultNullOpts.mkBool true '' Highlight changed values with `NvimDapVirtualTextChanged`, else always `NvimDapVirtualText`. ''; - highlightNewAsChanged = helpers.defaultNullOpts.mkBool false '' + highlightNewAsChanged = defaultNullOpts.mkBool false '' Highlight new variables in the same way as changed variables (if highlightChangedVariables). ''; - showStopReason = helpers.defaultNullOpts.mkBool true "Show stop reason when stopped for exceptions."; + showStopReason = defaultNullOpts.mkBool true "Show stop reason when stopped for exceptions."; - commented = helpers.defaultNullOpts.mkBool false "Prefix virtual text with comment string."; + commented = defaultNullOpts.mkBool false "Prefix virtual text with comment string."; - onlyFirstDefinition = helpers.defaultNullOpts.mkBool true "Only show virtual text at first definition (if there are multiple)."; + onlyFirstDefinition = defaultNullOpts.mkBool true "Only show virtual text at first definition (if there are multiple)."; - allReferences = helpers.defaultNullOpts.mkBool false "Show virtual text on all all references of the variable (not only definitions)."; + allReferences = defaultNullOpts.mkBool false "Show virtual text on all all references of the variable (not only definitions)."; - clearOnContinue = helpers.defaultNullOpts.mkBool false "Clear virtual text on `continue` (might cause flickering when stepping)."; + clearOnContinue = defaultNullOpts.mkBool false "Clear virtual text on `continue` (might cause flickering when stepping)."; - displayCallback = helpers.defaultNullOpts.mkLuaFn '' + displayCallback = defaultNullOpts.mkLuaFn '' function(variable, buf, stackframe, node, options) if options.virt_text_pos == 'inline' then return ' = ' .. variable.value @@ -52,16 +53,16 @@ in end, '' "A callback that determines how a variable is displayed or whether it should be omitted."; - virtTextPos = helpers.defaultNullOpts.mkStr "vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol'" '' + virtTextPos = defaultNullOpts.mkStr "vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol'" '' Position of virtual text, see `:h nvim_buf_set_extmark()`. Default tries to inline the virtual text. Use 'eol' to set to end of line. ''; - allFrames = helpers.defaultNullOpts.mkBool false "Show virtual text for all stack frames not only current."; + allFrames = defaultNullOpts.mkBool false "Show virtual text for all stack frames not only current."; - virtLines = helpers.defaultNullOpts.mkBool false "Show virtual lines instead of virtual text (will flicker!)."; + virtLines = defaultNullOpts.mkBool false "Show virtual lines instead of virtual text (will flicker!)."; - virtTextWinCol = helpers.mkNullOrOption lib.types.int '' + virtTextWinCol = lib.nixvim.mkNullOrOption lib.types.int '' Position the virtual text at a fixed window column (starting from the first text column). See `:h nvim_buf_set_extmark()`. ''; diff --git a/plugins/by-name/dap/dapHelpers.nix b/plugins/by-name/dap/dapHelpers.nix index d1f5084c..9bf198e2 100644 --- a/plugins/by-name/dap/dapHelpers.nix +++ b/plugins/by-name/dap/dapHelpers.nix @@ -1,35 +1,36 @@ -{ lib, helpers }: +{ lib }: let inherit (lib) types; + inherit (lib.nixvim) mkNullOrOption; in rec { mkAdapterType = attrs: types.submodule { options = { - id = helpers.mkNullOrOption types.str '' + id = mkNullOrOption types.str '' Identifier of the adapter. This is used for the `adapterId` property of the initialize request. For most debug adapters setting this is not necessary. ''; - enrichConfig = helpers.mkNullOrLuaFn '' + enrichConfig = lib.nixvim.mkNullOrLuaFn '' A lua function (`func(config, on_config)`) which allows an adapter to enrich a configuration with additional information. It receives a configuration as first argument, and a callback that must be called with the final configuration as second argument. ''; options = { - initializeTimeoutSec = helpers.defaultNullOpts.mkInt 4 '' + initializeTimeoutSec = lib.nixvim.defaultNullOpts.mkInt 4 '' How many seconds the client waits for a response on a initialize request before emitting a warning. ''; - disconnectTimeoutSec = helpers.defaultNullOpts.mkInt 3 '' + disconnectTimeoutSec = lib.nixvim.defaultNullOpts.mkInt 3 '' How many seconds the client waits for a disconnect response from the debug adapter before emitting a warning and closing the connection. ''; - sourceFiletype = helpers.mkNullOrOption types.str '' + sourceFiletype = mkNullOrOption types.str '' The filetype to use for content retrieved via a source request. ''; }; @@ -37,39 +38,39 @@ rec { }; executableAdapterOption = mkAdapterType { - command = helpers.mkNullOrOption types.str "The command to invoke."; + command = mkNullOrOption types.str "The command to invoke."; - args = helpers.mkNullOrOption (types.listOf types.str) "Arguments for the command."; + args = mkNullOrOption (types.listOf types.str) "Arguments for the command."; options = { - env = helpers.mkNullOrOption types.attrs "Set the environment variables for the command."; + env = mkNullOrOption types.attrs "Set the environment variables for the command."; - cwd = helpers.mkNullOrOption types.str "Set the working directory for the command."; + cwd = mkNullOrOption types.str "Set the working directory for the command."; - detached = helpers.defaultNullOpts.mkBool true "Start the debug adapter in a detached state."; + detached = lib.nixvim.defaultNullOpts.mkBool true "Start the debug adapter in a detached state."; }; }; serverAdapterOption = mkAdapterType { - host = helpers.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to."; + host = lib.nixvim.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to."; - port = helpers.mkNullOrOption (types.either types.int (types.enum [ "$\{port}" ])) '' + port = mkNullOrOption (types.either types.int (types.enum [ "$\{port}" ])) '' Port to connect to. If "$\{port}" dap resolves a free port. This is intended to be used with `executable.args`. ''; executable = { - command = helpers.mkNullOrOption types.str "Command that spawns the adapter."; + command = mkNullOrOption types.str "Command that spawns the adapter."; - args = helpers.mkNullOrOption (types.listOf types.str) "Command arguments."; + args = mkNullOrOption (types.listOf types.str) "Command arguments."; - detached = helpers.defaultNullOpts.mkBool true "Spawn the debug adapter in detached state."; + detached = lib.nixvim.defaultNullOpts.mkBool true "Spawn the debug adapter in detached state."; - cwd = helpers.mkNullOrOption types.str "Working directory."; + cwd = mkNullOrOption types.str "Working directory."; }; - options.maxRetries = helpers.defaultNullOpts.mkInt 14 '' + options.maxRetries = lib.nixvim.defaultNullOpts.mkInt 14 '' Amount of times the client should attempt to connect before erroring out. There is a 250ms delay between each retry. ''; @@ -77,7 +78,7 @@ rec { mkAdapterOption = name: type: - helpers.mkNullOrOption (with types; attrsOf (either str type)) '' + mkNullOrOption (with types; attrsOf (either str type)) '' Debug adapters of `${name}` type. The adapters can also be set to a function which takes three arguments: @@ -117,21 +118,20 @@ rec { }; mkSignOption = default: desc: { - text = helpers.defaultNullOpts.mkStr default desc; - texthl = helpers.mkNullOrOption types.str "`texthl` for sign."; - linehl = helpers.mkNullOrOption types.str "`linehl` for sign."; - numhl = helpers.mkNullOrOption types.str "`numhl` for sign."; + text = lib.nixvim.defaultNullOpts.mkStr default desc; + texthl = mkNullOrOption types.str "`texthl` for sign."; + linehl = mkNullOrOption types.str "`linehl` for sign."; + numhl = mkNullOrOption types.str "`numhl` for sign."; }; processAdapters = type: adapters: - with builtins; - mapAttrs ( + lib.mapAttrs ( _: adapter: - if isString adapter then - helpers.mkRaw adapter + if builtins.isString adapter then + lib.nixvim.mkRaw adapter else - filterAttrs (n: _: n != "enrichConfig") ( + lib.filterAttrs (n: _: n != "enrichConfig") ( adapter // { inherit type; diff --git a/plugins/by-name/dap/default.nix b/plugins/by-name/dap/default.nix index b77a3b63..ca267c96 100644 --- a/plugins/by-name/dap/default.nix +++ b/plugins/by-name/dap/default.nix @@ -1,23 +1,21 @@ { lib, - helpers, config, pkgs, ... }: let inherit (lib) - mkAdapterOption mkEnableOption mkOption - mkSignOption optionalString types ; cfg = config.plugins.dap; - dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; + dapHelpers = import ./dapHelpers.nix { inherit lib; }; + inherit (dapHelpers) mkSignOption; in { imports = [ @@ -37,18 +35,18 @@ in ]; }; - adapters = helpers.mkCompositeOption "Dap adapters." { - executables = mkAdapterOption "executable" dapHelpers.executableAdapterOption; - servers = mkAdapterOption "server" dapHelpers.serverAdapterOption; + adapters = lib.nixvim.mkCompositeOption "Dap adapters." { + executables = dapHelpers.mkAdapterOption "executable" dapHelpers.executableAdapterOption; + servers = dapHelpers.mkAdapterOption "server" dapHelpers.serverAdapterOption; }; configurations = - helpers.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption)) + lib.nixvim.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption)) '' Debuggee configurations, see `:h dap-configuration` for more info. ''; - signs = helpers.mkCompositeOption "Signs for dap." { + signs = lib.nixvim.mkCompositeOption "Signs for dap." { dapBreakpoint = mkSignOption "B" "Sign for breakpoints."; dapBreakpointCondition = mkSignOption "C" "Sign for conditional breakpoints."; @@ -79,9 +77,11 @@ in adapters = (lib.optionalAttrs (adapters.executables != null) ( - processAdapters "executable" adapters.executables + dapHelpers.processAdapters "executable" adapters.executables )) - // (lib.optionalAttrs (adapters.servers != null) (processAdapters "server" adapters.servers)); + // (lib.optionalAttrs (adapters.servers != null) ( + dapHelpers.processAdapters "server" adapters.servers + )); signs = with signs; { DapBreakpoint = dapBreakpoint;