From c229f41c61753d594085ea867ed3f0e05042a69d Mon Sep 17 00:00:00 2001 From: Akmadan23 Date: Sun, 8 Oct 2023 11:27:20 +0200 Subject: [PATCH 1/2] Format tables line by line for better readability --- lua/nvim-tree/actions/fs/copy-paste.lua | 10 +++++++-- lua/nvim-tree/actions/fs/create-file.lua | 6 +++++- lua/nvim-tree/actions/fs/rename-file.lua | 6 +++++- lua/nvim-tree/actions/node/system-open.lua | 6 +++++- lua/nvim-tree/actions/tree/open.lua | 6 +++++- lua/nvim-tree/actions/tree/toggle.lua | 6 +++++- lua/nvim-tree/api.lua | 24 ++++++++++++++++++---- lua/nvim-tree/commands.lua | 20 +++++++++++++++--- lua/nvim-tree/diagnostics.lua | 7 ++++++- lua/nvim-tree/help.lua | 8 +++++++- lua/nvim-tree/keymap.lua | 8 +++++++- lua/nvim-tree/marks/bulk-move.lua | 8 +++++++- lua/nvim-tree/renderer/builder.lua | 24 ++++++++++++++++++---- 13 files changed, 117 insertions(+), 22 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index abf25cf37f1..3ac651da90c 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -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) diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index a9569f6fc26..37ae4147b29 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -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() diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index a21eb6c80b2..caae5d0a0e6 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -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() diff --git a/lua/nvim-tree/actions/node/system-open.lua b/lua/nvim-tree/actions/node/system-open.lua index 9220c651360..6c12d186ec1 100644 --- a/lua/nvim-tree/actions/node/system-open.lua +++ b/lua/nvim-tree/actions/node/system-open.lua @@ -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() diff --git a/lua/nvim-tree/actions/tree/open.lua b/lua/nvim-tree/actions/tree/open.lua index 23a5d89d0d2..d4e759f8692 100644 --- a/lua/nvim-tree/actions/tree/open.lua +++ b/lua/nvim-tree/actions/tree/open.lua @@ -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 diff --git a/lua/nvim-tree/actions/tree/toggle.lua b/lua/nvim-tree/actions/tree/toggle.lua index 89ca2048d2a..10bff08c7eb 100644 --- a/lua/nvim-tree/actions/tree/toggle.lua +++ b/lua/nvim-tree/actions/tree/toggle.lua @@ -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 diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index 8b11fe5cfcb..fb6f3fdb234 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -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 = {}, } diff --git a/lua/nvim-tree/commands.lua b/lua/nvim-tree/commands.lua index ea622c03e2a..e5013f5753e 100644 --- a/lua/nvim-tree/commands.lua +++ b/lua/nvim-tree/commands.lua @@ -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, }, { diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 798e901470f..c1d783a7f4a 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -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 = {} diff --git a/lua/nvim-tree/help.lua b/lua/nvim-tree/help.lua index 8ccbb1bfb49..78617cb025e 100644 --- a/lua/nvim-tree/help.lua +++ b/lua/nvim-tree/help.lua @@ -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" }, { diff --git a/lua/nvim-tree/keymap.lua b/lua/nvim-tree/keymap.lua index 3742fc82392..b61f3ac1ed5 100644 --- a/lua/nvim-tree/keymap.lua +++ b/lua/nvim-tree/keymap.lua @@ -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 diff --git a/lua/nvim-tree/marks/bulk-move.lua b/lua/nvim-tree/marks/bulk-move.lua index 84672901277..8d77558a318 100644 --- a/lua/nvim-tree/marks/bulk-move.lua +++ b/lua/nvim-tree/marks/bulk-move.lua @@ -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 diff --git a/lua/nvim-tree/renderer/builder.lua b/lua/nvim-tree/renderer/builder.lua index 4f933b10935..0fb9bd8229d 100644 --- a/lua/nvim-tree/renderer/builder.lua +++ b/lua/nvim-tree/renderer/builder.lua @@ -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 From 44fc5542e93b863c1dd1a763de6554a8024a46d5 Mon Sep 17 00:00:00 2001 From: Akmadan23 Date: Sun, 8 Oct 2023 11:38:16 +0200 Subject: [PATCH 2/2] Forgot a comma --- lua/nvim-tree/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index fb6f3fdb234..c4a6e8771b6 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -7,7 +7,7 @@ local Api = { sibling = {}, git = {}, diagnostics = {}, - opened = {} + opened = {}, }, run = {}, open = {},