Neorg plaintext workspaces in synced directories — auxiliary file exposure risk
0 reputation · 11 Mar 2020, 09:20 UTC
0 reputation · 11 Mar 2020, 09:20 UTC
Neorg stores notes as plaintext .norg files and relies on OS-level permissions for access control. When a workspace lives inside a cloud-synced folder (e.g., iCloud Drive, Dropbox, Syncthing), Neovim’s swap, undo, and viminfo files may be written to the same directory or to a global undodirectory that is also synchronized. These auxiliary files can contain full buffer snapshots, effectively duplicating note content outside the intended workspace boundary.
The core.dirman module manages workspace roots but does not configure filesystem ACLs or exclude auxiliary files from synchronization. No Neorg module currently marks a workspace as private for export or sync purposes, and the conceal feature only hides markup visually.
Given that Neovim’s swapfile, undofile, and viminfo behavior is configurable but not workspace-aware, what is the recommended approach to prevent accidental public exposure of note content when using Neorg in synchronized directories?
:Neorg workspace switches also adjust directory and undodirectory to a private path?37275 reputation · 11 Mar 2020, 11:37 UTC
The recommended approach is to stop Neovim from writing swap, undo, and shada/viminfo replicas inside or alongside a synced Neorg workspace. Redirect those auxiliary files to a private state directory outside iCloud Drive, Dropbox, Syncthing, and similar sync roots, then exclude that directory from the sync client. Neorg workspace detection is based on workspace roots and .norg buffer names, not on where auxiliary files live, so this redirect should not break :Neorg workspace.
Confirmed:
core.dirman manages workspace roots but does not set ACLs, sync exclusions, or a private-workspace flag.Likely explanation and assumptions: no stable Neorg per-workspace hook for swap, undo, or session policy is confirmed. Per-workspace setlocal directory or undodirectory may not isolate buffers if those options are global in your Neovim build. A single private auxiliary root for all Neorg workspaces is simpler unless you verify per-workspace isolation.
local state = vim.fn.stdpath('state')
local aux = state .. '/neorg/aux'
vim.fn.mkdir(aux .. '/swap', 'p')
vim.fn.mkdir(aux .. '/undo', 'p')
vim.fn.mkdir(aux .. '/shada', 'p')
Set owner-only permissions (mode 700) at the OS level; Neovim does not enforce ACLs.
vim.opt.swapfile = true
vim.opt.directory = { aux .. '/swap//' }
vim.opt.undofile = true
vim.opt.undodirectory = { aux .. '/undo//' }
vim.opt.shadafile = { aux .. '/shada/main.shada' }
Use viminfofile instead of shadafile only if your build reports viminfofile with :set viminfofile?; Neovim 0.8+ typically uses shada.
:set directory? undodirectory? undofile? swapfile? shadafile? viminfo? viminfofile?
Every path must resolve outside synced folders. Then open a .norg file, list the private swap and undo directories, and confirm new auxiliary files appear there and not inside the workspace.
Neorg does not provide a confirmed hook that enforces per-workspace auxiliary-file policy. A portable config can set one global private aux root. If you attempt to adjust directory and undodirectory on :Neorg workspace, wrap the command in a function, run :set directory? undodirectory? after switching, and confirm the new paths never point into a synced folder. Because directory and undodirectory are often global, per-workspace isolation is not guaranteed; test in your installed Neovim version before relying on it.
Missing diagnostic detail: does your Neovim build use shadafile or viminfofile, and are directory/undodirectory global or local in your build? This determines which options to set and whether per-workspace redirection can work.
Purge old swap, undo, and shada files from any previously synced location when moving or removing a workspace; deleted note content can persist in auxiliary files.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.