aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/application.rs14
-rw-r--r--helix-term/src/health.rs10
-rw-r--r--helix-term/src/main.rs10
-rw-r--r--helix-term/tests/test/commands/write.rs2
-rw-r--r--helix-term/tests/test/helpers.rs18
5 files changed, 24 insertions, 30 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index b5150a13..b844b5f0 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -96,11 +96,7 @@ fn setup_integration_logging() {
}
impl Application {
- pub fn new(
- args: Args,
- config: Config,
- syn_loader_conf: syntax::Configuration,
- ) -> Result<Self, Error> {
+ pub fn new(args: Args, config: Config, lang_loader: syntax::Loader) -> Result<Self, Error> {
#[cfg(feature = "integration")]
setup_integration_logging();
@@ -126,7 +122,7 @@ impl Application {
})
.unwrap_or_else(|| theme_loader.default_theme(true_color));
- let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
+ let syn_loader = std::sync::Arc::new(lang_loader);
#[cfg(not(feature = "integration"))]
let backend = CrosstermBackend::new(stdout(), &config.editor);
@@ -394,10 +390,8 @@ impl Application {
/// refresh language config after config change
fn refresh_language_config(&mut self) -> Result<(), Error> {
- let syntax_config = helix_core::config::user_syntax_loader()
- .map_err(|err| anyhow::anyhow!("Failed to load language config: {}", err))?;
-
- self.syn_loader = std::sync::Arc::new(syntax::Loader::new(syntax_config));
+ let lang_loader = helix_core::config::user_lang_loader()?;
+ self.syn_loader = std::sync::Arc::new(lang_loader);
self.editor.syn_loader = self.syn_loader.clone();
for document in self.editor.documents.values_mut() {
document.detect_language(self.syn_loader.clone());
diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs
index 5f201926..0bbb5735 100644
--- a/helix-term/src/health.rs
+++ b/helix-term/src/health.rs
@@ -2,7 +2,7 @@ use crossterm::{
style::{Color, Print, Stylize},
tty::IsTty,
};
-use helix_core::config::{default_syntax_loader, user_syntax_loader};
+use helix_core::config::{default_lang_config, user_lang_config};
use helix_loader::grammar::load_runtime_file;
use helix_view::clipboard::get_clipboard_provider;
use std::io::Write;
@@ -128,7 +128,7 @@ pub fn languages_all() -> std::io::Result<()> {
let stdout = std::io::stdout();
let mut stdout = stdout.lock();
- let mut syn_loader_conf = match user_syntax_loader() {
+ let mut syn_loader_conf = match user_lang_config() {
Ok(conf) => conf,
Err(err) => {
let stderr = std::io::stderr();
@@ -141,7 +141,7 @@ pub fn languages_all() -> std::io::Result<()> {
err
)?;
writeln!(stderr, "{}", "Using default language config".yellow())?;
- default_syntax_loader()
+ default_lang_config()
}
};
@@ -234,7 +234,7 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
let stdout = std::io::stdout();
let mut stdout = stdout.lock();
- let syn_loader_conf = match user_syntax_loader() {
+ let syn_loader_conf = match user_lang_config() {
Ok(conf) => conf,
Err(err) => {
let stderr = std::io::stderr();
@@ -247,7 +247,7 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
err
)?;
writeln!(stderr, "{}", "Using default language config".yellow())?;
- default_syntax_loader()
+ default_lang_config()
}
};
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index 132ee796..fbe1a846 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -145,18 +145,18 @@ FLAGS:
}
};
- let syn_loader_conf = helix_core::config::user_syntax_loader().unwrap_or_else(|err| {
- eprintln!("Bad language config: {}", err);
+ let lang_loader = helix_core::config::user_lang_loader().unwrap_or_else(|err| {
+ eprintln!("{}", err);
eprintln!("Press <ENTER> to continue with default language config");
use std::io::Read;
// This waits for an enter press.
let _ = std::io::stdin().read(&mut []);
- helix_core::config::default_syntax_loader()
+ helix_core::config::default_lang_loader()
});
// TODO: use the thread local executor to spawn the application task separately from the work pool
- let mut app = Application::new(args, config, syn_loader_conf)
- .context("unable to create new application")?;
+ let mut app =
+ Application::new(args, config, lang_loader).context("unable to create new application")?;
let exit_code = app.run(&mut EventStream::new()).await?;
diff --git a/helix-term/tests/test/commands/write.rs b/helix-term/tests/test/commands/write.rs
index adc721c5..f65352c7 100644
--- a/helix-term/tests/test/commands/write.rs
+++ b/helix-term/tests/test/commands/write.rs
@@ -315,7 +315,7 @@ async fn test_write_auto_format_fails_still_writes() -> anyhow::Result<()> {
let mut app = helpers::AppBuilder::new()
.with_file(file.path(), None)
.with_input_text("#[l|]#et foo = 0;\n")
- .with_lang_config(helpers::test_syntax_conf(Some(lang_conf.into())))
+ .with_lang_loader(helpers::test_syntax_loader(Some(lang_conf.into())))
.build()?;
test_key_sequences(&mut app, vec![(Some(":w<ret>"), None)], false).await?;
diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs
index 112b5e35..a978f386 100644
--- a/helix-term/tests/test/helpers.rs
+++ b/helix-term/tests/test/helpers.rs
@@ -139,7 +139,7 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
let test_case = test_case.into();
let mut app = match app {
Some(app) => app,
- None => Application::new(Args::default(), test_config(), test_syntax_conf(None))?,
+ None => Application::new(Args::default(), test_config(), test_syntax_loader(None))?,
};
let (view, doc) = helix_view::current!(app.editor);
@@ -162,9 +162,9 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
.await
}
-/// Generates language configs that merge in overrides, like a user language
+/// Generates language config loader that merge in overrides, like a user language
/// config. The argument string must be a raw TOML document.
-pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Configuration {
+pub fn test_syntax_loader(overrides: Option<String>) -> helix_core::syntax::Loader {
let mut lang = helix_loader::config::default_lang_config();
if let Some(overrides) = overrides {
@@ -172,7 +172,7 @@ pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Config
lang = helix_loader::merge_toml_values(lang, override_toml, 3);
}
- lang.try_into().unwrap()
+ helix_core::syntax::Loader::new(lang.try_into().unwrap()).unwrap()
}
/// Use this for very simple test cases where there is one input
@@ -271,7 +271,7 @@ pub fn new_readonly_tempfile() -> anyhow::Result<NamedTempFile> {
pub struct AppBuilder {
args: Args,
config: Config,
- syn_conf: helix_core::syntax::Configuration,
+ syn_loader: helix_core::syntax::Loader,
input: Option<(String, Selection)>,
}
@@ -280,7 +280,7 @@ impl Default for AppBuilder {
Self {
args: Args::default(),
config: test_config(),
- syn_conf: test_syntax_conf(None),
+ syn_loader: test_syntax_loader(None),
input: None,
}
}
@@ -314,8 +314,8 @@ impl AppBuilder {
self
}
- pub fn with_lang_config(mut self, syn_conf: helix_core::syntax::Configuration) -> Self {
- self.syn_conf = syn_conf;
+ pub fn with_lang_loader(mut self, syn_loader: helix_core::syntax::Loader) -> Self {
+ self.syn_loader = syn_loader;
self
}
@@ -328,7 +328,7 @@ impl AppBuilder {
bail!("Having the directory {path:?} in args.files[0] is not yet supported for integration tests");
}
- let mut app = Application::new(self.args, self.config, self.syn_conf)?;
+ let mut app = Application::new(self.args, self.config, self.syn_loader)?;
if let Some((text, selection)) = self.input {
let (view, doc) = helix_view::current!(app.editor);