From 77b7b4f3b7a4e426054e4779e111e72ab6eef56a Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 14 Oct 2022 09:47:19 +0200 Subject: [PATCH] vim: improve `nvim-tree` behavior and add mappings --- config/nvim/after/plugin/nvim-tree.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/config/nvim/after/plugin/nvim-tree.lua b/config/nvim/after/plugin/nvim-tree.lua index aebaa73..5619bbb 100644 --- a/config/nvim/after/plugin/nvim-tree.lua +++ b/config/nvim/after/plugin/nvim-tree.lua @@ -1,13 +1,30 @@ -local ok, plugin = pcall(require, 'nvim-tree') +local nt, callback + +local ok, _ = pcall(function() + nt = require 'nvim-tree' + callback = require 'nvim-tree.config'.nvim_tree_callback +end) + if not ok then return end -plugin.setup { +nt.setup { + disable_netrw = true, -- replace netrw with nvim-tree + hijack_cursor = true, -- keep the cursor on begin of the filename + sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree + git = { ignore = false, -- don't hide files from .gitignore }, view = { + adaptive_size = true, -- resize the window based on the longest line width = 35, -- a little wider than the default 30 + mappings = { + list = { + { key = { 'l', '', 'o' }, cb = callback 'edit' }, + { key = 'h', cb = callback 'close_node' }, + }, + }, }, filters = { @@ -19,9 +36,6 @@ plugin.setup { add_trailing = true, -- add trailing / to folders group_empty = true, -- folders that contain only one folder are grouped highlight_git = true, -- enable highlight based on git attributes - indent_markers = { - enable = true, -- show indent markers - }, }, }