From 103d9391437b1a2088e95e0bd3e5ccd65e03f0c0 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 4 Sep 2023 20:23:49 +0200 Subject: [PATCH] Cleanup tree --- lua/config/tree.lua | 186 ++------------------------------------ lua/core/autocommands.lua | 7 +- lua/core/globals.lua | 3 + 3 files changed, 18 insertions(+), 178 deletions(-) diff --git a/lua/config/tree.lua b/lua/config/tree.lua index 3ab9ee9..c1afef9 100644 --- a/lua/config/tree.lua +++ b/lua/config/tree.lua @@ -16,119 +16,28 @@ -- https://github.com/nvim-tree/nvim-tree.lua -local nvim_tree = require("nvim-tree") - -nvim_tree.setup({ - auto_reload_on_write = true, - create_in_closed_folder = false, - disable_netrw = false, - hijack_cursor = true, - hijack_netrw = false, - hijack_unnamed_buffer_when_opening = false, - -- ignore_buffer_on_setup = false, - -- open_on_setup = false, - -- open_on_setup_file = false, - open_on_tab = false, - ignore_buf_on_tab_change = {}, - sort_by = "name", - root_dirs = {}, - prefer_startup_root = false, +require("nvim-tree").setup({ sync_root_with_cwd = true, - reload_on_bufenter = false, - respect_buf_cwd = false, - on_attach = "disable", - remove_keymaps = false, - select_prompts = false, view = { - adaptive_size = false, - centralize_selection = false, width = 40, - hide_root_folder = false, - side = "left", preserve_window_proportions = true, - number = false, - relativenumber = false, - signcolumn = "yes", - mappings = { - custom_only = false, - -- list = { - -- { key = "q", action = ""}, - -- }, - }, - float = { - enable = false, - quit_on_focus_loss = true, - open_win_config = { - relative = "editor", - border = "rounded", - width = 30, - height = 30, - row = 1, - col = 1, - }, - }, }, renderer = { add_trailing = true, group_empty = true, highlight_git = true, - full_name = false, highlight_opened_files = "name", - root_folder_modifier = ":~", - indent_width = 2, - indent_markers = { - enable = false, - inline_arrows = true, - icons = { - corner = "└", - edge = "│", - item = "│", - bottom = "─", - none = " ", - }, - }, icons = { - webdev_colors = true, - git_placement = "after", - padding = " ", - symlink_arrow = " ➛ ", - show = { - file = true, - folder = true, - folder_arrow = false, - git = true, - }, - glyphs = { - default = "", - symlink = "", - bookmark = "", + web_devicons = { folder = { - arrow_closed = "", - arrow_open = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌", + enable = true, }, }, + git_placement = "after", + show = { + folder_arrow = false, + }, }, - special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md", }, - symlink_destination = true, - }, - hijack_directories = { - enable = true, - auto_open = true, }, update_focused_file = { enable = true, @@ -137,96 +46,19 @@ nvim_tree.setup({ "help", }, }, - -- ignore_ft_on_setup = {}, - system_open = { - cmd = "", - args = {}, - }, diagnostics = { enable = true, show_on_dirs = false, - debounce_delay = 50, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - filters = { - dotfiles = false, - custom = {}, - exclude = {}, - }, - filesystem_watchers = { - enable = true, - debounce_delay = 50, - }, - git = { - enable = true, - ignore = true, - show_on_dirs = true, - timeout = 400, }, actions = { - use_system_clipboard = true, change_dir = { enable = false, - global = false, - restrict_above_cwd = false, - }, - expand_all = { - max_folder_discovery = 300, - exclude = {}, - }, - file_popup = { - open_win_config = { - col = 1, - row = 1, - relative = "cursor", - border = "shadow", - style = "minimal", - }, }, open_file = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", }, - buftype = { "nofile", "terminal", "help", }, - }, - }, - }, - remove_file = { - close_window = true, - }, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - live_filter = { - prefix = "[FILTER]: ", - always_show_folders = true, - }, - log = { - enable = false, - truncate = false, - types = { - all = false, - config = false, - copy_paste = false, - dev = false, - diagnostics = false, - git = false, - profile = false, - watcher = false, + resize_window = true, }, }, }) local opts = { remap = false, silent = true, } -vim.keymap.set("n", "tt", function () nvim_tree.toggle(false, true) end, opts) +vim.keymap.set("n", "tt", function () require("nvim-tree.api").tree.toggle() end, opts) diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua index e9eb88b..556ad90 100644 --- a/lua/core/autocommands.lua +++ b/lua/core/autocommands.lua @@ -20,8 +20,13 @@ local function term_close() -- Close previous window (terminal) vim.fn.execute(vim.fn.winnr("#") .. "wincmd q") end + +local function open_file_tree() + require("nvim-tree.api").tree.open() +end + vim.api.nvim_create_autocmd("TermClose", { pattern = "term://*", callback = term_close, }) - +vim.api.nvim_create_autocmd("VimEnter", { callback = open_file_tree, }) diff --git a/lua/core/globals.lua b/lua/core/globals.lua index 37d6c27..a351514 100644 --- a/lua/core/globals.lua +++ b/lua/core/globals.lua @@ -17,3 +17,6 @@ vim.g.mapleader = " " vim.g.vimsyn_embed = "1" vim.fn.execute("language en_US.utf-8") +-- Fix race condition in nvim-tree +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 \ No newline at end of file