diff --git a/plugins/filetrees/nvim-tree.nix b/plugins/filetrees/nvim-tree.nix index f09f6148..bc92a739 100644 --- a/plugins/filetrees/nvim-tree.nix +++ b/plugins/filetrees/nvim-tree.nix @@ -48,6 +48,20 @@ in { (optionWarnings.mkDeprecatedOption { option = basePluginPath ++ ["removeKeymaps"]; alternative = basePluginPath ++ ["onAttach"]; + message = '' + Mappings can now be customized from the `onAttach` function. + Learn more at `:help nvim-tree-mappings-legacy`. + ''; + }) + # Deprecate warning added 2023-04-24 + # TODO Remove both this warning and the one above (removeKeymaps) in ~1 month (June). + (optionWarnings.mkDeprecatedOption { + option = basePluginPath ++ ["view" "mappings"]; + alternative = basePluginPath ++ ["onAttach"]; + message = '' + Mappings can now be customized from the `onAttach` function. + Learn more at `:help nvim-tree-mappings-legacy`. + ''; }) ]; @@ -373,7 +387,7 @@ in { Necessary when using a UI prompt decorator such as dressing.nvim or telescope-ui-select.nvim. ''; - view = helpers.mkCompositeOption "Window / buffer setup." { + view = { centralizeSelection = helpers.defaultNullOpts.mkBool false '' When entering nvim-tree, reposition the view so that the current node is initially centralized, see |zz|. @@ -1036,43 +1050,42 @@ in { on_attach = onAttach; remove_keymaps = removeKeymaps; select_prompts = selectPrompts; - view = with view; - ifNonNull' cfg.view { - centralize_selection = centralizeSelection; - inherit cursorline; - debounce_delay = debounceDelay; - hide_root_folder = hideRootFolder; - inherit width; - inherit side; - preserve_window_proportions = preserveWindowProportions; - inherit number; - inherit relativenumber; - inherit signcolumn; - mappings = with mappings; - ifNonNull' cfg.view.mappings { - custom_only = customOnly; - list = - if list == null - then null - else - map ( - mapping: { - inherit (mapping) key action mode; - action_cb = - if (mapping.action_cb == null) - then null - else helpers.mkRaw mapping.action_cb; - } - ) - list; - }; - float = with float; - ifNonNull' cfg.view.float { - inherit enable; - quit_on_focus_loss = quitOnFocusLoss; - open_win_config = openWinConfig; - }; - }; + view = with view; { + centralize_selection = centralizeSelection; + inherit cursorline; + debounce_delay = debounceDelay; + hide_root_folder = hideRootFolder; + inherit width; + inherit side; + preserve_window_proportions = preserveWindowProportions; + inherit number; + inherit relativenumber; + inherit signcolumn; + mappings = with mappings; + ifNonNull' cfg.view.mappings { + custom_only = customOnly; + list = + if list == null + then null + else + map ( + mapping: { + inherit (mapping) key action mode; + action_cb = + if (mapping.action_cb == null) + then null + else helpers.mkRaw mapping.action_cb; + } + ) + list; + }; + float = with float; + ifNonNull' cfg.view.float { + inherit enable; + quit_on_focus_loss = quitOnFocusLoss; + open_win_config = openWinConfig; + }; + }; renderer = with renderer; ifNonNull' cfg.renderer { add_trailing = addTrailing; diff --git a/tests/test-sources/plugins/filetrees/nvim-tree.nix b/tests/test-sources/plugins/filetrees/nvim-tree.nix index 211df242..971bf9e7 100644 --- a/tests/test-sources/plugins/filetrees/nvim-tree.nix +++ b/tests/test-sources/plugins/filetrees/nvim-tree.nix @@ -90,34 +90,6 @@ number = false; relativenumber = false; signcolumn = "yes"; - mappings = { - customOnly = false; - list = [ - # remove a default mapping for cd - { - key = "<2-RightMouse>"; - action = ""; - } - - # add multiple normal mode mappings for edit - { - key = ["" "o"]; - action = "edit"; - mode = "n"; - } - - # custom action - { - key = "p"; - action = "print_the_node_path"; - action_cb = '' - function(node) - print(node.absolute_path) - end - ''; - } - ]; - }; float = { enable = false; quitOnFocusLoss = true;