small refacto

This commit is contained in:
kyazdani42 2020-02-09 15:36:18 +01:00
parent 04bd042869
commit d649119146

View File

@ -6,8 +6,8 @@ local BUF_NAME = '_LuaTree_'
local ROOT_PATH = string.sub(sys('pwd'), 1, -2) .. '/' -- get rid of \n and add leading '/' local ROOT_PATH = string.sub(sys('pwd'), 1, -2) .. '/' -- get rid of \n and add leading '/'
local function is_dir(path) local function is_dir(path)
local file_list = sys('ls -l '..path) local stat = vim.loop.fs_stat(path)
return string.match(file_list, 'total [0-9].*') ~= nil return stat and stat.type == 'directory' or false
end end
local function sort_dirs(dirs) local function sort_dirs(dirs)
@ -116,6 +116,12 @@ local function get_win()
return nil return nil
end end
local function buf_setup()
api.nvim_command('setlocal nonumber norelativenumber winfixwidth winfixheight')
api.nvim_command('hi NoEndOfBuffer guifg=bg')
api.nvim_command('setlocal winhighlight=EndOfBuffer:NoEndOfBuffer')
end
local function open() local function open()
local win_width = 30 local win_width = 30
local options = { local options = {
@ -133,7 +139,7 @@ local function open()
api.nvim_command('topleft '..win_width..'vnew') api.nvim_command('topleft '..win_width..'vnew')
api.nvim_win_set_buf(0, buf) api.nvim_win_set_buf(0, buf)
api.nvim_command('setlocal nonumber norelativenumber winfixwidth winfixheight') buf_setup()
api.nvim_command('echo "'..ROOT_PATH..'"') api.nvim_command('echo "'..ROOT_PATH..'"')
end end