fix tree when option is 'right'
This commit is contained in:
parent
7483abcf40
commit
03168a5155
@ -35,9 +35,8 @@ end
|
|||||||
local BUF_OPTIONS = {
|
local BUF_OPTIONS = {
|
||||||
'nowrap', 'sidescroll=5', 'nospell', 'nolist', 'nofoldenable',
|
'nowrap', 'sidescroll=5', 'nospell', 'nolist', 'nofoldenable',
|
||||||
'foldmethod=manual', 'foldcolumn=0', 'nonumber', 'norelativenumber',
|
'foldmethod=manual', 'foldcolumn=0', 'nonumber', 'norelativenumber',
|
||||||
'winfixwidth', 'winfixheight', 'noswapfile', 'bufhidden=wipe',
|
'winfixwidth', 'winfixheight', 'noswapfile', 'splitbelow', 'noruler',
|
||||||
'splitbelow', 'splitright', 'winhighlight=EndOfBuffer:LuaTreeEndOfBuffer',
|
'noshowmode', 'noshowcmd'
|
||||||
'noshowmode', 'noruler', 'noshowcmd',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local WIN_WIDTH = 30
|
local WIN_WIDTH = 30
|
||||||
@ -55,7 +54,7 @@ end
|
|||||||
|
|
||||||
local function open()
|
local function open()
|
||||||
local options = {
|
local options = {
|
||||||
bufhidden = 'delete';
|
bufhidden = 'wipe';
|
||||||
buftype = 'nowrite';
|
buftype = 'nowrite';
|
||||||
modifiable = false;
|
modifiable = false;
|
||||||
}
|
}
|
||||||
@ -71,9 +70,16 @@ local function open()
|
|||||||
api.nvim_command('wincmd '..SIDE)
|
api.nvim_command('wincmd '..SIDE)
|
||||||
api.nvim_command('vertical resize '..WIN_WIDTH)
|
api.nvim_command('vertical resize '..WIN_WIDTH)
|
||||||
api.nvim_win_set_buf(0, buf)
|
api.nvim_win_set_buf(0, buf)
|
||||||
|
|
||||||
|
api.nvim_command('setlocal winhighlight=EndOfBuffer:LuaTreeEndOfBuffer')
|
||||||
for _, opt in pairs(BUF_OPTIONS) do
|
for _, opt in pairs(BUF_OPTIONS) do
|
||||||
api.nvim_command('setlocal '..opt)
|
api.nvim_command('setlocal '..opt)
|
||||||
end
|
end
|
||||||
|
if SIDE == 'L' then
|
||||||
|
api.nvim_command('setlocal nosplitright')
|
||||||
|
else
|
||||||
|
api.nvim_command('setlocal splitright')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function replace_tree()
|
local function replace_tree()
|
||||||
|
|||||||
11
lua/tree.lua
11
lua/tree.lua
@ -45,6 +45,13 @@ local function toggle()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local MOVE_TO = 'l'
|
||||||
|
if api.nvim_call_function('exists', { 'g:lua_tree_side' }) == 1 then
|
||||||
|
if api.nvim_get_var('lua_tree_side') == 'right' then
|
||||||
|
MOVE_TO = 'h'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function open_file(open_type)
|
local function open_file(open_type)
|
||||||
local tree_index = api.nvim_win_get_cursor(0)[1]
|
local tree_index = api.nvim_win_get_cursor(0)[1]
|
||||||
local tree = get_tree()
|
local tree = get_tree()
|
||||||
@ -85,7 +92,7 @@ local function open_file(open_type)
|
|||||||
init_tree(new_path)
|
init_tree(new_path)
|
||||||
update_view()
|
update_view()
|
||||||
else
|
else
|
||||||
api.nvim_command('wincmd l | '..open_type..' '.. node.linkto)
|
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.linkto)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif node.dir == true then
|
elseif node.dir == true then
|
||||||
@ -94,7 +101,7 @@ local function open_file(open_type)
|
|||||||
update_view(true)
|
update_view(true)
|
||||||
|
|
||||||
else
|
else
|
||||||
api.nvim_command('wincmd l | '..open_type..' '.. node.path .. node.name)
|
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.path .. node.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,10 @@ au BufWritePost * lua require'tree'.refresh()
|
|||||||
au BufEnter * lua require'tree'.check_windows_and_close()
|
au BufEnter * lua require'tree'.check_windows_and_close()
|
||||||
au VimEnter * lua require'tree'.check_buffer_and_open()
|
au VimEnter * lua require'tree'.check_buffer_and_open()
|
||||||
|
|
||||||
|
" TODO set status line dynamically on bufenter in the luatree
|
||||||
|
" to remove lightline and other possible components
|
||||||
|
au BufEnter LuaTree setlocal statusline=""
|
||||||
|
|
||||||
if get(g:, 'lua_tree_follow') != 0
|
if get(g:, 'lua_tree_follow') != 0
|
||||||
au BufEnter * :LuaTreeFindFile
|
au BufEnter * :LuaTreeFindFile
|
||||||
endif
|
endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user