|
|
@ -192,7 +192,7 @@ impl Client {
|
|
|
|
text_document: Some(lsp::TextDocumentClientCapabilities {
|
|
|
|
text_document: Some(lsp::TextDocumentClientCapabilities {
|
|
|
|
completion: Some(lsp::CompletionClientCapabilities {
|
|
|
|
completion: Some(lsp::CompletionClientCapabilities {
|
|
|
|
completion_item: Some(lsp::CompletionItemCapability {
|
|
|
|
completion_item: Some(lsp::CompletionItemCapability {
|
|
|
|
snippet_support: Some(false), // TODO
|
|
|
|
snippet_support: Some(false),
|
|
|
|
..Default::default()
|
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
completion_item_kind: Some(lsp::CompletionItemKindCapability {
|
|
|
|
completion_item_kind: Some(lsp::CompletionItemKindCapability {
|
|
|
@ -284,7 +284,6 @@ impl Client {
|
|
|
|
mut character,
|
|
|
|
mut character,
|
|
|
|
} = pos;
|
|
|
|
} = pos;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: there should be a better way here
|
|
|
|
|
|
|
|
for ch in text.chars() {
|
|
|
|
for ch in text.chars() {
|
|
|
|
if ch == '\n' {
|
|
|
|
if ch == '\n' {
|
|
|
|
line += 1;
|
|
|
|
line += 1;
|
|
|
@ -299,8 +298,6 @@ impl Client {
|
|
|
|
let old_text = old_text.slice(..);
|
|
|
|
let old_text = old_text.slice(..);
|
|
|
|
let new_text = new_text.slice(..);
|
|
|
|
let new_text = new_text.slice(..);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: verify this function, specifically line num counting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while let Some(change) = iter.next() {
|
|
|
|
while let Some(change) = iter.next() {
|
|
|
|
let len = match change {
|
|
|
|
let len = match change {
|
|
|
|
Delete(i) | Retain(i) => *i,
|
|
|
|
Delete(i) | Retain(i) => *i,
|
|
|
@ -355,7 +352,6 @@ impl Client {
|
|
|
|
changes
|
|
|
|
changes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: trigger any time history.commit_revision happens
|
|
|
|
|
|
|
|
pub async fn text_document_did_change(
|
|
|
|
pub async fn text_document_did_change(
|
|
|
|
&self,
|
|
|
|
&self,
|
|
|
|
text_document: lsp::VersionedTextDocumentIdentifier,
|
|
|
|
text_document: lsp::VersionedTextDocumentIdentifier,
|
|
|
@ -365,7 +361,7 @@ impl Client {
|
|
|
|
) -> Result<()> {
|
|
|
|
) -> Result<()> {
|
|
|
|
// figure out what kind of sync the server supports
|
|
|
|
// figure out what kind of sync the server supports
|
|
|
|
|
|
|
|
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let sync_capabilities = match capabilities.text_document_sync {
|
|
|
|
let sync_capabilities = match capabilities.text_document_sync {
|
|
|
|
Some(lsp::TextDocumentSyncCapability::Kind(kind)) => kind,
|
|
|
|
Some(lsp::TextDocumentSyncCapability::Kind(kind)) => kind,
|
|
|
@ -384,7 +380,7 @@ impl Client {
|
|
|
|
range: None, //Some(Range)
|
|
|
|
range: None, //Some(Range)
|
|
|
|
range_length: None, // u64 apparently deprecated
|
|
|
|
range_length: None, // u64 apparently deprecated
|
|
|
|
text: "".to_string(),
|
|
|
|
text: "".to_string(),
|
|
|
|
}] // TODO: probably need old_state here too?
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lsp::TextDocumentSyncKind::Incremental => {
|
|
|
|
lsp::TextDocumentSyncKind::Incremental => {
|
|
|
|
Self::changeset_to_changes(old_text, new_text, changes)
|
|
|
|
Self::changeset_to_changes(old_text, new_text, changes)
|
|
|
@ -416,7 +412,7 @@ impl Client {
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
text: &Rope,
|
|
|
|
text: &Rope,
|
|
|
|
) -> Result<()> {
|
|
|
|
) -> Result<()> {
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let include_text = match &capabilities.text_document_sync {
|
|
|
|
let include_text = match &capabilities.text_document_sync {
|
|
|
|
Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
|
|
|
|
Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
|
|
|
@ -446,8 +442,6 @@ impl Client {
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
position: lsp::Position,
|
|
|
|
position: lsp::Position,
|
|
|
|
) -> Result<Vec<lsp::CompletionItem>> {
|
|
|
|
) -> Result<Vec<lsp::CompletionItem>> {
|
|
|
|
// TODO: figure out what should happen when you complete with multiple cursors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let params = lsp::CompletionParams {
|
|
|
|
let params = lsp::CompletionParams {
|
|
|
|
text_document_position: lsp::TextDocumentPositionParams {
|
|
|
|
text_document_position: lsp::TextDocumentPositionParams {
|
|
|
|
text_document,
|
|
|
|
text_document,
|
|
|
@ -489,7 +483,6 @@ impl Client {
|
|
|
|
text_document,
|
|
|
|
text_document,
|
|
|
|
position,
|
|
|
|
position,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// TODO: support these tokens
|
|
|
|
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_token: None,
|
|
|
|
work_done_token: None,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -514,7 +507,6 @@ impl Client {
|
|
|
|
text_document,
|
|
|
|
text_document,
|
|
|
|
position,
|
|
|
|
position,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// TODO: support these tokens
|
|
|
|
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_token: None,
|
|
|
|
work_done_token: None,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -533,7 +525,7 @@ impl Client {
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
options: lsp::FormattingOptions,
|
|
|
|
options: lsp::FormattingOptions,
|
|
|
|
) -> anyhow::Result<Vec<lsp::TextEdit>> {
|
|
|
|
) -> anyhow::Result<Vec<lsp::TextEdit>> {
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// check if we're able to format
|
|
|
|
// check if we're able to format
|
|
|
|
let _capabilities = match capabilities.document_formatting_provider {
|
|
|
|
let _capabilities = match capabilities.document_formatting_provider {
|
|
|
@ -547,7 +539,6 @@ impl Client {
|
|
|
|
let params = lsp::DocumentFormattingParams {
|
|
|
|
let params = lsp::DocumentFormattingParams {
|
|
|
|
text_document,
|
|
|
|
text_document,
|
|
|
|
options,
|
|
|
|
options,
|
|
|
|
// TODO: support these tokens
|
|
|
|
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_token: None,
|
|
|
|
work_done_token: None,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -564,7 +555,7 @@ impl Client {
|
|
|
|
range: lsp::Range,
|
|
|
|
range: lsp::Range,
|
|
|
|
options: lsp::FormattingOptions,
|
|
|
|
options: lsp::FormattingOptions,
|
|
|
|
) -> anyhow::Result<Vec<lsp::TextEdit>> {
|
|
|
|
) -> anyhow::Result<Vec<lsp::TextEdit>> {
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
|
|
|
|
let capabilities = self.capabilities.as_ref().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// check if we're able to format
|
|
|
|
// check if we're able to format
|
|
|
|
let _capabilities = match capabilities.document_range_formatting_provider {
|
|
|
|
let _capabilities = match capabilities.document_range_formatting_provider {
|
|
|
@ -579,7 +570,6 @@ impl Client {
|
|
|
|
text_document,
|
|
|
|
text_document,
|
|
|
|
range,
|
|
|
|
range,
|
|
|
|
options,
|
|
|
|
options,
|
|
|
|
// TODO: support these tokens
|
|
|
|
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_progress_params: lsp::WorkDoneProgressParams {
|
|
|
|
work_done_token: None,
|
|
|
|
work_done_token: None,
|
|
|
|
},
|
|
|
|
},
|
|
|
|