add some options for the user and info in the readme

This commit is contained in:
kiyan42 2020-02-20 21:16:13 +01:00
parent 1d61d6b123
commit f5af7aa95d
3 changed files with 53 additions and 7 deletions

View File

@ -1,12 +1,41 @@
# A File Explorer For Neovim Written In Lua
![alt text](.github/tree.png?raw=true "file explorer")
## Notice
- I am working on this plugin to learn lua, neovim's api and create a file explorer with features i need.
- This plugin does not work on windows.
## Install
Install with [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'kyazdani42/nvim-tree.lua'
```
## Setup
```vim
let g:lua_tree_side = 'right' | 'left' "left by default
let g:lua_tree_size = 40 "30 by default
nnoremap <C-n> :LuaTreeToggle<CR>
nnoremap <leader>n :LuaTreeRefresh<CR>
```
## KeyBindings
- move around like in any vim buffer
- `<CR>` on `..` will cd in the above directory
- `<C-[>` will cd in the directory under the cursor
- type `a` to add a file
- type `r` to rename a file
- type `d` to delete a file (will prompt for confirmation)
- if the file is a directory, `<CR>` will open the directory
- otherwise it will open the file in the buffer near the tree
- if the file is a symlink, `<CR>` will follow the symlink
- type `<C-v>` will open the file in a vertical split
- type `<C-x>` will open the file in a horizontal split
## Features
- [x] Open file in current buffer or in split with FzF like bindings (`CR`, `C-v`, `C-x`)
- [x] File icons with vim-devicons
@ -16,10 +45,13 @@
- [x] Git integration
- [x] Mouse support
## Screenshot
![alt text](.github/tree.png?raw=true "file explorer")
## TODO
- add docs
- fix coloring when no dev icons
- add options for users (tree side, tree size)
- cd command to move faster accross the fs if needed
- quickly find file in the directory structure
- use libuv functions instead of `touch` and `mkdir` in `create_file()` and allow file creation with path like `foo/bar/baz`

View File

@ -34,11 +34,24 @@ end
local BUF_OPTIONS = {
'nonumber', 'norelativenumber', 'winfixwidth', 'winfixheight',
'winhighlight=EndOfBuffer:LuaTreeEndOfBuffer', 'noswapfile'
'winhighlight=EndOfBuffer:LuaTreeEndOfBuffer', 'noswapfile',
'splitbelow'
}
local WIN_WIDTH = 30
local SIDE = 'topleft'
if api.nvim_call_function('exists', { 'g:lua_tree_width' }) == 1 then
WIN_WIDTH = api.nvim_get_var('lua_tree_width')
end
if api.nvim_call_function('exists', { 'g:lua_tree_side' }) == 1 then
if api.nvim_get_var('lua_tree_side') == 'right' then
SIDE = 'rightbelow'
end
end
local function open()
local win_width = 30
local options = {
bufhidden = 'delete';
buftype = 'nowrite';
@ -52,7 +65,7 @@ local function open()
api.nvim_buf_set_option(buf, opt, val)
end
api.nvim_command('topleft '..win_width..'vnew')
api.nvim_command(SIDE.. ' '..WIN_WIDTH..'vnew')
api.nvim_win_set_buf(0, buf)
for _, opt in pairs(BUF_OPTIONS) do
api.nvim_command('setlocal '..opt)

View File

@ -12,7 +12,8 @@ au BufWritePost * lua require'tree'.refresh()
au BufEnter * lua require'tree'.check_windows_and_close()
au VimEnter * lua require'tree'.check_buffer_and_open()
command! LuaTree lua require'tree'.toggle()
command! LuaTreeToggle lua require'tree'.toggle()
command! LuaTreeRefresh lua require'tree'.refresh()
let &cpo = s:save_cpo
unlet s:save_cpo