Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range formatting support #92

Merged
merged 18 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

# Development version

- The LSP gains range formatting support (#63).

- The `air format` command has been improved and is now able to take multiple files and directories.


# 0.1.0

- Initial release.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/air_r_factory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mod generated;
pub use crate::generated::RSyntaxFactory;
pub use crate::generated::node_factory::*;
pub use crate::generated::*;
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fn fmt_binary(
)
}

#[derive(Debug)]
struct TailPiece {
operator: SyntaxToken<RLanguage>,
right: AnyRExpression,
Expand Down
2 changes: 2 additions & 0 deletions crates/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ repository.workspace = true
rust-version.workspace = true

[dependencies]
air_r_factory.workspace = true
air_r_formatter.workspace = true
air_r_parser.workspace = true
air_r_syntax.workspace = true
anyhow.workspace = true
biome_formatter.workspace = true
biome_lsp_converters.workspace = true
biome_parser.workspace = true
biome_rowan.workspace = true
biome_text_size.workspace = true
crossbeam.workspace = true
dissimilar.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions crates/lsp/src/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ impl Document {
Self::new(contents.into(), None, PositionEncoding::Utf8)
}

#[cfg(test)]
pub fn doodle_and_range(contents: &str) -> (Self, biome_text_size::TextRange) {
let (contents, range) = crate::test_utils::extract_marked_range(contents);
let doc = Self::new(contents, None, PositionEncoding::Utf8);
(doc, range)
}

pub fn on_did_change(&mut self, mut params: lsp_types::DidChangeTextDocumentParams) {
let new_version = params.text_document.version;

Expand Down
7 changes: 0 additions & 7 deletions crates/lsp/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ pub(crate) async fn handle_initialized(
regs.append(&mut config_diagnostics_regs);
}

// TODO! Abstract this in a method
regs.push(lsp_types::Registration {
id: String::from("air_formatting"),
method: String::from("textDocument/formatting"),
register_options: None,
});

client
.register_capability(regs)
.instrument(span.exit())
Expand Down
Loading
Loading