added nvim-tree and setup keymap to toggle file-browser

This commit is contained in:
Micah Effiong 2023-06-08 01:03:05 +01:00
parent 564a16e7ab
commit 71074dd171
4 changed files with 61 additions and 1 deletions

View File

@ -41,6 +41,13 @@ P.S. You can delete this when you're done too. It's your config now :)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- disable netrw at the very start of your init.lua
-- needed for nvim-tree
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- vim.o.guifont = 'Inconsolata LGC Nerd Font'
-- Install package manager
-- https://github.com/folke/lazy.nvim
-- `:help lazy.nvim.txt` for more info
@ -513,7 +520,7 @@ cmp.setup {
}
-- custom settings
pcall(require('custom.options'))
pcall(require('custom'))
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et

2
lua/custom/init.lua Normal file
View File

@ -0,0 +1,2 @@
require 'custom.keymaps'
require 'custom.options'

View File

@ -0,0 +1,12 @@
-- toggle nvim tree
vim.keymap.set(
'n',
'<C-b>',
require('nvim-tree.api').tree.toggle,
{
desc = 'nvim-tree: Toggle tree',
noremap = true,
silent = true,
nowait = true
}
)

View File

@ -0,0 +1,39 @@
-- NVIM tree
-- a file explore plugin
local function on_nvim_tree_attach(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
-- vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
-- vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
vim.keymap.set('n', '<C-b>', api.tree.toggle, opts('Toggle tree'))
end
return {
"nvim-tree/nvim-tree.lua",
version = "*",
--
-- after = "nvim-web-devicons",
-- requires = "nvim-tree/nvim-web-devicons",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("nvim-tree").setup {
update_cwd = true,
update_focused_file = {
enable = true
},
respect_buf_cwd = true,
on_attach = on_nvim_tree_attach,
}
end,
}