feat(api): add api.config.mappings.default_on_attach (#2037)
This commit is contained in:
committed by
GitHub
parent
1b453441f4
commit
bbb6d48910
@@ -170,6 +170,8 @@ Api.marks.navigate.next = require("nvim-tree.marks.navigation").next
|
||||
Api.marks.navigate.prev = require("nvim-tree.marks.navigation").prev
|
||||
Api.marks.navigate.select = require("nvim-tree.marks.navigation").select
|
||||
|
||||
Api.config.mappings.default_on_attach = require("nvim-tree.keymap").default_on_attach
|
||||
|
||||
Api.config.mappings.active = function()
|
||||
return require("nvim-tree.keymap-legacy").active_mappings_clone()
|
||||
end
|
||||
|
||||
@@ -37,11 +37,10 @@ local BEGIN_ON_ATTACH = [[
|
||||
-- Please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach for assistance in migrating.
|
||||
--
|
||||
|
||||
local api = require('nvim-tree.api')
|
||||
local function on_attach(bufnr)
|
||||
local api = require('nvim-tree.api')
|
||||
|
||||
local on_attach = function(bufnr)
|
||||
|
||||
local opts = function(desc)
|
||||
local function opts(desc)
|
||||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||
end
|
||||
]]
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
local api = require "nvim-tree.api"
|
||||
|
||||
local M = {}
|
||||
|
||||
-- stylua: ignore start
|
||||
function M.default_on_attach(bufnr)
|
||||
-- BEGIN_DEFAULT_ON_ATTACH
|
||||
local opts = function(desc)
|
||||
local api = require('nvim-tree.api')
|
||||
|
||||
local function opts(desc)
|
||||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||
end
|
||||
|
||||
-- BEGIN_DEFAULT_ON_ATTACH
|
||||
vim.keymap.set('n', '<C-]>', api.tree.change_root_to_node, opts('CD'))
|
||||
vim.keymap.set('n', '<C-e>', api.node.open.replace_tree_buffer, opts('Open: In Place'))
|
||||
vim.keymap.set('n', '<C-k>', api.node.show_info_popup, opts('Info'))
|
||||
|
||||
Reference in New Issue
Block a user