aboutsummaryrefslogtreecommitdiffstats
path: root/neovim/.config/nvim/lua/config/autocmds.lua
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2026-09-24 19:43:46 +0200
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2026-09-24 19:43:46 +0200
commitfcbdefe39ef741f8fdcd23cbc537b2e16ccd2490 (patch)
treeb882673332bc632bd690dd4c7b58be4c4c288396 /neovim/.config/nvim/lua/config/autocmds.lua
parent84b9eb4d9751b9c6b0e9408417684590c43f2831 (diff)
downloaddotfiles-fcbdefe39ef741f8fdcd23cbc537b2e16ccd2490.tar.gz
dotfiles-fcbdefe39ef741f8fdcd23cbc537b2e16ccd2490.tar.bz2
dotfiles-fcbdefe39ef741f8fdcd23cbc537b2e16ccd2490.zip
Fixed stuff
Diffstat (limited to 'neovim/.config/nvim/lua/config/autocmds.lua')
-rw-r--r--neovim/.config/nvim/lua/config/autocmds.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/config/autocmds.lua b/neovim/.config/nvim/lua/config/autocmds.lua
index e9ebe04..5ebe5ec 100644
--- a/neovim/.config/nvim/lua/config/autocmds.lua
+++ b/neovim/.config/nvim/lua/config/autocmds.lua
@@ -13,6 +13,27 @@ vim.api.nvim_create_autocmd("BufWritePre", {
13 callback = strip_trailing_whitespace, 13 callback = strip_trailing_whitespace,
14}) 14})
15 15
16-- Make the directory Neovim was opened with (`nvim .`, `nvim ~/project`,
17-- `nvim /some/dir`) the cwd for the whole session, not just the cwd of the
18-- directory-listing buffer it shows. Only fires for the "single directory
19-- argument" invocation; opening files, multiple args, or no args leaves cwd
20-- untouched. Uses chdir() (global scope, like :cd) rather than :lcd/:tcd
21-- since this should apply session-wide. This itself fires DirChanged, so
22-- the handler below re-runs and correctly picks up a .nvim.lua for the new
23-- directory too.
24vim.api.nvim_create_autocmd("VimEnter", {
25 callback = function()
26 if vim.fn.argc() ~= 1 then
27 return
28 end
29 local arg = vim.fn.argv(0)
30 if vim.fn.isdirectory(arg) == 0 then
31 return
32 end
33 vim.fn.chdir(vim.fn.fnamemodify(arg, ":p"))
34 end,
35})
36
16-- Project-local config: search upward from cwd for a .nvim.lua, the same 37-- Project-local config: search upward from cwd for a .nvim.lua, the same
17-- nearest-ancestor pattern LSP root-dir detection uses, so it's found 38-- nearest-ancestor pattern LSP root-dir detection uses, so it's found
18-- regardless of exactly which subdirectory Neovim's cwd is or how you got 39-- regardless of exactly which subdirectory Neovim's cwd is or how you got