From 5ab65e98b338d43eb6ecc60cfe19f47c5a08d888 Mon Sep 17 00:00:00 2001 From: kyazdani42 Date: Wed, 19 Feb 2020 18:47:02 +0100 Subject: [PATCH] remove conf.lua file --- lua/lib/conf.lua | 23 ----------------------- lua/lib/state.lua | 11 +++++++++-- lua/lib/winutils.lua | 10 +--------- lua/tree.lua | 6 ++---- 4 files changed, 12 insertions(+), 38 deletions(-) delete mode 100644 lua/lib/conf.lua diff --git a/lua/lib/conf.lua b/lua/lib/conf.lua deleted file mode 100644 index f9635640..00000000 --- a/lua/lib/conf.lua +++ /dev/null @@ -1,23 +0,0 @@ -local BUF_NAME = 'LuaTree' -local function get_cwd() return vim.loop.cwd() end -local ROOT_PATH = get_cwd() .. '/' - -local function get_buf_name() - return BUF_NAME -end - -local function get_root_path() - return ROOT_PATH -end - -local function set_root_path(path) - ROOT_PATH = path -end - -return { - get_buf_name = get_buf_name; - get_root_path = get_root_path; - set_root_path = set_root_path; - get_cwd = get_cwd; -} - diff --git a/lua/lib/state.lua b/lua/lib/state.lua index b01e8fad..f625f501 100644 --- a/lua/lib/state.lua +++ b/lua/lib/state.lua @@ -1,8 +1,14 @@ local api = vim.api local function syslist(v) return api.nvim_call_function('systemlist', { v }) end -local get_root_path = require 'lib/conf'.get_root_path local get_git_attr = require 'lib/git'.get_git_attr +local function get_cwd() return vim.loop.cwd() end +local ROOT_PATH = get_cwd() .. '/' + +local function set_root_path(path) + ROOT_PATH = path +end + local Tree = {} local function is_dir(path) @@ -78,7 +84,6 @@ local function create_nodes(path, relpath, depth, dirs) end local function init_tree() - local ROOT_PATH = get_root_path() Tree = create_nodes(ROOT_PATH, '', 0, list_dirs()) if ROOT_PATH ~= '/' then table.insert(Tree, 1, { @@ -152,4 +157,6 @@ return { open_dir = open_dir; check_dir_access = check_dir_access; is_dir = is_dir; + set_root_path = set_root_path; + get_cwd = get_cwd; } diff --git a/lua/lib/winutils.lua b/lua/lib/winutils.lua index 8eb17ef7..036ec6fd 100644 --- a/lua/lib/winutils.lua +++ b/lua/lib/winutils.lua @@ -1,3 +1,4 @@ +local BUF_NAME = 'LuaTree' local api = vim.api local libformat = require 'lib/format' @@ -7,14 +8,9 @@ local highlight = libformat.highlight_buffer local stateutils = require 'lib/state' local get_tree = stateutils.get_tree -local confutils = require 'lib/conf' -local get_buf_name = confutils.get_buf_name -local get_root_path = confutils.get_root_path - local scratch_buf = nil local function get_buf() - local BUF_NAME = get_buf_name() local regex = '.*'..BUF_NAME..'$'; for _, win in pairs(api.nvim_list_wins()) do @@ -28,7 +24,6 @@ local function get_buf() end local function get_win() - local BUF_NAME = get_buf_name() local regex = '.*'..BUF_NAME..'$'; for _, win in pairs(api.nvim_list_wins()) do @@ -129,8 +124,6 @@ local function scratch_wrapper(edit_type, ...) end local function open() - local BUF_NAME = get_buf_name() - local ROOT_PATH = get_root_path() local win_width = 30 local options = { bufhidden = 'wipe'; @@ -148,7 +141,6 @@ local function open() api.nvim_command('topleft '..win_width..'vnew') api.nvim_win_set_buf(0, buf) buf_setup() - api.nvim_command('echo "'..ROOT_PATH..'"') end local function close() diff --git a/lua/tree.lua b/lua/tree.lua index 76e566d7..150cfbb3 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -12,6 +12,8 @@ local open_dir = stateutils.open_dir local check_dir_access = stateutils.check_dir_access local refresh_tree = stateutils.refresh_tree local is_dir = stateutils.is_dir +local set_root_path = stateutils.set_root_path +local get_cwd = stateutils.get_cwd local winutils = require 'lib/winutils' local update_view = winutils.update_view @@ -20,10 +22,6 @@ local close = winutils.close local open = winutils.open local set_mappings = winutils.set_mappings -local conf = require 'lib/conf' -local set_root_path = conf.set_root_path -local get_cwd = conf.get_cwd - local git = require 'lib/git' local refresh_git = git.refresh_git local force_refresh_git = git.force_refresh_git