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:
@@ -105,8 +105,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if dest_stats then
|
if dest_stats then
|
||||||
|
local input_opts = {
|
||||||
|
prompt = "Rename to ",
|
||||||
|
default = dest,
|
||||||
|
completion = "dir",
|
||||||
|
}
|
||||||
|
|
||||||
if source == dest then
|
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()
|
utils.clear_prompt()
|
||||||
if new_dest then
|
if new_dest then
|
||||||
do_single_paste(source, new_dest, action_type, action_fn)
|
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
|
if item_short == "y" then
|
||||||
on_process()
|
on_process()
|
||||||
elseif item_short == "" or item_short == "r" then
|
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()
|
utils.clear_prompt()
|
||||||
if new_dest then
|
if new_dest then
|
||||||
do_single_paste(source, new_dest, action_type, action_fn)
|
do_single_paste(source, new_dest, action_type, action_fn)
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ function M.fn(node)
|
|||||||
|
|
||||||
local containing_folder = get_containing_folder(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)
|
vim.ui.input(input_opts, function(new_file_path)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
|
|||||||
@@ -77,7 +77,11 @@ function M.fn(default_modifier)
|
|||||||
default_path = default_path .. "/"
|
default_path = default_path .. "/"
|
||||||
end
|
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)
|
vim.ui.input(input_opts, function(new_file_path)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ function M.fn(node)
|
|||||||
}
|
}
|
||||||
table.insert(process.args, node.link_to or node.absolute_path)
|
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.handle, process.pid = vim.loop.spawn(process.cmd, opts, function(code)
|
||||||
process.stderr:read_stop()
|
process.stderr:read_stop()
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ function M.fn(opts)
|
|||||||
view.focus()
|
view.focus()
|
||||||
else
|
else
|
||||||
-- open
|
-- 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
|
end
|
||||||
|
|
||||||
-- find file
|
-- find file
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ function M.fn(opts, no_focus, cwd, bang)
|
|||||||
view.close()
|
view.close()
|
||||||
else
|
else
|
||||||
-- open
|
-- 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
|
-- find file
|
||||||
if M.config.update_focused_file.enable or opts.find_file then
|
if M.config.update_focused_file.enable or opts.find_file then
|
||||||
|
|||||||
@@ -2,13 +2,29 @@ local notify = require "nvim-tree.notify"
|
|||||||
|
|
||||||
local Api = {
|
local Api = {
|
||||||
tree = {},
|
tree = {},
|
||||||
node = { navigate = { sibling = {}, git = {}, diagnostics = {}, opened = {} }, run = {}, open = {} },
|
node = {
|
||||||
|
navigate = {
|
||||||
|
sibling = {},
|
||||||
|
git = {},
|
||||||
|
diagnostics = {},
|
||||||
|
opened = {},
|
||||||
|
},
|
||||||
|
run = {},
|
||||||
|
open = {},
|
||||||
|
},
|
||||||
events = {},
|
events = {},
|
||||||
marks = { bulk = {}, navigate = {} },
|
marks = {
|
||||||
fs = { copy = {} },
|
bulk = {},
|
||||||
|
navigate = {},
|
||||||
|
},
|
||||||
|
fs = {
|
||||||
|
copy = {},
|
||||||
|
},
|
||||||
git = {},
|
git = {},
|
||||||
live_filter = {},
|
live_filter = {},
|
||||||
config = { mappings = {} },
|
config = {
|
||||||
|
mappings = {},
|
||||||
|
},
|
||||||
commands = {},
|
commands = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ local CMDS = {
|
|||||||
complete = "dir",
|
complete = "dir",
|
||||||
},
|
},
|
||||||
command = function(c)
|
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,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,7 +79,11 @@ local CMDS = {
|
|||||||
bar = true,
|
bar = true,
|
||||||
},
|
},
|
||||||
command = function(c)
|
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,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -86,7 +95,12 @@ local CMDS = {
|
|||||||
complete = "dir",
|
complete = "dir",
|
||||||
},
|
},
|
||||||
command = function(c)
|
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,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ local log = require "nvim-tree.log"
|
|||||||
|
|
||||||
local M = {}
|
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 function from_nvim_lsp()
|
||||||
local buffer_severity = {}
|
local buffer_severity = {}
|
||||||
|
|||||||
@@ -176,7 +176,13 @@ local function open()
|
|||||||
vim.wo[M.winnr].cursorline = M.config.cursorline
|
vim.wo[M.winnr].cursorline = M.config.cursorline
|
||||||
|
|
||||||
-- quit binding
|
-- 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
|
-- close window and delete buffer on leave
|
||||||
vim.api.nvim_create_autocmd({ "BufLeave", "WinLeave" }, {
|
vim.api.nvim_create_autocmd({ "BufLeave", "WinLeave" }, {
|
||||||
|
|||||||
@@ -24,7 +24,13 @@ function M.default_on_attach(bufnr)
|
|||||||
local api = require('nvim-tree.api')
|
local api = require('nvim-tree.api')
|
||||||
|
|
||||||
local function opts(desc)
|
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
|
end
|
||||||
|
|
||||||
-- BEGIN_DEFAULT_ON_ATTACH
|
-- BEGIN_DEFAULT_ON_ATTACH
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ function M.bulk_move()
|
|||||||
return
|
return
|
||||||
end
|
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()
|
utils.clear_prompt()
|
||||||
if not location or location == "" then
|
if not location or location == "" then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -224,7 +224,11 @@ end
|
|||||||
function Builder:_get_git_icons(node)
|
function Builder:_get_git_icons(node)
|
||||||
local git_icons = git.get_icons(node)
|
local git_icons = git.get_icons(node)
|
||||||
if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then
|
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
|
git_icons = nil
|
||||||
end
|
end
|
||||||
return git_icons
|
return git_icons
|
||||||
@@ -235,7 +239,11 @@ end
|
|||||||
function Builder:_get_diagnostics_icon(node)
|
function Builder:_get_diagnostics_icon(node)
|
||||||
local diagnostics_icon = diagnostics.get_icon(node)
|
local diagnostics_icon = diagnostics.get_icon(node)
|
||||||
if diagnostics_icon and self.diagnostics_placement == "signcolumn" then
|
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
|
diagnostics_icon = nil
|
||||||
end
|
end
|
||||||
return diagnostics_icon
|
return diagnostics_icon
|
||||||
@@ -246,7 +254,11 @@ end
|
|||||||
function Builder:_get_modified_icon(node)
|
function Builder:_get_modified_icon(node)
|
||||||
local modified_icon = modified.get_icon(node)
|
local modified_icon = modified.get_icon(node)
|
||||||
if modified_icon and self.modified_placement == "signcolumn" then
|
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
|
modified_icon = nil
|
||||||
end
|
end
|
||||||
return modified_icon
|
return modified_icon
|
||||||
@@ -257,7 +269,11 @@ end
|
|||||||
function Builder:_get_bookmark_icon(node)
|
function Builder:_get_bookmark_icon(node)
|
||||||
local bookmark_icon = bookmarks.get_icon(node)
|
local bookmark_icon = bookmarks.get_icon(node)
|
||||||
if bookmark_icon and self.bookmarks_placement == "signcolumn" then
|
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
|
bookmark_icon = nil
|
||||||
end
|
end
|
||||||
return bookmark_icon
|
return bookmark_icon
|
||||||
|
|||||||
Reference in New Issue
Block a user