Fixes #53 Fixes #207
@ -28,8 +28,8 @@ pub struct LanguageConfiguration {
pub file_types: Vec<String>, // filename ends_with? <Gemfile, rb, etc>
pub roots: Vec<String>, // these indicate project roots <.git, Cargo.toml>
// pub path: PathBuf,
// root_path for tree-sitter (^)
#[serde(default)]
pub auto_format: bool,
// content_regex
// injection_regex
@ -966,7 +966,13 @@ mod cmd {
editor.set_error("cannot write a buffer without a filename".to_string());
return;
}
let autofmt = doc
.language_config()
.map(|config| config.auto_format)
.unwrap_or_default();
if autofmt {
doc.format(view.id); // TODO: merge into save
tokio::spawn(doc.save());
@ -4,6 +4,7 @@ scope = "source.rust"
injection-regex = "rust"
file-types = ["rs"]
roots = []
auto-format = true
language-server = { command = "rust-analyzer" }
indent = { tab-width = 4, unit = " " }
@ -61,6 +62,7 @@ scope = "source.go"
injection-regex = "go"
file-types = ["go"]
roots = ["Gopkg.toml", "go.mod"]
language-server = { command = "gopls" }
# TODO: gopls needs utf-8 offsets?