merge
This commit is contained in:
commit
1d90b5a23b
@ -1,8 +1,12 @@
|
|||||||
|
use std::future;
|
||||||
|
use std::sync::Arc;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use tower_lsp::jsonrpc::Result;
|
use tower_lsp::jsonrpc::Result;
|
||||||
use tower_lsp::lsp_types::*;
|
use tower_lsp::lsp_types::*;
|
||||||
|
|
||||||
|
use crate::server::Backend;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct CustomRequestParams {
|
pub struct CustomRequestParams {
|
||||||
// 定义你需要的参数
|
// 定义你需要的参数
|
||||||
@ -14,8 +18,18 @@ pub struct CustomResponse {
|
|||||||
result: serde_json::Value
|
result: serde_json::Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct CustomRequest;
|
||||||
|
|
||||||
pub async fn customRequest() -> Result<i32> {
|
impl <'a>tower_lsp::jsonrpc::Method<&'a Arc<Backend>, (), Result<i32>> for CustomRequest {
|
||||||
|
type Future = future::Ready<Result<i32>>;
|
||||||
|
|
||||||
|
fn invoke(&self, _server: &'a Arc<Backend>, _params: ()) -> Self::Future {
|
||||||
|
future::ready(customRequest())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn customRequest() -> Result<i32> {
|
||||||
// let command = params[0].clone();
|
// let command = params[0].clone();
|
||||||
// let message = String::from("receive command: ") + &command;
|
// let message = String::from("receive command: ") + &command;
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ impl LSPServer {
|
|||||||
|
|
||||||
let scope_tree = self.srcs.scope_tree.read().ok()?;
|
let scope_tree = self.srcs.scope_tree.read().ok()?;
|
||||||
|
|
||||||
self.key_comps
|
|
||||||
|
|
||||||
// info!("scope tree: {:?}", scope_tree);
|
// info!("scope tree: {:?}", scope_tree);
|
||||||
|
|
||||||
trace!("{:#?}", scope_tree.as_ref()?);
|
trace!("{:#?}", scope_tree.as_ref()?);
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -1,6 +1,6 @@
|
|||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
use custom_request::customRequest;
|
use custom_request::CustomRequest;
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
@ -33,11 +33,11 @@ async fn main() {
|
|||||||
let stdin = tokio::io::stdin();
|
let stdin = tokio::io::stdin();
|
||||||
let stdout = tokio::io::stdout();
|
let stdout = tokio::io::stdout();
|
||||||
|
|
||||||
let (service, socket) = LspService::new(|client| Arc::new(Backend::new(client, log_handle)));
|
// let (service, socket) = LspService::new(|client| Arc::new(Backend::new(client, log_handle)));
|
||||||
|
|
||||||
// let (service, socket) = LspService::build(|client| Arc::new(Backend::new(client, log_handle)))
|
let (service, socket) = LspService::build(|client| Arc::new(Backend::new(client, log_handle)))
|
||||||
// .custom_method("custom/request", customRequest)
|
.custom_method("custom/request", CustomRequest)
|
||||||
// .finish();
|
.finish();
|
||||||
|
|
||||||
Server::new(stdin, stdout, socket)
|
Server::new(stdin, stdout, socket)
|
||||||
.serve(service)
|
.serve(service)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user