feat: support working directory via env and config (#3301)

This commit is contained in:
Alexsander Falcucci 2025-11-19 03:01:30 +01:00 committed by GitHub
parent 9fcbdef17c
commit 822874fd4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 3 deletions

View file

@ -159,7 +159,7 @@ pub struct CmdLineSettings {
pub opengl: bool,
/// Change to this directory during startup.
#[arg(long = "chdir")]
#[arg(long = "chdir", env = "NEOVIDE_CHDIR")]
pub chdir: Option<String>,
}

View file

@ -60,6 +60,7 @@ pub struct Config {
pub wsl: Option<bool>,
pub backtraces_path: Option<PathBuf>,
pub icon: Option<String>,
pub chdir: Option<PathBuf>,
}
#[derive(Debug, Clone, PartialEq)]
@ -125,6 +126,9 @@ impl Config {
if let Some(icon) = &self.icon {
env::set_var("NEOVIDE_ICON", icon);
}
if let Some(chdir) = &self.chdir {
env::set_var("NEOVIDE_CHDIR", chdir.to_string_lossy().to_string());
}
}
// TODO: should maybe return well-typed error?

View file

@ -273,9 +273,12 @@ Wayland, depending on what you are running on.
### Working Directory
```sh
--chdir <path>
--chdir <path> or $NEOVIDE_CHDIR
```
**Unreleased yet.**
Start neovim in the specified working directory. This will impact neovim
arguments that use relative path names (e.g. file names), and the initial
working directory for all instances of neovim or terminal.
working directory for all instances of neovim or terminal. This value can
also be set via the `chdir` entry in the [Neovide Config File](config-file.md).

View file

@ -30,6 +30,7 @@ Settings currently available in the config file with default values:
```toml
backtraces_path = "/path/to/neovide_backtraces.log" # see below for the default platform specific location
chdir = "/path/to/dir"
fork = false
frame = "full"
idle = true