@@ -397,38 +397,49 @@ impl Application {
397 self.editor.refresh_config();
397 self.editor.refresh_config();
400+ /// refresh language config after config change
401+ fn refresh_language_config(&mut self) -> Result<(), Error> {
402+ let syntax_config = helix_core::config::user_syntax_loader()
403+ .map_err(|err| anyhow::anyhow!("Failed to load language config: {}", err))?;
405+ self.syn_loader = std::sync::Arc::new(syntax::Loader::new(syntax_config));
406+ for document in self.editor.documents.values_mut() {
407+ document.detect_language(self.syn_loader.clone());
400 /// Refresh theme after config change
413 /// Refresh theme after config change
401− fn refresh_theme(&mut self, config: &Config) {
414+ fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
402 if let Some(theme) = config.theme.clone() {
415 if let Some(theme) = config.theme.clone() {
403 let true_color = self.true_color();
416 let true_color = self.true_color();
404− match self.theme_loader.load(&theme) {
418+ .theme_loader
405− Ok(theme) => {
419+ .load(&theme)
420+ .map_err(|err| anyhow::anyhow!("Failed to load theme `{}`: {}", theme, err))?;
406− if true_color || theme.is_16_color() {
422+ if true_color || theme.is_16_color() {
407− self.editor.set_theme(theme);
423+ self.editor.set_theme(theme);
408− } else {
424+ } else {
410− .set_error("theme requires truecolor support, which is not available");
425+ anyhow::bail!("theme requires truecolor support, which is not available")
414− let err_string = format!("failed to load theme `{}` - {}", theme, err);
415− self.editor.set_error(err_string);
421 fn refresh_config(&mut self) {
432 fn refresh_config(&mut self) {
433+ let mut refresh_config = || -> Result<(), Error> {
422− match Config::load_default() {
434+ let default_config = Config::load_default()
423− Ok(config) => {
435+ .map_err(|err| anyhow::anyhow!("Failed to load config: {}", err))?;
436+ self.refresh_language_config()?;
424− self.refresh_theme(&config);
437+ self.refresh_theme(&default_config)?;
426− // Store new config
441+ if let Err(err) = refresh_config() {
427− self.config.store(Arc::new(config));
430− self.editor.set_error(err.to_string());
442+ self.editor.set_error(err.to_string());