2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-12-07 05:46:39 -05:00
|
|
|
|
|
|
|
///!
|
|
|
|
///! Provides information about what capabilities that are supported by the
|
|
|
|
///! language server, which helps determine what messages are sent from the
|
|
|
|
///! client.
|
|
|
|
///!
|
2021-01-29 14:34:33 -05:00
|
|
|
use lspower::lsp::ClientCapabilities;
|
2021-02-04 13:53:02 -05:00
|
|
|
use lspower::lsp::CodeActionKind;
|
|
|
|
use lspower::lsp::CodeActionOptions;
|
|
|
|
use lspower::lsp::CodeActionProviderCapability;
|
2021-01-31 22:30:41 -05:00
|
|
|
use lspower::lsp::CodeLensOptions;
|
2021-01-29 14:34:33 -05:00
|
|
|
use lspower::lsp::CompletionOptions;
|
|
|
|
use lspower::lsp::HoverProviderCapability;
|
|
|
|
use lspower::lsp::ImplementationProviderCapability;
|
|
|
|
use lspower::lsp::OneOf;
|
|
|
|
use lspower::lsp::SaveOptions;
|
2021-03-23 19:33:25 -04:00
|
|
|
use lspower::lsp::SelectionRangeProviderCapability;
|
2021-01-29 14:34:33 -05:00
|
|
|
use lspower::lsp::ServerCapabilities;
|
2021-02-15 21:34:09 -05:00
|
|
|
use lspower::lsp::SignatureHelpOptions;
|
2021-01-29 14:34:33 -05:00
|
|
|
use lspower::lsp::TextDocumentSyncCapability;
|
|
|
|
use lspower::lsp::TextDocumentSyncKind;
|
|
|
|
use lspower::lsp::TextDocumentSyncOptions;
|
|
|
|
use lspower::lsp::WorkDoneProgressOptions;
|
2020-12-07 05:46:39 -05:00
|
|
|
|
2021-02-04 13:53:02 -05:00
|
|
|
fn code_action_capabilities(
|
|
|
|
client_capabilities: &ClientCapabilities,
|
|
|
|
) -> CodeActionProviderCapability {
|
|
|
|
client_capabilities
|
|
|
|
.text_document
|
|
|
|
.as_ref()
|
|
|
|
.and_then(|it| it.code_action.as_ref())
|
|
|
|
.and_then(|it| it.code_action_literal_support.as_ref())
|
|
|
|
.map_or(CodeActionProviderCapability::Simple(true), |_| {
|
|
|
|
CodeActionProviderCapability::Options(CodeActionOptions {
|
|
|
|
code_action_kinds: Some(vec![CodeActionKind::QUICKFIX]),
|
2021-02-05 15:10:53 -05:00
|
|
|
resolve_provider: Some(true),
|
2021-02-04 13:53:02 -05:00
|
|
|
work_done_progress_options: Default::default(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 05:46:39 -05:00
|
|
|
pub fn server_capabilities(
|
2021-02-04 13:53:02 -05:00
|
|
|
client_capabilities: &ClientCapabilities,
|
2020-12-07 05:46:39 -05:00
|
|
|
) -> ServerCapabilities {
|
2021-02-04 13:53:02 -05:00
|
|
|
let code_action_provider = code_action_capabilities(client_capabilities);
|
2020-12-07 05:46:39 -05:00
|
|
|
ServerCapabilities {
|
|
|
|
text_document_sync: Some(TextDocumentSyncCapability::Options(
|
|
|
|
TextDocumentSyncOptions {
|
|
|
|
open_close: Some(true),
|
|
|
|
change: Some(TextDocumentSyncKind::Incremental),
|
|
|
|
will_save: None,
|
|
|
|
will_save_wait_until: None,
|
|
|
|
save: Some(SaveOptions::default().into()),
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
hover_provider: Some(HoverProviderCapability::Simple(true)),
|
2020-12-08 05:36:13 -05:00
|
|
|
completion_provider: Some(CompletionOptions {
|
2021-03-15 18:01:41 -04:00
|
|
|
all_commit_characters: Some(vec![
|
|
|
|
".".to_string(),
|
|
|
|
",".to_string(),
|
|
|
|
";".to_string(),
|
|
|
|
"(".to_string(),
|
|
|
|
]),
|
2020-12-08 05:36:13 -05:00
|
|
|
trigger_characters: Some(vec![
|
|
|
|
".".to_string(),
|
|
|
|
"\"".to_string(),
|
|
|
|
"'".to_string(),
|
|
|
|
"`".to_string(),
|
|
|
|
"/".to_string(),
|
|
|
|
"@".to_string(),
|
|
|
|
"<".to_string(),
|
|
|
|
"#".to_string(),
|
|
|
|
]),
|
2021-03-15 18:01:41 -04:00
|
|
|
resolve_provider: Some(true),
|
2020-12-08 05:36:13 -05:00
|
|
|
work_done_progress_options: WorkDoneProgressOptions {
|
|
|
|
work_done_progress: None,
|
|
|
|
},
|
|
|
|
}),
|
2021-02-15 21:34:09 -05:00
|
|
|
signature_help_provider: Some(SignatureHelpOptions {
|
|
|
|
trigger_characters: Some(vec![
|
|
|
|
",".to_string(),
|
|
|
|
"(".to_string(),
|
|
|
|
"<".to_string(),
|
|
|
|
]),
|
2021-03-15 18:01:41 -04:00
|
|
|
retrigger_characters: Some(vec![")".to_string()]),
|
2021-02-15 21:34:09 -05:00
|
|
|
work_done_progress_options: WorkDoneProgressOptions {
|
|
|
|
work_done_progress: None,
|
|
|
|
},
|
|
|
|
}),
|
2020-12-07 05:46:39 -05:00
|
|
|
declaration_provider: None,
|
|
|
|
definition_provider: Some(OneOf::Left(true)),
|
|
|
|
type_definition_provider: None,
|
2021-01-12 16:53:27 -05:00
|
|
|
implementation_provider: Some(ImplementationProviderCapability::Simple(
|
|
|
|
true,
|
|
|
|
)),
|
2020-12-07 05:46:39 -05:00
|
|
|
references_provider: Some(OneOf::Left(true)),
|
|
|
|
document_highlight_provider: Some(OneOf::Left(true)),
|
|
|
|
document_symbol_provider: None,
|
|
|
|
workspace_symbol_provider: None,
|
2021-02-04 13:53:02 -05:00
|
|
|
code_action_provider: Some(code_action_provider),
|
2021-01-31 22:30:41 -05:00
|
|
|
code_lens_provider: Some(CodeLensOptions {
|
|
|
|
resolve_provider: Some(true),
|
|
|
|
}),
|
2020-12-07 05:46:39 -05:00
|
|
|
document_formatting_provider: Some(OneOf::Left(true)),
|
|
|
|
document_range_formatting_provider: None,
|
|
|
|
document_on_type_formatting_provider: None,
|
2021-03-23 19:33:25 -04:00
|
|
|
selection_range_provider: Some(SelectionRangeProviderCapability::Simple(
|
|
|
|
true,
|
|
|
|
)),
|
2020-12-07 05:46:39 -05:00
|
|
|
folding_range_provider: None,
|
2020-12-29 19:58:20 -05:00
|
|
|
rename_provider: Some(OneOf::Left(true)),
|
2020-12-07 05:46:39 -05:00
|
|
|
document_link_provider: None,
|
|
|
|
color_provider: None,
|
|
|
|
execute_command_provider: None,
|
|
|
|
call_hierarchy_provider: None,
|
2020-12-21 08:44:26 -05:00
|
|
|
semantic_tokens_provider: None,
|
|
|
|
workspace: None,
|
2020-12-07 05:46:39 -05:00
|
|
|
experimental: None,
|
2021-01-12 02:50:02 -05:00
|
|
|
linked_editing_range_provider: None,
|
|
|
|
moniker_provider: None,
|
2020-12-07 05:46:39 -05:00
|
|
|
}
|
|
|
|
}
|