LunarVim/lua/lvim/core/nvimtree.lua

345 lines
9.5 KiB
Lua
Raw Normal View History

2021-06-28 04:11:33 +02:00
local M = {}
local Log = require "lvim.core.log"
function M.config()
lvim.builtin.nvimtree = {
active = true,
on_config_done = nil,
setup = {
experimental = {},
auto_reload_on_write = false,
disable_netrw = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
sort = {
sorter = "name",
folders_first = true,
files_first = false,
},
root_dirs = {},
prefer_startup_root = false,
sync_root_with_cwd = true,
reload_on_bufenter = false,
respect_buf_cwd = false,
on_attach = "default",
select_prompts = false,
view = {
adaptive_size = false,
centralize_selection = true,
width = 30,
cursorline = true,
debounce_delay = 15,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
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 = "name",
highlight_opened_files = "none",
root_folder_label = ":t",
full_name = false,
indent_width = 2,
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
symlink_destination = true,
highlight_diagnostics = "none",
highlight_modified = "none",
highlight_bookmarks = "none",
highlight_clipboard = "name",
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "",
edge = "",
item = "",
bottom = "",
none = " ",
},
},
icons = {
webdev_colors = lvim.use_icons,
web_devicons = {
file = {
enable = lvim.use_icons,
color = lvim.use_icons,
},
folder = {
enable = false,
color = lvim.use_icons,
},
},
git_placement = "before",
padding = " ",
symlink_arrow = "",
modified_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "signcolumn",
show = {
file = lvim.use_icons,
folder = lvim.use_icons,
folder_arrow = lvim.use_icons,
git = lvim.use_icons,
modified = lvim.use_icons,
diagnostics = lvim.use_icons,
bookmarks = lvim.use_icons,
},
glyphs = {
default = lvim.icons.ui.Text,
symlink = lvim.icons.ui.FileSymlink,
bookmark = lvim.icons.ui.BookMark,
modified = lvim.icons.ui.Circle,
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,
},
},
},
},
hijack_directories = {
enable = false,
auto_open = true,
},
update_focused_file = {
enable = true,
update_root = {
enable = true,
ignore_list = {},
},
exclude = false,
},
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,
},
},
2021-11-29 09:12:13 +01:00
filters = {
enable = true,
2021-11-29 09:12:13 +01:00
dotfiles = false,
git_clean = false,
git_ignored = false,
no_bookmark = false,
no_buffer = false,
custom = { "node_modules", "\\.cache" },
exclude = {},
},
filesystem_watchers = {
enable = true,
debounce_delay = 50,
ignore_dirs = {},
2021-11-29 09:12:13 +01:00
},
git = {
enable = true,
show_on_dirs = true,
show_on_open_dirs = true,
disable_for_dirs = {},
timeout = 400,
cygwin_support = false,
},
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,
eject = true,
resize_window = false,
window_picker = {
enable = true,
picker = "default",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
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
filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
remove_file = {
close_window = true,
},
},
trash = {
cmd = "gio trash",
},
live_filter = {
prefix = "[FILTER]: ",
always_show_folders = true,
},
tab = {
sync = {
open = false,
close = false,
ignore = {},
},
},
notify = {
threshold = vim.log.levels.INFO,
absolute_path = true,
},
ui = {
confirm = {
remove = true,
trash = true,
default_yes = false,
},
},
modified = {
enable = false,
show_on_dirs = true,
show_on_open_dirs = true,
},
help = {
sort_by = "key",
},
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.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
local function on_attach(bufnr)
local api = require "nvim-tree.api"
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
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
api.config.mappings.default_on_attach(bufnr)
local useful_keys = {
["l"] = { api.node.open.edit, opts "Open" },
["o"] = { api.node.open.edit, opts "Open" },
["<CR>"] = { api.node.open.edit, opts "Open" },
["v"] = { api.node.open.vertical, opts "Open: Vertical Split" },
["h"] = { api.node.navigate.parent_close, opts "Close Directory" },
["C"] = { api.tree.change_root_to_node, opts "CD" },
["gtg"] = { telescope_live_grep, opts "Telescope Live Grep" },
["gtf"] = { telescope_find_files, opts "Telescope Find File" },
}
require("lvim.keymappings").load_mode("n", useful_keys)
end
function M.setup()
local status_ok, nvim_tree = pcall(require, "nvim-tree")
2021-07-18 13:27:06 +02:00
if not status_ok then
Log:error "Failed to load nvim-tree"
2021-07-18 13:27:06 +02:00
return
end
2021-04-15 06:17:48 +02:00
-- 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
lvim.builtin.nvimtree.setup.update_focused_file.update_cwd = true
end
-- Add useful keymaps
if lvim.builtin.nvimtree.setup.on_attach == "default" then
lvim.builtin.nvimtree.setup.on_attach = on_attach
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
2021-06-28 04:11:33 +02:00
return M