dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit f99564d615d31d7ac75d357d606fe1d997d1183b
parent 27e012541e28bbab8a95aedb1da8ee0dccd15ea8
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri, 17 Oct 2025 15:35:56 +0900

nvim: add support for convenient cd shortcuts

Diffstat:
M.config/nvim/init.lua | 14++++++++++++++
A.config/nvim/lua/custom/utils.lua | 22++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua @@ -1,8 +1,22 @@ -- Core configuration options. require('config.options') + +-- General key mappings. require('config.keymaps') + +-- Machine-local keymaps (if they exist). +local local_keymaps_path = vim.fn.expand('~/.local/config/nvim/lua/config/keymaps.lua') +if vim.fn.filereadable(local_keymaps_path) == 1 then + dofile(local_keymaps_path) +end + +-- Colorschemes. require('config.colorscheme') + +-- Reusable code snippets. require('config.snippets') + +-- Project-specific code. require('config.projects') -- Package manager. diff --git a/.config/nvim/lua/custom/utils.lua b/.config/nvim/lua/custom/utils.lua @@ -0,0 +1,22 @@ +local M = {} + +function M.change_google3_subdir(subdir) + return function() + local cwd = vim.fn.getcwd() + local google3_pattern = "/google3" + local google3_start, google3_end = string.find(cwd, google3_pattern, 1, true) + + if google3_start then + local root = string.sub(cwd, 1, google3_end) + local new_dir = root .. "/" .. subdir + if vim.fn.isdirectory(new_dir) == 1 then + vim.cmd("cd " .. new_dir) + vim.notify("Changed directory to: " .. new_dir, vim.log.levels.INFO) + else + vim.notify("Directory not found: " .. new_dir, vim.log.levels.WARN) + end + end + end +end + +return M