Add new LSP extension for workspace symbol lookup
The new extension allows filtering of workspace symbool lookup results by search scope or search kind. Filtering can be configured in 3 different ways: - The '#' or '*' markers can be added inline with the symbol lookup query. The '#' marker means symbols should be looked up in the current workspace and any dependencies. If not specified, only current workspace is considered. The '*' marker means all kinds of symbols should be looked up (types, functions, etc). If not specified, only type symbols are returned. - Each LSP request can take an optional search_scope or search_kind argument query parameter. - Finally there are 2 global config options that can be set for all requests served by the active RA instance. Add support for setting the global config options to the VSCode extension. The extension does not use the per-request way, but it's useful for other IDEs. The latest version of VSCode filters out the inline markers, so currently the only reasonable way to use the new functionality is via the global config.
This commit is contained in:
@@ -4,7 +4,8 @@ use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use lsp_types::request::Request;
|
||||
use lsp_types::{
|
||||
notification::Notification, CodeActionKind, Position, Range, TextDocumentIdentifier,
|
||||
notification::Notification, CodeActionKind, PartialResultParams, Position, Range,
|
||||
TextDocumentIdentifier, WorkDoneProgressParams,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -438,3 +439,42 @@ pub enum MoveItemDirection {
|
||||
Up,
|
||||
Down,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WorkspaceSymbol {}
|
||||
|
||||
impl Request for WorkspaceSymbol {
|
||||
type Params = WorkspaceSymbolParams;
|
||||
type Result = Option<Vec<lsp_types::SymbolInformation>>;
|
||||
const METHOD: &'static str = "workspace/symbol";
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
|
||||
pub struct WorkspaceSymbolParams {
|
||||
#[serde(flatten)]
|
||||
pub partial_result_params: PartialResultParams,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub work_done_progress_params: WorkDoneProgressParams,
|
||||
|
||||
/// A non-empty query string
|
||||
pub query: String,
|
||||
|
||||
pub search_scope: Option<WorkspaceSymbolSearchScope>,
|
||||
|
||||
pub search_kind: Option<WorkspaceSymbolSearchKind>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum WorkspaceSymbolSearchScope {
|
||||
Workspace,
|
||||
WorkspaceAndDependencies,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum WorkspaceSymbolSearchKind {
|
||||
OnlyTypes,
|
||||
AllSymbols,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user