Control how files are being opened
This commit is contained in:
parent
b199763856
commit
41b050a6ab
15
README.md
15
README.md
@ -69,19 +69,10 @@ nnoremap <leader>n :LuaTreeFindFile<CR>
|
||||
## TODO
|
||||
|
||||
### Perf / Fixes
|
||||
- Tree creation should be async
|
||||
- Tree creation could be async
|
||||
- refactor all `system` call to `libuv` functions, with better error management
|
||||
- bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open
|
||||
|
||||
### Features
|
||||
- sneak like cd command to find a file/directory
|
||||
- better default colors (use default vim groups)
|
||||
- better default colors (use vim highlight groups)
|
||||
- create proper highlight groups or add highlight function to give the user ability to setup colors themselves
|
||||
|
||||
### Window Feature / Fixes
|
||||
- opening help should open on the bottom
|
||||
- better window management:
|
||||
- check tree buffer/window for change so we can avoid it being resized or moved around or replaced by another file
|
||||
- monitor window layout in current tab to open files in the right place
|
||||
> this might be a little hard to implement since window layout events do not exist yet
|
||||
|
||||
- bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open
|
||||
|
||||
16
lua/tree.lua
16
lua/tree.lua
@ -53,6 +53,17 @@ if api.nvim_call_function('exists', { 'g:lua_tree_side' }) == 1 then
|
||||
end
|
||||
end
|
||||
|
||||
local function create_new_buf(open_type, bufname)
|
||||
if open_type == 'edit' or open_type == 'split' then
|
||||
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '..bufname)
|
||||
elseif open_type == 'vsplit' then
|
||||
local windows = api.nvim_list_wins();
|
||||
api.nvim_command(#windows..'wincmd '..MOVE_TO..' | vsplit '..bufname)
|
||||
elseif open_type == 'tabnew' then
|
||||
api.nvim_command('tabnew '..bufname)
|
||||
end
|
||||
end
|
||||
|
||||
local function open_file(open_type)
|
||||
local tree_index = api.nvim_win_get_cursor(0)[1]
|
||||
local tree = get_tree()
|
||||
@ -93,16 +104,15 @@ local function open_file(open_type)
|
||||
init_tree(new_path)
|
||||
update_view()
|
||||
else
|
||||
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.linkto)
|
||||
create_new_buf(open_type, node.link_to);
|
||||
end
|
||||
|
||||
elseif node.dir == true then
|
||||
if check_dir_access(node.path .. node.name) == false then return end
|
||||
open_dir(tree_index)
|
||||
update_view(true)
|
||||
|
||||
else
|
||||
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.path .. node.name)
|
||||
create_new_buf(open_type, node.path .. node.name);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user