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 <alex@courtis.org>
This commit is contained in:
Azad
2023-10-14 09:07:28 +02:00
committed by GitHub
parent e64a498a5e
commit 4054fc4be3
13 changed files with 117 additions and 22 deletions

View File

@@ -105,8 +105,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
end
if dest_stats then
local input_opts = {
prompt = "Rename to ",
default = dest,
completion = "dir",
}
if source == dest then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
vim.ui.input(input_opts, function(new_dest)
utils.clear_prompt()
if new_dest then
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)
if item_short == "y" then
on_process()
elseif item_short == "" or item_short == "r" then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
vim.ui.input(input_opts, function(new_dest)
utils.clear_prompt()
if new_dest then
do_single_paste(source, new_dest, action_type, action_fn)

View File

@@ -47,7 +47,11 @@ function M.fn(node)
local containing_folder = get_containing_folder(node)
local input_opts = { prompt = "Create file ", default = containing_folder, completion = "file" }
local input_opts = {
prompt = "Create file ",
default = containing_folder,
completion = "file",
}
vim.ui.input(input_opts, function(new_file_path)
utils.clear_prompt()

View File

@@ -77,7 +77,11 @@ function M.fn(default_modifier)
default_path = default_path .. "/"
end
local input_opts = { prompt = "Rename to ", default = default_path, completion = "file" }
local input_opts = {
prompt = "Rename to ",
default = default_path,
completion = "file",
}
vim.ui.input(input_opts, function(new_file_path)
utils.clear_prompt()

View File

@@ -17,7 +17,11 @@ function M.fn(node)
}
table.insert(process.args, node.link_to or node.absolute_path)
local opts = { args = process.args, stdio = { nil, nil, process.stderr }, detached = true }
local opts = {
args = process.args,
stdio = { nil, nil, process.stderr },
detached = true,
}
process.handle, process.pid = vim.loop.spawn(process.cmd, opts, function(code)
process.stderr:read_stop()

View File

@@ -29,7 +29,11 @@ function M.fn(opts)
view.focus()
else
-- open
lib.open { path = opts.path, current_window = opts.current_window, winid = opts.winid }
lib.open {
path = opts.path,
current_window = opts.current_window,
winid = opts.winid,
}
end
-- find file

View File

@@ -45,7 +45,11 @@ function M.fn(opts, no_focus, cwd, bang)
view.close()
else
-- open
lib.open { path = opts.path, current_window = opts.current_window, winid = opts.winid }
lib.open {
path = opts.path,
current_window = opts.current_window,
winid = opts.winid,
}
-- find file
if M.config.update_focused_file.enable or opts.find_file then

View File

@@ -2,13 +2,29 @@ local notify = require "nvim-tree.notify"
local Api = {
tree = {},
node = { navigate = { sibling = {}, git = {}, diagnostics = {}, opened = {} }, run = {}, open = {} },
node = {
navigate = {
sibling = {},
git = {},
diagnostics = {},
opened = {},
},
run = {},
open = {},
},
events = {},
marks = { bulk = {}, navigate = {} },
fs = { copy = {} },
marks = {
bulk = {},
navigate = {},
},
fs = {
copy = {},
},
git = {},
live_filter = {},
config = { mappings = {} },
config = {
mappings = {},
},
commands = {},
}

View File

@@ -33,7 +33,12 @@ local CMDS = {
complete = "dir",
},
command = function(c)
api.tree.toggle { find_file = false, focus = true, path = c.args, update_root = false }
api.tree.toggle {
find_file = false,
focus = true,
path = c.args,
update_root = false,
}
end,
},
{
@@ -74,7 +79,11 @@ local CMDS = {
bar = true,
},
command = function(c)
api.tree.find_file { open = true, focus = true, update_root = c.bang }
api.tree.find_file {
open = true,
focus = true,
update_root = c.bang,
}
end,
},
{
@@ -86,7 +95,12 @@ local CMDS = {
complete = "dir",
},
command = function(c)
api.tree.toggle { find_file = true, focus = true, path = c.args, update_root = c.bang }
api.tree.toggle {
find_file = true,
focus = true,
path = c.args,
update_root = c.bang,
}
end,
},
{

View File

@@ -5,7 +5,12 @@ local log = require "nvim-tree.log"
local M = {}
local severity_levels = { Error = 1, Warning = 2, Information = 3, Hint = 4 }
local severity_levels = {
Error = 1,
Warning = 2,
Information = 3,
Hint = 4,
}
local function from_nvim_lsp()
local buffer_severity = {}

View File

@@ -176,7 +176,13 @@ local function open()
vim.wo[M.winnr].cursorline = M.config.cursorline
-- quit binding
vim.keymap.set("n", "q", close, { desc = "nvim-tree: exit help", buffer = M.bufnr, noremap = true, silent = true, nowait = true })
vim.keymap.set("n", "q", close, {
desc = "nvim-tree: exit help",
buffer = M.bufnr,
noremap = true,
silent = true,
nowait = true,
})
-- close window and delete buffer on leave
vim.api.nvim_create_autocmd({ "BufLeave", "WinLeave" }, {

View File

@@ -24,7 +24,13 @@ function M.default_on_attach(bufnr)
local api = require('nvim-tree.api')
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
return {
desc = 'nvim-tree: ' .. desc,
buffer = bufnr,
noremap = true,
silent = true,
nowait = true,
}
end
-- BEGIN_DEFAULT_ON_ATTACH

View File

@@ -14,7 +14,13 @@ function M.bulk_move()
return
end
vim.ui.input({ prompt = "Move to: ", default = core.get_cwd(), completion = "dir" }, function(location)
local input_opts = {
prompt = "Move to: ",
default = core.get_cwd(),
completion = "dir",
}
vim.ui.input(input_opts, function(location)
utils.clear_prompt()
if not location or location == "" then
return

View File

@@ -224,7 +224,11 @@ end
function Builder:_get_git_icons(node)
local git_icons = git.get_icons(node)
if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then
table.insert(self.signs, { sign = git_icons[1].hl[1], lnum = self.index + 1, priority = 1 })
table.insert(self.signs, {
sign = git_icons[1].hl[1],
lnum = self.index + 1,
priority = 1,
})
git_icons = nil
end
return git_icons
@@ -235,7 +239,11 @@ end
function Builder:_get_diagnostics_icon(node)
local diagnostics_icon = diagnostics.get_icon(node)
if diagnostics_icon and self.diagnostics_placement == "signcolumn" then
table.insert(self.signs, { sign = diagnostics_icon.hl[1], lnum = self.index + 1, priority = 2 })
table.insert(self.signs, {
sign = diagnostics_icon.hl[1],
lnum = self.index + 1,
priority = 2,
})
diagnostics_icon = nil
end
return diagnostics_icon
@@ -246,7 +254,11 @@ end
function Builder:_get_modified_icon(node)
local modified_icon = modified.get_icon(node)
if modified_icon and self.modified_placement == "signcolumn" then
table.insert(self.signs, { sign = modified_icon.hl[1], lnum = self.index + 1, priority = 3 })
table.insert(self.signs, {
sign = modified_icon.hl[1],
lnum = self.index + 1,
priority = 3,
})
modified_icon = nil
end
return modified_icon
@@ -257,7 +269,11 @@ end
function Builder:_get_bookmark_icon(node)
local bookmark_icon = bookmarks.get_icon(node)
if bookmark_icon and self.bookmarks_placement == "signcolumn" then
table.insert(self.signs, { sign = bookmark_icon.hl[1], lnum = self.index + 1, priority = 4 })
table.insert(self.signs, {
sign = bookmark_icon.hl[1],
lnum = self.index + 1,
priority = 4,
})
bookmark_icon = nil
end
return bookmark_icon