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
|
- [x] Mouse support
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- handle permissions properly (display error on Read access denied)
|
- 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 left)
|
- fix all window problems (force size to stay always the same and keep it on the side)
|
||||||
- kill window when its the last one (BufLeave)
|
- add options for users
|
||||||
- open automatically when opening neovim with `nvim` or `nvim .`
|
|
||||||
- cd command to move faster accross the fs if needed
|
- cd command to move faster accross the fs if needed
|
||||||
- quickly find file in the directory structure
|
- quickly find file in the directory structure
|
||||||
- use libuv functions instead of `touch` and `mkdir` in `add_file()`
|
- 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
|
||||||
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 {
|
return {
|
||||||
toggle = toggle;
|
toggle = toggle;
|
||||||
open_file = open_file;
|
open_file = open_file;
|
||||||
edit_file = edit_file;
|
edit_file = edit_file;
|
||||||
refresh = refresh;
|
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
|
set cpo&vim
|
||||||
|
|
||||||
let g:loaded_netrw = 1
|
let g:loaded_netrw = 1
|
||||||
let g:loaded_netrwPlugin = 1 " Disable netrw
|
let g:loaded_netrwPlugin = 1
|
||||||
|
|
||||||
hi def link LuaTreePopup Normal
|
hi def link LuaTreePopup Normal
|
||||||
|
|
||||||
au BufWritePost * lua require'tree'.refresh()
|
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()
|
command! LuaTree lua require'tree'.toggle()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user