mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 19:03:30 +04:00
parent
69fe46a122
commit
278361a086
@ -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 @@ fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {
|
||||
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"]
|
||||
auto-format = true
|
||||
|
||||
language-server = { command = "gopls" }
|
||||
# TODO: gopls needs utf-8 offsets?
|
||||
|
Loading…
Reference in New Issue
Block a user