Skip to content
Open
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Apache-2.0"
[dependencies]
log = "0.3"
env_logger = "0.3"
rust_lsp = { version = "0.5.0" , git = "https://github.com/RustDT/RustLSP" }
rust_lsp = "0.6"

[lib]
name = "mock_ls_lib"
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#[macro_use] extern crate log;
extern crate env_logger;
extern crate example_ls;
extern crate rust_lsp;

mod mock_ls;

use std::env;
use std::io;
Expand Down Expand Up @@ -37,7 +37,7 @@ fn main() {
// Use stdin/stdout

let stdin = std::io::stdin();
example_ls::run_lsp_server(&mut stdin.lock(), move || std::io::stdout());
mock_ls::run_lsp_server(&mut stdin.lock(), move || std::io::stdout());
} else {
let mut args = env::args();
args.next();
Expand Down Expand Up @@ -87,7 +87,7 @@ fn handle_client(stream: TcpStream) {

let mut input = io::BufReader::new(stream.try_clone().expect("Failed to clone stream"));

example_ls::run_lsp_server(&mut input, || {
mock_ls::run_lsp_server(&mut input, || {
stream
});
}
17 changes: 11 additions & 6 deletions src/mock_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@

extern crate rust_lsp;


use rust_lsp::ls_types::*;
use rust_lsp::lsp_server::*;
use rust_lsp::lsp::{LanguageServerHandling, LSCompletable, LSPEndpoint};
use rust_lsp::jsonrpc::method_types::MethodError;
use rust_lsp::jsonrpc::EndpointOutput;
use rust_lsp::jsonrpc::MethodCompletable;
use rust_lsp::jsonrpc::Endpoint;

use std::io;

pub struct DummyLanguageServer {
endpoint_output : EndpointOutput,
endpoint_output : Endpoint
}

pub fn run_lsp_server<OUT, OUT_P>(input: &mut io::BufRead, out_stream_provider: OUT_P)
Expand All @@ -33,7 +32,7 @@ where

let ls = DummyLanguageServer{ endpoint_output : endpoint_output.clone() };

LSPEndpoint::run_server_from_input(ls, input, endpoint_output);
LSPEndpoint::run_server_from_input(input, endpoint_output, ls);
}

/**
Expand All @@ -49,7 +48,7 @@ impl DummyLanguageServer {

}

impl LanguageServer for DummyLanguageServer {
impl LanguageServerHandling for DummyLanguageServer {

fn initialize(&mut self, _: InitializeParams, completable: MethodCompletable<InitializeResult, InitializeError>) {
let capabilities = ServerCapabilities::default();
Expand Down Expand Up @@ -116,4 +115,10 @@ impl LanguageServer for DummyLanguageServer {
fn rename(&mut self, _: RenameParams, completable: LSCompletable<WorkspaceEdit>) {
completable.complete(Err(Self::error_not_available(())))
}
fn document_link(&mut self, params: DocumentLinkParams, completable: LSCompletable<Vec<DocumentLink>>) {
completable.complete(Err(Self::error_not_available(())))
}
fn document_link_resolve(&mut self, params: DocumentLink, completable: LSCompletable<DocumentLink>) {
completable.complete(Err(Self::error_not_available(())))
}
}