neorg icon indicating copy to clipboard operation
neorg copied to clipboard

`autochdir = false` not behaving as expected

Open jakobkhansen opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] I have read contribution guidelines
  • [X] I am using the latest version of the plugin
  • [X] I am using either 0.6 stable or the latest compiled neovim version

Neovim Version

NVIM v0.8.0-dev+165-g8658e82357 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/jakob/.cache/yay/neovim-git/src/build/config -I/home/jakob/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/jakob/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/jakob/.cache/yay/neovim-git/src/build/include Compiled by jakob@eduroam-193-157-212-216 Features: +acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim" Run :checkhealth for more info

Neorg setup

require("neorg").setup({
	load = {
		["core.defaults"] = {}, -- Load all the default modules
		["core.norg.dirman"] = { -- Manage your directories with Neorg
			config = {
				workspaces = {
					gtd = "~/Documents/gtd",
				},
                autochdir = false,
                open_last_workspace = false
			},
		},
		["core.norg.completion"] = {
			config = {
				engine = "nvim-cmp", -- We current support nvim-compe and nvim-cmp only
			},
		},
		["core.norg.concealer"] = {
		},
		["core.keybinds"] = { -- Configure core.keybinds
			config = {
				default_keybinds = true, -- Generate the default keybinds
				neorg_leader = "<Leader>o", -- This is the default if unspecified
			},
		},
        ["core.presenter"] = {
            config = {
                zen_mode = "zen-mode"
            }
        },
		["core.gtd.ui"] = {},
		["core.gtd.queries"] = {},
		["core.gtd.base"] = {
			config = {
				workspace = "gtd",
				exclude = {
					"journal",
				},
			},
		},
		["core.norg.journal"] = {
			config = {
				workspace = "gtd",
			},
		},
	},
})

Actual behavior

I have set autochdir = false in core.norg.dirman, I open both .norg files other filetypes. I cannot change the cwd when the neorg file is open, and if I tab through buffers, Neorg sets the cwd to the .norg files workspace root, and it persists when tabbing to non-neorg files.

Expected behavior

I would expect Neorg to not change my cwd at all.

Steps to reproduce

Open .norg file, :cd .., cwd does not change.

Potentially conflicting plugins

No response

Other information

No response

Help

No

Implementation help

No response

jakobkhansen avatar May 09 '22 14:05 jakobkhansen

I'd like to add that:

  • When I open two tabs and only then run NeorgStart, only the tab that I ran NeorgStart from changes its working directory. But when I configure autochdir = true both tabs changes.
  • When I use Neorg commands that open files (like Neorg journal ...) in the tab that did not change the working directory, it opens it relative to cwd instead of using the workspace's root directory.

idanarye avatar Jul 31 '22 13:07 idanarye

Thanks for all the info! Dealing with working directories is quite the pain, I'll see what I can do

vhyrro avatar Aug 02 '22 15:08 vhyrro

to quote https://github.com/nvim-neorg/neorg/wiki/Dirman#changing-the-current-working-directory

After a recent update core.dirman will no longer change the current working directory after switching workspace. To get the best experience it's recommended to set the autochdir Neovim option.

Is this issue still relevant?

d-r-a-b avatar Apr 20 '23 15:04 d-r-a-b

This issue has since been fixed, both because dirman does not change your working directory, but if it does it now does so in a more tame way. Closing as complete!

vhyrro avatar Apr 27 '23 15:04 vhyrro