Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions lua/nvim-tree/commands.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local api = require("nvim-tree.api")
local view = require("nvim-tree.view")

local M = {}

local CMDS = {
Expand All @@ -12,7 +9,7 @@ local CMDS = {
complete = "dir",
},
command = function(c)
api.tree.open({ path = c.args })
require("nvim-tree.api").tree.open({ path = c.args })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial thought was to use a common function like

local function api()
  require("nvim-tree.api")
end

however that would just obscure things.
The inline require make it really clear what's going on.

end,
},
{
Expand All @@ -22,7 +19,7 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.close()
require("nvim-tree.api").tree.close()
end,
},
{
Expand All @@ -33,7 +30,7 @@ local CMDS = {
complete = "dir",
},
command = function(c)
api.tree.toggle({
require("nvim-tree.api").tree.toggle({
find_file = false,
focus = true,
path = c.args,
Expand All @@ -48,7 +45,7 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.open()
require("nvim-tree.api").tree.open()
end,
},
{
Expand All @@ -58,7 +55,7 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.reload()
require("nvim-tree.api").tree.reload()
end,
},
{
Expand All @@ -68,7 +65,7 @@ local CMDS = {
bar = true,
},
command = function()
api.fs.print_clipboard()
require("nvim-tree.api").fs.print_clipboard()
end,
},
{
Expand All @@ -79,7 +76,7 @@ local CMDS = {
bar = true,
},
command = function(c)
api.tree.find_file({
require("nvim-tree.api").tree.find_file({
open = true,
focus = true,
update_root = c.bang,
Expand All @@ -95,7 +92,7 @@ local CMDS = {
complete = "dir",
},
command = function(c)
api.tree.toggle({
require("nvim-tree.api").tree.toggle({
find_file = true,
focus = true,
path = c.args,
Expand All @@ -111,7 +108,7 @@ local CMDS = {
bar = true,
},
command = function(c)
view.resize(c.args)
require("nvim-tree.view").resize(c.args)
end,
},
{
Expand All @@ -121,7 +118,7 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.collapse_all(false)
require("nvim-tree.api").tree.collapse_all(false)
end,
},
{
Expand All @@ -131,15 +128,17 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.collapse_all(true)
require("nvim-tree.api").tree.collapse_all(true)
end,
},
{
name = "NvimTreeHiTest",
opts = {
desc = "nvim-tree: highlight test",
},
command = api.diagnostics.hi_test,
command = function()
require("nvim-tree.api").diagnostics.hi_test()
end,
},
}

Expand Down
Loading