Skip to content

chore: remove legacy view.mappings.list #2371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ Take a look at the [wiki](https://github.com/nvim-tree/nvim-tree.lua/wiki) for S

Community support: [matrix](https://matrix.to/#/#nvim-tree:matrix.org)

## New Mapping Method 2023-02-27

[:help nvim-tree.view.mappings](doc/nvim-tree-lua.txt) have been deprecated in favour of [:help nvim-tree.on_attach](doc/nvim-tree-lua.txt). Please visit [Migrating To on_attach](https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach) to transition.

## Requirements

[neovim >=0.8.0](https://github.com/neovim/neovim/wiki/Installing-Neovim)
Expand Down
105 changes: 0 additions & 105 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ CONTENTS *nvim-tree*
5.9 API Commands |nvim-tree-api.commands|
6. Mappings |nvim-tree-mappings|
6.1 Default Mappings |nvim-tree-mappings-default|
6.2 Legacy Mappings |nvim-tree-mappings-legacy|
7. Highlight Groups |nvim-tree-highlight|
8. Events |nvim-tree-events|
9. Bookmarks |nvim-tree-bookmarks|
Expand Down Expand Up @@ -285,14 +284,6 @@ Show the mappings: `g?`

Calls: `api.tree.collapse_all(true)`

*:NvimTreeGenerateOnAttach*

Creates and opens a new file `nvim-tree-on-attach.lua` in |stdpath| `"cache"`,
usually `$XDG_CACHE_HOME/nvim`. Contains |nvim-tree.on_attach| function based
on your |nvim-tree.view.mappings|, |nvim-tree.remove_keymaps| as well as the
defaults.
See https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach

==============================================================================
4. SETUP *nvim-tree-setup*

Expand Down Expand Up @@ -324,7 +315,6 @@ applying configuration.
reload_on_bufenter = false,
respect_buf_cwd = false,
on_attach = "default",
remove_keymaps = false,
select_prompts = false,
view = {
centralize_selection = false,
Expand All @@ -337,12 +327,6 @@ applying configuration.
number = false,
relativenumber = false,
signcolumn = "yes",
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
float = {
enable = false,
quit_on_focus_loss = true,
Expand Down Expand Up @@ -816,15 +800,6 @@ specific mappings. See |nvim-tree-mappings|.
When on_attach is not a function, |nvim-tree-mappings-default| will be called.
Type: `function(bufnr) | string`, Default: `"default"`

*nvim-tree.remove_keymaps*
Deprecated: please see |nvim-tree-mappings-legacy|
This can be used to remove the default mappings in the tree.
- Remove specific keys by passing a `string` table of keys
eg. {"<C-o>", "<CR>", "o", "<Tab>"}
- Remove all default mappings by passing `true`
- Ignore by passing `false`
Type: `bool` or `{string}`, Default: `false`

*nvim-tree.select_prompts*
Use |vim.ui.select| style prompts. Necessary when using a UI prompt decorator
such as dressing.nvim or telescope-ui-select.nvim
Expand Down Expand Up @@ -894,20 +869,6 @@ Window / buffer setup.
Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`.
Type: `string`, Default: `"yes"`

*nvim-tree.view.mappings*
Deprecated: please see |nvim-tree-mappings-legacy|

*nvim-tree.view.mappings.custom_only*
Will use only the provided user mappings and not the default otherwise,
extends the default mappings with the provided user mappings.
Overrides |nvim-tree.remove_keymaps|
Type: `boolean`, Default: `false`

*nvim-tree.view.mappings.list*
A list of keymaps that will extend or override the default keymaps.
Type: `table`
Default: see |nvim-tree-mappings-legacy|

*nvim-tree.view.float*
Configuration options for floating window

Expand Down Expand Up @@ -1827,21 +1788,6 @@ config.mappings.default_on_attach({bufnr})
Parameters: ~
• {bufnr} (number) nvim-tree buffer number passed to |nvim-tree.on_attach|

config.mappings.active() *nvim-tree-api.config.mappings.active()*
Deprecated: only functions when using legacy |nvim-tree.view.mappings|
Retrieve a clone of the currently active mappings: defaults + user.
Changing the active mappings will require a call to |nvim-tree-setup|

Return: ~
(table) as per |nvim-tree.view.mappings.list|

config.mappings.default() *nvim-tree-api.config.mappings.default()*
Deprecated: only functions when using legacy |nvim-tree.view.mappings|
Retrieve a clone of the default mappings.

Return: ~
(table) as per |nvim-tree.view.mappings.list|

*nvim-tree-api.config.mappings.get_keymap()*
config.mappings.get_keymap()
Retrieves all buffer local mappings for nvim-tree.
Expand Down Expand Up @@ -2019,57 +1965,6 @@ Alternatively, you may apply these default mappings from your |nvim-tree.on_atta
-- your removals and mappings go here
end
<
==============================================================================
6.2 LEGACY MAPPINGS *nvim-tree-mappings-legacy*

nvim-tree mappings were provided via the deprecated |nvim-tree.view.mappings|
and |nvim-tree.remove_keymaps|

These are ignored when |nvim-tree.on_attach| is present.

You are encouraged to migrate you existing legacy mappings to
|nvim-tree.on_attach| using |:NvimTreeGenerateOnAttach|

Please visit https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach

`view.mappings.list` is a table of:
{key} (string|table of string) mandatory |{lhs}|.

{action} (string) mandatory name of the action.
`""` to remove an action with {key}. The case of {key} must
exactly match the action you are removing e.g. `'<Tab>'` to
remove the default preview action.
An arbitrary description when using `action_cb`.

{action_cb} (function) optional custom function that will be called.
Receives the node as a parameter.
Non-empty description for `action` is required.

{mode} (string) optional mode as per |nvim_set_keymap|.
Default `'n'`.

Examples:
>
local function print_node_path(node)
print(node.absolute_path)
end

----

view = {
mappings = {
list = {
-- remove a default mapping for cd
{ key = "<2-RightMouse>", action = "" },

-- add multiple normal mode mappings for edit
{ key = { "<CR>", "o" }, action = "edit", mode = "n" },

-- custom action
{ key = "p", action = "print_the_node_path", action_cb = print_node_path },

----
<
==============================================================================
7. HIGHLIGHT GROUPS *nvim-tree-highlight*

Expand Down
11 changes: 0 additions & 11 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ local reloaders = require "nvim-tree.actions.reloaders.reloaders"
local git = require "nvim-tree.git"
local filters = require "nvim-tree.explorer.filters"
local modified = require "nvim-tree.modified"
local keymap_legacy = require "nvim-tree.keymap-legacy"
local find_file = require "nvim-tree.actions.tree.find-file"
local open = require "nvim-tree.actions.tree.open"
local events = require "nvim-tree.events"
Expand Down Expand Up @@ -380,7 +379,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
reload_on_bufenter = false,
respect_buf_cwd = false,
on_attach = "default",
remove_keymaps = false,
select_prompts = false,
view = {
centralize_selection = false,
Expand All @@ -393,12 +391,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
number = false,
relativenumber = false,
signcolumn = "yes",
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
float = {
enable = false,
quit_on_focus_loss = true,
Expand Down Expand Up @@ -619,7 +611,6 @@ local FIELD_OVERRIDE_TYPECHECK = {
width = { string = true, ["function"] = true, number = true, ["table"] = true },
max = { string = true, ["function"] = true, number = true },
min = { string = true, ["function"] = true, number = true },
remove_keymaps = { boolean = true, table = true },
on_attach = { ["function"] = true, string = true },
sorter = { ["function"] = true, string = true },
root_folder_label = { ["function"] = true, string = true, boolean = true },
Expand Down Expand Up @@ -721,8 +712,6 @@ function M.setup(conf)
log.raw("config", "%s\n", vim.inspect(opts))
end

keymap_legacy.generate_legacy_on_attach(opts)

require("nvim-tree.actions").setup(opts)
require("nvim-tree.keymap").setup(opts)
require("nvim-tree.colors").setup()
Expand Down
10 changes: 0 additions & 10 deletions lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,6 @@ Api.marks.navigate.select = wrap(require("nvim-tree.marks.navigation").select)

Api.config.mappings.default_on_attach = require("nvim-tree.keymap").default_on_attach

Api.config.mappings.active = wrap(function()
notify.warn "api.config.mappings.active is deprecated in favor of config.mappings.get_keymap"
return require("nvim-tree.keymap-legacy").active_mappings_clone()
end)

Api.config.mappings.default = function()
notify.warn "api.config.mappings.default is deprecated in favor of config.mappings.get_keymap_default"
return require("nvim-tree.keymap-legacy").default_mappings_clone()
end

Api.config.mappings.get_keymap = wrap(function()
return require("nvim-tree.keymap").get_keymap()
end)
Expand Down
10 changes: 0 additions & 10 deletions lua/nvim-tree/commands.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local keymap_legacy = require "nvim-tree.keymap-legacy"
local api = require "nvim-tree.api"
local view = require "nvim-tree.view"

Expand Down Expand Up @@ -121,15 +120,6 @@ local CMDS = {
api.tree.collapse_all(true)
end,
},
{
name = "NvimTreeGenerateOnAttach",
opts = {
desc = "nvim-tree: generate on_attach function from deprecated view.mappings",
},
command = function()
keymap_legacy.cmd_generate_on_attach()
end,
},
}

function M.get()
Expand Down
11 changes: 0 additions & 11 deletions lua/nvim-tree/config.lua

This file was deleted.

Loading