quit when tree is last buf, open on enter if dir or no file
This commit is contained in:
parent
f397e1050c
commit
6670b8e494
@ -17,10 +17,9 @@
|
||||
- [x] Mouse support
|
||||
|
||||
## TODO
|
||||
- handle permissions properly (display error on Read access denied)
|
||||
- fix all window problems (force size to stay always the same and keep it on the left)
|
||||
- kill window when its the last one (BufLeave)
|
||||
- open automatically when opening neovim with `nvim` or `nvim .`
|
||||
- display error on Read access denied (and better handling of errors if any)
|
||||
- fix all window problems (force size to stay always the same and keep it on the side)
|
||||
- add options for users
|
||||
- cd command to move faster accross the fs if needed
|
||||
- quickly find file in the directory structure
|
||||
- use libuv functions instead of `touch` and `mkdir` in `add_file()`
|
||||
|
||||
16
lua/tree.lua
16
lua/tree.lua
@ -119,10 +119,26 @@ local function refresh()
|
||||
end
|
||||
end
|
||||
|
||||
local function check_windows_and_close()
|
||||
local wins = api.nvim_list_wins()
|
||||
|
||||
if #wins == 1 and is_win_open() then
|
||||
-- TODO: find why it hangs
|
||||
api.nvim_command('q!')
|
||||
end
|
||||
end
|
||||
|
||||
local function check_buffer_and_open()
|
||||
local bufname = api.nvim_buf_get_name(0)
|
||||
if bufname == '' or is_dir(bufname) then toggle() end
|
||||
end
|
||||
|
||||
return {
|
||||
toggle = toggle;
|
||||
open_file = open_file;
|
||||
edit_file = edit_file;
|
||||
refresh = refresh;
|
||||
check_windows_and_close = check_windows_and_close;
|
||||
check_buffer_and_open = check_buffer_and_open;
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,13 @@ let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1 " Disable netrw
|
||||
let g:loaded_netrwPlugin = 1
|
||||
|
||||
hi def link LuaTreePopup Normal
|
||||
|
||||
au BufWritePost * lua require'tree'.refresh()
|
||||
au BufEnter * lua require'tree'.check_windows_and_close()
|
||||
au VimEnter * lua require'tree'.check_buffer_and_open()
|
||||
|
||||
command! LuaTree lua require'tree'.toggle()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user