From 8f8db2de106c78fe9ff73006d7da9bc3c8032a0e Mon Sep 17 00:00:00 2001 From: newbie Date: Wed, 22 Nov 2023 23:19:24 +0800 Subject: [PATCH] update' --- init.lua | 2 ++ lua/G.lua | 20 +++++++++++++++++++- lua/plugs.lua | 1 + lua/plugs/nvimtree.lua | 27 ++++++++++++++++++--------- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 49c72a9..8dd9dbd 100644 --- a/init.lua +++ b/init.lua @@ -23,6 +23,7 @@ if not G.loop.fs_stat(lazypath) then end + G.opt.rtp:prepend(lazypath) require("keymap") @@ -32,6 +33,7 @@ if G.g.vscode then else require("options") require("lazy").setup(require('plugs')) +require("lazy").lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json" end diff --git a/lua/G.lua b/lua/G.lua index 2615c00..c878293 100644 --- a/lua/G.lua +++ b/lua/G.lua @@ -13,11 +13,29 @@ G.cgp = vim.nvim_create_augroup function G.map(maps) for _,map in pairs(maps) do - vim.keymap.set(map[1], map[2], map[3], map[4]) + if #map == 3 then + vim.keymap.set(map[1], map[2], map[3], {noremap = true}) + elseif #map == 4 then + vim.keymap.set(map[1], map[2], map[3], map[4]) + else + print("太多变量了") + end --G.api.nvim_set_keymap(map[1], map[2], map[3], map[4]) end end +function G.delmap(maps) + for _,map in pairs(maps) do + if #map == 2 then + vim.keymap.del(map[1], map[2], {}) + elseif #map == 3 then + vim.keymap.del(map[1], map[2], map[3]) + else + print("太多变量了") + end + end +end + function G.cmd(cmd) G.api.nvim_command(cmd) end diff --git a/lua/plugs.lua b/lua/plugs.lua index 242babd..c8bc787 100644 --- a/lua/plugs.lua +++ b/lua/plugs.lua @@ -1,3 +1,4 @@ + return { 'github/copilot.vim', -- github copilot diff --git a/lua/plugs/nvimtree.lua b/lua/plugs/nvimtree.lua index 09080b9..880b3b3 100644 --- a/lua/plugs/nvimtree.lua +++ b/lua/plugs/nvimtree.lua @@ -1,22 +1,31 @@ return { 'kyazdani42/nvim-web-devicons', { - 'https://git.qyhhh.top/newbieQQ/nvim-tree.lua', + "nvim-tree/nvim-tree.lua", config = function () - G.map({ - {"n", "", ":NvimTreeToggle", {noremap = true}}, - }) + require'nvim-tree'.setup { sort_by = "case_sensitive", - view = { width = 30, }, + view = { + width = 30, + }, filters = { dotfiles = true, }, git = { enable = true }, --- on_attach = my_on_attach, + on_attach = function (bufnr) + local api = require'nvim-tree.api' + api.config.mappings.default_on_attach(bufnr) + + -- override a default + G.delmap({ + {'n', '', { buffer = bufnr }}, + }) + + end } - + G.map({ + {"n", "", ":NvimTreeToggle", { noremap = true }}, + }) end - } - }