Skip to content

Commit

Permalink
Merge pull request #92 from posit-dev/feature/range-formatting
Browse files Browse the repository at this point in the history
Add range formatting support
  • Loading branch information
lionel- authored Dec 16, 2024
2 parents 093bb96 + 8f425bc commit 357be89
Show file tree
Hide file tree
Showing 34 changed files with 703 additions and 11 deletions.
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

0 comments on commit 357be89

Please sign in to comment.