Skip to content
Draft
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
1 change: 1 addition & 0 deletions crates/roughly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod index;
pub mod references;
pub mod rename;
pub mod server;
pub mod signature_help;
pub mod symbols;
pub mod tree;
pub mod utils;
Expand Down
43 changes: 39 additions & 4 deletions crates/roughly/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ use {
GlobPattern, InitializeParams, InitializeResult, InitializedParams, Location,
MessageType, OneOf, Position, PublishDiagnosticsParams, Range, ReferenceParams,
Registration, RegistrationParams, RelativePattern, RenameParams, SaveOptions,
ServerCapabilities, ServerInfo, ShowMessageParams, TextDocumentSyncCapability,
TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions, TextEdit,
Url, WorkspaceEdit, WorkspaceSymbolParams, WorkspaceSymbolResponse,
ServerCapabilities, ServerInfo, ShowMessageParams, SignatureHelp, SignatureHelpOptions,
SignatureHelpParams, TextDocumentSyncCapability, TextDocumentSyncKind,
TextDocumentSyncOptions, TextDocumentSyncSaveOptions, TextEdit, Url, WorkspaceEdit,
WorkspaceSymbolParams, WorkspaceSymbolResponse,
notification::{DidChangeWatchedFiles, Notification},
},
references, rename, symbols, tree, utils,
references, rename, signature_help, symbols, tree, utils,
},
async_lsp::{
ClientSocket, ErrorCode, LanguageClient, LanguageServer, ResponseError,
Expand Down Expand Up @@ -157,6 +158,11 @@ impl LanguageServer for ServerState {
document_symbol_provider: Some(OneOf::Left(true)),
references_provider: Some(OneOf::Left(self.experimental_features.goto_references)),
rename_provider: Some(OneOf::Left(self.experimental_features.rename)),
signature_help_provider: Some(SignatureHelpOptions {
trigger_characters: Some(vec!["(".into(), ",".into()]),
retrigger_characters: None,
work_done_progress_options: Default::default(),
}),
text_document_sync: Some(TextDocumentSyncCapability::Options(
TextDocumentSyncOptions {
open_close: Some(true),
Expand Down Expand Up @@ -477,6 +483,35 @@ impl LanguageServer for ServerState {
box_future(Ok(definitions))
}

//
// SIGNATURE HELP
//

fn signature_help(
&mut self,
params: SignatureHelpParams,
) -> BoxFuture<'static, Result<Option<SignatureHelp>, ResponseError>> {
let uri = params.text_document_position_params.text_document.uri;
let path = uri.to_file_path().unwrap();
let position = params.text_document_position_params.position;

tracing::debug!(?path, "signature help");

let Some(document) = self.document_map.get(&path) else {
tracing::info!(?path, "document not found");
return box_future(Err(path_not_found_error(&path)));
};

let signature_help = signature_help::get(
position,
&document.rope,
&document.tree,
&self.workspace_items,
);

box_future(Ok(signature_help))
}

//
// FORMATTING
//
Expand Down
Loading