@@ -7,7 +7,9 @@ use anyhow::anyhow;
77use helix_core::{find_root, ChangeSet, Rope};
88use jsonrpc_core as jsonrpc;
99use lsp_types as lsp;
10+use serde::Deserialize;
1011use serde_json::Value;
12+use std::collections::HashMap;
1113use std::future::Future;
1214use std::process::Stdio;
1315use std::sync::{
@@ -693,6 +695,24 @@ impl Client {
693695 };
694696 // TODO: return err::unavailable so we can fall back to tree sitter formatting
695697
698+ // merge FormattingOptions with 'config.format'
699+ let config_format = self
700+ .config
701+ .as_ref()
702+ .and_then(|cfg| cfg.get("format"))
703+ .and_then(|fmt| HashMap::<String, lsp::FormattingProperty>::deserialize(fmt).ok());
704+
705+ let options = if let Some(mut properties) = config_format {
706+ // passed in options take precedence over 'config.format'
707+ properties.extend(options.properties);
708+ lsp::FormattingOptions {
709+ properties,
710+ ..options
711+ }
712+ } else {
713+ options
714+ };
715+
696716 let params = lsp::DocumentFormattingParams {
697717 text_document,
698718 options,