From 5552b5c7433214faa99a4fd400e50c12f10a0940 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Thu, 8 Jun 2023 20:50:59 -0400 Subject: [PATCH] neovim: cd to git directory if it exists This prevents an issue where it was previously possible to open files in vim without the current directory being the project root. --- modules/neovim/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 07c38ef6..3966e0bc 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -60,6 +60,10 @@ in { autocmd BufNewFile,BufRead *.ecr setlocal syntax=html autocmd BufWritePre,FileWritePre * silent! call mkdir(expand(':p:h'), 'p') + augroup cdgit + autocmd! + autocmd VimEnter * silent! :cd `git rev-parse --show-toplevel` + augroup END ''; plugins = with pkgs.vimPlugins; [ {