add tree.lua nvim

This commit is contained in:
vincent 2021-11-15 20:55:41 +01:00
parent 2ed375d0c2
commit 43d77841b3
2 changed files with 17 additions and 0 deletions

View File

@ -66,6 +66,7 @@ nnoremap <C-n> :NvimTreeToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
nnoremap <leader>n :NvimTreeFindFile<CR>
nnoremap <silent> <C-s> :BufferPick<CR>
noremap <silent> <C-n> :lua require'tree'.toggle()<CR>
lua require('init')
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %

View File

@ -0,0 +1,16 @@
local tree ={}
local g = vim.g
-- Explicitly set the nvim tree width
g.nvim_tree_width = 30
local tree_width = g.nvim_tree_width
tree.toggle = function()
require('nvim-tree').toggle()
if require('nvim-tree.view').win_open() then
require('bufferline.state').set_offset(tree_width + 1, 'FileTree')
require('nvim-tree').find_file(true)
else
require('bufferline.state').set_offset(0)
end
end
return tree