LunarVim/lua/lvim/core/nvimtree.lua
LostNeophyte ccb80e41ee
refactor: migrate to lazy.nvim (#3647)
* refactor: convert plugins spec to lazy

* refactor(lazy): remove impatient

* fix(telescope): no more errors if theme is nil

* refactor(lazy): use lazy in plugin_loader

* refactor(lazy): pin plugins with packer's snapshot

* fix: add plugins to rtp before config:init

* fix: fs_stat nil check

* feat: lazy cache

* feat(lazy): reloading

* refactor(lazy): plugin-loader functions

* feat(lazy): cache reset

* refactor: set runtimepath manually

* fix: runtimepath

* refactor(rtp)

* refactor(lazy): packer -> lazy in various places

* fix(lazy): disable tree-sitter ensure installed

* refactor(lazy): restore order to bootstrap

* refactor(lazy): remove unused impatient profiler

* small fixes

* `lvim.plugins` deprecation handling

* fix: deprecation of `requires` in plugin specs

* feat: core plugins pinning

* refactor(lazy): plugin loader tests

* refactor(lazy): use lazy in scripts

* refactor(lazy): which-key keybinds

* chore: format

* fix: installer

* fix: first time setup

* feat: changes required for packaging

commit 951ac2b7c01b5200b973660c967852d1706cce28
Author: LostNeophyte <lostneophyte@tuta.io>
Date:   Wed Dec 28 13:49:44 2022 +0100

    fix: clean folder before copying plugins

commit 64e9afa44b8e528ba527e0510d0d8c2d2237a095
Author: LostNeophyte <lostneophyte@tuta.io>
Date:   Wed Dec 28 13:35:41 2022 +0100

    feat: copy core plugins on first run

commit 2d8e72090c7624f68c09a9aa6582223373a810c1
Author: LostNeophyte <lostneophyte@tuta.io>
Date:   Wed Dec 28 13:11:22 2022 +0100

    feat(utils): fs_copy

commit 85c1f025a6ba13183e85141f75f60e2eefc77bb5
Author: LostNeophyte <lostneophyte@tuta.io>
Date:   Wed Dec 28 13:04:38 2022 +0100

    fix: copy correct example config

* fix: packer specs deprecation handling

* fix: plugin specs deprecation

* feat: pin lazy's version

* fix: remove plugins form rtp before loading lazy

* fix: plugin-loader test

* feat(lazy): add keymappings for profile, log, and debug (#3665)

* feat(lazy): Add keymappings for profile, log, and debug

* feat(lazy): Add keymap for cleaning

* chore: format

* pref: lazy load many plugins

Co-authored-by: Uzair Aftab <uzaaft@outlook.com>

* fix: bootstrap correct version of lazy

* fix: also use CmdLineEnter event for cmp

* fix: don't use lazy's modules before it's set up

* perf: (hack) enable lazy's cache before loading lazy

* fix: plugins.lua

* fix: plugins bump script

* chore: remove debug print

* feat: add rounded border for `:Lazy`

* fix: bufferline flashing

* fix: don't close lazy on startup

* fix: load breadcrumbs on startup

* fix: don't lazy load bufferline

* chore: bump lazy's version

* fix: remove site from rtp (fixes treesitter issues)

* revert default config copying changes

* fix(bootstrap): actually remove plugins dir on windows

* chore: bump lazy's version

* chore: bump lazy's version

Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com>
Co-authored-by: Uzair Aftab <uzaaft@outlook.com>
Co-authored-by: opalmay <opal.mizrahi2@gmail.com>
2023-01-10 21:18:17 +01:00

295 lines
8.2 KiB
Lua

local M = {}
local Log = require "lvim.core.log"
function M.config()
lvim.builtin.nvimtree = {
active = true,
on_config_done = nil,
setup = {
auto_reload_on_write = false,
disable_netrw = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false,
open_on_setup = false,
open_on_setup_file = false,
sort_by = "name",
root_dirs = {},
prefer_startup_root = false,
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 = 30,
hide_root_folder = false,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
mappings = {
custom_only = false,
list = {},
},
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 = false,
group_empty = false,
highlight_git = true,
full_name = false,
highlight_opened_files = "none",
root_folder_label = ":t",
indent_width = 2,
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "",
edge = "",
item = "",
none = " ",
},
},
icons = {
webdev_colors = lvim.use_icons,
git_placement = "before",
padding = " ",
symlink_arrow = "",
show = {
file = lvim.use_icons,
folder = lvim.use_icons,
folder_arrow = lvim.use_icons,
git = lvim.use_icons,
},
glyphs = {
default = lvim.icons.ui.Text,
symlink = lvim.icons.ui.FileSymlink,
bookmark = lvim.icons.ui.BookMark,
folder = {
arrow_closed = lvim.icons.ui.TriangleShortArrowRight,
arrow_open = lvim.icons.ui.TriangleShortArrowDown,
default = lvim.icons.ui.Folder,
open = lvim.icons.ui.FolderOpen,
empty = lvim.icons.ui.EmptyFolder,
empty_open = lvim.icons.ui.EmptyFolderOpen,
symlink = lvim.icons.ui.FolderSymlink,
symlink_open = lvim.icons.ui.FolderOpen,
},
git = {
unstaged = lvim.icons.git.FileUnstaged,
staged = lvim.icons.git.FileStaged,
unmerged = lvim.icons.git.FileUnmerged,
renamed = lvim.icons.git.FileRenamed,
untracked = lvim.icons.git.FileUntracked,
deleted = lvim.icons.git.FileDeleted,
ignored = lvim.icons.git.FileIgnored,
},
},
},
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
symlink_destination = true,
},
hijack_directories = {
enable = false,
auto_open = true,
},
update_focused_file = {
enable = true,
debounce_delay = 15,
update_root = true,
ignore_list = {},
},
ignore_ft_on_setup = {
"startify",
"dashboard",
"alpha",
},
diagnostics = {
enable = lvim.use_icons,
show_on_dirs = false,
show_on_open_dirs = true,
debounce_delay = 50,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
icons = {
hint = lvim.icons.diagnostics.BoldHint,
info = lvim.icons.diagnostics.BoldInformation,
warning = lvim.icons.diagnostics.BoldWarning,
error = lvim.icons.diagnostics.BoldError,
},
},
filters = {
dotfiles = false,
git_clean = false,
no_buffer = false,
custom = { "node_modules", "\\.cache" },
exclude = {},
},
filesystem_watchers = {
enable = true,
debounce_delay = 50,
ignore_dirs = {},
},
git = {
enable = true,
ignore = false,
show_on_dirs = true,
show_on_open_dirs = true,
timeout = 200,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
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,
picker = "default",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "lazy", "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,
},
tab = {
sync = {
open = false,
close = false,
ignore = {},
},
},
notify = {
threshold = vim.log.levels.INFO,
},
log = {
enable = false,
truncate = false,
types = {
all = false,
config = false,
copy_paste = false,
dev = false,
diagnostics = false,
git = false,
profile = false,
watcher = false,
},
},
system_open = {
cmd = nil,
args = {},
},
},
}
end
function M.setup()
local status_ok, nvim_tree = pcall(require, "nvim-tree")
if not status_ok then
Log:error "Failed to load nvim-tree"
return
end
if lvim.builtin.nvimtree._setup_called then
Log:debug "ignoring repeated setup call for nvim-tree, see kyazdani42/nvim-tree.lua#1308"
return
end
lvim.builtin.nvimtree._setup_called = true
-- Implicitly update nvim-tree when project module is active
if lvim.builtin.project.active then
lvim.builtin.nvimtree.setup.respect_buf_cwd = true
lvim.builtin.nvimtree.setup.update_cwd = true
lvim.builtin.nvimtree.setup.update_focused_file = { enable = true, update_cwd = true }
end
local function telescope_find_files(_)
require("lvim.core.nvimtree").start_telescope "find_files"
end
local function telescope_live_grep(_)
require("lvim.core.nvimtree").start_telescope "live_grep"
end
-- Add useful keymaps
if #lvim.builtin.nvimtree.setup.view.mappings.list == 0 then
lvim.builtin.nvimtree.setup.view.mappings.list = {
{ key = { "l", "<CR>", "o" }, action = "edit", mode = "n" },
{ key = "h", action = "close_node" },
{ key = "v", action = "vsplit" },
{ key = "C", action = "cd" },
{ key = "gtf", action = "telescope_find_files", action_cb = telescope_find_files },
{ key = "gtg", action = "telescope_live_grep", action_cb = telescope_live_grep },
}
end
nvim_tree.setup(lvim.builtin.nvimtree.setup)
if lvim.builtin.nvimtree.on_config_done then
lvim.builtin.nvimtree.on_config_done(nvim_tree)
end
end
function M.start_telescope(telescope_mode)
local node = require("nvim-tree.lib").get_node_at_cursor()
local abspath = node.link_to or node.absolute_path
local is_folder = node.open ~= nil
local basedir = is_folder and abspath or vim.fn.fnamemodify(abspath, ":h")
require("telescope.builtin")[telescope_mode] {
cwd = basedir,
}
end
return M