From c23e87f56cbe76a0ca9124e539f6228d5e6ca80e Mon Sep 17 00:00:00 2001 From: aleidk Date: Tue, 12 Sep 2023 20:33:02 -0300 Subject: [PATCH] update astronvim config --- config/Distro-AstroNvim | 2 +- .../astronvim/lua/user/plugins/nvim-tree.lua | 41 +++++++++++-------- config/zsh/zshrc | 2 +- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/config/Distro-AstroNvim b/config/Distro-AstroNvim index f10b473..dad0bec 160000 --- a/config/Distro-AstroNvim +++ b/config/Distro-AstroNvim @@ -1 +1 @@ -Subproject commit f10b4730176b567e15911b3c1a7c5a31c82c8b8e +Subproject commit dad0bec1fef2833561d04ea446a544fbfde92539 diff --git a/config/astronvim/lua/user/plugins/nvim-tree.lua b/config/astronvim/lua/user/plugins/nvim-tree.lua index 1e6deb5..37e73a9 100644 --- a/config/astronvim/lua/user/plugins/nvim-tree.lua +++ b/config/astronvim/lua/user/plugins/nvim-tree.lua @@ -1,6 +1,6 @@ return { "nvim-tree/nvim-tree.lua", - -- enabled = false, + enabled = true, version = "*", dependencies = { "nvim-tree/nvim-web-devicons", @@ -8,7 +8,7 @@ return { lazy = false, config = function() local tree = require("nvim-tree") - local tree_cb = require("nvim-tree.config").nvim_tree_callback + local api = require("nvim-tree.api") tree.setup({ hijack_unnamed_buffer_when_opening = true, @@ -31,23 +31,28 @@ return { }, view = { centralize_selection = true, -- center current file on enter - width = 30, -- N° of columns or % - mappings = { - custom_only = false, - -- list of mappings to set on the tree manually - list = { - { key = { "l", "", "o", "<2-LeftMouse>" }, action = "edit" }, - -- {key = {"L", "<2-RightMouse>", ""}, action = "cd"}, - { key = "s", action = "vsplit" }, - { key = "v", action = "split" }, - { key = "t", action = "tabnew" }, - { key = { "h", "" }, action = "close_node" }, - { key = "i", action = "toggle_dotfiles" }, - { key = "I", action = "toggle_ignored" }, - { key = { "", "" }, cb = tree_cb("system_open") }, - }, - }, + width = 30, -- N° of columns or % }, + on_attach = function(bufnr) + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Check defaults here: https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach + api.config.mappings.default_on_attach(bufnr) + + vim.keymap.set("n", "l", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "o", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "s", api.node.open.vertical, opts("Open in vsplit")) + vim.keymap.set("n", "v", api.node.open.horizontal, opts("Open in hsplit")) + vim.keymap.set("n", "t", api.node.open.tab, opts("Open in tab")) + vim.keymap.set("n", "h", api.node.navigate.parent_close, opts("Close dir")) + vim.keymap.set("n", "", api.node.navigate.parent_close, opts("Close dir")) + vim.keymap.set("n", "i", api.tree.toggle_hidden_filter, opts("Toggle Dotfiles")) + vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore")) + end, }) -- Auto open when a dir is opened diff --git a/config/zsh/zshrc b/config/zsh/zshrc index 7f325c0..8a0af90 100755 --- a/config/zsh/zshrc +++ b/config/zsh/zshrc @@ -110,5 +110,5 @@ if [[ "$ZPROF" = true ]]; then fi eval "$(starship init zsh)" -# eval "$(rtx activate zsh)" +eval "$(rtx activate zsh)" # eval "$(zellij setup --generate-auto-start zsh)"