Skip to content

Commit 61ba9a6

Browse files
authored
build: fix stylua check (#409)
1 parent 811a7e2 commit 61ba9a6

29 files changed

+353
-340
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: JohnnyMorganz/[email protected]
2020
with:
2121
token: ${{ secrets.GITHUB_TOKEN }}
22-
args: --glob '*.lua' --glob '!defaults.lua' --check lua
22+
args: --color always --check lua/
2323

2424
plenary-tests:
2525
runs-on: ubuntu-20.04

lua/neo-tree.lua

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ local get_position = function(source_name)
3232
return pos
3333
end
3434

35-
3635
M.ensure_config = function()
3736
if not M.config then
3837
M.setup({ log_to_file = false }, true)
@@ -243,7 +242,6 @@ M.setup = function(config, is_auto_config)
243242
if not is_auto_config and netrw.get_hijack_netrw_behavior() ~= "disabled" then
244243
vim.cmd("silent! autocmd! FileExplorer *")
245244
end
246-
247245
end
248246

249247
M.show_logs = function()

lua/neo-tree/events/queue.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local log = require("neo-tree.log")
33

44
Node = {}
55
function Node:new(value)
6-
local props = {prev = nil, next = nil, value = value}
6+
local props = { prev = nil, next = nil, value = value }
77
setmetatable(props, self)
88
self.__index = self
99
return props

lua/neo-tree/git/status.lua

+56-58
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ M.status = function(base, exclude_directories, path)
144144
git_root = git_root,
145145
git_status = {},
146146
exclude_directories = exclude_directories,
147-
lines_parsed = 0
147+
lines_parsed = 0,
148148
}
149149

150150
for _, line in ipairs(staged_result) do
@@ -232,7 +232,7 @@ M.status_async = function(path, base, opts)
232232
return true
233233
end
234234

235-
local job_complete_callback = function ()
235+
local job_complete_callback = function()
236236
utils.debounce(event_id, nil, nil, nil, utils.debounce_action.COMPLETE_ASYNC_JOB)
237237
vim.schedule(function()
238238
events.fire_event(events.GIT_STATUS_CHANGED, {
@@ -247,67 +247,65 @@ M.status_async = function(path, base, opts)
247247
end)
248248

249249
utils.debounce(event_id, function()
250-
local staged_job = Job
251-
:new({
252-
command = "git",
253-
args = { "-C", git_root, "diff", "--staged", "--name-status", base, "--" },
254-
enable_recording = false,
255-
maximium_results = context.max_lines,
256-
on_stdout = vim.schedule_wrap(function(err, line, job)
257-
if should_process(err, line, job, "status_async staged error:") then
258-
table.insert(context.lines, line)
259-
end
260-
end),
261-
on_stderr = function(err, line)
262-
if err and err > 0 then
263-
log.error("status_async staged error: ", err, line)
264-
end
265-
end,
266-
})
250+
local staged_job = Job:new({
251+
command = "git",
252+
args = { "-C", git_root, "diff", "--staged", "--name-status", base, "--" },
253+
enable_recording = false,
254+
maximium_results = context.max_lines,
255+
on_stdout = vim.schedule_wrap(function(err, line, job)
256+
if should_process(err, line, job, "status_async staged error:") then
257+
table.insert(context.lines, line)
258+
end
259+
end),
260+
on_stderr = function(err, line)
261+
if err and err > 0 then
262+
log.error("status_async staged error: ", err, line)
263+
end
264+
end,
265+
})
267266

268-
local unstaged_job = Job
269-
:new({
270-
command = "git",
271-
args = { "-C", git_root, "diff", "--name-status" },
272-
enable_recording = false,
273-
maximium_results = context.max_lines,
274-
on_stdout = vim.schedule_wrap(function(err, line, job)
275-
if should_process(err, line, job, "status_async unstaged error:") then
276-
if line then
277-
line = " " .. line
278-
end
279-
table.insert(context.lines, line)
267+
local unstaged_job = Job:new({
268+
command = "git",
269+
args = { "-C", git_root, "diff", "--name-status" },
270+
enable_recording = false,
271+
maximium_results = context.max_lines,
272+
on_stdout = vim.schedule_wrap(function(err, line, job)
273+
if should_process(err, line, job, "status_async unstaged error:") then
274+
if line then
275+
line = " " .. line
280276
end
281-
end),
282-
on_stderr = function(err, line)
283-
if err and err > 0 then
284-
log.error("status_async unstaged error: ", err, line)
285-
end
286-
end,
287-
})
277+
table.insert(context.lines, line)
278+
end
279+
end),
280+
on_stderr = function(err, line)
281+
if err and err > 0 then
282+
log.error("status_async unstaged error: ", err, line)
283+
end
284+
end,
285+
})
288286

289-
local untracked_job = Job
290-
:new({
291-
command = "git",
292-
args = { "-C", git_root, "ls-files", "--exclude-standard", "--others" },
293-
enable_recording = false,
294-
maximium_results = context.max_lines,
295-
on_stdout = vim.schedule_wrap(function(err, line, job)
296-
if should_process(err, line, job, "status_async untracked error:") then
297-
if line then
298-
line = "? " .. line
299-
end
300-
table.insert(context.lines, line)
287+
local untracked_job = Job:new({
288+
command = "git",
289+
args = { "-C", git_root, "ls-files", "--exclude-standard", "--others" },
290+
enable_recording = false,
291+
maximium_results = context.max_lines,
292+
on_stdout = vim.schedule_wrap(function(err, line, job)
293+
if should_process(err, line, job, "status_async untracked error:") then
294+
if line then
295+
line = "? " .. line
301296
end
302-
end),
303-
on_stderr = function(err, line)
304-
if err and err > 0 then
305-
log.error("status_async untracked error: ", err, line)
306-
end
307-
end,
308-
})
297+
table.insert(context.lines, line)
298+
end
299+
end),
300+
on_stderr = function(err, line)
301+
if err and err > 0 then
302+
log.error("status_async untracked error: ", err, line)
303+
end
304+
end,
305+
})
309306

310-
local showUntracked = vim.fn.systemlist({"git", "-C", git_root, "config", "--get", "status.showUntrackedFiles"})
307+
local showUntracked =
308+
vim.fn.systemlist({ "git", "-C", git_root, "config", "--get", "status.showUntrackedFiles" })
311309
log.debug("git status.showUntrackedFiles =", showUntracked[1])
312310
if showUntracked[1] == "no" then
313311
unstaged_job:after(parse_lines)

lua/neo-tree/log.lua

+6-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
-- This library is free software; you can redistribute it and/or modify it
77
-- under the terms of the MIT license. See LICENSE for details.
88

9-
109
local vim = vim
1110
-- User configuration section
1211
local default_config = {
@@ -28,8 +27,8 @@ local default_config = {
2827
-- Level configuration
2928
modes = {
3029
{ name = "trace", hl = "None", level = vim.log.levels.TRACE },
31-
{ name = "debug", hl = "None" , level = vim.log.levels.DEBGUG},
32-
{ name = "info", hl = "None" , level = vim.log.levels.INFO},
30+
{ name = "debug", hl = "None", level = vim.log.levels.DEBGUG },
31+
{ name = "info", hl = "None", level = vim.log.levels.INFO },
3332
{ name = "warn", hl = "WarningMsg", level = vim.log.levels.WARN },
3433
{ name = "error", hl = "ErrorMsg", level = vim.log.levels.ERROR },
3534
{ name = "fatal", hl = "ErrorMsg", level = vim.log.levels.ERROR },
@@ -44,25 +43,22 @@ local log = {}
4443

4544
local unpack = unpack or table.unpack
4645

47-
local notify = function (message, level_config)
46+
local notify = function(message, level_config)
4847
if type(vim.notify) == "table" then
4948
-- probably using nvim-notify
5049
vim.notify(message, level_config.level, { title = "Neo-tree" })
5150
else
5251
local nameupper = level_config.name:upper()
53-
local console_string = string.format( "[Neo-tree %s] %s", nameupper, message)
52+
local console_string = string.format("[Neo-tree %s] %s", nameupper, message)
5453
vim.notify(console_string, level_config.level)
5554
end
5655
end
5756

5857
log.new = function(config, standalone)
5958
config = vim.tbl_deep_extend("force", default_config, config)
6059

61-
local outfile = string.format(
62-
"%s/%s.log",
63-
vim.api.nvim_call_function("stdpath", { "data" }),
64-
config.plugin
65-
)
60+
local outfile =
61+
string.format("%s/%s.log", vim.api.nvim_call_function("stdpath", { "data" }), config.plugin)
6662

6763
local obj
6864
if standalone then
@@ -96,7 +92,6 @@ log.new = function(config, standalone)
9692
levels[v.name] = i
9793
end
9894

99-
10095
obj.set_level = function(level)
10196
if levels[level] then
10297
if config.level ~= level then

lua/neo-tree/setup/deprecations.lua

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local utils = require "neo-tree.utils"
1+
local utils = require("neo-tree.utils")
22

33
local M = {}
44

@@ -9,7 +9,11 @@ M.show_migrations = function()
99
for i, message in ipairs(migrations) do
1010
migrations[i] = " * " .. message
1111
end
12-
table.insert(migrations, 1, "# Neo-tree configuration has been updated. Please review the changes below.")
12+
table.insert(
13+
migrations,
14+
1,
15+
"# Neo-tree configuration has been updated. Please review the changes below."
16+
)
1317
local buf = vim.api.nvim_create_buf(false, true)
1418
vim.api.nvim_buf_set_lines(buf, 0, -1, false, migrations)
1519
vim.api.nvim_buf_set_option(buf, "buftype", "nofile")
@@ -19,25 +23,26 @@ M.show_migrations = function()
1923
vim.api.nvim_buf_set_option(buf, "modifiable", false)
2024
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
2125
vim.api.nvim_buf_set_name(buf, "Neo-tree migrations")
22-
vim.defer_fn(function ()
26+
vim.defer_fn(function()
2327
vim.cmd(string.format("%ssplit", #migrations))
2428
vim.api.nvim_win_set_buf(0, buf)
2529
end, 100)
2630
end
2731
end
2832

29-
M.migrate = function (config)
33+
M.migrate = function(config)
3034
migrations = {}
3135

32-
local moved = function (old, new, converter)
36+
local moved = function(old, new, converter)
3337
local exising = utils.get_value(config, old)
3438
if type(exising) ~= "nil" then
3539
if type(converter) == "function" then
3640
exising = converter(exising)
3741
end
3842
utils.set_value(config, new, exising)
3943
config[old] = nil
40-
migrations[#migrations + 1] = string.format("The `%s` option has been deprecated, please use `%s` instead.", old, new)
44+
migrations[#migrations + 1] =
45+
string.format("The `%s` option has been deprecated, please use `%s` instead.", old, new)
4146
end
4247
end
4348

@@ -53,11 +58,12 @@ M.migrate = function (config)
5358
local value = utils.get_value(config, key)
5459
if value == old_value then
5560
utils.set_value(config, key, new_value)
56-
migrations[#migrations + 1] = string.format("The `%s=%s` option has been renamed to `%s`.", key, old_value, new_value)
61+
migrations[#migrations + 1] =
62+
string.format("The `%s=%s` option has been renamed to `%s`.", key, old_value, new_value)
5763
end
5864
end
5965

60-
local opposite = function (value)
66+
local opposite = function(value)
6167
return not value
6268
end
6369

@@ -67,7 +73,7 @@ M.migrate = function (config)
6773
removed("filesystem.filters.gitignore_source")
6874
removed("filesystem.filter_items.gitignore_source")
6975
renamed_value("filesystem.hijack_netrw_behavior", "open_split", "open_current")
70-
for _, source in ipairs({"filesystem", "buffers", "git_status"}) do
76+
for _, source in ipairs({ "filesystem", "buffers", "git_status" }) do
7177
renamed_value(source .. "window.position", "split", "current")
7278
end
7379

lua/neo-tree/setup/init.lua

+26-23
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local sources = {
1515
"filesystem",
1616
"buffers",
1717
"git_status",
18-
"example"
18+
"example",
1919
}
2020

2121
local M = {}
@@ -50,22 +50,23 @@ local define_events = function()
5050
return args
5151
end)
5252

53-
events.define_autocmd_event(
54-
events.VIM_BUFFER_CHANGED,
55-
{ "BufWritePost", "BufFilePost" },
56-
200
57-
)
53+
events.define_autocmd_event(events.VIM_BUFFER_CHANGED, { "BufWritePost", "BufFilePost" }, 200)
5854

59-
events.define_autocmd_event(events.VIM_BUFFER_MODIFIED_SET, { "BufModifiedSet" }, 0, function(args)
60-
if utils.is_real_file(args.afile) then
61-
-- we could use args.afile to update the sigle file that changed, but it seems like we miss
62-
-- buffers when `:wa` is used.
63-
args.modified_buffers = utils.get_modified_buffers()
64-
return args
65-
else
66-
return false
55+
events.define_autocmd_event(
56+
events.VIM_BUFFER_MODIFIED_SET,
57+
{ "BufModifiedSet" },
58+
0,
59+
function(args)
60+
if utils.is_real_file(args.afile) then
61+
-- we could use args.afile to update the sigle file that changed, but it seems like we miss
62+
-- buffers when `:wa` is used.
63+
args.modified_buffers = utils.get_modified_buffers()
64+
return args
65+
else
66+
return false
67+
end
6768
end
68-
end)
69+
)
6970

7071
events.define_autocmd_event(events.VIM_BUFFER_ADDED, { "BufAdd" }, 200)
7172
events.define_autocmd_event(events.VIM_BUFFER_DELETED, { "BufDelete" }, 200)
@@ -78,15 +79,15 @@ local define_events = function()
7879
events.define_autocmd_event(events.VIM_LEAVE, { "VimLeavePre" })
7980
events.define_autocmd_event(events.VIM_WIN_CLOSED, { "WinClosed" })
8081
events.define_autocmd_event(events.VIM_COLORSCHEME, { "ColorScheme" }, 0)
81-
events.define_autocmd_event(events.GIT_EVENT, { "User FugitiveChanged" }, 100 )
82+
events.define_autocmd_event(events.GIT_EVENT, { "User FugitiveChanged" }, 100)
8283
events.define_event(events.GIT_STATUS_CHANGED, { debounce_frequency = 0 })
8384
events_setup = true
8485

8586
events.subscribe({
8687
event = events.VIM_LEAVE,
8788
handler = function()
8889
events.clear_all_events()
89-
end
90+
end,
9091
})
9192
end
9293

@@ -100,9 +101,10 @@ M.buffer_enter_event = function()
100101
setlocal nolist nospell nonumber norelativenumber
101102
]])
102103

103-
local winhighlight = 'Normal:NeoTreeNormal,NormalNC:NeoTreeNormalNC,SignColumn:NeoTreeSignColumn,CursorLine:NeoTreeCursorLine,FloatBorder:NeoTreeFloatBorder,StatusLine:NeoTreeStatusLine,StatusLineNC:NeoTreeStatusLineNC,VertSplit:NeoTreeVertSplit,EndOfBuffer:NeoTreeEndOfBuffer'
104+
local winhighlight =
105+
"Normal:NeoTreeNormal,NormalNC:NeoTreeNormalNC,SignColumn:NeoTreeSignColumn,CursorLine:NeoTreeCursorLine,FloatBorder:NeoTreeFloatBorder,StatusLine:NeoTreeStatusLine,StatusLineNC:NeoTreeStatusLineNC,VertSplit:NeoTreeVertSplit,EndOfBuffer:NeoTreeEndOfBuffer"
104106
if vim.version().minor >= 7 then
105-
vim.cmd("setlocal winhighlight=" .. winhighlight .. ',WinSeparator:NeoTreeWinSeparator')
107+
vim.cmd("setlocal winhighlight=" .. winhighlight .. ",WinSeparator:NeoTreeWinSeparator")
106108
else
107109
vim.cmd("setlocal winhighlight=" .. winhighlight)
108110
end
@@ -409,10 +411,11 @@ M.merge_config = function(user_config, is_auto_config)
409411
normalize_mappings(user_config)
410412
merge_renderers(default_config, nil, user_config)
411413
for _, source_name in ipairs(sources) do
412-
default_config[source_name] = default_config[source_name] or {
413-
renderers = {},
414-
components = {},
415-
}
414+
default_config[source_name] = default_config[source_name]
415+
or {
416+
renderers = {},
417+
components = {},
418+
}
416419
local source_default_config = default_config[source_name]
417420
local mod_root = "neo-tree.sources." .. source_name
418421
source_default_config.components = require(mod_root .. ".components")

0 commit comments

Comments
 (0)