add preview

This commit is contained in:
kyazdani42
2020-06-07 14:51:46 +02:00
parent e9548d7992
commit b55ed7c5a7
5 changed files with 36 additions and 20 deletions

View File

@@ -49,6 +49,7 @@ function M.get_bindings()
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
edit_split = keybindings.edit_split or '<C-x>',
edit_tab = keybindings.edit_tab or '<C-t>',
preview = keybindings.preview or '<Tab>',
cd = keybindings.cd or '<C-]>',
create = keybindings.create or 'a',
remove = keybindings.remove or 'd',

View File

@@ -183,7 +183,16 @@ function M.open_file(mode, filename)
else
api.nvim_command('noautocmd wincmd l')
end
api.nvim_command(string.format("%s %s", mode, filename))
if mode == 'preview' then
api.nvim_command(string.format("edit %s", filename))
if vim.g.lua_tree_side == 'right' then
api.nvim_command('noautocmd wincmd l')
else
api.nvim_command('noautocmd wincmd h')
end
else
api.nvim_command(string.format("%s %s", mode, filename))
end
end
function M.change_dir(foldername)
@@ -207,6 +216,7 @@ local function set_mappings()
[bindings.create] = 'on_keypress("create")';
[bindings.remove] = 'on_keypress("remove")';
[bindings.rename] = 'on_keypress("rename")';
[bindings.preview] = 'on_keypress("preview")';
gx = "xdg_open()";
}