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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.15.2
version: v0.16.0
args: --color always --check -g '!**/defaults.lua' lua/

plenary-tests:
Expand Down
4 changes: 2 additions & 2 deletions lua/neo-tree/events/queue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function Queue:for_each(func)
"Handler ",
node.value.id,
" for "
.. node.value.event
.. " returned handled = true, skipping the rest of the queue."
.. node.value.event
.. " returned handled = true, skipping the rest of the queue."
)
return result
end
Expand Down
16 changes: 8 additions & 8 deletions lua/neo-tree/setup/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ local prior_window_options = {}
local store_local_window_settings = function(winid)
winid = winid or vim.api.nvim_get_current_win()
local neo_tree_settings_applied, _ =
pcall(vim.api.nvim_win_get_var, winid, "neo_tree_settings_applied")
pcall(vim.api.nvim_win_get_var, winid, "neo_tree_settings_applied")
if neo_tree_settings_applied then
-- don't store our own window settings
return
Expand All @@ -121,7 +121,7 @@ end

--- Restore the window options for the current window
--- @param winid number | nil The window id to restore the options for, defaults to current window
local restore_local_window_settings = function (winid)
local restore_local_window_settings = function(winid)
winid = winid or vim.api.nvim_get_current_win()
-- return local window settings to their prior values
local wo = prior_window_options[tostring(winid)]
Expand Down Expand Up @@ -159,7 +159,7 @@ M.buffer_enter_event = function()
]])

local winhighlight =
"Normal:NeoTreeNormal,NormalNC:NeoTreeNormalNC,SignColumn:NeoTreeSignColumn,CursorLine:NeoTreeCursorLine,FloatBorder:NeoTreeFloatBorder,StatusLine:NeoTreeStatusLine,StatusLineNC:NeoTreeStatusLineNC,VertSplit:NeoTreeVertSplit,EndOfBuffer:NeoTreeEndOfBuffer"
"Normal:NeoTreeNormal,NormalNC:NeoTreeNormalNC,SignColumn:NeoTreeSignColumn,CursorLine:NeoTreeCursorLine,FloatBorder:NeoTreeFloatBorder,StatusLine:NeoTreeStatusLine,StatusLineNC:NeoTreeStatusLineNC,VertSplit:NeoTreeVertSplit,EndOfBuffer:NeoTreeEndOfBuffer"
if vim.version().minor >= 7 then
vim.cmd("setlocal winhighlight=" .. winhighlight .. ",WinSeparator:NeoTreeWinSeparator")
else
Expand Down Expand Up @@ -499,7 +499,7 @@ M.merge_config = function(user_config, is_auto_config)
restore_local_window_settings()
end
end
vim.api.nvim_create_autocmd({"BufWinLeave"}, {
vim.api.nvim_create_autocmd({ "BufWinLeave" }, {
group = augroup,
pattern = "neo-tree *",
callback = bufleave,
Expand Down Expand Up @@ -557,10 +557,10 @@ M.merge_config = function(user_config, is_auto_config)
for source_name, mod_root in pairs(all_sources) do
local module = require(mod_root)
default_config[source_name] = default_config[source_name]
or {
renderers = {},
components = {},
}
or {
renderers = {},
components = {},
}
local source_default_config = default_config[source_name]
source_default_config.components = module.components or require(mod_root .. ".components")
source_default_config.commands = module.commands or require(mod_root .. ".commands")
Expand Down
10 changes: 3 additions & 7 deletions lua/neo-tree/sources/common/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,13 @@ M.filtered_by = function(config, node, state)
return result
end



M.icon = function(config, node, state)
local icon = config.default or " "
local highlight = config.highlight or highlights.FILE_ICON
if node.type == "directory" then
highlight = highlights.DIRECTORY_ICON
if node.loaded and not node:has_children() then
icon = not node.empty_expanded
and config.folder_empty
or config.folder_empty_open
icon = not node.empty_expanded and config.folder_empty or config.folder_empty_open
elseif node:is_expanded() then
icon = config.folder_open or "-"
else
Expand Down Expand Up @@ -357,14 +353,14 @@ M.indent = function(config, node, state)
local level = node.level
local with_markers = config.with_markers
local with_expanders = config.with_expanders == nil and file_nesting.is_enabled()
or config.with_expanders
or config.with_expanders
local marker_highlight = config.highlight or highlights.INDENT_MARKER
local expander_highlight = config.expander_highlight or config.highlight or highlights.EXPANDER

local function get_expander()
if with_expanders and utils.is_expandable(node) then
return node:is_expanded() and (config.expander_expanded or "")
or (config.expander_collapsed or "")
or (config.expander_collapsed or "")
end
end

Expand Down
4 changes: 3 additions & 1 deletion lua/neo-tree/sources/filesystem/lib/fs_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ M.create_node = function(in_directory, callback, using_root_directory)
if is_dir then
loop.fs_mkdir(destination, 493)
else
local open_mode = loop.constants.O_CREAT + loop.constants.O_WRONLY + loop.constants.O_TRUNC
local open_mode = loop.constants.O_CREAT
+ loop.constants.O_WRONLY
+ loop.constants.O_TRUNC
local fd = loop.fs_open(destination, "w", open_mode)
if not fd then
api.nvim_err_writeln("Could not create file " .. destination)
Expand Down
1 change: 0 additions & 1 deletion lua/neo-tree/sources/filesystem/lib/fs_scan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ local job_complete = function(context)
render_context(context)
end


local function create_node(context, node)
local success3, item = pcall(file_items.create_item, context, node.path, node.type)
end
Expand Down
25 changes: 13 additions & 12 deletions lua/neo-tree/ui/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ create_nodes = function(source_items, state, level)
local nodeData = {
id = hidden[#hidden].id .. "_hidden_message",
name = "(forced to show "
.. #hidden
.. " hidden "
.. (#hidden > 1 and "items" or "item")
.. ")",
.. #hidden
.. " hidden "
.. (#hidden > 1 and "items" or "item")
.. ")",
type = "message",
level = level,
is_last_child = show_indent_marker_for_message,
Expand Down Expand Up @@ -286,7 +286,7 @@ M.render_component = function(component, item, state, remaining_width)
local component_func = state.components[component[1]]
if component_func then
local success, component_data, wanted_width =
pcall(component_func, component, item, state, remaining_width)
pcall(component_func, component, item, state, remaining_width)
if success then
if component_data == nil then
return { {} }
Expand Down Expand Up @@ -332,10 +332,11 @@ local prepare_node = function(item, state)
local line = item.line
-- Only use it once, we don't want to accidentally use stale data
item.line = nil
if line
and item.wanted_width
and state.longest_node
and item.wanted_width <= state.longest_node
if
line
and item.wanted_width
and state.longest_node
and item.wanted_width <= state.longest_node
then
return line
end
Expand Down Expand Up @@ -363,7 +364,7 @@ local prepare_node = function(item, state)
end
for _, component in ipairs(renderer) do
local component_data, component_wanted_width =
M.render_component(component, item, state, remaining_cols)
M.render_component(component, item, state, remaining_cols)
local actual_width = 0
if component_data then
for _, data in ipairs(component_data) do
Expand Down Expand Up @@ -946,8 +947,8 @@ M.window_exists = function(state)
window_exists = false
elseif position == "current" then
window_exists = vim.api.nvim_win_is_valid(winid)
and vim.api.nvim_buf_is_valid(bufnr)
and vim.api.nvim_win_get_buf(winid) == bufnr
and vim.api.nvim_buf_is_valid(bufnr)
and vim.api.nvim_win_get_buf(winid) == bufnr
else
local isvalid = M.is_window_valid(winid)
window_exists = isvalid and (vim.api.nvim_win_get_number(winid) > 0)
Expand Down
21 changes: 10 additions & 11 deletions lua/neo-tree/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,13 @@ local brace_expand_split = function(s, separator)
local depth = 0
while pos <= s:len() do
local c = s:sub(pos, pos)
if c == '\\' then
if c == "\\" then
pos = pos + 1
elseif c == separator and depth == 0 then
return s:sub(1, pos - 1), s:sub(pos + 1)
elseif c == '{' then
elseif c == "{" then
depth = depth + 1
elseif c == '}' then
elseif c == "}" then
if depth > 0 then
depth = depth - 1
end
Expand Down Expand Up @@ -897,11 +897,11 @@ local brace_expand_contents = function(s)

---Process numeric sequence expression. e.g. {0..2} -> {0,1,2}, {01..05..2} -> {01,03,05}
local resolve_sequence_num = function(from, to, step)
local format = '%d'
local format = "%d"
-- Pad strings in the presence of a leading zero
local pattern = '^-?0%d'
local pattern = "^-?0%d"
if from:match(pattern) or to:match(pattern) then
format = '%0' .. math.max(#from, #to) .. 'd'
format = "%0" .. math.max(#from, #to) .. "d"
end
return resolve_sequence(from, to, step, function(i)
return string.format(format, i)
Expand Down Expand Up @@ -952,7 +952,7 @@ end
---@param s string: input string. e.g. {a..e..2} -> {a,c,e}, {00..05..2} -> {00,03,05}
---@return string[]: result of expansion, array with at least one string (one means it failed to expand and the raw string is returned)
M.brace_expand = function(s)
local preamble, postamble = brace_expand_split(s, '{')
local preamble, postamble = brace_expand_split(s, "{")
if postamble == nil then
return { s }
end
Expand All @@ -961,12 +961,12 @@ M.brace_expand = function(s)
postscript = postamble
while contents == nil do
local old_expr = expr
expr, postscript = brace_expand_split(postscript, '}')
expr, postscript = brace_expand_split(postscript, "}")
if old_expr then
expr = old_expr .. '}' .. expr
expr = old_expr .. "}" .. expr
end
if postscript == nil then -- No closing brace found, so we put back the unmatched '{'
preamble = preamble .. '{'
preamble = preamble .. "{"
expr, postscript = nil, postamble
end
contents = brace_expand_contents(expr)
Expand All @@ -983,5 +983,4 @@ M.brace_expand = function(s)
return result
end


return M
8 changes: 4 additions & 4 deletions tests/neo-tree/ui/icons_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("ui/icons", function()

vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")

vim.wait(100)

u.assert_buf_lines(bufnr, {
Expand Down Expand Up @@ -107,7 +107,7 @@ describe("ui/icons", function()

vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")

vim.wait(100)

u.assert_buf_lines(bufnr, {
Expand Down Expand Up @@ -170,7 +170,7 @@ describe("ui/icons", function()

vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")

vim.wait(100)

u.assert_buf_lines(bufnr, {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe("ui/icons", function()

vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")

vim.wait(100)

u.assert_buf_lines(bufnr, {
Expand Down
10 changes: 4 additions & 6 deletions tests/utils/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ function fs.create_temp_dir()
-- 2. Remove any double separators (on macOS TMPDIR can end in a trailing / which absolute doesn't remove, this should
-- be coverted by https://github.com/nvim-lua/plenary.nvim/issues/330).
local temp_dir = vim.fn.resolve(
Path
:new(
vim.fn.fnamemodify(vim.fn.tempname(), ":h"),
string.format("neo-tree-test-%s", vim.fn.rand())
)
:absolute()
Path:new(
vim.fn.fnamemodify(vim.fn.tempname(), ":h"),
string.format("neo-tree-test-%s", vim.fn.rand())
):absolute()
)
vim.fn.mkdir(temp_dir, "p")
return temp_dir
Expand Down