Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ local config = {
-- you can also specify border here, if you want a different setting from
-- the global popup_border_style.
},
same_level = false, -- Create and paste/move files/directories on the same level as the directory under cursor (as opposed to within the directory under cursor).
insert_as = "child", -- Affects how nodes get inserted into the tree during creation/pasting/moving of files if the node under the cursor is a directory:
-- "child": Insert nodes as children of the directory under cursor.
-- "sibling": Insert nodes as siblings of the directory under cursor.
Expand Down
26 changes: 12 additions & 14 deletions lua/neo-tree/health/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ local function check_dependencies()
end
end

local vim_validate_new
local softvalidate
if vim.fn.has("nvim-0.11") == 1 then
vim_validate_new = vim.validate
softvalidate = vim.validate
else
---@alias neotree.Health.Type type|"callable"
---@alias neotree.Health.Types neotree.Health.Type|(neotree.Health.Type[])
Expand All @@ -44,7 +44,7 @@ else
return false
end

vim_validate_new = function(name, value, validator, optional, message)
softvalidate = function(name, value, validator, optional, message)
local matched, errmsg, errinfo
if type(validator) == "string" then
matched = matches_type(value, validator)
Expand All @@ -59,6 +59,7 @@ else
matched, errinfo = validator(value)
end
matched = matched or (optional and value == nil)

if not matched then
local expected_types = type(validator) == "string" and { validator } or validator
if optional then
Expand Down Expand Up @@ -108,7 +109,7 @@ function M.check_config(config)
end

-- do regular validate
local valid, errmsg = pcall(vim_validate_new, full_path .. name, value, validator, optional)
local valid, errmsg = pcall(softvalidate, full_path .. name, value, validator, optional)
if not valid then
-- if type(validator) == "string" then
-- advice = advice or ("Change this option to a %s"):format(validator)
Expand Down Expand Up @@ -151,12 +152,10 @@ function M.check_config(config)
end,
},

Source = {
---@param window neotree.Config.Source.Window
Window = function(window)
validate("mappings", window.mappings, "table") -- TODO: More specific validation for mappings table
end,
},
---@param window neotree.Config.Window
Window = function(window)
validate("mappings", window.mappings, "table") -- TODO: More specific validation for mappings table
end,
SourceSelector = {
---@param item neotree.Config.SourceSelector.Item
Item = function(item)
Expand Down Expand Up @@ -285,7 +284,6 @@ function M.check_config(config)
true
)
end)
validate("same_level", window.same_level, "boolean")
validate("insert_as", window.insert_as, validator.literal({ "child", "sibling", "nil" }))
validate("mapping_options", window.mapping_options, "table") -- TODO: More specific validation
validate("mappings", window.mappings, validator.array("table")) -- TODO: More specific validation for mapping items
Expand Down Expand Up @@ -360,19 +358,19 @@ function M.check_config(config)
validate("show_unloaded", buffers.show_unloaded, "boolean")
validate("terminals_first", buffers.terminals_first, "boolean")
validate("renderers", buffers.renderers, schema.Renderers)
validate("window", buffers.window, schema.Source.Window)
validate("window", buffers.window, schema.Window)
end)
validate("git_status", config.git_status, function(git_status)
validate("renderers", git_status.renderers, schema.Renderers)
validate("window", git_status.window, schema.Source.Window)
validate("window", git_status.window, schema.Window)
end)
validate("document_symbols", config.document_symbols, function(document_symbols)
validate("follow_cursor", document_symbols.follow_cursor, "boolean")
validate("client_filters", document_symbols.client_filters, { "string", "table" }) -- TODO: More specific validation
validate("custom_kinds", document_symbols.custom_kinds, "table") -- TODO: More specific validation
validate("kinds", document_symbols.kinds, "table")
validate("renderers", document_symbols.renderers, schema.Renderers)
validate("window", document_symbols.window, schema.Source.Window)
validate("window", document_symbols.window, schema.Window)
end)

if #errors == 0 then
Expand Down
2 changes: 1 addition & 1 deletion lua/neo-tree/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local default_config = {
-- {{{ NO NEED TO CHANGE
local log = {}

local unpack = unpack or table.unpack
local unpack = unpack

local notify = function(message, level_config)
if type(vim.notify) == "table" then
Expand Down
3 changes: 2 additions & 1 deletion lua/neo-tree/setup/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ local hijack_cursor = require("neo-tree.sources.common.hijack_cursor")

local M = {}

---@param config neotree.Config.Base
local normalize_mappings = function(config)
if config == nil then
return false
end
local mappings = utils.get_value(config, "window.mappings", nil)
local mappings = vim.tbl_get(config, { "window", "mappings" })
if mappings then
local fixed = mapping_helper.normalize_map(mappings)
config.window.mappings = fixed
Expand Down
3 changes: 3 additions & 0 deletions lua/neo-tree/setup/mapping-helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local utils = require("neo-tree.utils")

local M = {}

---@param key string
M.normalize_map_key = function(key)
if key == nil then
return nil
Expand Down Expand Up @@ -33,6 +34,8 @@ M.normalize_map_key = function(key)
return key
end

---@param map table<string, function|string>
---@return table<string, function|string> new_map
M.normalize_map = function(map)
local new_map = {}
for key, value in pairs(map) do
Expand Down
1 change: 0 additions & 1 deletion lua/neo-tree/sources/common/filters/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ M.show_filter = function(state, search_as_you_type, keep_filter_on_submit)

-- create mappings and autocmd
input:map("i", "<C-w>", "<C-S-w>", { noremap = true })
input:map("i", "<esc>", cmds.close, { noremap = true })

local config = require("neo-tree").config
for lhs, cmd_name in pairs(config.filesystem.window.fuzzy_finder_mappings) do
Expand Down
1 change: 0 additions & 1 deletion lua/neo-tree/sources/filesystem/lib/filter_external.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local Queue = require("neo-tree.collections").Queue

local M = {}
local fd_supports_max_results = nil
local unpack = unpack or table.unpack

local test_for_max_results = function(cmd)
if fd_supports_max_results == nil then
Expand Down
28 changes: 15 additions & 13 deletions lua/neo-tree/types/config.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
---@meta

---@class neotree.Config.MappingOptions
---@class neotree.Config.Mapping.Options
---@field noremap boolean?
---@field nowait boolean?

---@class neotree.Config.Mapping : neotree.Config.MappingOptions
---@class neotree.Config.Window.Command.Configured : neotree.Config.Mapping.Options
---@field [1] string
---@field nowait boolean?
---@field noremap boolean?
---@field config table?

---@class neotree.Config.Source
---@field window neotree.Config.Source.Window?
---@field window neotree.Config.Window?
---@field renderers neotree.Component[]?

---@class neotree.Config.Source.Window
---@field mappings table<string, string|neotree.Config.Mapping>?

---@class neotree.Config.SourceSelector.Item
---@field source string?
---@field padding integer|{left:integer,right:integer}?
Expand All @@ -38,8 +33,8 @@
---@field statusline boolean?
---@field show_scrolled_off_parent_node boolean?
---@field sources neotree.Config.SourceSelector.Item[]?
---@field content_layout string? "start"|"end"|"center"
---@field tabs_layout string? "equal"|"start"|"end"|"center"|"focus"
---@field content_layout? "start"|"end"|"center"
---@field tabs_layout? "equal"|"start"|"end"|"center"|"focus"
---@field truncation_character string
---@field tabs_min_width integer?
---@field tabs_max_width integer?
Expand Down Expand Up @@ -67,16 +62,23 @@
---@field size neotree.Config.Window.Size?
---@field border neotree.Config.BorderStyle?

---@alias neotree.Config.Window.Command string|function|neotree.Config.Window.Command.Configured

---@class (exact) neotree.Config.Window.Commands
---@field [string] function

---@class (exact) neotree.Config.Window.Mappings
---@field [string] neotree.Config.Window.Command

---@class neotree.Config.Window
---@field position string?
---@field width integer?
---@field height integer?
---@field auto_expand_width boolean?
---@field popup neotree.Config.Window.Popup?
---@field same_level boolean?
---@field insert_as "child"|"sibling"|nil
---@field mapping_options neotree.Config.MappingOptions?
---@field mappings neotree.Config.Mapping[]?
---@field mapping_options neotree.Config.Mapping.Options?
---@field mappings neotree.Config.Window.Mappings?

---@class neotree.Config.Renderers
---@field directory neotree.Component.Common[]?
Expand Down
2 changes: 1 addition & 1 deletion lua/neo-tree/types/config/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

---@class neotree.Config.Filesystem.Renderers : neotree.Config.Renderers

---@class neotree.Config.Filesystem.Window : neotree.Config.Source.Window
---@class neotree.Config.Filesystem.Window : neotree.Config.Window
---@field fuzzy_finder_mappings table<string, neotree.FuzzyFinder.Commands>?

---@class (exact) neotree.Config.Filesystem : neotree.Config.Source
Expand Down
7 changes: 7 additions & 0 deletions lua/neo-tree/ui/inputs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local events = require("neo-tree.events")

local M = {}

---@param input NuiInput
---@param callback function?
M.show_input = function(input, callback)
input:mount()

Expand Down Expand Up @@ -41,6 +43,11 @@ M.show_input = function(input, callback)
end
end

---@param message string
---@param default_value string?
---@param callback function
---@param options nui_popup_options?
---@param completion string?
M.input = function(message, default_value, callback, options, completion)
if nt.config.use_popups_for_input then
local popup_options = popups.popup_options(message, 10, options)
Expand Down
15 changes: 7 additions & 8 deletions lua/neo-tree/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ if ffi_available then
]])
end

-- Backwards compatibility
table.pack = table.pack or function(...)
return { n = select("#", ...), ... }
end
table.unpack = table.unpack or unpack

local M = {}

local diag_severity_to_string = function(severity)
Expand All @@ -34,6 +28,11 @@ local diag_severity_to_string = function(severity)
end
end

-- Backwards compatibility
M.pack = table.pack or function(...)
return { n = select("#", ...), ... }
end

local tracked_functions = {}
---@enum NeotreeDebounceStrategy
M.debounce_strategy = {
Expand Down Expand Up @@ -1171,8 +1170,8 @@ M.wrap = function(func, ...)
end
local wrapped_args = { ... }
return function(...)
local all_args = table.pack(table.unpack(wrapped_args), ...)
func(table.unpack(all_args))
local all_args = M.pack(unpack(wrapped_args), ...)
func(unpack(all_args))
end
end

Expand Down
Loading