From 021d2774e7783564ad2dc84b4474ac272f2767e9 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 8 Apr 2024 13:18:48 +0200 Subject: [PATCH] cd to startup directory keymap --- init.lua | 3 +++ lua/keymaps.lua | 2 ++ 2 files changed, 5 insertions(+) diff --git a/init.lua b/init.lua index 3ed4ea3..817ae07 100644 --- a/init.lua +++ b/init.lua @@ -6,6 +6,9 @@ vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed vim.g.have_nerd_font = true +-- Save start directory as base +vim.g.base_dir = vim.fn.getcwd() + -- [[ Setting options ]] require 'options' diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 206211c..d326f0f 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -39,6 +39,8 @@ vim.keymap.set('v', 'pny', '"_dP', { desc = '[P]aste [N]o [Y]ank' }) -- Populate CMD to prepare for change directory vim.keymap.set('n', 'cd ', ':cd ', { desc = 'Prepare CMD for [C]hange [D]irectory' }) +-- Navigate to 'base' directory, the initial dir that nvim was run in +vim.keymap.set('n', 'cdh', 'cd ' .. vim.g.base_dir .. '', { desc = '[C]hange [D]irectory to [H]ome' }) -- Delete current buffer without closing window vim.keymap.set('n', 'bd', 'bpspbnbd', { desc = '[B]uffer [D]elete' })