Skip to content

Commit 6885a08

Browse files
committed
format code
1 parent 0de56c4 commit 6885a08

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "protols"
33
description = "Language server for proto3 files"
4-
version = "0.9.0"
4+
version = "0.10.0"
55
edition = "2021"
66
license = "MIT"
77
homepage = "https://github.com/coder3101/protols"

src/formatter/clang.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl ClangFormatter {
7070
Self {
7171
temp_dir: tempdir().expect("faile to creat temp dir"),
7272
path: cmd.to_owned(),
73-
working_dir: wdir.to_owned()
73+
working_dir: wdir.to_owned(),
7474
}
7575
}
7676

@@ -85,7 +85,10 @@ impl ClangFormatter {
8585
let mut c = Command::new(self.path.as_str());
8686
c.current_dir(self.working_dir.as_str());
8787
c.stdin(File::open(u).ok()?);
88-
c.args(["--output-replacements-xml", format!("--assume-filename={f}").as_str()]);
88+
c.args([
89+
"--output-replacements-xml",
90+
format!("--assume-filename={f}").as_str(),
91+
]);
8992
Some(c)
9093
}
9194

@@ -116,7 +119,12 @@ impl ProtoFormatter for ClangFormatter {
116119
self.output_to_textedit(&String::from_utf8_lossy(&output.stdout), content)
117120
}
118121

119-
fn format_document_range(&self, r: &Range, filename: &str, content: &str) -> Option<Vec<TextEdit>> {
122+
fn format_document_range(
123+
&self,
124+
r: &Range,
125+
filename: &str,
126+
content: &str,
127+
) -> Option<Vec<TextEdit>> {
120128
let p = self.get_temp_file_path(content)?;
121129
let start = r.start.line + 1;
122130
let end = r.end.line + 1;

src/formatter/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ pub mod clang;
44

55
pub trait ProtoFormatter: Sized {
66
fn format_document(&self, filename: &str, content: &str) -> Option<Vec<TextEdit>>;
7-
fn format_document_range(&self, r: &Range, filename: &str, content: &str) -> Option<Vec<TextEdit>>;
7+
fn format_document_range(
8+
&self,
9+
r: &Range,
10+
filename: &str,
11+
content: &str,
12+
) -> Option<Vec<TextEdit>>;
813
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use server::{ProtoLanguageServer, TickEvent};
99
use tower::ServiceBuilder;
1010
use tracing::Level;
1111

12+
mod config;
1213
mod formatter;
1314
mod lsp;
1415
mod nodekind;
@@ -17,7 +18,6 @@ mod server;
1718
mod state;
1819
mod utils;
1920
mod workspace;
20-
mod config;
2121

2222
#[tokio::main(flavor = "current_thread")]
2323
async fn main() {

src/workspace/rename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ mod test {
9999
let b = include_str!("input/b.proto");
100100
let c = include_str!("input/c.proto");
101101

102-
let mut state: ProtoLanguageState<ClangFormatter> = ProtoLanguageState::new();
102+
let mut state: ProtoLanguageState = ProtoLanguageState::new();
103103
state.upsert_file(&a_uri, a.to_owned());
104104
state.upsert_file(&b_uri, b.to_owned());
105105
state.upsert_file(&c_uri, c.to_owned());

0 commit comments

Comments
 (0)