Skip to content

refactor: format tables line by line for better readability #2456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2023
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
10 changes: 8 additions & 2 deletions lua/nvim-tree/actions/fs/copy-paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/actions/fs/create-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/actions/fs/rename-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/actions/node/system-open.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/actions/tree/open.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/actions/tree/toggle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
}

Expand Down
20 changes: 17 additions & 3 deletions lua/nvim-tree/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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,
},
{
Expand All @@ -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,
},
{
Expand Down
7 changes: 6 additions & 1 deletion lua/nvim-tree/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
8 changes: 7 additions & 1 deletion lua/nvim-tree/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" }, {
Expand Down
8 changes: 7 additions & 1 deletion lua/nvim-tree/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lua/nvim-tree/marks/bulk-move.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions lua/nvim-tree/renderer/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down