diff --git a/home/common/nvim/lua/tomodachi94/autocmds/init.lua b/home/common/nvim/lua/tomodachi94/autocmds/init.lua new file mode 100644 index 0000000..ba7aa0b --- /dev/null +++ b/home/common/nvim/lua/tomodachi94/autocmds/init.lua @@ -0,0 +1 @@ +require("tomodachi94.autocmds.set_cwd_automatically") diff --git a/home/common/nvim/lua/tomodachi94/autocmds/set_cwd_automatically.lua b/home/common/nvim/lua/tomodachi94/autocmds/set_cwd_automatically.lua new file mode 100644 index 0000000..5e5a244 --- /dev/null +++ b/home/common/nvim/lua/tomodachi94/autocmds/set_cwd_automatically.lua @@ -0,0 +1,8 @@ +vim.api.nvim_create_autocmd("BufEnter", { + callback = function(event_args) + local root = vim.fs.root(event_args.buf, { ".git", ".hg", "_FOSSIL", ".svn" }) + if root then + vim.uv.chdir(root) + end + end, +}) diff --git a/home/common/nvim/lua/tomodachi94/init.lua b/home/common/nvim/lua/tomodachi94/init.lua index ff66e5d..ec8aa3f 100644 --- a/home/common/nvim/lua/tomodachi94/init.lua +++ b/home/common/nvim/lua/tomodachi94/init.lua @@ -6,6 +6,7 @@ vim.cmd("source ~/.config/nvim/vimscript/no-autoload/source-vimscript.vim") require("tomodachi94.options") require("tomodachi94.keybinds") +require("tomodachi94.autocmds") require("tomodachi94.setup-plugins") require("tomodachi94.filetype.mcmeta") require("tomodachi94.filetype.gemrc")