refresh tree when changing fs
This commit is contained in:
parent
b448b1a0fa
commit
0ed31e065e
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
- [x] change directory base
|
- [x] change directory base
|
||||||
- [x] add / rename / delete file in directory
|
- [x] add / rename / delete file in directory
|
||||||
- [ ] update tree when altering the FS
|
- [x] update tree when altering the FS
|
||||||
|
|
||||||
- [x] syntax highlighting ([exa](https://github.com/ogham/exa) like) and file icons with vim-devicons
|
- [x] syntax highlighting ([exa](https://github.com/ogham/exa) like) and file icons with vim-devicons
|
||||||
- [ ] simple git integration (color of file changing when staged/changed)
|
- [ ] simple git integration (color of file changing when staged/changed)
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local buf, win
|
local buf, win
|
||||||
local system = function(v) api.nvim_call_function('system', { v }) end
|
local system = function(v) api.nvim_call_function('system', { v }) end
|
||||||
-- local update_tree_view = require ''
|
local update_tree_view = require 'lib/winutils'.update_view
|
||||||
local update_tree_state = require 'lib/state'.update_tree
|
local update_tree_state = require 'lib/state'.refresh_tree
|
||||||
|
|
||||||
local EDIT_FILE = nil
|
local EDIT_FILE = nil
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local function syslist(v) return api.nvim_call_function('systemlist', { v }) end
|
local function syslist(v) return api.nvim_call_function('systemlist', { v }) end
|
||||||
|
local get_root_path = require 'lib/conf'.get_root_path
|
||||||
|
|
||||||
local Tree = {}
|
local Tree = {}
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ local function create_nodes(path, depth, dirs)
|
|||||||
return sort_dirs(tree)
|
return sort_dirs(tree)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_tree(ROOT_PATH)
|
local function init_tree()
|
||||||
|
local ROOT_PATH = get_root_path()
|
||||||
Tree = create_nodes(ROOT_PATH, 0, list_dirs())
|
Tree = create_nodes(ROOT_PATH, 0, list_dirs())
|
||||||
if ROOT_PATH ~= '/' then
|
if ROOT_PATH ~= '/' then
|
||||||
table.insert(Tree, 1, {
|
table.insert(Tree, 1, {
|
||||||
@ -90,10 +92,6 @@ local function refresh_tree()
|
|||||||
for j, n in pairs(create_nodes(path, node.depth + 1, dirs)) do
|
for j, n in pairs(create_nodes(path, node.depth + 1, dirs)) do
|
||||||
table.insert(Tree, i + j, n)
|
table.insert(Tree, i + j, n)
|
||||||
end
|
end
|
||||||
-- TODO: maybe extract this function to make a recursive call to reexplore the list
|
|
||||||
-- when adding a new list of dirs to make sure we go to the bottom of the opened structure
|
|
||||||
-- otherwise it might close opened directories
|
|
||||||
-- im not sure how lua behaves in this matter
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,10 +20,9 @@ local set_mappings = winutils.set_mappings
|
|||||||
|
|
||||||
local conf = require 'lib/conf'
|
local conf = require 'lib/conf'
|
||||||
local set_root_path = conf.set_root_path
|
local set_root_path = conf.set_root_path
|
||||||
local get_root_path = conf.get_root_path
|
|
||||||
local get_cwd = conf.get_cwd
|
local get_cwd = conf.get_cwd
|
||||||
|
|
||||||
init_tree(get_root_path())
|
init_tree()
|
||||||
|
|
||||||
local function toggle()
|
local function toggle()
|
||||||
if is_win_open() == true then
|
if is_win_open() == true then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user