Skip to content

Commit

Permalink
Some structure to the formatting module
Browse files Browse the repository at this point in the history
  • Loading branch information
ebresafegaga committed Mar 31, 2023
1 parent 78dd54b commit 4fcb51d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lsp/nls/src/requests/formatting.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use lsp_server::{RequestId, ResponseError};
use lsp_types::DocumentFormattingParams;
use lsp_server::{RequestId, Response, ResponseError};
use lsp_types::{DocumentFormattingParams, Position, Range, TextEdit};

use crate::server::Server;

Expand All @@ -8,5 +8,26 @@ pub fn handle_format_document(
id: RequestId,
server: &mut Server,
) -> Result<(), ResponseError> {
let document_id = params.text_document.uri.to_file_path().unwrap();
let file_id = server.cache.id_of(document_id).unwrap();
let text = server.cache.files().source(file_id);

let new_text = String::new();
let result = Some(vec![TextEdit {
range: Range {
start: Position {
line: 0,
character: 0,
},
// for now
end: Position {
line: 0,
character: 0,
},
},
new_text,
}]);
let response = Response::new_ok(id, result);

Ok(())
}

0 comments on commit 4fcb51d

Please sign in to comment.