-
-
Notifications
You must be signed in to change notification settings - Fork 633
Expand file tree
/
Copy pathnvim-tree.lua
More file actions
62 lines (49 loc) · 1.77 KB
/
nvim-tree.lua
File metadata and controls
62 lines (49 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local M = {}
---`require("nvim-tree").setup` must be called once to initialise nvim-tree.
---
---Call again to apply a change in configuration without restarting Nvim.
---
---See :help nvim-tree-setup
---
---@param config_user? nvim_tree.config subset, uses defaults when nil
function M.setup(config_user)
local api = require("nvim-tree.api")
local api_impl = require("nvim-tree.api.impl")
local appearance = require("nvim-tree.appearance")
local autocmd = require("nvim-tree.autocmd")
local config = require("nvim-tree.config")
local log = require("nvim-tree.log")
local view_state = require("nvim-tree.view-state")
-- Nvim version check
if vim.fn.has("nvim-0.10") == 0 then
require("nvim-tree.notify").warn(
"nvim-tree.lua requires Nvim >= 0.10. You may use a compat-nvim-0.X tag for earlier Nvim versions, however they will receive no updates or support.")
return
end
-- validate and merge with defaults as config.g
config.setup(config_user)
-- optionally create the log file
log.start()
-- optionally log the configuration
if log.enabled("config") then
log.line("config", "default config + user")
log.raw("config", "%s\n", vim.inspect(config.g))
end
-- idempotent highlight definition
appearance.highlight()
-- set the initial view state based on config
view_state.initialize()
-- idempotent au (re)definition
autocmd.global()
-- subsequent calls to setup clear all state
if vim.g.NvimTreeSetup == 1 then
require("nvim-tree.core").purge_all_state()
end
-- hydrate post setup API
api_impl.hydrate_post_setup(api)
vim.g.NvimTreeSetup = 1
vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeSetup" })
end
vim.g.NvimTreeRequired = 1
vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeRequired" })
return M