fix tree when option is 'right'
This commit is contained in:
parent
7483abcf40
commit
03168a5155
@ -35,9 +35,8 @@ end
|
||||
local BUF_OPTIONS = {
|
||||
'nowrap', 'sidescroll=5', 'nospell', 'nolist', 'nofoldenable',
|
||||
'foldmethod=manual', 'foldcolumn=0', 'nonumber', 'norelativenumber',
|
||||
'winfixwidth', 'winfixheight', 'noswapfile', 'bufhidden=wipe',
|
||||
'splitbelow', 'splitright', 'winhighlight=EndOfBuffer:LuaTreeEndOfBuffer',
|
||||
'noshowmode', 'noruler', 'noshowcmd',
|
||||
'winfixwidth', 'winfixheight', 'noswapfile', 'splitbelow', 'noruler',
|
||||
'noshowmode', 'noshowcmd'
|
||||
}
|
||||
|
||||
local WIN_WIDTH = 30
|
||||
@ -55,7 +54,7 @@ end
|
||||
|
||||
local function open()
|
||||
local options = {
|
||||
bufhidden = 'delete';
|
||||
bufhidden = 'wipe';
|
||||
buftype = 'nowrite';
|
||||
modifiable = false;
|
||||
}
|
||||
@ -71,9 +70,16 @@ local function open()
|
||||
api.nvim_command('wincmd '..SIDE)
|
||||
api.nvim_command('vertical resize '..WIN_WIDTH)
|
||||
api.nvim_win_set_buf(0, buf)
|
||||
|
||||
api.nvim_command('setlocal winhighlight=EndOfBuffer:LuaTreeEndOfBuffer')
|
||||
for _, opt in pairs(BUF_OPTIONS) do
|
||||
api.nvim_command('setlocal '..opt)
|
||||
end
|
||||
if SIDE == 'L' then
|
||||
api.nvim_command('setlocal nosplitright')
|
||||
else
|
||||
api.nvim_command('setlocal splitright')
|
||||
end
|
||||
end
|
||||
|
||||
local function replace_tree()
|
||||
|
||||
11
lua/tree.lua
11
lua/tree.lua
@ -45,6 +45,13 @@ local function toggle()
|
||||
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 tree_index = api.nvim_win_get_cursor(0)[1]
|
||||
local tree = get_tree()
|
||||
@ -85,7 +92,7 @@ local function open_file(open_type)
|
||||
init_tree(new_path)
|
||||
update_view()
|
||||
else
|
||||
api.nvim_command('wincmd l | '..open_type..' '.. node.linkto)
|
||||
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.linkto)
|
||||
end
|
||||
|
||||
elseif node.dir == true then
|
||||
@ -94,7 +101,7 @@ local function open_file(open_type)
|
||||
update_view(true)
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -12,6 +12,10 @@ au BufWritePost * lua require'tree'.refresh()
|
||||
au BufEnter * lua require'tree'.check_windows_and_close()
|
||||
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
|
||||
au BufEnter * :LuaTreeFindFile
|
||||
endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user