summaryrefslogtreecommitdiff
path: root/lua/lvim/core/nvimtree.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-12-13 17:58:35 +0100
committerGitHub <[email protected]>2021-12-13 17:58:35 +0100
commit6cf21e9ddec41addf01744176afb2e138b3e1b3f (patch)
tree4abf843da0e2ed38689c872694b13d7418536106 /lua/lvim/core/nvimtree.lua
parent3a2d62ed2510ca05eb6ea87240a86df82338f5aa (diff)
parentb09ada89402e668ea1636bdbf671a89330199717 (diff)
Merge LunarVim/release-candidate
Diffstat (limited to 'lua/lvim/core/nvimtree.lua')
-rw-r--r--lua/lvim/core/nvimtree.lua69
1 files changed, 54 insertions, 15 deletions
diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua
index 893ddffc..cb91e344 100644
--- a/lua/lvim/core/nvimtree.lua
+++ b/lua/lvim/core/nvimtree.lua
@@ -6,12 +6,22 @@ function M.config()
active = true,
on_config_done = nil,
setup = {
+ disable_netrw = true,
+ hijack_netrw = true,
open_on_setup = false,
- auto_close = true,
- open_on_tab = false,
- update_focused_file = {
+ ignore_ft_on_setup = {
+ "startify",
+ "dashboard",
+ "alpha",
+ },
+ update_to_buf_dir = {
enable = true,
+ auto_open = true,
},
+ auto_close = true,
+ open_on_tab = false,
+ hijack_cursor = false,
+ update_cwd = false,
diagnostics = {
enable = true,
icons = {
@@ -21,14 +31,36 @@ function M.config()
error = "",
},
},
+ update_focused_file = {
+ enable = true,
+ update_cwd = true,
+ ignore_list = {},
+ },
+ system_open = {
+ cmd = nil,
+ args = {},
+ },
+ git = {
+ enable = true,
+ ignore = true,
+ timeout = 200,
+ },
view = {
width = 30,
+ height = 30,
side = "left",
auto_resize = true,
+ number = false,
+ relativenumber = false,
mappings = {
custom_only = false,
+ list = {},
},
},
+ filters = {
+ dotfiles = false,
+ custom = { ".git", "node_modules", ".cache" },
+ },
},
show_icons = {
git = 1,
@@ -37,13 +69,10 @@ function M.config()
folder_arrows = 1,
tree_width = 30,
},
- ignore = { ".git", "node_modules", ".cache" },
quit_on_open = 0,
- hide_dotfiles = 1,
git_hl = 1,
+ disable_window_picker = 0,
root_folder_modifier = ":t",
- allow_resize = 1,
- auto_ignore_ft = { "startify", "dashboard" },
icons = {
default = "",
symlink = "",
@@ -65,6 +94,7 @@ function M.config()
},
},
}
+ lvim.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
end
function M.setup()
@@ -73,10 +103,9 @@ function M.setup()
Log:error "Failed to load nvim-tree.config"
return
end
- local g = vim.g
for opt, val in pairs(lvim.builtin.nvimtree) do
- g["nvim_tree_" .. opt] = val
+ vim.g["nvim_tree_" .. opt] = val
end
-- Implicitly update nvim-tree when project module is active
@@ -88,21 +117,21 @@ function M.setup()
vim.g.netrw_banner = false
end
+ -- Add useful keymaps
local tree_cb = nvim_tree_config.nvim_tree_callback
-
- if not lvim.builtin.nvimtree.setup.view.mappings.list then
+ if #lvim.builtin.nvimtree.setup.view.mappings.list == 0 then
lvim.builtin.nvimtree.setup.view.mappings.list = {
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
{ key = "h", cb = tree_cb "close_node" },
{ key = "v", cb = tree_cb "vsplit" },
+ { key = "C", cb = tree_cb "cd" },
+ { key = "gtf", cb = "<cmd>lua require'lvim.core.nvimtree'.start_telescope('find_files')<cr>" },
+ { key = "gtg", cb = "<cmd>lua require'lvim.core.nvimtree'.start_telescope('live_grep')<cr>" },
}
end
- lvim.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
-
- local tree_view = require "nvim-tree.view"
-
-- Add nvim_tree open callback
+ local tree_view = require "nvim-tree.view"
local open = tree_view.open
tree_view.open = function()
M.on_open()
@@ -138,4 +167,14 @@ function M.change_tree_dir(dir)
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