@@ -8,13 +8,11 @@ mod ui;
9use application::Application;
9use application::Application;
11−use helix_core::config_dir;
13use std::path::PathBuf;
11use std::path::PathBuf;
15use anyhow::{Context, Error, Result};
13use anyhow::{Context, Error, Result};
17−fn setup_logging(verbosity: u64) -> Result<()> {
15+fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
18 let mut base_config = fern::Dispatch::new();
16 let mut base_config = fern::Dispatch::new();
20 // Let's say we depend on something which whose "info" level messages are too
18 // Let's say we depend on something which whose "info" level messages are too
@@ -40,7 +38,7 @@ fn setup_logging(verbosity: u64) -> Result<()> {
43− .chain(fern::log_file(config_dir().join("helix.log"))?);
41+ .chain(fern::log_file(logpath)?);
45 base_config.chain(file_config).apply()?;
43 base_config.chain(file_config).apply()?;
@@ -96,6 +94,12 @@ fn parse_args(mut args: Args) -> Result<Args> {
97#[tokio::main]
95#[tokio::main]
98async fn main() -> Result<()> {
96async fn main() -> Result<()> {
97+ let cache_dir = helix_core::cache_dir();
98+ if !cache_dir.exists() {
99+ std::fs::create_dir(&cache_dir);
102+ let logpath = cache_dir.join("helix.log");
99 let help = format!(
103 let help = format!(
@@ -111,12 +115,14 @@ ARGS:
112 -h, --help Prints help information
116 -h, --help Prints help information
113 -v Increases logging verbosity each use for up to 3 times
117 -v Increases logging verbosity each use for up to 3 times
114 -V, --version Prints version information
119 -V, --version Prints version information
116 env!("CARGO_PKG_NAME"),
121 env!("CARGO_PKG_NAME"),
117 env!("CARGO_PKG_VERSION"),
122 env!("CARGO_PKG_VERSION"),
118 env!("CARGO_PKG_AUTHORS"),
123 env!("CARGO_PKG_AUTHORS"),
119 env!("CARGO_PKG_DESCRIPTION"),
124 env!("CARGO_PKG_DESCRIPTION"),
122 let mut args: Args = Args {
128 let mut args: Args = Args {
@@ -139,19 +145,18 @@ FLAGS:
139 std::process::exit(0);
145 std::process::exit(0);
142− let conf_dir = config_dir();
148+ let conf_dir = helix_core::config_dir();
144 if !conf_dir.exists() {
149 if !conf_dir.exists() {
145 std::fs::create_dir(&conf_dir);
150 std::fs::create_dir(&conf_dir);
148− setup_logging(args.verbosity).context("failed to initialize logging")?;
153+ setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
150 // initialize language registry
155 // initialize language registry
151 use helix_core::syntax::{Loader, LOADER};
156 use helix_core::syntax::{Loader, LOADER};
153 // load $HOME/.config/helix/languages.toml, fallback to default config
158 // load $HOME/.config/helix/languages.toml, fallback to default config
154− let config = std::fs::read(config_dir().join("languages.toml"));
159+ let config = std::fs::read(helix_core::config_dir().join("languages.toml"));
155 let toml = config
160 let toml = config
156 .as_deref()
161 .as_deref()
157 .unwrap_or(include_bytes!("../../languages.toml"));
162 .unwrap_or(include_bytes!("../../languages.toml"));