Skip to content

Commit 4054fc4

Browse files
refactor: format tables line by line for better readability (#2456)
* Format tables line by line for better readability * Forgot a comma --------- Co-authored-by: Alexander Courtis <[email protected]>
1 parent e64a498 commit 4054fc4

File tree

13 files changed

+117
-22
lines changed

13 files changed

+117
-22
lines changed

lua/nvim-tree/actions/fs/copy-paste.lua

+8-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
105105
end
106106

107107
if dest_stats then
108+
local input_opts = {
109+
prompt = "Rename to ",
110+
default = dest,
111+
completion = "dir",
112+
}
113+
108114
if source == dest then
109-
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
115+
vim.ui.input(input_opts, function(new_dest)
110116
utils.clear_prompt()
111117
if new_dest then
112118
do_single_paste(source, new_dest, action_type, action_fn)
@@ -120,7 +126,7 @@ local function do_single_paste(source, dest, action_type, action_fn)
120126
if item_short == "y" then
121127
on_process()
122128
elseif item_short == "" or item_short == "r" then
123-
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
129+
vim.ui.input(input_opts, function(new_dest)
124130
utils.clear_prompt()
125131
if new_dest then
126132
do_single_paste(source, new_dest, action_type, action_fn)

lua/nvim-tree/actions/fs/create-file.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function M.fn(node)
4747

4848
local containing_folder = get_containing_folder(node)
4949

50-
local input_opts = { prompt = "Create file ", default = containing_folder, completion = "file" }
50+
local input_opts = {
51+
prompt = "Create file ",
52+
default = containing_folder,
53+
completion = "file",
54+
}
5155

5256
vim.ui.input(input_opts, function(new_file_path)
5357
utils.clear_prompt()

lua/nvim-tree/actions/fs/rename-file.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ function M.fn(default_modifier)
7777
default_path = default_path .. "/"
7878
end
7979

80-
local input_opts = { prompt = "Rename to ", default = default_path, completion = "file" }
80+
local input_opts = {
81+
prompt = "Rename to ",
82+
default = default_path,
83+
completion = "file",
84+
}
8185

8286
vim.ui.input(input_opts, function(new_file_path)
8387
utils.clear_prompt()

lua/nvim-tree/actions/node/system-open.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ function M.fn(node)
1717
}
1818
table.insert(process.args, node.link_to or node.absolute_path)
1919

20-
local opts = { args = process.args, stdio = { nil, nil, process.stderr }, detached = true }
20+
local opts = {
21+
args = process.args,
22+
stdio = { nil, nil, process.stderr },
23+
detached = true,
24+
}
2125

2226
process.handle, process.pid = vim.loop.spawn(process.cmd, opts, function(code)
2327
process.stderr:read_stop()

lua/nvim-tree/actions/tree/open.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ function M.fn(opts)
2929
view.focus()
3030
else
3131
-- open
32-
lib.open { path = opts.path, current_window = opts.current_window, winid = opts.winid }
32+
lib.open {
33+
path = opts.path,
34+
current_window = opts.current_window,
35+
winid = opts.winid,
36+
}
3337
end
3438

3539
-- find file

lua/nvim-tree/actions/tree/toggle.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ function M.fn(opts, no_focus, cwd, bang)
4545
view.close()
4646
else
4747
-- open
48-
lib.open { path = opts.path, current_window = opts.current_window, winid = opts.winid }
48+
lib.open {
49+
path = opts.path,
50+
current_window = opts.current_window,
51+
winid = opts.winid,
52+
}
4953

5054
-- find file
5155
if M.config.update_focused_file.enable or opts.find_file then

lua/nvim-tree/api.lua

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@ local notify = require "nvim-tree.notify"
22

33
local Api = {
44
tree = {},
5-
node = { navigate = { sibling = {}, git = {}, diagnostics = {}, opened = {} }, run = {}, open = {} },
5+
node = {
6+
navigate = {
7+
sibling = {},
8+
git = {},
9+
diagnostics = {},
10+
opened = {},
11+
},
12+
run = {},
13+
open = {},
14+
},
615
events = {},
7-
marks = { bulk = {}, navigate = {} },
8-
fs = { copy = {} },
16+
marks = {
17+
bulk = {},
18+
navigate = {},
19+
},
20+
fs = {
21+
copy = {},
22+
},
923
git = {},
1024
live_filter = {},
11-
config = { mappings = {} },
25+
config = {
26+
mappings = {},
27+
},
1228
commands = {},
1329
}
1430

lua/nvim-tree/commands.lua

+17-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ local CMDS = {
3333
complete = "dir",
3434
},
3535
command = function(c)
36-
api.tree.toggle { find_file = false, focus = true, path = c.args, update_root = false }
36+
api.tree.toggle {
37+
find_file = false,
38+
focus = true,
39+
path = c.args,
40+
update_root = false,
41+
}
3742
end,
3843
},
3944
{
@@ -74,7 +79,11 @@ local CMDS = {
7479
bar = true,
7580
},
7681
command = function(c)
77-
api.tree.find_file { open = true, focus = true, update_root = c.bang }
82+
api.tree.find_file {
83+
open = true,
84+
focus = true,
85+
update_root = c.bang,
86+
}
7887
end,
7988
},
8089
{
@@ -86,7 +95,12 @@ local CMDS = {
8695
complete = "dir",
8796
},
8897
command = function(c)
89-
api.tree.toggle { find_file = true, focus = true, path = c.args, update_root = c.bang }
98+
api.tree.toggle {
99+
find_file = true,
100+
focus = true,
101+
path = c.args,
102+
update_root = c.bang,
103+
}
90104
end,
91105
},
92106
{

lua/nvim-tree/diagnostics.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ local log = require "nvim-tree.log"
55

66
local M = {}
77

8-
local severity_levels = { Error = 1, Warning = 2, Information = 3, Hint = 4 }
8+
local severity_levels = {
9+
Error = 1,
10+
Warning = 2,
11+
Information = 3,
12+
Hint = 4,
13+
}
914

1015
local function from_nvim_lsp()
1116
local buffer_severity = {}

lua/nvim-tree/help.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,13 @@ local function open()
176176
vim.wo[M.winnr].cursorline = M.config.cursorline
177177

178178
-- quit binding
179-
vim.keymap.set("n", "q", close, { desc = "nvim-tree: exit help", buffer = M.bufnr, noremap = true, silent = true, nowait = true })
179+
vim.keymap.set("n", "q", close, {
180+
desc = "nvim-tree: exit help",
181+
buffer = M.bufnr,
182+
noremap = true,
183+
silent = true,
184+
nowait = true,
185+
})
180186

181187
-- close window and delete buffer on leave
182188
vim.api.nvim_create_autocmd({ "BufLeave", "WinLeave" }, {

lua/nvim-tree/keymap.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ function M.default_on_attach(bufnr)
2424
local api = require('nvim-tree.api')
2525

2626
local function opts(desc)
27-
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
27+
return {
28+
desc = 'nvim-tree: ' .. desc,
29+
buffer = bufnr,
30+
noremap = true,
31+
silent = true,
32+
nowait = true,
33+
}
2834
end
2935

3036
-- BEGIN_DEFAULT_ON_ATTACH

lua/nvim-tree/marks/bulk-move.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ function M.bulk_move()
1414
return
1515
end
1616

17-
vim.ui.input({ prompt = "Move to: ", default = core.get_cwd(), completion = "dir" }, function(location)
17+
local input_opts = {
18+
prompt = "Move to: ",
19+
default = core.get_cwd(),
20+
completion = "dir",
21+
}
22+
23+
vim.ui.input(input_opts, function(location)
1824
utils.clear_prompt()
1925
if not location or location == "" then
2026
return

lua/nvim-tree/renderer/builder.lua

+20-4
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ end
224224
function Builder:_get_git_icons(node)
225225
local git_icons = git.get_icons(node)
226226
if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then
227-
table.insert(self.signs, { sign = git_icons[1].hl[1], lnum = self.index + 1, priority = 1 })
227+
table.insert(self.signs, {
228+
sign = git_icons[1].hl[1],
229+
lnum = self.index + 1,
230+
priority = 1,
231+
})
228232
git_icons = nil
229233
end
230234
return git_icons
@@ -235,7 +239,11 @@ end
235239
function Builder:_get_diagnostics_icon(node)
236240
local diagnostics_icon = diagnostics.get_icon(node)
237241
if diagnostics_icon and self.diagnostics_placement == "signcolumn" then
238-
table.insert(self.signs, { sign = diagnostics_icon.hl[1], lnum = self.index + 1, priority = 2 })
242+
table.insert(self.signs, {
243+
sign = diagnostics_icon.hl[1],
244+
lnum = self.index + 1,
245+
priority = 2,
246+
})
239247
diagnostics_icon = nil
240248
end
241249
return diagnostics_icon
@@ -246,7 +254,11 @@ end
246254
function Builder:_get_modified_icon(node)
247255
local modified_icon = modified.get_icon(node)
248256
if modified_icon and self.modified_placement == "signcolumn" then
249-
table.insert(self.signs, { sign = modified_icon.hl[1], lnum = self.index + 1, priority = 3 })
257+
table.insert(self.signs, {
258+
sign = modified_icon.hl[1],
259+
lnum = self.index + 1,
260+
priority = 3,
261+
})
250262
modified_icon = nil
251263
end
252264
return modified_icon
@@ -257,7 +269,11 @@ end
257269
function Builder:_get_bookmark_icon(node)
258270
local bookmark_icon = bookmarks.get_icon(node)
259271
if bookmark_icon and self.bookmarks_placement == "signcolumn" then
260-
table.insert(self.signs, { sign = bookmark_icon.hl[1], lnum = self.index + 1, priority = 4 })
272+
table.insert(self.signs, {
273+
sign = bookmark_icon.hl[1],
274+
lnum = self.index + 1,
275+
priority = 4,
276+
})
261277
bookmark_icon = nil
262278
end
263279
return bookmark_icon

0 commit comments

Comments
 (0)