diff --git a/.config/nvim/lua/plugin/Filetree.lua b/.config/nvim/lua/plugin/Filetree.lua index 1bdf76d..8d61b72 100644 --- a/.config/nvim/lua/plugin/Filetree.lua +++ b/.config/nvim/lua/plugin/Filetree.lua @@ -2,12 +2,27 @@ vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 +local function my_on_attach(bufnr) + local api = require "nvim-tree.api" + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Default mappings. + api.config.mappings.default_on_attach(bufnr) + + -- Custom mappings. + vim.keymap.set('n', '', api.tree.change_root_to_node, opts('Cd into')) +end + -- Set termguicolors to enable highlight groups. vim.opt.termguicolors = true -- Setup nvim-tree. require("nvim-tree").setup({ - sort_by = "case_sensitive", + on_attach = my_on_attach, + sort_by = "case_sensitive", view = { width = 30, }, diff --git a/.config/nvim/lua/plugin/Init.lua b/.config/nvim/lua/plugin/Init.lua index bac49bd..e2be9bb 100644 --- a/.config/nvim/lua/plugin/Init.lua +++ b/.config/nvim/lua/plugin/Init.lua @@ -48,9 +48,9 @@ return require("packer").startup(function(use) local treesitter = true -- Plugin setup. Order is important. + require("plugin/Filetree") require("plugin/Mason") require("plugin/lsp/Init") - require("plugin/Filetree") require("plugin/Bufferline") require("plugin/Lualine") require("plugin/Autoclose")