Skip to content

Commit 03168a5

Browse files
committed
fix tree when option is 'right'
1 parent 7483abc commit 03168a5

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

lua/lib/winutils.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ end
3535
local BUF_OPTIONS = {
3636
'nowrap', 'sidescroll=5', 'nospell', 'nolist', 'nofoldenable',
3737
'foldmethod=manual', 'foldcolumn=0', 'nonumber', 'norelativenumber',
38-
'winfixwidth', 'winfixheight', 'noswapfile', 'bufhidden=wipe',
39-
'splitbelow', 'splitright', 'winhighlight=EndOfBuffer:LuaTreeEndOfBuffer',
40-
'noshowmode', 'noruler', 'noshowcmd',
38+
'winfixwidth', 'winfixheight', 'noswapfile', 'splitbelow', 'noruler',
39+
'noshowmode', 'noshowcmd'
4140
}
4241

4342
local WIN_WIDTH = 30
@@ -55,7 +54,7 @@ end
5554

5655
local function open()
5756
local options = {
58-
bufhidden = 'delete';
57+
bufhidden = 'wipe';
5958
buftype = 'nowrite';
6059
modifiable = false;
6160
}
@@ -71,9 +70,16 @@ local function open()
7170
api.nvim_command('wincmd '..SIDE)
7271
api.nvim_command('vertical resize '..WIN_WIDTH)
7372
api.nvim_win_set_buf(0, buf)
73+
74+
api.nvim_command('setlocal winhighlight=EndOfBuffer:LuaTreeEndOfBuffer')
7475
for _, opt in pairs(BUF_OPTIONS) do
7576
api.nvim_command('setlocal '..opt)
7677
end
78+
if SIDE == 'L' then
79+
api.nvim_command('setlocal nosplitright')
80+
else
81+
api.nvim_command('setlocal splitright')
82+
end
7783
end
7884

7985
local function replace_tree()

lua/tree.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ local function toggle()
4545
end
4646
end
4747

48+
local MOVE_TO = 'l'
49+
if api.nvim_call_function('exists', { 'g:lua_tree_side' }) == 1 then
50+
if api.nvim_get_var('lua_tree_side') == 'right' then
51+
MOVE_TO = 'h'
52+
end
53+
end
54+
4855
local function open_file(open_type)
4956
local tree_index = api.nvim_win_get_cursor(0)[1]
5057
local tree = get_tree()
@@ -85,7 +92,7 @@ local function open_file(open_type)
8592
init_tree(new_path)
8693
update_view()
8794
else
88-
api.nvim_command('wincmd l | '..open_type..' '.. node.linkto)
95+
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.linkto)
8996
end
9097

9198
elseif node.dir == true then
@@ -94,7 +101,7 @@ local function open_file(open_type)
94101
update_view(true)
95102

96103
else
97-
api.nvim_command('wincmd l | '..open_type..' '.. node.path .. node.name)
104+
api.nvim_command('wincmd '..MOVE_TO..' | '..open_type..' '.. node.path .. node.name)
98105
end
99106
end
100107

plugin/tree.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ au BufWritePost * lua require'tree'.refresh()
1212
au BufEnter * lua require'tree'.check_windows_and_close()
1313
au VimEnter * lua require'tree'.check_buffer_and_open()
1414

15+
" TODO set status line dynamically on bufenter in the luatree
16+
" to remove lightline and other possible components
17+
au BufEnter LuaTree setlocal statusline=""
18+
1519
if get(g:, 'lua_tree_follow') != 0
1620
au BufEnter * :LuaTreeFindFile
1721
endif

0 commit comments

Comments
 (0)